From: Robert Varga Date: Thu, 23 Jan 2020 11:02:46 +0000 (+0100) Subject: Remove use of org.junit.rules.ExpectedException X-Git-Tag: v5.0.10~27 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=219f8cfe65beae4753ceddae0063a461426137ad;p=mdsal.git Remove use of org.junit.rules.ExpectedException We can use assertThrows() instead. Change-Id: I8d752851d11496c74388f625067e41582447a8c5 Signed-off-by: Robert Varga --- diff --git a/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/BindingGeneratorUtilTest.java b/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/BindingGeneratorUtilTest.java index 76240b3126..b41b8463e5 100644 --- a/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/BindingGeneratorUtilTest.java +++ b/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/BindingGeneratorUtilTest.java @@ -12,6 +12,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; @@ -21,9 +22,7 @@ import com.google.common.collect.Range; import java.io.Serializable; import java.util.Optional; import java.util.Set; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.opendaylight.mdsal.binding.model.api.AccessModifier; import org.opendaylight.mdsal.binding.model.api.JavaTypeName; import org.opendaylight.mdsal.binding.model.api.Restrictions; @@ -53,9 +52,6 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; public class BindingGeneratorUtilTest { private static final SchemaPath ROOT_PATH = SchemaPath.create(true, QName.create("test", "root")); - @Rule - public ExpectedException expectedEx = ExpectedException.none(); - /* * Tests methods: * <ul> @@ -124,8 +120,7 @@ public class BindingGeneratorUtilTest { */ @Test public void testPackageNameForGeneratedTypeNullBasePackageName() { - expectedEx.expect(NullPointerException.class); - BindingGeneratorUtil.packageNameForGeneratedType(null, null); + assertThrows(NullPointerException.class, () -> BindingGeneratorUtil.packageNameForGeneratedType(null, null)); } /* @@ -137,8 +132,8 @@ public class BindingGeneratorUtilTest { */ @Test public void testPackageNameForGeneratedTypeNullSchemaPath() { - expectedEx.expect(NullPointerException.class); - BindingGeneratorUtil.packageNameForGeneratedType("test.package", null); + assertThrows(NullPointerException.class, + () -> BindingGeneratorUtil.packageNameForGeneratedType("test.package", null)); } /* diff --git a/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/TypeNameTest.java b/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/TypeNameTest.java index 3b558bb048..63483d08b4 100644 --- a/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/TypeNameTest.java +++ b/binding/mdsal-binding-generator-util/src/test/java/org/opendaylight/mdsal/binding/model/util/TypeNameTest.java @@ -11,16 +11,10 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; -import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.opendaylight.mdsal.binding.model.api.JavaTypeName; public class TypeNameTest { - - @Rule - public ExpectedException expException = ExpectedException.none(); - @Test public void testHashCode() { JavaTypeName baseType1 = JavaTypeName.create("org.opendaylight.yangtools.test", "Test");