blob: 6a02ca1968d1e5f11ebec3cc5e8c8953b8abbf79 [file] [log] [blame]
b.janani68c55e12016-02-24 12:23:03 +05301/*
2 * Copyright 2016 Open Networking Laboratory
3 *
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
19import org.junit.Test;
20import org.junit.Rule;
21import org.junit.rules.ExpectedException;
22import java.lang.reflect.Constructor;
23import java.lang.reflect.InvocationTargetException;
24import static org.junit.Assert.assertNotNull;
25
26/**
27 * Test case for testing the util constants.
28 */
29public final class UtilConstantsTest {
30
31 @Rule
32 public ExpectedException thrown = ExpectedException.none();
33
34 /**
35 * A private constructor is tested.
36 *
Vinod Kumar S38046502016-03-23 15:30:27 +053037 * @throws SecurityException if any security violation is observed
38 * @throws NoSuchMethodException if when the method is not found
39 * @throws IllegalArgumentException if there is illegal argument found
40 * @throws InstantiationException if instantiation is provoked for the private constructor
41 * @throws IllegalAccessException if instance is provoked or a method is provoked
42 * @throws InvocationTargetException when an exception occurs by the method or constructor
b.janani68c55e12016-02-24 12:23:03 +053043 */
44 @Test
45 public void callPrivateConstructors() throws SecurityException, NoSuchMethodException, IllegalArgumentException,
46 InstantiationException, IllegalAccessException, InvocationTargetException {
47
48 Class<?>[] classesToConstruct = {UtilConstants.class};
49 for (Class<?> clazz : classesToConstruct) {
50 Constructor<?> constructor = clazz.getDeclaredConstructor();
51 constructor.setAccessible(true);
52 assertNotNull(constructor.newInstance());
53 }
54 }
55}