Further testing cleanup 97/100397/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Apr 2022 23:24:32 +0000 (01:24 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 4 Apr 2022 23:24:32 +0000 (01:24 +0200)
Remove more StmtTestUtils duplication.

Change-Id: Icd8798d8f89c6fdd3a526347e0b2a182189c1110
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
15 files changed:
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6867BasicTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6874Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6884Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentProcessTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4933Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5335Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6183Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6491Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6972Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7440Test.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/TypedefConstraintsTest.java
parser/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/YT1339Test.java

index ef3b1cbde3e6ab0729508a3494b10243934d286e..3a37acb78496f8f505e9176a4653c0545d7aaa03 100644 (file)
@@ -8,12 +8,10 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
 
 import static org.hamcrest.CoreMatchers.startsWith;
-import static org.junit.Assert.assertNotNull;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InvalidSubstatementException;
 import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6867BasicTest extends AbstractYangTest {
     @Test
@@ -50,8 +48,8 @@ public class Bug6867BasicTest extends AbstractYangTest {
     }
 
     @Test
-    public void yangModelTest() throws Exception {
-        assertNotNull(StmtTestUtils.parseYangSources("/rfc7950/model"));
+    public void yangModelTest() {
+        assertEffectiveModelDir("/rfc7950/model");
     }
 
     @Test
index d65eb0d960fe3aefb1226d5b6c5fe4f446576de6..d0dffbf3323ded1c2d77824c7486dfa54f3f6e35 100644 (file)
@@ -61,7 +61,7 @@ public class Bug6874Test {
     }
 
     @Test
-    public void invalid10IncludeStmtTest() throws Exception {
+    public void invalid10IncludeStmtTest() {
         final var ex = assertThrows(SomeModifiersUnresolvedException.class,
             () -> StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/invalid-include-10")).getCause();
         assertThat(ex, instanceOf(InvalidSubstatementException.class));
index 88bdc2b0821c97976f56fab0168b185967cebfeb..eb770b252047ff321ced291cf5bc320e6b290072 100644 (file)
@@ -15,16 +15,16 @@ import static org.junit.Assert.assertThrows;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
-public class Bug6876Test {
+public class Bug6876Test extends AbstractYangTest {
     @Test
-    public void yang11Test() throws Exception {
-        final EffectiveModelContext context = StmtTestUtils.parseYangSources("/rfc7950/bug6876/yang11");
+    public void yang11Test() {
+        final var context = assertEffectiveModelDir("/rfc7950/bug6876/yang11");
         DataSchemaNode node = context.findDataTreeChild(bar("augment-target"), bar("my-leaf")).orElse(null);
         assertThat(node, instanceOf(LeafSchemaNode.class));
         node = context.findDataTreeChild(bar("augment-target"), foo("mandatory-leaf")).orElse(null);
index de42a79bec6262c576749d232c963f8e1d1f13a5..2b1f0fba354ec074f9c1eaa11b33bcda17fcd0e3 100644 (file)
@@ -23,16 +23,16 @@ import org.opendaylight.yangtools.yang.model.api.AnydataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaTreeEffectiveStatement;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6883Test {
+public class Bug6883Test extends AbstractYangTest {
     private static final XMLNamespace FOO = XMLNamespace.of("foo");
 
     private ModuleEffectiveStatement foo;
 
     @Before
-    public void before() throws Exception {
-        foo = StmtTestUtils.parseYangSources("/bugs/bug6883").getModuleStatement(QName.create(FOO, "foo"));
+    public void before() {
+        foo = assertEffectiveModelDir("/bugs/bug6883").getModuleStatement(QName.create(FOO, "foo"));
     }
 
     @Test
index ede2333964e2e0b7b273676ff20b569cc311285b..9b9d840f3d200e47f580abdbc99ac8a7263d38f9 100644 (file)
@@ -14,21 +14,19 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
-import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+import org.opendaylight.yangtools.yang.stmt.AbstractYangTest;
 
-public class Bug6884Test {
+public class Bug6884Test extends AbstractYangTest {
     @Test
-    public void testYang11() throws Exception {
-        final EffectiveModelContext schemaContext = StmtTestUtils.parseYangSources("/rfc7950/bug6884/yang1-1");
+    public void testYang11() {
+        final var schemaContext = assertEffectiveModelDir("/rfc7950/bug6884/yang1-1");
         final DataSchemaNode node = schemaContext.findDataTreeChild(foo("sub-root"), foo("sub-foo-2-con")).orElse(null);
         assertThat(node, instanceOf(ContainerSchemaNode.class));
     }
 
     @Test
-    public void testCircularIncludesYang10() throws Exception {
-        final EffectiveModelContext schemaContext =
-            StmtTestUtils.parseYangSources("/rfc7950/bug6884/circular-includes");
+    public void testCircularIncludesYang10() {
+        final var schemaContext = assertEffectiveModelDir("/rfc7950/bug6884/circular-includes");
         DataSchemaNode node = schemaContext.findDataTreeChild(foo("sub-root"), foo("sub-foo-2-con")).orElse(null);
         assertThat(node, instanceOf(ContainerSchemaNode.class));
 
index 5eff39db71d8d3e4395cc78054f62d0929c5c6d8..7819eabb6add3ea0eed57f8f04e6a7f35809b59a 100644 (file)
@@ -31,7 +31,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class AugmentProcessTest {
+public class AugmentProcessTest extends AbstractYangTest {
     private static final StatementStreamSource AUGMENTED = sourceForResource("/stmt-test/augments/augmented.yang");
     private static final StatementStreamSource ROOT = sourceForResource("/stmt-test/augments/aug-root.yang");
 
@@ -99,7 +99,7 @@ public class AugmentProcessTest {
     }
 
     @Test(expected = SomeModifiersUnresolvedException.class)
-    public void multipleAugmentIncorrectPathTest() throws  ReactorException {
+    public void multipleAugmentIncorrectPathTest() throws ReactorException {
         SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
                 .addSource(MULTIPLE_AUGMENT_INCORRECT)
                 .buildEffective();
@@ -107,7 +107,7 @@ public class AugmentProcessTest {
     }
 
     @Test(expected = SomeModifiersUnresolvedException.class)
-    public void multipleAugmentIncorrectPathAndGrpTest() throws  ReactorException {
+    public void multipleAugmentIncorrectPathAndGrpTest() throws ReactorException {
         SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
                 .addSource(MULTIPLE_AUGMENT_INCORRECT2)
                 .buildEffective();
@@ -146,8 +146,8 @@ public class AugmentProcessTest {
     }
 
     @Test
-    public void caseShortHandAugmentingTest() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/choice-case-type-test-models");
+    public void caseShortHandAugmentingTest() {
+        final SchemaContext context = assertEffectiveModelDir("/choice-case-type-test-models");
 
         assertNotNull(context);
 
index 76b742bc54e1e1a66fd36d7c54b03bcf384f2b05..f3293fb1b1addee2c16169257faa7aeff1706a0a 100644 (file)
@@ -7,27 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.isA;
+import static org.hamcrest.CoreMatchers.startsWith;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.util.Collection;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
-public class Bug4933Test {
 
+public class Bug4933Test extends AbstractYangTest {
     @Test
-    public void test() throws Exception {
-        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug4933/correct");
-        assertNotNull(context);
+    public void test() {
+        final var context = assertEffectiveModelDir("/bugs/bug4933/correct");
 
         final Module foo = context.findModules("foo").iterator().next();
         Collection<? extends Deviation> deviations = foo.getDeviations();
@@ -35,14 +26,8 @@ public class Bug4933Test {
     }
 
     @Test
-    public void incorrectKeywordTest() throws Exception {
-        try {
-            StmtTestUtils.parseYangSources("/bugs/bug4933/incorrect");
-            fail("ReactorException should be thrown.");
-        } catch (ReactorException e) {
-            final Throwable cause = e.getCause();
-            assertThat(cause, isA(SourceException.class));
-            assertTrue(cause.getMessage().startsWith("String 'not_supported' is not valid deviate argument"));
-        }
+    public void incorrectKeywordTest() {
+        assertSourceExceptionDir("/bugs/bug4933/incorrect",
+            startsWith("String 'not_supported' is not valid deviate argument"));
     }
 }
index dd7f258dd1e4c0d0ae3c63bd9f3c9db82fae6073..297e96754edc48d937950bb5e4c6207b98d93fc7 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
-public class Bug5335Test {
+public class Bug5335Test extends AbstractYangTest {
     private static final String FOO = "foo";
     private static final String BAR = "bar";
     private static final String REV = "2016-03-04";
@@ -63,32 +63,32 @@ public class Bug5335Test {
     }
 
     @Test
-    public void correctTest1() throws Exception {
-        final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-1");
+    public void correctTest1() {
+        final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-1");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B, MANDATORY_LEAF_B)
             .orElse(null);
         assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
     }
 
     @Test
-    public void correctTest2() throws Exception {
-        final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-2");
+    public void correctTest2() {
+        final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-2");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B,
             NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
         assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
     }
 
     @Test
-    public void correctTest3() throws Exception {
-        final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-3");
+    public void correctTest3() {
+        final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-3");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, PRESENCE_CONTAINER_B,
             NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B).orElse(null);
         assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
     }
 
     @Test
-    public void correctTest4() throws Exception {
-        final EffectiveModelContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-4");
+    public void correctTest4() {
+        final EffectiveModelContext context = assertEffectiveModelDir("/bugs/bug5335/correct/case-4");
         final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, NON_PRESENCE_CONTAINER_F, MANDATORY_LEAF_F)
             .orElse(null);
         assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
index ec336cf85d092a7ed3d23255417ffee1ab1b036d..8414172d0b5c5e003106078cc7b6760c2fbdef2b 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
@@ -19,24 +18,23 @@ import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class Bug6183Test {
+public class Bug6183Test extends AbstractYangTest {
     private static final String FOO_NS = "foo";
 
     @Test
-    public void testYang10() throws Exception {
-        assertSchemaContext(StmtTestUtils.parseYangSources("/bugs/bug6183/yang10"));
+    public void testYang10() {
+        assertSchemaContext(assertEffectiveModelDir("/bugs/bug6183/yang10"));
     }
 
     @Test
-    public void testYang11() throws Exception {
-        assertSchemaContext(StmtTestUtils.parseYangSources("/bugs/bug6183/yang11"));
+    public void testYang11() {
+        assertSchemaContext(assertEffectiveModelDir("/bugs/bug6183/yang11"));
     }
 
-    public void assertSchemaContext(final SchemaContext context) throws Exception {
-        assertNotNull(context);
+    public void assertSchemaContext(final EffectiveModelContext context) {
         assertEquals(3, context.getChildNodes().size());
         assertEquals(1, context.getModules().size());
         assertEquals(4, context.getModules().iterator().next().getAugmentations().size());
index bbd43b5079cf1ca3515f6fac7304c6ebbac78551..8995f80518659aad767b2e7ce616b0bc828baedc 100644 (file)
@@ -18,11 +18,11 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-public class Bug6491Test {
+public class Bug6491Test extends AbstractYangTest {
     private static final Revision DATE = Revision.of("2016-01-01");
 
     @Test
-    public void tetststs() throws Exception {
+    public void tetststs() {
         testRevision("withoutRevision", null, Optional.empty());
         testRevision("withRevision", DATE, Optional.of(DATE));
         testRevision("importedModuleRevisionOnly", null, Optional.of(DATE));
@@ -30,9 +30,8 @@ public class Bug6491Test {
     }
 
     private static void testRevision(final String path, final Revision moduleRevision,
-            final Optional<Revision> importedRevision) throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6491/".concat(path));
-        assertNotNull(context);
+            final Optional<Revision> importedRevision) {
+        final SchemaContext context = assertEffectiveModelDir("/bugs/bug6491/" + path);
         final Module module = context.findModule("bar", moduleRevision).get();
         final Collection<? extends ModuleImport> imports = module.getImports();
         assertNotNull(imports);
index e2f4444ed9563b8ebfdda6d8f6fa95c7b305c5b2..4cba325213031d350e04c8cbfbd31430ddb3c03e 100644 (file)
@@ -17,16 +17,14 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.LeafEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.UnitsEffectiveStatement;
 
-public class Bug6972Test {
+public class Bug6972Test extends AbstractYangTest {
     @Test
-    public void allUnitsShouldBeTheSameInstance() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug6972");
-        assertNotNull(schemaContext);
+    public void allUnitsShouldBeTheSameInstance() {
+        final var schemaContext = assertEffectiveModelDir("/bugs/bug6972");
         assertEquals(3, schemaContext.getModules().size());
 
         final Revision revision = Revision.of("2016-10-20");
index 77cc6559cde2cdac65d297e76f089cf075a8541a..fa875f2ffdff54c27cbe8a405160945f447965da 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 
 import java.util.Collection;
 import org.junit.Test;
@@ -17,14 +16,12 @@ import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.DeviateDefinition;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
-public class Bug7440Test {
+public class Bug7440Test extends AbstractYangTest {
     @Test
-    public void testRestrictedTypeParentSchemaPathInDeviate() throws Exception {
-        final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug7440");
-        assertNotNull(schemaContext);
+    public void testRestrictedTypeParentSchemaPathInDeviate() {
+        final var schemaContext = assertEffectiveModelDir("/bugs/bug7440");
 
         final Revision revision = Revision.of("2016-12-23");
         final Module foo = schemaContext.findModule("foo", revision).get();
index 339591cad111a5614996011169c13eaf25835f5c..aab46a403f556897991058f2b6c0c062fa7d64ac 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.stmt;
 import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
@@ -32,8 +31,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 
-public class MoreRevisionsTest {
-
+public class MoreRevisionsTest extends AbstractYangTest {
     private static final StatementStreamSource REVFILE = sourceForResource(
             "/semantic-statement-parser/revisions/more-revisions-test.yang");
 
@@ -95,17 +93,16 @@ public class MoreRevisionsTest {
     }
 
     @Test
-    public void multipleRevisionsTest() throws Exception {
+    public void multipleRevisionsTest() {
         for (int i = 0; i < 100; i++) {
-            assertNotNull(StmtTestUtils.parseYangSources("/semantic-statement-parser/multiple-revisions"));
+            assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions");
         }
     }
 
     @Test
-    public void multipleRevisionsFullTest() throws Exception {
+    public void multipleRevisionsFullTest() {
         for (int i = 0; i < 100; i++) {
-            EffectiveModelContext context =
-                StmtTestUtils.parseYangSources("/semantic-statement-parser/multiple-revisions/full");
+            var context = assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions/full");
             assertEquals(6, context.getModules().size());
             checkContentFullTest(context);
         }
@@ -164,10 +161,9 @@ public class MoreRevisionsTest {
     }
 
     @Test
-    public void multipleRevisionsSimpleTest() throws Exception {
+    public void multipleRevisionsSimpleTest() {
         for (int i = 0; i < 1000; i++) {
-            EffectiveModelContext context = StmtTestUtils.parseYangSources(
-                "/semantic-statement-parser/multiple-revisions/simple");
+            var context = assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions/simple");
             assertEquals(5, context.getModules().size());
             checkContentSimpleTest(context);
         }
@@ -248,9 +244,8 @@ public class MoreRevisionsTest {
     }
 
     @Test
-    public void nodeTest() throws Exception {
-        EffectiveModelContext context = StmtTestUtils.parseYangSources(
-            "/semantic-statement-parser/multiple-revisions/node-test");
+    public void nodeTest() {
+        final var context = assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions/node-test");
 
         QName root = QName.create("foo", "2016-04-06", "foo-root");
         QName container20160404 = QName.create("foo", "2016-04-06", "con20160404");
index fb5cf74e7adcbfbc8bae3f86d5336938d9f9ed32..f51d9d340b1e5951d496443dad608f3d97ab1451 100644 (file)
@@ -20,15 +20,14 @@ import org.opendaylight.yangtools.yang.common.Decimal64;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.TypeDefinitions;
 
-public class TypedefConstraintsTest {
+public class TypedefConstraintsTest extends AbstractYangTest {
     @Test
-    public void decimalRangeConstraintsTest() throws Exception {
-        final SchemaContext context = StmtTestUtils.parseYangSources("/stmt-test/constraints");
+    public void decimalRangeConstraintsTest() {
+        final var context = assertEffectiveModelDir("/stmt-test/constraints");
 
         assertNotNull(context);
 
index ec06bc96f274c972a36d9164787fa2ce1c0c3ff6..c2518756dd5a10f79cbaef34a0ee2e0783799098 100644 (file)
@@ -7,21 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.CoreMatchers.startsWith;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertThrows;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.YangVersion;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.source.YangVersionLinkageException;
 
 /**
  * Tests for {@code MUST NOT} statements around include/import interop of RFC6020 and RFC7950, as per
  * <a href="https://datatracker.ietf.org/doc/html/rfc7950#section-12">RFC7950 section 12</a>.
  */
-public class YT1339Test {
+public class YT1339Test extends AbstractYangTest {
     @Test
     public void testInclude() {
         // A YANG version 1.1 module MUST NOT include a YANG version 1 submodule,
@@ -31,22 +28,22 @@ public class YT1339Test {
     }
 
     @Test
-    public void testImportNewByRev() throws Exception {
+    public void testImportNewByRev() {
         // A YANG version 1 module or submodule MUST NOT import a YANG version 1.1 module by revision.
         assertFailedImport("import-rev");
         assertFailedImport("import-rev-sub");
     }
 
     @Test
-    public void testImportOldByRev() throws Exception {
+    public void testImportOldByRev() {
         // A YANG version 1.1 module or submodule MAY import a YANG version 1 module by revision.
-        compile("import");
+        assertEffectiveModelDir("/bugs/YT1339/import");
     }
 
     @Test
-    public void testImportNoRev() throws Exception {
+    public void testImportNoRev() {
         // no language forbidding imports without revision
-        compile("import-norev");
+        assertEffectiveModelDir("/bugs/YT1339/import-norev");
     }
 
     private static void assertFailedImport(final String subdir) {
@@ -60,12 +57,6 @@ public class YT1339Test {
     }
 
     private static String assertYangVersionLinkageException(final String subdir) {
-        final var cause = assertThrows(ReactorException.class, () -> compile(subdir)).getCause();
-        assertThat(cause, instanceOf(YangVersionLinkageException.class));
-        return cause.getMessage();
-    }
-
-    private static void compile(final String subdir) throws Exception {
-        StmtTestUtils.parseYangSources("/bugs/YT1339/" + subdir);
+        return assertExceptionDir("/bugs/YT1339/" + subdir, YangVersionLinkageException.class).getMessage();
     }
 }