Remove more StmtTestUtils duplication.
Change-Id: Icd8798d8f89c6fdd3a526347e0b2a182189c1110
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
15 files changed:
package org.opendaylight.yangtools.yang.parser.stmt.rfc7950;
import static org.hamcrest.CoreMatchers.startsWith;
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.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
public class Bug6867BasicTest extends AbstractYangTest {
@Test
- public void yangModelTest() throws Exception {
- assertNotNull(StmtTestUtils.parseYangSources("/rfc7950/model"));
+ public void yangModelTest() {
+ assertEffectiveModelDir("/rfc7950/model");
- 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));
final var ex = assertThrows(SomeModifiersUnresolvedException.class,
() -> StmtTestUtils.parseYangSources("/rfc7950/include-import-stmt-test/invalid-include-10")).getCause();
assertThat(ex, instanceOf(InvalidSubstatementException.class));
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
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.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;
import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
-public class Bug6876Test {
+public class Bug6876Test extends AbstractYangTest {
- 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);
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);
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.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
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"));
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.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 {
- 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
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));
DataSchemaNode node = schemaContext.findDataTreeChild(foo("sub-root"), foo("sub-foo-2-con")).orElse(null);
assertThat(node, instanceOf(ContainerSchemaNode.class));
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
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");
private static final StatementStreamSource AUGMENTED = sourceForResource("/stmt-test/augments/augmented.yang");
private static final StatementStreamSource ROOT = sourceForResource("/stmt-test/augments/aug-root.yang");
}
@Test(expected = SomeModifiersUnresolvedException.class)
}
@Test(expected = SomeModifiersUnresolvedException.class)
- public void multipleAugmentIncorrectPathTest() throws ReactorException {
+ public void multipleAugmentIncorrectPathTest() throws ReactorException {
SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
.addSource(MULTIPLE_AUGMENT_INCORRECT)
.buildEffective();
SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
.addSource(MULTIPLE_AUGMENT_INCORRECT)
.buildEffective();
}
@Test(expected = SomeModifiersUnresolvedException.class)
}
@Test(expected = SomeModifiersUnresolvedException.class)
- public void multipleAugmentIncorrectPathAndGrpTest() throws ReactorException {
+ public void multipleAugmentIncorrectPathAndGrpTest() throws ReactorException {
SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
.addSource(MULTIPLE_AUGMENT_INCORRECT2)
.buildEffective();
SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
.addSource(MULTIPLE_AUGMENT_INCORRECT2)
.buildEffective();
- 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");
*/
package org.opendaylight.yangtools.yang.stmt;
*/
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.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 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 {
- 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();
final Module foo = context.findModules("foo").iterator().next();
Collection<? extends Deviation> deviations = foo.getDeviations();
- 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"));
import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
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";
private static final String FOO = "foo";
private static final String BAR = "bar";
private static final String REV = "2016-03-04";
- 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
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
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
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));
final DataSchemaNode mandatoryLeaf = context.findDataTreeChild(ROOT, NON_PRESENCE_CONTAINER_F, MANDATORY_LEAF_F)
.orElse(null);
assertThat(mandatoryLeaf, instanceOf(LeafSchemaNode.class));
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
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;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
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.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.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
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"));
- 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());
assertEquals(3, context.getChildNodes().size());
assertEquals(1, context.getModules().size());
assertEquals(4, context.getModules().iterator().next().getAugmentations().size());
import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
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
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));
testRevision("withoutRevision", null, Optional.empty());
testRevision("withRevision", DATE, Optional.of(DATE));
testRevision("importedModuleRevisionOnly", null, Optional.of(DATE));
}
private static void testRevision(final String path, final Revision moduleRevision,
}
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);
final Module module = context.findModule("bar", moduleRevision).get();
final Collection<? extends ModuleImport> imports = module.getImports();
assertNotNull(imports);
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.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;
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 {
- 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");
assertEquals(3, schemaContext.getModules().size());
final Revision revision = Revision.of("2016-10-20");
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertEquals;
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;
import java.util.Collection;
import org.junit.Test;
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.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;
import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-public class Bug7440Test {
+public class Bug7440Test extends AbstractYangTest {
- 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();
final Revision revision = Revision.of("2016-12-23");
final Module foo = schemaContext.findModule("foo", revision).get();
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
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;
import static org.junit.Assert.assertTrue;
import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
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");
private static final StatementStreamSource REVFILE = sourceForResource(
"/semantic-statement-parser/revisions/more-revisions-test.yang");
- public void multipleRevisionsTest() throws Exception {
+ public void multipleRevisionsTest() {
for (int i = 0; i < 100; i++) {
for (int i = 0; i < 100; i++) {
- assertNotNull(StmtTestUtils.parseYangSources("/semantic-statement-parser/multiple-revisions"));
+ assertEffectiveModelDir("/semantic-statement-parser/multiple-revisions");
- public void multipleRevisionsFullTest() throws Exception {
+ public void multipleRevisionsFullTest() {
for (int i = 0; i < 100; i++) {
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);
}
assertEquals(6, context.getModules().size());
checkContentFullTest(context);
}
- public void multipleRevisionsSimpleTest() throws Exception {
+ public void multipleRevisionsSimpleTest() {
for (int i = 0; i < 1000; i++) {
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);
}
assertEquals(5, context.getModules().size());
checkContentSimpleTest(context);
}
- 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");
QName root = QName.create("foo", "2016-04-06", "foo-root");
QName container20160404 = QName.create("foo", "2016-04-06", "con20160404");
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.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;
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 {
- public void decimalRangeConstraintsTest() throws Exception {
- final SchemaContext context = StmtTestUtils.parseYangSources("/stmt-test/constraints");
+ public void decimalRangeConstraintsTest() {
+ final var context = assertEffectiveModelDir("/stmt-test/constraints");
*/
package org.opendaylight.yangtools.yang.stmt;
*/
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.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.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>.
*/
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,
@Test
public void testInclude() {
// A YANG version 1.1 module MUST NOT include a YANG version 1 submodule,
- 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
// 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.
// A YANG version 1.1 module or submodule MAY import a YANG version 1 module by revision.
+ assertEffectiveModelDir("/bugs/YT1339/import");
- public void testImportNoRev() throws Exception {
+ public void testImportNoRev() {
// no language forbidding imports without revision
// no language forbidding imports without revision
- compile("import-norev");
+ assertEffectiveModelDir("/bugs/YT1339/import-norev");
}
private static void assertFailedImport(final String subdir) {
}
private static void assertFailedImport(final String subdir) {
}
private static String assertYangVersionLinkageException(final String subdir) {
}
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();