blob: a63d43222879af458ecf93d4e16723e4882dff75 [file] [log] [blame]
b.janani68c55e12016-02-24 12:23:03 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
b.janani68c55e12016-02-24 12:23:03 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.yangutils.utils;
18
b.janani68c55e12016-02-24 12:23:03 +053019import java.lang.reflect.Constructor;
20import java.lang.reflect.InvocationTargetException;
Bharat saraswal6ef0b762016-04-05 12:45:45 +053021
22import org.junit.Rule;
23import org.junit.Test;
24import org.junit.rules.ExpectedException;
25
26import static org.hamcrest.core.IsNot.not;
27import static org.junit.Assert.assertThat;
b.janani68c55e12016-02-24 12:23:03 +053028
29/**
30 * Test case for testing the util constants.
31 */
32public final class UtilConstantsTest {
33
34 @Rule
35 public ExpectedException thrown = ExpectedException.none();
36
37 /**
38 * A private constructor is tested.
39 *
Vinod Kumar S38046502016-03-23 15:30:27 +053040 * @throws SecurityException if any security violation is observed
41 * @throws NoSuchMethodException if when the method is not found
42 * @throws IllegalArgumentException if there is illegal argument found
43 * @throws InstantiationException if instantiation is provoked for the private constructor
44 * @throws IllegalAccessException if instance is provoked or a method is provoked
45 * @throws InvocationTargetException when an exception occurs by the method or constructor
b.janani68c55e12016-02-24 12:23:03 +053046 */
47 @Test
48 public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
Bharat saraswal6ef0b762016-04-05 12:45:45 +053049 InstantiationException, IllegalAccessException, InvocationTargetException {
b.janani68c55e12016-02-24 12:23:03 +053050
Bharat saraswal6ef0b762016-04-05 12:45:45 +053051 Class<?>[] classesToConstruct = {UtilConstants.class };
b.janani68c55e12016-02-24 12:23:03 +053052 for (Class<?> clazz : classesToConstruct) {
53 Constructor<?> constructor = clazz.getDeclaredConstructor();
54 constructor.setAccessible(true);
Bharat saraswal6ef0b762016-04-05 12:45:45 +053055 assertThat(null, not(constructor.newInstance()));
b.janani68c55e12016-02-24 12:23:03 +053056 }
57 }
58}