b.janani | 68c55e1 | 2016-02-24 12:23:03 +0530 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.yangutils.utils; |
| 18 | |
| 19 | import org.junit.Test; |
| 20 | import org.junit.Rule; |
| 21 | import org.junit.rules.ExpectedException; |
| 22 | import java.lang.reflect.Constructor; |
| 23 | import java.lang.reflect.InvocationTargetException; |
| 24 | import static org.junit.Assert.assertNotNull; |
| 25 | |
| 26 | /** |
| 27 | * Test case for testing the util constants. |
| 28 | */ |
| 29 | public final class UtilConstantsTest { |
| 30 | |
| 31 | @Rule |
| 32 | public ExpectedException thrown = ExpectedException.none(); |
| 33 | |
| 34 | /** |
| 35 | * A private constructor is tested. |
| 36 | * |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 37 | * @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.janani | 68c55e1 | 2016-02-24 12:23:03 +0530 | [diff] [blame] | 43 | */ |
| 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 | } |