<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
@Override
public String toString() {
return "Module [name=" + getName() + ", revision=" + getRevision()
- + ", semanticVersion=" + getSemanticVersion().orElse(null)
- + ", dependencies=" + getDependencies()
- + "]";
+ + ", semanticVersion=" + getSemanticVersion().orElse(null)
+ + ", dependencies=" + getDependencies()
+ + "]";
}
}
}
@Override
- public void characters(final char ch[], final int start, final int length) throws SAXException {
+ public void characters(final char[] ch, final int start, final int length) throws SAXException {
sb.append(ch, start, length);
}
ImportPrefixToModuleCtx.class);
if (allImports != null) {
allImports.forEach((key, value) ->
- prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value)));
+ prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value)));
}
final Map<String, StmtContext<?, ?, ?>> allBelongsTo = getRoot().getAllFromNamespace(
BelongsToPrefixToModuleCtx.class);
if (allBelongsTo != null) {
allBelongsTo.forEach((key, value) ->
- prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value)));
+ prefixToModuleMap.put(key, getRoot().getFromNamespace(ModuleCtxToModuleQName.class, value)));
}
return prefixToModuleMap;
* bundle of supported verions
*/
public CustomStatementParserBuilder(final Set<YangVersion> supportedVersions) {
- reactorSupportBundles = ImmutableMap.<ModelProcessingPhase, StatementSupportBundle.Builder> builder()
+ reactorSupportBundles = ImmutableMap.<ModelProcessingPhase, StatementSupportBundle.Builder>builder()
.put(ModelProcessingPhase.INIT, StatementSupportBundle.builder(supportedVersions))
.put(ModelProcessingPhase.SOURCE_PRE_LINKAGE, StatementSupportBundle.builder(supportedVersions))
.put(ModelProcessingPhase.SOURCE_LINKAGE, StatementSupportBundle.builder(supportedVersions))
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-with-features-test");
- final SettableSchemaProvider<ASTSchemaSource> foobar = getImmediateYangSourceProviderFromResource
- ("/if-feature-resolution-test/shared-schema-repository/foobar.yang");
+ final SettableSchemaProvider<ASTSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
+ "/if-feature-resolution-test/shared-schema-repository/foobar.yang");
foobar.register(sharedSchemaRepository);
foobar.setResult();
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-with-features-test");
- final SettableSchemaProvider<ASTSchemaSource> foobar = getImmediateYangSourceProviderFromResource
- ("/if-feature-resolution-test/shared-schema-repository/foobar.yang");
+ final SettableSchemaProvider<ASTSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
+ "/if-feature-resolution-test/shared-schema-repository/foobar.yang");
foobar.register(sharedSchemaRepository);
foobar.setResult();
final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
"shared-schema-repo-with-features-test");
- final SettableSchemaProvider<ASTSchemaSource> foobar = getImmediateYangSourceProviderFromResource
- ("/if-feature-resolution-test/shared-schema-repository/foobar.yang");
+ final SettableSchemaProvider<ASTSchemaSource> foobar = getImmediateYangSourceProviderFromResource(
+ "/if-feature-resolution-test/shared-schema-repository/foobar.yang");
foobar.register(sharedSchemaRepository);
foobar.setResult();
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
}
}
- @Test
+ @Test(expected = IllegalArgumentException.class)
@Ignore
- public void invalidAugEmptyTest() throws SourceException {
+ public void invalidAugEmptyTest() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(INVALID_EMPTY);
- try {
- reactor.build();
- fail("reactor.process should fail due to empty path");
- } catch (Exception e) {
- assertEquals(IllegalArgumentException.class, e.getClass());
- }
+ reactor.build();
+ fail("reactor.process should fail due to empty path");
}
- @Test
+ @Test(expected = IllegalArgumentException.class)
@Ignore
- public void invalidAugXPathTest() throws SourceException {
+ public void invalidAugXPathTest() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(INVALID_XPATH);
-
- try {
- reactor.build();
- fail("reactor.process should fail due to invalid XPath");
- } catch (Exception e) {
- assertEquals(IllegalArgumentException.class, e.getClass());
- }
+ reactor.build();
+ fail("reactor.process should fail due to invalid XPath");
}
- private static void assertSourceExceptionCause(final Throwable e, final String start) {
- final Throwable cause = e.getCause();
+ private static void assertSourceExceptionCause(final Throwable exception, final String start) {
+ final Throwable cause = exception.getCause();
assertTrue(cause instanceof SourceException);
assertTrue(cause.getMessage().startsWith(start));
}
import java.net.URI;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public void testAugmentParsing() throws Exception {
final SchemaContext context = TestUtils.loadModules(getClass().getResource("/augment-test/augment-in-augment")
.toURI());
- SchemaPath expectedSchemaPath;
final List<QName> qnames = new ArrayList<>();
qnames.add(Q0);
qnames.add(Q1);
final AugmentationSchema augment = augmentations.iterator().next();
assertNotNull(augment);
- expectedSchemaPath = SchemaPath.create(qnames, true);
+ SchemaPath expectedSchemaPath = SchemaPath.create(qnames, true);
assertEquals(expectedSchemaPath, augment.getTargetPath());
final Collection<DataSchemaNode> augmentChildren = augment.getChildNodes();
final ListSchemaNode ifEntry = (ListSchemaNode) interfaces.getDataChildByName(QName.create(
module2.getQNameModule(), "ifEntry"));
- SchemaPath expectedPath;
final List<QName> qnames = new ArrayList<>();
qnames.add(Q0);
qnames.add(Q1);
"augment-holder"));
TestUtils.checkIsAugmenting(augmentHolder, true);
assertEquals(Q2, augmentHolder.getQName());
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, augmentHolder.getPath());
+ assertEquals(SchemaPath.create(qnames, true), augmentHolder.getPath());
// foo.yang
// augment "/br:interfaces/br:ifEntry/bz:augment-holder"
QName qname = QName.create(FOO, "ds0ChannelNumber");
assertEquals(qname, ds0ChannelNumber.getQName());
qnames.add(qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, ds0ChannelNumber.getPath());
+ assertEquals(SchemaPath.create(qnames, true), ds0ChannelNumber.getPath());
// leaf interface-id
qname = QName.create(FOO, "interface-id");
assertEquals(qname, interfaceId.getQName());
qnames.set(3, qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, interfaceId.getPath());
+ assertEquals(SchemaPath.create(qnames, true), interfaceId.getPath());
// container schemas
qname = QName.create(FOO, "schemas");
assertEquals(qname, schemas.getQName());
qnames.set(3, qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, schemas.getPath());
+ assertEquals(SchemaPath.create(qnames, true), schemas.getPath());
// choice odl
qname = QName.create(FOO, "odl");
assertEquals(qname, odl.getQName());
qnames.set(3, qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, odl.getPath());
+ assertEquals(SchemaPath.create(qnames, true), odl.getPath());
}
@Test
assertNotNull(node2);
assertNotNull(node3);
- SchemaPath expectedPath;
final List<QName> qnames = new ArrayList<>();
qnames.add(Q0);
qnames.add(Q1);
QName qname = QName.create(FOO, "id");
assertEquals(qname, id.getQName());
qnames.add(qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, id.getPath());
+ assertEquals(SchemaPath.create(qnames, true), id.getPath());
final Collection<DataSchemaNode> idChildren = id.getChildNodes();
assertEquals(1, idChildren.size());
qname = QName.create(FOO, "node1");
assertEquals(qname, node1.getQName());
qnames.set(4, qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, node1.getPath());
+ assertEquals(SchemaPath.create(qnames, true), node1.getPath());
final Collection<DataSchemaNode> node1Children = node1.getChildNodes();
assertTrue(node1Children.isEmpty());
qname = QName.create(FOO, "node2");
assertEquals(qname, node2.getQName());
qnames.set(4, qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, node2.getPath());
+ assertEquals(SchemaPath.create(qnames, true), node2.getPath());
final Collection<DataSchemaNode> node2Children = node2.getChildNodes();
assertTrue(node2Children.isEmpty());
qname = QName.create(FOO, "node3");
assertEquals(qname, node3.getQName());
qnames.set(4, qname);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, node3.getPath());
+ assertEquals(SchemaPath.create(qnames, true), node3.getPath());
final Collection<DataSchemaNode> node3Children = node3.getChildNodes();
assertEquals(1, node3Children.size());
qnames.add(QName.create(FOO, "id"));
final LeafSchemaNode caseIdChild = (LeafSchemaNode) idChildren.iterator().next();
assertNotNull(caseIdChild);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, caseIdChild.getPath());
+ assertEquals(SchemaPath.create(qnames, true), caseIdChild.getPath());
// case node3 child
qnames.set(4, QName.create(FOO, "node3"));
qnames.set(5, QName.create(FOO, "node3"));
final ContainerSchemaNode caseNode3Child = (ContainerSchemaNode) node3Children.iterator().next();
assertNotNull(caseNode3Child);
- expectedPath = SchemaPath.create(qnames, true);
- assertEquals(expectedPath, caseNode3Child.getPath());
+ assertEquals(SchemaPath.create(qnames, true), caseNode3Child.getPath());
}
@Test
assertTrue(create.isAugmenting());
assertTrue(destroy.isAugmenting());
- SchemaPath expectedPath;
final QName[] qnames = new QName[4];
qnames[0] = submitQName;
qnames[1] = inputQName;
// case attach
qnames[3] = QName.create(NS_FOO, revision, "attach");
assertEquals(qnames[3], attach.getQName());
- expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
- assertEquals(expectedPath, attach.getPath());
+ assertEquals(SchemaPath.create(true, qnames), attach.getPath());
final Collection<DataSchemaNode> attachChildren = attach.getChildNodes();
assertEquals(1, attachChildren.size());
// case create
qnames[3] = QName.create(NS_FOO, revision, "create");
assertEquals(qnames[3], create.getQName());
- expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
- assertEquals(expectedPath, create.getPath());
+ assertEquals(SchemaPath.create(true, qnames), create.getPath());
final Collection<DataSchemaNode> createChildren = create.getChildNodes();
assertEquals(1, createChildren.size());
// case attach
qnames[3] = QName.create(NS_FOO, revision, "destroy");
assertEquals(qnames[3], destroy.getQName());
- expectedPath = SchemaPath.create(Arrays.asList(qnames), true);
- assertEquals(expectedPath, destroy.getPath());
+ assertEquals(SchemaPath.create(true, qnames), destroy.getPath());
final Collection<DataSchemaNode> destroyChildren = destroy.getChildNodes();
assertEquals(1, destroyChildren.size());
}
/*
* FIXME: Figure way to determine use case of tail-f:input without hacks
- *
*/
@Test
public void testCorrectPathIntoUnsupportedTarget() throws Exception {
- try {
context = TestUtils.loadModules(getClass().getResource(
"/augment-to-extension-test/correct-path-into-unsupported-target").toURI());
- } catch (final Exception e) {
- StmtTestUtils.log(e, " ");
- throw e;
- }
final Module devicesModule = TestUtils.findModule(context, "augment-module").get();
-
- final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(QName
- .create(devicesModule.getQNameModule(), "my-container"));
+ final ContainerSchemaNode devicesContainer = (ContainerSchemaNode) devicesModule.getDataChildByName(
+ QName.create(devicesModule.getQNameModule(), "my-container"));
final Set<UsesNode> uses = devicesContainer.getUses();
for (final UsesNode usesNode : uses) {
/**
* Test ANTLR4 grammar capability to parse description statement in unknown node.
*
+ * <p>
* Note: Everything under unknown node is unknown node.
*/
public class Bug1412Test {
* Test ANTLR4 grammar capability to parse unknown node in extension argument
* declaration.
*
+ * <p>
* Note: Everything under unknown node is unknown node.
*/
public class Bug1413Test {
package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertNotNull;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import java.io.File;
import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public class Bug2291Test {
@Test(expected = PatternSyntaxException.class)
public void testInvalidPattern2() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD("(\\p{IsSpecials}|\\\\\\\\p{IsBasicLatin})*+");
+ String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD(
+ "(\\p{IsSpecials}|\\\\\\\\p{IsBasicLatin})*+");
assertEquals("^(\\p{InSpecials}|\\\\\\\\p{IsBasicLatin})*+$", fixedUnicodeScriptPattern);
// should throw exception
Pattern.compile(fixedUnicodeScriptPattern);
@Test(expected = PatternSyntaxException.class)
public void testInvalidPattern3() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
- String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD("(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+");
+ String fixedUnicodeScriptPattern = RegexUtils.getJavaRegexFromXSD(
+ "(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+");
assertEquals("^(\\\\\\\\\\\\p{IsBasicLatin}|\\p{IsTags})*+$", fixedUnicodeScriptPattern);
// should throw exception
Pattern.compile(fixedUnicodeScriptPattern);
.getLocalName();
switch (extensionDefinition.getQName().getLocalName()) {
- case "a":
- assertEquals("b", unknownNodeExtensionDefName);
- assertEquals("c", subUnknownNodeExtensionDefName);
- break;
- case "b":
- assertEquals("c", unknownNodeExtensionDefName);
- assertEquals("a", subUnknownNodeExtensionDefName);
- break;
- case "c":
- assertEquals("a", unknownNodeExtensionDefName);
- assertEquals("b", subUnknownNodeExtensionDefName);
- break;
- case "r":
- assertEquals("r", unknownNodeExtensionDefName);
- assertEquals("r2", subUnknownNodeExtensionDefName);
- break;
- case "r2":
- assertEquals("r2", unknownNodeExtensionDefName);
- assertEquals("r", subUnknownNodeExtensionDefName);
- break;
- default:
- fail("Unexpected extension definition");
+ case "a":
+ assertEquals("b", unknownNodeExtensionDefName);
+ assertEquals("c", subUnknownNodeExtensionDefName);
+ break;
+ case "b":
+ assertEquals("c", unknownNodeExtensionDefName);
+ assertEquals("a", subUnknownNodeExtensionDefName);
+ break;
+ case "c":
+ assertEquals("a", unknownNodeExtensionDefName);
+ assertEquals("b", subUnknownNodeExtensionDefName);
+ break;
+ case "r":
+ assertEquals("r", unknownNodeExtensionDefName);
+ assertEquals("r2", subUnknownNodeExtensionDefName);
+ break;
+ case "r2":
+ assertEquals("r2", unknownNodeExtensionDefName);
+ assertEquals("r", subUnknownNodeExtensionDefName);
+ break;
+ default:
+ fail("Unexpected extension definition");
}
}
}
}
@After
+ @SuppressWarnings("checkstyle:regexpSinglelineJava")
public void cleanUp() {
System.setOut(System.out);
}
assertNull(mandatoryLeaf);
final String testLog = output.toString();
- assertTrue(testLog
- .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
+ assertTrue(testLog.contains(
+ "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
@Test
assertNull(mandatoryLeaf);
final String testLog = output.toString();
- assertTrue(testLog
- .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
+ assertTrue(testLog.contains(
+ "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
@Test
assertNull(mandatoryLeaf);
final String testLog = output.toString();
- assertTrue(testLog
- .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
+ assertTrue(testLog.contains(
+ "An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different than target"));
}
@Test
StringTypeDefinition stringType2 = (StringTypeDefinition) type2;
StringTypeDefinition stringType3 = (StringTypeDefinition) type3;
- List<PatternConstraint> patternConstraints0 = stringType0.getPatternConstraints();
- List<PatternConstraint> patternConstraints1 = stringType1.getPatternConstraints();
- List<PatternConstraint> patternConstraints2 = stringType2.getPatternConstraints();
- List<PatternConstraint> patternConstraints3 = stringType3.getPatternConstraints();
+ final List<PatternConstraint> patternConstraints0 = stringType0.getPatternConstraints();
+ final List<PatternConstraint> patternConstraints1 = stringType1.getPatternConstraints();
+ final List<PatternConstraint> patternConstraints2 = stringType2.getPatternConstraints();
+ final List<PatternConstraint> patternConstraints3 = stringType3.getPatternConstraints();
assertEquals(1, patternConstraints0.size());
assertEquals(1, patternConstraints1.size());
assertEquals(1, patternConstraints2.size());
assertEquals(1, patternConstraints3.size());
- PatternConstraint patternConstraint0 = patternConstraints0.get(0);
- PatternConstraint patternConstraint1 = patternConstraints1.get(0);
- PatternConstraint patternConstraint2 = patternConstraints2.get(0);
- PatternConstraint patternConstraint3 = patternConstraints3.get(0);
+ final PatternConstraint patternConstraint0 = patternConstraints0.get(0);
+ final PatternConstraint patternConstraint1 = patternConstraints1.get(0);
+ final PatternConstraint patternConstraint2 = patternConstraints2.get(0);
+ final PatternConstraint patternConstraint3 = patternConstraints3.get(0);
assertEquals("^dp[0-9]+o[0-9]+(d[0-9]+)?$", patternConstraint0.getRegularExpression());
assertEquals("^dp[0-9]+s[0-9]+(f[0-9]+)?(d[0-9]+)?$", patternConstraint1.getRegularExpression());
package org.opendaylight.yangtools.yang.stmt;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.FileNotFoundException;
+import java.io.IOException;
import java.net.URISyntaxException;
import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
public class Bug6131Test {
- @Test
- public void test() throws ReactorException, SourceException, FileNotFoundException, URISyntaxException {
- try {
- StmtTestUtils.parseYangSources("/bugs/bug6131");
- fail("A NullPointerException should have been thrown.");
- } catch (final Exception e) {
- assertTrue(e instanceof NullPointerException);
- }
+ @Test(expected = NullPointerException.class)
+ public void test() throws ReactorException, URISyntaxException, SourceException, IOException,
+ YangSyntaxErrorException {
+ StmtTestUtils.parseYangSources("/bugs/bug6131");
}
}
\ No newline at end of file
assertNotNull(schemaContext);
assertEquals(1, schemaContext.getModules().size());
final Module module = schemaContext.getModules().iterator().next();
- assertEquals(" 1. this text contains \"string enclosed in double quotes\" and"+
- " special characters: \\,\n,\t 2. this text contains \"string enclosed in double quotes\" and"+
- " special characters: \\,\n,\n, 3. this text contains \"string enclosed in double quotes\" and"+
- " special characters: \\,\n,\t ", module.getDescription());
+ assertEquals(" 1. this text contains \"string enclosed in double quotes\" and"
+ + " special characters: \\,\n,\t 2. this text contains \"string enclosed in double quotes\""
+ + " and special characters: \\,\n,\n, 3. this text contains \"string enclosed in"
+ + " double quotes\" and special characters: \\,\n,\t ", module.getDescription());
}
@Test
final ContainerSchemaNode subBarCon = (ContainerSchemaNode) dataChildByName;
assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "foo-grp-con")) instanceof ContainerSchemaNode);
- assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con")) instanceof ContainerSchemaNode);
+ assertTrue(subBarCon.getDataChildByName(QName.create(NS, REV, "sub-foo-grp-con"))
+ instanceof ContainerSchemaNode);
}
@Test
for (final EnumPair enumPair : values) {
final String name = enumPair.getName();
switch (name) {
- case "zero":
- assertEquals(0, enumPair.getValue());
- break;
- case "twenty":
- assertEquals(20, enumPair.getValue());
- break;
- case "twenty-one":
- assertEquals(21, enumPair.getValue());
- break;
- case "two":
- assertEquals(2, enumPair.getValue());
- break;
- case "twenty-two":
- assertEquals(22, enumPair.getValue());
- break;
- default:
- fail("Unexpected enum name.");
+ case "zero":
+ assertEquals(0, enumPair.getValue());
+ break;
+ case "twenty":
+ assertEquals(20, enumPair.getValue());
+ break;
+ case "twenty-one":
+ assertEquals(21, enumPair.getValue());
+ break;
+ case "two":
+ assertEquals(2, enumPair.getValue());
+ break;
+ case "twenty-two":
+ assertEquals(22, enumPair.getValue());
+ break;
+ default:
+ fail("Unexpected enum name.");
}
}
}
for (final Bit bit : positions) {
final String name = bit.getName();
switch (name) {
- case "zero":
- assertEquals(0, bit.getPosition());
- break;
- case "twenty":
- assertEquals(20, bit.getPosition());
- break;
- case "twenty-one":
- assertEquals(21, bit.getPosition());
- break;
- case "two":
- assertEquals(2, bit.getPosition());
- break;
- case "twenty-two":
- assertEquals(22, bit.getPosition());
- break;
- default:
- fail("Unexpected bit name.");
+ case "zero":
+ assertEquals(0, bit.getPosition());
+ break;
+ case "twenty":
+ assertEquals(20, bit.getPosition());
+ break;
+ case "twenty-one":
+ assertEquals(21, bit.getPosition());
+ break;
+ case "two":
+ assertEquals(2, bit.getPosition());
+ break;
+ case "twenty-two":
+ assertEquals(22, bit.getPosition());
+ break;
+ default:
+ fail("Unexpected bit name.");
}
}
}
final QName barExportCont = QName.create("bar-ns", "bar-export", revision);
final QName barFooCont = QName.create("bar-ns", "bar-foo", revision);
- final QName barFooLeaf= QName.create("bar-ns", "foo", revision);
+ final QName barFooLeaf = QName.create("bar-ns", "foo", revision);
final UnitsEffectiveStatementImpl unitsBar1 = getEffectiveUnits(bar, barExportCont, barFooLeaf);
final UnitsEffectiveStatementImpl unitsBar2 = getEffectiveUnits(bar, barFooCont, barFooLeaf);
final QName bazExportCont = QName.create("baz-ns", "baz-export", revision);
final QName bazFooCont = QName.create("baz-ns", "baz-foo", revision);
- final QName bazFooLeaf= QName.create("baz-ns", "foo", revision);
+ final QName bazFooLeaf = QName.create("baz-ns", "foo", revision);
final UnitsEffectiveStatementImpl unitsBaz1 = getEffectiveUnits(baz, bazExportCont, bazFooLeaf);
final UnitsEffectiveStatementImpl unitsBaz2 = getEffectiveUnits(baz, bazFooCont, bazFooLeaf);
final Iterator<UnknownSchemaNode> iterator = barExtUnknownNodes.iterator();
UnknownSchemaNode barExtCont2 = null;
- while(iterator.hasNext()) {
+ while (iterator.hasNext()) {
final UnknownSchemaNode next = iterator.next();
- if(bar("container").equals(next.getNodeType())) {
+ if (bar("container").equals(next.getNodeType())) {
barExtCont2 = next;
break;
}
try {
StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug7146/foo.yang"));
fail("RuntimeException should have been thrown because of an unknown character in yang module.");
- } catch (RuntimeException ex) {
+ } catch (IllegalArgumentException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof YangSyntaxErrorException);
assertTrue(cause.getMessage().contains("extraneous input '#'"));
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
final SchemaContext context = TestUtils.parseYangSources("/bugs/bug7879");
assertNotNull(context);
- assertTrue(findNode(context, ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-container")))
+ assertTrue(findNode(context, qN("my-alarm"), qN("my-content"), qN("my-event-container"))
instanceof ContainerSchemaNode);
- final SchemaNode myEventValueLeaf = findNode(context,
- ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-value")));
+ final SchemaNode myEventValueLeaf = findNode(context, qN("my-alarm"), qN("my-content"), qN("my-event-value"));
assertTrue(myEventValueLeaf instanceof LeafSchemaNode);
assertEquals("new description", myEventValueLeaf.getDescription());
}
- private static SchemaNode findNode(final SchemaContext context, final Iterable<QName> qNames) {
- return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true));
+ private static SchemaNode findNode(final SchemaContext context, final QName... qnames) {
+ return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qnames));
}
private static QName qN(final String localName) {
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableList;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
public void test() throws Exception {
final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8126");
assertNotNull(context);
- assertTrue(findNode(context, ImmutableList.of(foo("root"), bar("my-container"), bar("my-choice"), bar("one"),
- bar("one"), bar("mandatory-leaf"))) instanceof LeafSchemaNode);
- assertTrue(findNode(context, ImmutableList.of(foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2")))
+ assertTrue(findNode(context, foo("root"), bar("my-container"), bar("my-choice"), bar("one"), bar("one"),
+ bar("mandatory-leaf")) instanceof LeafSchemaNode);
+ assertTrue(findNode(context, foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2"))
instanceof LeafSchemaNode);
- assertNull(findNode(context, ImmutableList.of(foo("root"), bar("mandatory-list"))));
- assertNull(findNode(context, ImmutableList.of(foo("root"), bar("mandatory-container"),
- bar("mandatory-choice"))));
- assertNull(findNode(context,
- ImmutableList.of(foo("root"), bar("mandatory-container-2"), bar("one"), bar("mandatory-leaf-3"))));
+ assertNull(findNode(context, foo("root"), bar("mandatory-list")));
+ assertNull(findNode(context, foo("root"), bar("mandatory-container"), bar("mandatory-choice")));
+ assertNull(findNode(context, foo("root"), bar("mandatory-container-2"), bar("one"), bar("mandatory-leaf-3")));
}
- private static SchemaNode findNode(final SchemaContext context, final Iterable<QName> qNames) {
- return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true));
+ private static SchemaNode findNode(final SchemaContext context, final QName... qnames) {
+ return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qnames));
}
private static QName foo(final String localName) {
assertTrue(context.getAvailableAugmentations().isEmpty());
}
- private static SchemaNode findNode(final SchemaContext context, final QName... qNames) {
- return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qNames));
+ private static SchemaNode findNode(final SchemaContext context, final QName... qnames) {
+ return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, qnames));
}
private static QName qN(final String localName) {
public class CaseStmtTest {
private SchemaContext schema;
- private Module rootFoo, rootBar;
- private QNameModule qnameFoo, qnameBar;
- private DataSchemaNode tempChild, tempSecondChild, tempThirdChild;
+ private Module rootFoo;
+ private Module rootBar;
+ private QNameModule qnameFoo;
+ private QNameModule qnameBar;
+ private DataSchemaNode tempChild;
+ private DataSchemaNode tempSecondChild;
+ private DataSchemaNode tempThirdChild;
private ChoiceCaseNode tempChoice;
@Rule
}
@Test
- public void InferenceExceptionChoiceTest() throws Exception {
+ public void testInferenceExceptionChoice() throws Exception {
expectedEx.expect(ReactorException.class);
schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/choice");
}
@Test
- public void InferenceExceptionCaseTest() throws Exception {
+ public void testInferenceExceptionCase() throws Exception {
expectedEx.expect(ReactorException.class);
schema = StmtTestUtils.parseYangSources("/case-test/case-test-exceptions/case");
}
final Collection<? extends IfFeatureStatement> caseStatementIfFeatures = caseStatement.getIfFeatures();
assertNotNull(caseStatementIfFeatures);
assertEquals(1, caseStatementIfFeatures.size());
- final Collection<? extends DataDefinitionStatement> caseStatementDataDefinitions = caseStatement.getDataDefinitions();
+ final Collection<? extends DataDefinitionStatement> caseStatementDataDefinitions =
+ caseStatement.getDataDefinitions();
assertNotNull(caseStatementDataDefinitions);
assertEquals(1, caseStatementDataDefinitions.size());
final StatusStatement caseStatementStatus = caseStatement.getStatus();
assertNotNull(moduleStatementNamspace);
assertNotNull(moduleStatementNamspace.getUri());
- final PrefixStatement moduleStatementPrefix= moduleStatement.getPrefix();
+ final PrefixStatement moduleStatementPrefix = moduleStatement.getPrefix();
assertNotNull(moduleStatementPrefix);
assertNotNull(moduleStatementPrefix.getValue());
final ContainerSchemaNode containerSchemaNode = (ContainerSchemaNode) testModule.getDataChildByName(
QName.create(testModule.getQNameModule(), "test-container"));
assertNotNull(containerSchemaNode);
- final ContainerStatement containerStatement = ((ContainerEffectiveStatementImpl) containerSchemaNode).getDeclared();
+ final ContainerStatement containerStatement =
+ ((ContainerEffectiveStatementImpl) containerSchemaNode).getDeclared();
final QName name = containerStatement.getName();
assertNotNull(name);
final WhenStatement containerStatementWhen = containerStatement.getWhenStatement();
assertNotNull(containerStatementWhen);
- final Collection<? extends IfFeatureStatement> containerStatementIfFeatures = containerStatement.getIfFeatures();
+ final Collection<? extends IfFeatureStatement> containerStatementIfFeatures =
+ containerStatement.getIfFeatures();
assertNotNull(containerStatementIfFeatures);
assertEquals(1, containerStatementIfFeatures.size());
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("(bar?revision=2017-01-20)my-cont is not a valid deviation " +
- "target for substatement (urn:ietf:params:xml:ns:yang:yin:1)max-elements."));
+ assertTrue(cause.getMessage().startsWith("(bar?revision=2017-01-20)my-cont is not a valid deviation "
+ + "target for substatement (urn:ietf:params:xml:ns:yang:yin:1)max-elements."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause().getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(bar?revision=2017-01-20)" +
- "invalid, (bar?revision=2017-01-20)path]}' not found"));
+ assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(bar?revision=2017-01-20)"
+ + "invalid, (bar?revision=2017-01-20)path]}' not found"));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" +
- ":yin:1)config to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" +
- " target and can appear only once."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang"
+ + ":yin:1)config to target node (bar?revision=2017-01-20)my-leaf because it is already defined in"
+ + " target and can appear only once."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" +
- ":yin:1)default to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" +
- " target and can appear only once."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang"
+ + ":yin:1)default to target node (bar?revision=2017-01-20)my-leaf because it is already defined in"
+ + " target and can appear only once."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" +
- ":yin:1)default to target node (bar?revision=2017-02-01)my-used-leaf because it is already " +
- "defined in target and can appear only once."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang"
+ + ":yin:1)default to target node (bar?revision=2017-02-01)my-used-leaf because it is already "
+ + "defined in target and can appear only once."));
}
}
} catch (final ReactorException ex) {
final Throwable cause = ex.getCause();
assertTrue(cause instanceof InferenceException);
- assertTrue(cause.getMessage().startsWith("Deviation cannot replace substatement " +
- "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (bar?revision=2017-01-20)my-leaf " +
- "because it does not exist in target node."));
+ assertTrue(cause.getMessage().startsWith("Deviation cannot replace substatement "
+ + "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (bar?revision=2017-01-20)my-leaf "
+ + "because it does not exist in target node."));
}
}
@Test
+ @SuppressWarnings("checkstyle:regexpSinglelineJava")
public void shouldLogInvalidDeviateReplaceAttempt() throws Exception {
final PrintStream stdout = System.out;
final ByteArrayOutputStream output = new ByteArrayOutputStream();
sourceForResource("/deviation-resolution-test/deviation-replace/bar-invalid-2.yang"));
testLog = output.toString();
- assertTrue(testLog.contains("Deviation cannot replace substatement (urn:ietf:params:xml:ns:yang:yin:1)default" +
- " in target leaf-list (bar?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple " +
- "default statements."));
System.setOut(stdout);
+ assertTrue(testLog.contains("Deviation cannot replace substatement (urn:ietf:params:xml:ns:yang:yin:1)default"
+ + " in target leaf-list (bar?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple "
+ + "default statements."));
}
@Test
+ @SuppressWarnings("checkstyle:regexpSinglelineJava")
public void shouldLogInvalidDeviateDeleteAttempt() throws Exception {
final PrintStream stdout = System.out;
final ByteArrayOutputStream output = new ByteArrayOutputStream();
sourceForResource("/deviation-resolution-test/deviation-delete/bar-invalid.yang"));
testLog = output.toString();
- assertTrue(testLog.contains("Deviation cannot delete substatement (urn:ietf:params:xml:ns:yang:yin:1)units " +
- "with argument 'seconds' in target node (bar?revision=2017-01-20)my-leaf because it does not exist " +
- "in the target node."));
System.setOut(stdout);
+ assertTrue(testLog.contains("Deviation cannot delete substatement (urn:ietf:params:xml:ns:yang:yin:1)units "
+ + "with argument 'seconds' in target node (bar?revision=2017-01-20)my-leaf because it does not exist "
+ + "in the target node."));
}
@Test
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
"/stmt-test/extensions/yang-ext.yang");
@Test
- public void effectiveBuildTest() throws SourceException, ReactorException {
+ public void effectiveBuildTest() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(SIMPLE_MODULE);
SchemaContext result = reactor.buildEffective();
Module simpleModule = result.findModules("simple-module").iterator().next();
assertNotNull(simpleModule);
- QName q1 = QName.create(SIMPLE_MODULE_QNAME, "root-container");
- QName q2 = QName.create(SIMPLE_MODULE_QNAME, "sub-container");
- QName q3 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container");
- QName q4 = QName.create(SIMPLE_MODULE_QNAME, "root-container2");
- QName q5 = QName.create(SIMPLE_MODULE_QNAME, "sub-container2");
- QName q6 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container2");
- QName q7 = QName.create(SIMPLE_MODULE_QNAME, "grp");
+ final QName q1 = QName.create(SIMPLE_MODULE_QNAME, "root-container");
+ final QName q2 = QName.create(SIMPLE_MODULE_QNAME, "sub-container");
+ final QName q3 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container");
+ final QName q4 = QName.create(SIMPLE_MODULE_QNAME, "root-container2");
+ final QName q5 = QName.create(SIMPLE_MODULE_QNAME, "sub-container2");
+ final QName q6 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container2");
+ final QName q7 = QName.create(SIMPLE_MODULE_QNAME, "grp");
- ContainerSchemaNode rootCon = (ContainerSchemaNode) simpleModule
- .getDataChildByName(q1);
+ ContainerSchemaNode rootCon = (ContainerSchemaNode) simpleModule.getDataChildByName(q1);
assertNotNull(rootCon);
- ContainerSchemaNode subCon = (ContainerSchemaNode) rootCon
- .getDataChildByName(q2);
+ ContainerSchemaNode subCon = (ContainerSchemaNode) rootCon.getDataChildByName(q2);
assertNotNull(subCon);
- ContainerSchemaNode subSubCon = (ContainerSchemaNode) subCon
- .getDataChildByName(q3);
+ ContainerSchemaNode subSubCon = (ContainerSchemaNode) subCon.getDataChildByName(q3);
assertNotNull(subSubCon);
- ContainerSchemaNode rootCon2 = (ContainerSchemaNode) simpleModule
- .getDataChildByName(q4);
+ ContainerSchemaNode rootCon2 = (ContainerSchemaNode) simpleModule.getDataChildByName(q4);
assertNotNull(rootCon2);
- ContainerSchemaNode subCon2 = (ContainerSchemaNode) rootCon2
- .getDataChildByName(q5);
+ ContainerSchemaNode subCon2 = (ContainerSchemaNode) rootCon2.getDataChildByName(q5);
assertNotNull(subCon2);
- ContainerSchemaNode subSubCon2 = (ContainerSchemaNode) subCon2
- .getDataChildByName(q6);
+ ContainerSchemaNode subSubCon2 = (ContainerSchemaNode) subCon2.getDataChildByName(q6);
assertNotNull(subSubCon2);
GroupingDefinition grp = simpleModule.getGroupings().iterator().next();
assertNotNull(grp);
assertEquals(q7, grp.getQName());
- ContainerSchemaNode grpSubCon2 = (ContainerSchemaNode) grp
- .getDataChildByName(q5);
+ ContainerSchemaNode grpSubCon2 = (ContainerSchemaNode) grp.getDataChildByName(q5);
assertNotNull(grpSubCon2);
- ContainerSchemaNode grpSubSubCon2 = (ContainerSchemaNode) grpSubCon2
- .getDataChildByName(q6);
+ ContainerSchemaNode grpSubSubCon2 = (ContainerSchemaNode) grpSubCon2.getDataChildByName(q6);
assertNotNull(grpSubSubCon2);
assertEquals(SchemaPath.create(true, q1, q2, q3), subSubCon.getPath());
assertEquals(SchemaPath.create(true, q4, q5, q6), subSubCon2.getPath());
- assertEquals(SchemaPath.create(true, q7, q5, q6),
- grpSubSubCon2.getPath());
+ assertEquals(SchemaPath.create(true, q7, q5, q6), grpSubSubCon2.getPath());
}
@Test
- public void extensionsTest() throws SourceException, ReactorException {
+ public void extensionsTest() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(YANG_EXT);
SchemaContext result = reactor.buildEffective();
}
@Test
- public void mockTest() throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
+ public void mockTest() throws ReactorException, FileNotFoundException, URISyntaxException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSource(YANG_EXT);
IdentitySchemaNode child12 = null;
for (IdentitySchemaNode identitySchemaNode : identities) {
switch (identitySchemaNode.getQName().getLocalName()) {
- case "root-identity":
- root = identitySchemaNode;
- break;
- case "child-identity-1":
- child1 = identitySchemaNode;
- break;
- case "child-identity-2":
- child2 = identitySchemaNode;
- break;
- case "child-identity-1-2":
- child12 = identitySchemaNode;
- break;
- default:
- break;
+ case "root-identity":
+ root = identitySchemaNode;
+ break;
+ case "child-identity-1":
+ child1 = identitySchemaNode;
+ break;
+ case "child-identity-2":
+ child2 = identitySchemaNode;
+ break;
+ case "child-identity-1-2":
+ child12 = identitySchemaNode;
+ break;
+ default:
+ break;
}
}
private static final QNameModule ROOT_MODULE_QNAME = QNameModule.create(URI.create("root-ns"));
- private static final QName cont = QName.create(ROOT_MODULE_QNAME, "cont");
- private static final QName feature1 = QName.create(ROOT_MODULE_QNAME, "feature1");
+ private static final QName CONT = QName.create(ROOT_MODULE_QNAME, "cont");
+ private static final QName FEATURE1 = QName.create(ROOT_MODULE_QNAME, "feature1");
- private static final SchemaPath contSchemaPath = SchemaPath.create(true, cont);
- private static final SchemaPath feature1SchemaPath = SchemaPath.create(true, feature1);
+ private static final SchemaPath CONT_SCHEMA_PATH = SchemaPath.create(true, CONT);
+ private static final SchemaPath FEATURE1_SCHEMA_PATH = SchemaPath.create(true, FEATURE1);
private static final Revision REVISION = Revision.valueOf("2000-01-01");
assertEquals("cisco", rootModule.getOrganization());
assertEquals("cisco email", rootModule.getContact());
- final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(cont);
+ final ContainerSchemaNode contSchemaNode = (ContainerSchemaNode) rootModule.getDataChildByName(CONT);
assertNotNull(contSchemaNode);
final Set<AugmentationSchema> augmentations = rootModule.getAugmentations();
assertEquals(1, augmentations.size());
- assertEquals(contSchemaPath, augmentations.iterator().next().getTargetPath());
+ assertEquals(CONT_SCHEMA_PATH, augmentations.iterator().next().getTargetPath());
final Set<ModuleImport> imports = rootModule.getImports();
assertEquals(1, imports.size());
assertEquals(1, features.size());
final FeatureDefinition featureStmt = features.iterator().next();
assertNotNull(featureStmt);
- assertEquals(feature1, featureStmt.getQName());
- assertEquals(feature1SchemaPath, featureStmt.getPath());
+ assertEquals(FEATURE1, featureStmt.getQName());
+ assertEquals(FEATURE1_SCHEMA_PATH, featureStmt.getPath());
assertEquals("feature1 description", featureStmt.getDescription());
assertEquals("feature1 reference", featureStmt.getReference());
assertEquals(Status.CURRENT, featureStmt.getStatus());
final Bit bitEff = bitsEffIter.get(0);
final Bit bitEffSecond = bitsEffIter.get(1);
- final BitsTypeDefinition bitsEff = ((BitsSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final BitsTypeDefinition bitsEff = ((BitsSpecificationEffectiveStatementImpl)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertNull(bitsEff.getBaseType());
assertNotNull(bitsEff.getQName());
public void testBoolean() {
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-boolean"));
assertNotNull(currentLeaf.getType());
- final BooleanTypeDefinition booleanEff = (BooleanTypeDefinition) ((TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final BooleanTypeDefinition booleanEff = (BooleanTypeDefinition) ((TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertNull(booleanEff.getBaseType());
assertNull(booleanEff.getUnits());
public void testDecimal64() {
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-decimal64"));
assertNotNull(currentLeaf.getType());
- final DecimalTypeDefinition decimal64Eff = ((Decimal64SpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final DecimalTypeDefinition decimal64Eff = ((Decimal64SpecificationEffectiveStatementImpl)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertNull(decimal64Eff.getBaseType());
assertNull(decimal64Eff.getUnits());
assertEquals("decimal64", decimal64Eff.getQName().getLocalName());
assertNotNull(decimal64Eff.getUnknownSchemaNodes());
- // FIXME: The yang model api is wrong: description/reference/status are not allowed under 'type', how come we parse it?
+ // FIXME: The yang model api is wrong: description/reference/status are not allowed under 'type', how come we
+ // parse it?
// allowed under 'type', how come we parse it?
assertNull(decimal64Eff.getDescription());
assertNull(decimal64Eff.getReference());
public void testEmpty() {
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-empty"));
assertNotNull(currentLeaf.getType());
- final EmptyTypeDefinition emptyEff = (EmptyTypeDefinition) ((TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final EmptyTypeDefinition emptyEff = (EmptyTypeDefinition) ((TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertNull(emptyEff.getUnits());
assertNull(emptyEff.getDefaultValue());
final List<EnumTypeDefinition.EnumPair> enumEffIter = ((EnumTypeDefinition) currentLeaf.getType()).getValues();
final EnumPair enumEff = enumEffIter.iterator().next();
- final EnumTypeDefinition enumSpecEff = ((EnumSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final EnumTypeDefinition enumSpecEff = ((EnumSpecificationEffectiveStatementImpl)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertEquals("enumeration", enumSpecEff.getQName().getLocalName());
assertEquals("enumeration", enumSpecEff.getPath().getLastComponent().getLocalName());
currentLeaf = (LeafSchemaNode) types
.getDataChildByName(QName.create(types.getQNameModule(), "leaf-identityref"));
assertNotNull(currentLeaf.getType());
- final IdentityrefTypeDefinition identityRefEff = ((IdentityRefSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final IdentityrefTypeDefinition identityRefEff = ((IdentityRefSpecificationEffectiveStatementImpl)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertNull(identityRefEff.getDefaultValue());
assertEquals("identityref", identityRefEff.getQName().getLocalName());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
"leaf-instance-identifier"));
assertNotNull(currentLeaf.getType());
- final InstanceIdentifierTypeDefinition instanceIdentEff = (InstanceIdentifierTypeDefinition) ((TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final InstanceIdentifierTypeDefinition instanceIdentEff = (InstanceIdentifierTypeDefinition)
+ ((TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements()
+ .iterator().next()).getTypeDefinition();
assertNotNull(instanceIdentEff.toString());
assertFalse(instanceIdentEff.requireInstance());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-leafref"));
assertNotNull(currentLeaf.getType());
- final LeafrefTypeDefinition leafrefEff = ((LeafrefSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final LeafrefTypeDefinition leafrefEff = ((LeafrefSpecificationEffectiveStatementImpl)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertEquals("/container-test/leaf-test", leafrefEff.getPathStatement().toString());
assertNull(leafrefEff.getBaseType());
public void testIntAll() {
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int8"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> int8Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> int8Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(int8Eff.toString());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int16"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> int16Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> int16Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(int16Eff.toString());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int32"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> int32Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> int32Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(int32Eff.toString());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-int64"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> int64Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> int64Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(int64Eff.toString());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint8"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> uint8Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> uint8Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(uint8Eff.toString());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint16"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> uint16Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> uint16Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(uint16Eff.toString());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint32"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> uint32Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> uint32Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(uint32Eff.toString());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-uint64"));
assertNotNull(currentLeaf.getType());
- final TypeEffectiveStatement<?> uint64Eff = (TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next();
+ final TypeEffectiveStatement<?> uint64Eff = (TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next();
assertNotNull(uint64Eff.toString());
}
public void testUnion() {
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-union"));
assertNotNull(currentLeaf.getType());
- final UnionTypeDefinition unionEff = ((UnionSpecificationEffectiveStatementImpl) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final UnionTypeDefinition unionEff = ((UnionSpecificationEffectiveStatementImpl)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertEquals(2, unionEff.getTypes().size());
assertEquals("union", unionEff.getQName().getLocalName());
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
"leaf-length-pattern"));
assertNotNull(currentLeaf.getType());
- final PatternConstraintEffectiveImpl patternConstraint = (PatternConstraintEffectiveImpl) ((StringTypeDefinition) currentLeaf
- .getType()).getPatternConstraints().get(0);
- final PatternConstraintEffectiveImpl patternConstraintThird = (PatternConstraintEffectiveImpl) ((StringTypeDefinition) currentLeaf
- .getType()).getPatternConstraints().get(0);
+ final PatternConstraintEffectiveImpl patternConstraint = (PatternConstraintEffectiveImpl)
+ ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0);
+ final PatternConstraintEffectiveImpl patternConstraintThird = (PatternConstraintEffectiveImpl)
+ ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0);
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(),
"leaf-length-pattern-second"));
assertNotNull(currentLeaf.getType());
- final PatternConstraintEffectiveImpl patternConstraintSecond = (PatternConstraintEffectiveImpl) ((StringTypeDefinition) currentLeaf
- .getType()).getPatternConstraints().get(0);
+ final PatternConstraintEffectiveImpl patternConstraintSecond = (PatternConstraintEffectiveImpl)
+ ((StringTypeDefinition) currentLeaf.getType()).getPatternConstraints().get(0);
assertEquals("^[0-9a-fA-F]*$", patternConstraint.getRegularExpression());
assertNull(patternConstraint.getReference());
assertNull(patternConstraint.getDescription());
- assertEquals("Supplied value does not match the regular expression ^[0-9a-fA-F]*$.", patternConstraint.getErrorMessage());
+ assertEquals("Supplied value does not match the regular expression ^[0-9a-fA-F]*$.",
+ patternConstraint.getErrorMessage());
assertEquals("invalid-regular-expression", patternConstraint.getErrorAppTag());
assertNotNull(patternConstraint.toString());
assertNotNull(patternConstraint.hashCode());
public void testString() {
currentLeaf = (LeafSchemaNode) types.getDataChildByName(QName.create(types.getQNameModule(), "leaf-string"));
assertNotNull(currentLeaf.getType());
- final StringTypeDefinition stringEff = (StringTypeDefinition) ((TypeEffectiveStatement<?>) ((LeafEffectiveStatementImpl) currentLeaf)
- .effectiveSubstatements().iterator().next()).getTypeDefinition();
+ final StringTypeDefinition stringEff = (StringTypeDefinition) ((TypeEffectiveStatement<?>)
+ ((LeafEffectiveStatementImpl) currentLeaf).effectiveSubstatements().iterator().next())
+ .getTypeDefinition();
assertEquals("string", stringEff.getQName().getLocalName());
assertEquals("CURRENT", stringEff.getStatus().toString());
import static org.junit.Assert.assertTrue;
import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
-import java.net.URISyntaxException;
import java.util.Set;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
private static final StatementStreamSource REFINE_TEST = sourceForResource("/stmt-test/uses/refine-test.yang");
@Test
- public void refineTest() throws SourceException, ReactorException,
- URISyntaxException {
+ public void refineTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(REFINE_TEST);
Module module = modules.iterator().next();
- QNameModule qnameModule = module.getQNameModule();
- QName rootContainer = QName.create(qnameModule, "root-container");
- QName grp1 = QName.create(qnameModule, "grp-1");
+ final QNameModule qnameModule = module.getQNameModule();
+ final QName rootContainer = QName.create(qnameModule, "root-container");
+ final QName grp1 = QName.create(qnameModule, "grp-1");
- QName containerFromGrouping = QName.create(qnameModule, "container-from-grouping");
- QName listInContainer = QName.create(qnameModule, "list-in-container");
- QName choiceFromGrp = QName.create(qnameModule, "choice-from-grp");
+ final QName containerFromGrouping = QName.create(qnameModule, "container-from-grouping");
+ final QName listInContainer = QName.create(qnameModule, "list-in-container");
+ final QName choiceFromGrp = QName.create(qnameModule, "choice-from-grp");
- QName containerFromGrouping2 = QName.create(qnameModule, "container-from-grouping2");
- QName presenceContainer = QName.create(qnameModule, "presence-container");
+ final QName containerFromGrouping2 = QName.create(qnameModule, "container-from-grouping2");
+ final QName presenceContainer = QName.create(qnameModule, "presence-container");
- SchemaPath listInContainerPath = SchemaPath.create(true, rootContainer,
- containerFromGrouping, listInContainer);
- SchemaPath choiceFromGrpPath = SchemaPath.create(true, rootContainer,
- containerFromGrouping, choiceFromGrp);
- SchemaPath presenceContainerPath = SchemaPath.create(true,
- rootContainer, containerFromGrouping2, presenceContainer);
+ SchemaPath listInContainerPath = SchemaPath.create(true, rootContainer, containerFromGrouping, listInContainer);
+ SchemaPath choiceFromGrpPath = SchemaPath.create(true, rootContainer, containerFromGrouping, choiceFromGrp);
+ SchemaPath presenceContainerPath = SchemaPath.create(true, rootContainer, containerFromGrouping2,
+ presenceContainer);
checkRefinedList(result, listInContainerPath);
checkRefinedChoice(result, choiceFromGrpPath);
checkRefinedContainer(result, presenceContainerPath);
- SchemaPath originalListInContainerPath = SchemaPath.create(true, grp1,
- containerFromGrouping, listInContainer);
- SchemaPath originalChoiceFromGrpPath = SchemaPath.create(true, grp1,
- containerFromGrouping, choiceFromGrp);
- SchemaPath originalPresenceContainerPath = SchemaPath.create(true,
- grp1, containerFromGrouping2, presenceContainer);
+ SchemaPath originalListInContainerPath = SchemaPath.create(true, grp1, containerFromGrouping, listInContainer);
+ SchemaPath originalChoiceFromGrpPath = SchemaPath.create(true, grp1, containerFromGrouping, choiceFromGrp);
+ SchemaPath originalPresenceContainerPath = SchemaPath.create(true, grp1, containerFromGrouping2,
+ presenceContainer);
checkOriginalList(result, originalListInContainerPath);
checkOriginalChoice(result, originalChoiceFromGrpPath);
ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) choiceInContainerNode;
- ConstraintDefinition choiceConstraints = choiceSchemaNode
- .getConstraints();
+ ConstraintDefinition choiceConstraints = choiceSchemaNode.getConstraints();
assertFalse(choiceConstraints.isMandatory());
assertTrue(choiceConstraints.getMustConstraints().isEmpty());
}
ChoiceSchemaNode choiceSchemaNode = (ChoiceSchemaNode) choiceInContainerNode;
- ConstraintDefinition choiceConstraints = choiceSchemaNode
- .getConstraints();
+ ConstraintDefinition choiceConstraints = choiceSchemaNode.getConstraints();
assertTrue(choiceConstraints.isMandatory());
assertTrue(choiceConstraints.getMustConstraints().isEmpty());
}
final Module testModule2 = result.findModules("ext-use").iterator().next();
assertNotNull(testModule2);
- final LeafSchemaNode leaf = (LeafSchemaNode) testModule2.getDataChildByName(QName.create(testModule2.getQNameModule(), "value"));
+ final LeafSchemaNode leaf = (LeafSchemaNode) testModule2.getDataChildByName(
+ QName.create(testModule2.getQNameModule(), "value"));
assertNotNull(leaf);
assertEquals(1, leaf.getUnknownSchemaNodes().size());
assertEquals("target", grouping.getQName().getLocalName());
assertEquals(5, grouping.getChildNodes().size());
- final AnyXmlSchemaNode anyXmlNode = (AnyXmlSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "data"));
+ final AnyXmlSchemaNode anyXmlNode = (AnyXmlSchemaNode) grouping.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "data"));
assertNotNull(anyXmlNode);
- final ChoiceSchemaNode choiceNode = (ChoiceSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "how"));
+ final ChoiceSchemaNode choiceNode = (ChoiceSchemaNode) grouping.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "how"));
assertNotNull(choiceNode);
- final LeafSchemaNode leafNode = (LeafSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "address"));
+ final LeafSchemaNode leafNode = (LeafSchemaNode) grouping.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "address"));
assertNotNull(leafNode);
- final ContainerSchemaNode containerNode = (ContainerSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "port"));
+ final ContainerSchemaNode containerNode = (ContainerSchemaNode) grouping.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "port"));
assertNotNull(containerNode);
- final ListSchemaNode listNode = (ListSchemaNode) grouping.getDataChildByName(QName.create(testModule.getQNameModule(), "addresses"));
+ final ListSchemaNode listNode = (ListSchemaNode) grouping.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "addresses"));
assertNotNull(listNode);
assertEquals(1, grouping.getGroupings().size());
assertEquals("target", usesNode.getGroupingPath().getLastComponent().getLocalName());
assertEquals(1, usesNode.getAugmentations().size());
- ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "peer"));
+ ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "peer"));
assertNotNull(container);
- container = (ContainerSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(), "destination"));
+ container = (ContainerSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(),
+ "destination"));
assertEquals(1, container.getUses().size());
usesNode = container.getUses().iterator().next();
for (final GroupingDefinition gd : groupings) {
final String name = gd.getQName().getLocalName();
switch (name) {
- case "grouping-U":
- gu = gd;
- break;
- case "grouping-V":
- gv = gd;
- break;
- case "grouping-X":
- gx = gd;
- break;
- case "grouping-Y":
- gy = gd;
- break;
- case "grouping-Z":
- gz = gd;
- break;
- case "grouping-ZZ":
- gzz = gd;
- break;
+ case "grouping-U":
+ gu = gd;
+ break;
+ case "grouping-V":
+ gv = gd;
+ break;
+ case "grouping-X":
+ gx = gd;
+ break;
+ case "grouping-Y":
+ gy = gd;
+ break;
+ case "grouping-Z":
+ gz = gd;
+ break;
+ case "grouping-ZZ":
+ gzz = gd;
+ break;
+ default:
+ break;
}
}
assertNotNull(gu);
final QNameModule expectedModule = QNameModule.create(URI.create("urn:grouping:cascade-uses"),
Revision.valueOf("2013-07-18"));
- SchemaPath expectedPath;
// grouping-U
Collection<DataSchemaNode> childNodes = gu.getChildNodes();
// grouping-V/container-grouping-V
assertNotNull(containerGroupingV);
assertFalse(containerGroupingV.isAddedByUses());
- expectedPath = TestUtils.createPath(true, expectedModule, "grouping-V", "container-grouping-V");
+ SchemaPath expectedPath = TestUtils.createPath(true, expectedModule, "grouping-V", "container-grouping-V");
assertEquals(expectedPath, containerGroupingV.getPath());
childNodes = containerGroupingV.getChildNodes();
assertEquals(2, childNodes.size());
Iterator<IdentitySchemaNode> identitiesIterator = identities.iterator();
IdentitySchemaNode identity = identitiesIterator.next();
- assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is
- ("third-identity"), is("fourth-identity")));
+ assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
+ is("third-identity"), is("fourth-identity")));
identity = identitiesIterator.next();
- assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is
- ("third-identity"), is("fourth-identity")));
+ assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
+ is("third-identity"), is("fourth-identity")));
identity = identitiesIterator.next();
- assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is
- ("third-identity"), is("fourth-identity")));
+ assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
+ is("third-identity"), is("fourth-identity")));
identity = identitiesIterator.next();
- assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"), is
- ("third-identity"), is("fourth-identity")));
+ assertThat(identity.getQName().getLocalName(), anyOf(is("first-identity"), is("second-identity"),
+ is("third-identity"), is("fourth-identity")));
}
@Test
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
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.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
@Test
- public void inImportOrderTest() throws SourceException, ReactorException {
+ public void inImportOrderTest() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(ROOT_WITHOUT_IMPORT, IMPORT_ROOT, IMPORT_DERIVED);
EffectiveModelContext result = reactor.build();
}
@Test
- public void inInverseOfImportOrderTest() throws SourceException, ReactorException {
+ public void inInverseOfImportOrderTest() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(IMPORT_DERIVED, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
EffectiveModelContext result = reactor.build();
}
@Test
- public void missingImportedSourceTest() throws SourceException {
+ public void missingImportedSourceTest() {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(IMPORT_DERIVED, ROOT_WITHOUT_IMPORT);
try {
}
@Test
- public void circularImportsTest() throws SourceException {
+ public void circularImportsTest() {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(CYCLE_YIN, CYCLE_YANG);
try {
}
@Test
- public void selfImportTest() throws SourceException {
+ public void selfImportTest() {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(IMPORT_SELF, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
try {
}
@Test
- public void bug2649Test() throws SourceException, ReactorException{
+ public void bug2649Test() throws ReactorException {
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(FOO, IMPORT);
@Test
public void revisionDatesInImportedOnlyTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- reactor.addSources( ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE);
+ reactor.addSources(ROOT_WITHOUT_DATE, IMPORTED_WITH_DATE);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
public class IncludeResolutionTest {
- private static final Logger log = Logger.getLogger(IncludeResolutionTest.class.getName());
+ private static final Logger LOG = Logger.getLogger(IncludeResolutionTest.class.getName());
private static final StatementStreamSource ROOT = sourceForResource(
"/semantic-statement-parser/include-arg-parsing/root-module.yang");
} catch (ReactorException e) {
assertTrue(e instanceof SomeModifiersUnresolvedException);
assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
- log.info(e.getMessage());
+ LOG.info(e.getMessage());
}
}
} catch (ReactorException e) {
assertTrue(e instanceof SomeModifiersUnresolvedException);
assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
- log.info(e.getMessage());
+ LOG.info(e.getMessage());
}
}
reactor.build();
fail("reactor.process should fail due to missing belongsTo source");
} catch (ReactorException e) {
- log.info(e.getMessage());
+ LOG.info(e.getMessage());
}
}
public void revsEqualTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, EQUAL_REV, EQUAL_ROOT);
+ reactor.addSources(EQUAL_REV, EQUAL_ROOT);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
public void revsUnequalTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, UNEQUAL_REV, UNEQUAL_ROOT);
+ reactor.addSources(UNEQUAL_REV, UNEQUAL_ROOT);
try {
reactor.build();
public void revIncludeOnly() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT);
+ reactor.addSources(SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
public void revInModuleOnly() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, MOD_ONLY_REV, MOD_ONLY_ROOT);
+ reactor.addSources(MOD_ONLY_REV, MOD_ONLY_ROOT);
try {
reactor.build();
public void revNowhereTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, NOWHERE_REV, NOWHERE_ROOT);
+ reactor.addSources(NOWHERE_REV, NOWHERE_ROOT);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
}
-
- private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) {
- for (StatementStreamSource source : sources) {
- reactor.addSource(source);
- }
- }
}
final Module testModule = result.findModules("root-module").iterator().next();
assertNotNull(testModule);
- ContainerSchemaNode cont = (ContainerSchemaNode) testModule.getDataChildByName(QName.create(testModule.getQNameModule(), "parent-container"));
+ ContainerSchemaNode cont = (ContainerSchemaNode) testModule.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "parent-container"));
assertNotNull(cont);
- cont = (ContainerSchemaNode) cont.getDataChildByName(QName.create(testModule.getQNameModule(), "child-container"));
+ cont = (ContainerSchemaNode) cont.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "child-container"));
assertNotNull(cont);
assertEquals(2, cont.getChildNodes().size());
- LeafSchemaNode leaf = (LeafSchemaNode) cont.getDataChildByName(QName.create(testModule.getQNameModule(), "autumn-leaf"));
+ LeafSchemaNode leaf = (LeafSchemaNode) cont.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "autumn-leaf"));
assertNotNull(leaf);
leaf = (LeafSchemaNode) cont.getDataChildByName(QName.create(testModule.getQNameModule(), "winter-snow"));
assertNotNull(leaf);
import static org.junit.Assert.fail;
import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
-import java.io.IOException;
-import java.net.URISyntaxException;
import org.junit.Test;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
}
@Test
- public void incorrectListKeysTest1() throws IOException, YangSyntaxErrorException, URISyntaxException {
+ public void incorrectListKeysTest1() {
final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test.yang");
try {
reactor.buildEffective();
fail("effective build should fail due to list instead of leaf referenced in list key");
- } catch (Exception e) {
- assertTrue(e instanceof ReactorException);
+ } catch (ReactorException e) {
assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
}
}
@Test
- public void incorrectListKeysTest2() throws IOException, YangSyntaxErrorException, URISyntaxException {
+ public void incorrectListKeysTest2() {
final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test2.yang");
try {
reactor.buildEffective();
fail("effective build should fail due to missing leaf referenced in list key");
- } catch (Exception e) {
- assertTrue(e instanceof ReactorException);
+ } catch (ReactorException e) {
assertTrue(e.getCause().getMessage().startsWith("Key 'test1_key1 test1_key2' misses node 'test1_key2'"));
}
}
@Test
- public void incorrectListKeysTest3() throws IOException, YangSyntaxErrorException, URISyntaxException {
+ public void incorrectListKeysTest3() {
final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test3.yang");
try {
reactor.buildEffective();
fail("effective build should fail due to list instead of leaf in grouping referenced in list key");
- } catch (Exception e) {
- assertTrue(e instanceof ReactorException);
+ } catch (ReactorException e) {
assertTrue(e.getCause().getMessage().startsWith("Key 'grp_list' misses node 'grp_list'"));
}
}
@Test
- public void incorrectListKeysTest4() throws IOException, YangSyntaxErrorException, URISyntaxException {
+ public void incorrectListKeysTest4() {
final StatementStreamSource yangFile = sourceForResource("/list-keys-test/incorrect-list-keys-test4.yang");
try {
reactor.buildEffective();
- fail("effective build should fail due to list instead of leaf in grouping augmented to list referenced " +
- "in list key");
- } catch (Exception e) {
- assertTrue(e instanceof ReactorException);
+ fail("effective build should fail due to list instead of leaf in grouping augmented to list referenced "
+ + "in list key");
+ } catch (ReactorException e) {
assertTrue(e.getCause().getMessage().startsWith("Key 'grp_leaf' misses node 'grp_leaf'"));
}
}
final Revision rev20130516 = Revision.valueOf("2013-05-16");
final Revision rev20130715 = Revision.valueOf("2013-07-15");
- final QNameModule yangTypes_20100924 = QNameModule.create(yangTypesNS, rev20100924);
- final QNameModule yangTypes_20130516 = QNameModule.create(yangTypesNS, rev20130516);
- final QNameModule yangTypes_20130715 = QNameModule.create(yangTypesNS, rev20130715);
-
- final QName dateTimeTypeDef_20100924 = QName.create(yangTypes_20100924, "date-and-time");
- final QName dateTimeTypeDef_20130516 = QName.create(yangTypes_20130516, "date-and-time");
- final QName dateTimeTypeDef_20130715 = QName.create(yangTypes_20130715, "date-and-time");
-
- Module yangTypesModule_20100924 = context.findModule("ietf-yang-types", rev20100924).get();
- Module yangTypesModule_20130516 = context.findModule("ietf-yang-types", rev20130516).get();
- Module yangTypesModule_20130715 = context.findModule("ietf-yang-types", rev20130715).get();
- assertTrue(findTypeDef(yangTypesModule_20100924, dateTimeTypeDef_20100924));
- assertTrue(findTypeDef(yangTypesModule_20130516, dateTimeTypeDef_20130516));
- assertTrue(findTypeDef(yangTypesModule_20130715, dateTimeTypeDef_20130715));
-
- checkNetconfMonitoringModuleFullTest(context, rev20130715, dateTimeTypeDef_20130715);
- checkInterfacesModuleFullTest(context, rev20100924, dateTimeTypeDef_20100924);
+ final QNameModule yangTypes20100924 = QNameModule.create(yangTypesNS, rev20100924);
+ final QNameModule yangTypes20130516 = QNameModule.create(yangTypesNS, rev20130516);
+ final QNameModule yangTypes20130715 = QNameModule.create(yangTypesNS, rev20130715);
+
+ final QName dateTimeTypeDef20100924 = QName.create(yangTypes20100924, "date-and-time");
+ final QName dateTimeTypeDef20130516 = QName.create(yangTypes20130516, "date-and-time");
+ final QName dateTimeTypeDef20130715 = QName.create(yangTypes20130715, "date-and-time");
+
+ Module yangTypesModule20100924 = context.findModule("ietf-yang-types", rev20100924).get();
+ Module yangTypesModule20130516 = context.findModule("ietf-yang-types", rev20130516).get();
+ Module yangTypesModule20130715 = context.findModule("ietf-yang-types", rev20130715).get();
+ assertTrue(findTypeDef(yangTypesModule20100924, dateTimeTypeDef20100924));
+ assertTrue(findTypeDef(yangTypesModule20130516, dateTimeTypeDef20130516));
+ assertTrue(findTypeDef(yangTypesModule20130715, dateTimeTypeDef20130715));
+
+ checkNetconfMonitoringModuleFullTest(context, rev20130715, dateTimeTypeDef20130715);
+ checkInterfacesModuleFullTest(context, rev20100924, dateTimeTypeDef20100924);
}
private static void checkInterfacesModuleFullTest(final SchemaContext context, final Revision rev20100924,
- final QName dateTimeTypeDef_20100924) {
+ final QName dateTimeTypeDef20100924) {
Revision rev20121115 = Revision.valueOf("2012-11-15");
- Module interfacesModule_20121115 = context.findModule("ietf-interfaces", rev20121115).get();
- Set<ModuleImport> imports = interfacesModule_20121115.getImports();
+ Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get();
+ Set<ModuleImport> imports = interfacesModule20121115.getImports();
assertEquals(1, imports.size());
ModuleImport interfacesImport = imports.iterator().next();
assertEquals("ietf-yang-types", interfacesImport.getModuleName());
}
private static void checkNetconfMonitoringModuleFullTest(final SchemaContext context,
- final Revision rev20130715, final QName dateTimeTypeDef_20130715) {
+ final Revision rev20130715, final QName dateTimeTypeDef20130715) {
Revision rev20101004 = Revision.valueOf("2010-10-04");
- Module monitoringModule_20101004 = context.findModule("ietf-netconf-monitoring", rev20101004).get();
- Set<ModuleImport> imports = monitoringModule_20101004.getImports();
+ Module monitoringModule20101004 = context.findModule("ietf-netconf-monitoring", rev20101004).get();
+ Set<ModuleImport> imports = monitoringModule20101004.getImports();
assertEquals(2, imports.size());
for (ModuleImport monitoringImport : imports) {
if (monitoringImport.getModuleName().equals("ietf-yang-types")) {
final Revision rev20130516 = Revision.valueOf("2013-05-16");
final Revision rev20130715 = Revision.valueOf("2013-07-15");
- final QNameModule yangTypes_20100924 = QNameModule.create(yangTypesNS, rev20100924);
- final QNameModule yangTypes_20130516 = QNameModule.create(yangTypesNS, rev20130516);
- final QNameModule yangTypes_20130715 = QNameModule.create(yangTypesNS, rev20130715);
+ final QNameModule yangTypes20100924 = QNameModule.create(yangTypesNS, rev20100924);
+ final QNameModule yangTypes20130516 = QNameModule.create(yangTypesNS, rev20130516);
+ final QNameModule yangTypes20130715 = QNameModule.create(yangTypesNS, rev20130715);
- final QName dateTimeTypeDef_20100924 = QName.create(yangTypes_20100924, "date-and-time");
- final QName dateTimeTypeDef_20130516 = QName.create(yangTypes_20130516, "date-and-time");
- final QName dateTimeTypeDef_20130715 = QName.create(yangTypes_20130715, "date-and-time");
+ final QName dateTimeTypeDef20100924 = QName.create(yangTypes20100924, "date-and-time");
+ final QName dateTimeTypeDef20130516 = QName.create(yangTypes20130516, "date-and-time");
+ final QName dateTimeTypeDef20130715 = QName.create(yangTypes20130715, "date-and-time");
- Module yangTypesModule_20100924 = context.findModule("ietf-yang-types", rev20100924).get();
- Module yangTypesModule_20130516 = context.findModule("ietf-yang-types", rev20130516).get();
- Module yangTypesModule_20130715 = context.findModule("ietf-yang-types", rev20130715).get();
- assertTrue(findTypeDef(yangTypesModule_20100924, dateTimeTypeDef_20100924));
- assertTrue(findTypeDef(yangTypesModule_20130516, dateTimeTypeDef_20130516));
- assertTrue(findTypeDef(yangTypesModule_20130715, dateTimeTypeDef_20130715));
+ Module yangTypesModule20100924 = context.findModule("ietf-yang-types", rev20100924).get();
+ Module yangTypesModule20130516 = context.findModule("ietf-yang-types", rev20130516).get();
+ Module yangTypesModule20130715 = context.findModule("ietf-yang-types", rev20130715).get();
+ assertTrue(findTypeDef(yangTypesModule20100924, dateTimeTypeDef20100924));
+ assertTrue(findTypeDef(yangTypesModule20130516, dateTimeTypeDef20130516));
+ assertTrue(findTypeDef(yangTypesModule20130715, dateTimeTypeDef20130715));
- checkNetconfMonitoringModuleSimpleTest(context, rev20130715, dateTimeTypeDef_20130715);
- checkInterfacesModuleSimpleTest(context, rev20100924, dateTimeTypeDef_20100924);
+ checkNetconfMonitoringModuleSimpleTest(context, rev20130715, dateTimeTypeDef20130715);
+ checkInterfacesModuleSimpleTest(context, rev20100924, dateTimeTypeDef20100924);
}
private static void checkInterfacesModuleSimpleTest(final SchemaContext context,
- final Revision rev20100924, final QName dateTimeTypeDef_20100924) {
+ final Revision rev20100924, final QName dateTimeTypeDef20100924) {
URI interfacesNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-interfaces");
Revision rev20121115 = Revision.valueOf("2012-11-15");
- final QNameModule interfacesNS_20121115 = QNameModule.create(interfacesNS, rev20121115);
- QName lastChange = QName.create(interfacesNS_20121115, "last-change");
+ final QNameModule interfacesNS20121115 = QNameModule.create(interfacesNS, rev20121115);
+ QName lastChange = QName.create(interfacesNS20121115, "last-change");
- Module interfacesModule_20121115 = context.findModule("ietf-interfaces", rev20121115).get();
- DataSchemaNode leafLastChange = interfacesModule_20121115.getDataChildByName(lastChange);
+ Module interfacesModule20121115 = context.findModule("ietf-interfaces", rev20121115).get();
+ DataSchemaNode leafLastChange = interfacesModule20121115.getDataChildByName(lastChange);
assertNotNull(leafLastChange);
assertTrue(leafLastChange instanceof LeafSchemaNode);
QName lastChangeTypeQName = ((LeafSchemaNode) leafLastChange).getType().getQName();
- assertEquals(dateTimeTypeDef_20100924, lastChangeTypeQName);
+ assertEquals(dateTimeTypeDef20100924, lastChangeTypeQName);
- Set<ModuleImport> imports = interfacesModule_20121115.getImports();
+ Set<ModuleImport> imports = interfacesModule20121115.getImports();
assertEquals(1, imports.size());
ModuleImport interfacesImport = imports.iterator().next();
assertEquals("ietf-yang-types", interfacesImport.getModuleName());
}
private static void checkNetconfMonitoringModuleSimpleTest(final SchemaContext context,
- final Revision rev20130715, final QName dateTimeTypeDef_20130715) {
+ final Revision rev20130715, final QName dateTimeTypeDef20130715) {
URI monitoringNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring");
- final QNameModule monitoring_19700101 = QNameModule.create(monitoringNS);
- QName lockedTime = QName.create(monitoring_19700101, "locked-time");
+ final QNameModule monitoring19700101 = QNameModule.create(monitoringNS);
+ QName lockedTime = QName.create(monitoring19700101, "locked-time");
- Module monitoringModule_19700101 = context.findModule("ietf-netconf-monitoring").get();
- DataSchemaNode leafLockedTime = monitoringModule_19700101.getDataChildByName(lockedTime);
+ Module monitoringModule19700101 = context.findModule("ietf-netconf-monitoring").get();
+ DataSchemaNode leafLockedTime = monitoringModule19700101.getDataChildByName(lockedTime);
assertNotNull(leafLockedTime);
assertTrue(leafLockedTime instanceof LeafSchemaNode);
QName lockedTimeTypeQName = ((LeafSchemaNode) leafLockedTime).getType().getQName();
- assertEquals(dateTimeTypeDef_20130715, lockedTimeTypeQName);
+ assertEquals(dateTimeTypeDef20130715, lockedTimeTypeQName);
- Set<ModuleImport> imports = monitoringModule_19700101.getImports();
+ Set<ModuleImport> imports = monitoringModule19700101.getImports();
assertEquals(1, imports.size());
ModuleImport monitoringImport = imports.iterator().next();
assertEquals("ietf-yang-types", monitoringImport.getModuleName());
@Test
public void testOrderingTypedef() throws Exception {
final Set<TypeDefinition<?>> typedefs = bar.getTypeDefinitions();
- final String[] expectedOrder = new String[] { "int32-ext1", "int32-ext2",
- "string-ext1", "string-ext2", "string-ext3", "string-ext4",
- "invalid-string-pattern", "multiple-pattern-string",
- "my-decimal-type", "my-union", "my-union-ext", "nested-union2" };
+ final String[] expectedOrder = { "int32-ext1", "int32-ext2", "string-ext1", "string-ext2", "string-ext3",
+ "string-ext4", "invalid-string-pattern", "multiple-pattern-string", "my-decimal-type", "my-union",
+ "my-union-ext", "nested-union2"
+ };
final String[] actualOrder = new String[typedefs.size()];
- int i = 0;
+ int offset = 0;
for (final TypeDefinition<?> type : typedefs) {
- actualOrder[i] = type.getQName().getLocalName();
- i++;
+ actualOrder[offset] = type.getQName().getLocalName();
+ offset++;
}
assertArrayEquals(expectedOrder, actualOrder);
}
}
assertNotNull(augment1);
- final String[] expectedOrder = new String[] { "ds0ChannelNumber",
- "interface-id", "my-type", "schemas", "odl" };
+ final String[] expectedOrder = { "ds0ChannelNumber", "interface-id", "my-type", "schemas", "odl" };
final String[] actualOrder = new String[expectedOrder.length];
- int i = 0;
+ int offset = 0;
for (final DataSchemaNode augmentChild : augment1.getChildNodes()) {
- actualOrder[i] = augmentChild.getQName().getLocalName();
- i++;
+ actualOrder[offset] = augmentChild.getQName().getLocalName();
+ offset++;
}
assertArrayEquals(expectedOrder, actualOrder);
@Test
public void testOrderingNestedChildNodes1() throws Exception {
final Collection<DataSchemaNode> childNodes = foo.getChildNodes();
- final String[] expectedOrder = new String[] { "int32-leaf", "string-leaf",
- "invalid-pattern-string-leaf",
- "invalid-direct-string-pattern-def-leaf",
- "multiple-pattern-string-leaf",
- "multiple-pattern-direct-string-def-leaf", "length-leaf",
- "decimal-leaf", "decimal-leaf2", "ext", "union-leaf",
- "custom-union-leaf", "transfer", "datas", "mycont", "data",
- "how", "address", "port", "addresses", "peer", "id", "foo-id",
- "sub-ext", "sub-transfer", "sub-datas" };
+ final String[] expectedOrder = { "int32-leaf", "string-leaf", "invalid-pattern-string-leaf",
+ "invalid-direct-string-pattern-def-leaf", "multiple-pattern-string-leaf",
+ "multiple-pattern-direct-string-def-leaf", "length-leaf", "decimal-leaf", "decimal-leaf2", "ext",
+ "union-leaf", "custom-union-leaf", "transfer", "datas", "mycont", "data", "how", "address", "port",
+ "addresses", "peer", "id", "foo-id", "sub-ext", "sub-transfer", "sub-datas"
+ };
final String[] actualOrder = new String[childNodes.size()];
- int i = 0;
+ int offset = 0;
for (final DataSchemaNode child : childNodes) {
- actualOrder[i] = child.getQName().getLocalName();
- i++;
+ actualOrder[offset] = child.getQName().getLocalName();
+ offset++;
}
assertArrayEquals(expectedOrder, actualOrder);
}
final GroupingDefinition target = groupings.iterator().next();
final Collection<DataSchemaNode> childNodes = target.getChildNodes();
- final String[] expectedOrder = new String[] { "data", "how", "address",
- "port", "addresses" };
+ final String[] expectedOrder = { "data", "how", "address", "port", "addresses" };
final String[] actualOrder = new String[childNodes.size()];
- int i = 0;
+ int offset = 0;
for (final DataSchemaNode child : childNodes) {
- actualOrder[i] = child.getQName().getLocalName();
- i++;
+ actualOrder[offset] = child.getQName().getLocalName();
+ offset++;
}
assertArrayEquals(expectedOrder, actualOrder);
}
.getDataChildByName(QName.create(baz.getQNameModule(), "x"));
final Collection<DataSchemaNode> childNodes = x.getChildNodes();
- final String[] expectedOrder = new String[] { "x15", "x10", "x5", "x1", "a5",
- "a1", "x2", "b5", "b1", "x3", "ax15", "ax5" };
+ final String[] expectedOrder = { "x15", "x10", "x5", "x1", "a5", "a1", "x2", "b5", "b1", "x3", "ax15", "ax5" };
final String[] actualOrder = new String[childNodes.size()];
- int i = 0;
+ int offset = 0;
for (final DataSchemaNode child : childNodes) {
- actualOrder[i] = child.getQName().getLocalName();
- i++;
+ actualOrder[offset] = child.getQName().getLocalName();
+ offset++;
}
assertArrayEquals(expectedOrder, actualOrder);
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import java.io.IOException;
+import java.net.URISyntaxException;
import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+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.SourceException;
public class ParsingExtensionValueTest {
@Test
- public void extensionTest() throws Exception {
+ public void extensionTest() throws IOException, YangSyntaxErrorException, URISyntaxException {
try {
TestUtils.loadModules(getClass().getResource("/extensions").toURI());
- } catch (Exception e) {
+ } catch (ReactorException e) {
assertEquals(SomeModifiersUnresolvedException.class, e.getClass());
assertTrue(e.getCause() instanceof SourceException);
assertTrue(e.getCause().getMessage().startsWith("ext:id is not a YANG statement or use of extension"));
import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
public class StmtTestUtils {
public static final FileFilter YANG_FILE_FILTER =
- file -> file.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile();
+ file -> file.getName().endsWith(YangConstants.RFC6020_YANG_FILE_EXTENSION) && file.isFile();
public static final FileFilter YIN_FILE_FILTER =
- file -> file.getName().endsWith(YangConstants.RFC6020_YIN_FILE_EXTENSION) && file.isFile();
+ file -> file.getName().endsWith(YangConstants.RFC6020_YIN_FILE_EXTENSION) && file.isFile();
private static final Logger LOG = LoggerFactory.getLogger(StmtTestUtils.class);
}
- public static void log(final Throwable e, final String indent) {
- LOG.debug(indent + e.getMessage());
+ public static void log(final Throwable exception, final String indent) {
+ LOG.debug(indent + exception.getMessage());
- final Throwable[] suppressed = e.getSuppressed();
+ final Throwable[] suppressed = exception.getSuppressed();
for (final Throwable throwable : suppressed) {
log(throwable, indent + " ");
}
}
}
- public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws SourceException,
- ReactorException {
+ public static SchemaContext parseYangSource(final String yangSourcePath) throws ReactorException,
+ URISyntaxException, IOException, YangSyntaxErrorException {
+ return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, null);
+ }
+
+ public static SchemaContext parseYangSource(final String yangSourcePath, final Set<QName> supportedFeatures)
+ throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
+ return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, supportedFeatures);
+ }
+
+ public static SchemaContext parseYangSource(final String yangSourcePath,
+ final StatementParserMode statementParserMode, final Set<QName> supportedFeatures)
+ throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
+ final URL source = StmtTestUtils.class.getResource(yangSourcePath);
+ final File sourceFile = new File(source.toURI());
+ return parseYangSources(statementParserMode, supportedFeatures, sourceFile);
+ }
+
+ public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws ReactorException {
return parseYangSources(StatementParserMode.DEFAULT_MODE, null, sources);
}
public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
- final Set<QName> supportedFeatures, final StatementStreamSource... sources)
- throws SourceException, ReactorException {
+ final Set<QName> supportedFeatures, final StatementStreamSource... sources) throws ReactorException {
return parseYangSources(statementParserMode, supportedFeatures, Arrays.asList(sources));
}
public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
final Set<QName> supportedFeatures, final Collection<? extends StatementStreamSource> sources)
- throws SourceException, ReactorException {
+ throws ReactorException {
final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(
statementParserMode);
reactor.addSources(sources);
return reactor.buildEffective();
}
- public static SchemaContext parseYangSources(final File... files) throws SourceException, ReactorException,
- IOException, YangSyntaxErrorException {
+ public static SchemaContext parseYangSources(final File... files) throws ReactorException, IOException,
+ YangSyntaxErrorException {
return parseYangSources(StatementParserMode.DEFAULT_MODE, null, files);
}
public static SchemaContext parseYangSources(final StatementParserMode statementParserMode,
- final Set<QName> supportedFeatures, final File... files) throws SourceException,
- ReactorException, IOException, YangSyntaxErrorException {
+ final Set<QName> supportedFeatures, final File... files) throws ReactorException, IOException,
+ YangSyntaxErrorException {
final Collection<YangStatementStreamSource> sources = new ArrayList<>(files.length);
for (File file : files) {
return parseYangSources(statementParserMode, supportedFeatures, sources);
}
- public static SchemaContext parseYangSources(final Collection<File> files) throws SourceException, ReactorException,
- IOException, YangSyntaxErrorException {
+ public static SchemaContext parseYangSources(final Collection<File> files) throws ReactorException, IOException,
+ YangSyntaxErrorException {
return parseYangSources(files, StatementParserMode.DEFAULT_MODE);
}
- public static SchemaContext parseYangSources(final Collection<File> files, final StatementParserMode statementParserMode)
- throws SourceException, ReactorException, IOException, YangSyntaxErrorException {
+ public static SchemaContext parseYangSources(final Collection<File> files,
+ final StatementParserMode statementParserMode) throws ReactorException, IOException,
+ YangSyntaxErrorException {
return parseYangSources(statementParserMode, null, files.toArray(new File[files.size()]));
}
- public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws SourceException,
+ public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath) throws
ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
return parseYangSources(yangSourcesDirectoryPath, StatementParserMode.DEFAULT_MODE);
}
- public static SchemaContext parseYangSource(final String yangSourcePath) throws SourceException, ReactorException,
- URISyntaxException, IOException, YangSyntaxErrorException {
- return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, null);
- }
-
- public static SchemaContext parseYangSource(final String yangSourcePath, final Set<QName> supportedFeatures)
- throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
- return parseYangSource(yangSourcePath, StatementParserMode.DEFAULT_MODE, supportedFeatures);
- }
-
- public static SchemaContext parseYangSource(final String yangSourcePath,
- final StatementParserMode statementParserMode, final Set<QName> supportedFeatures)
- throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
- final URL source = StmtTestUtils.class.getResource(yangSourcePath);
- final File sourceFile = new File(source.toURI());
- return parseYangSources(statementParserMode, supportedFeatures, sourceFile);
- }
-
public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
- final StatementParserMode statementParserMode) throws SourceException, ReactorException,
- URISyntaxException, IOException, YangSyntaxErrorException {
+ final StatementParserMode statementParserMode) throws ReactorException, URISyntaxException, IOException,
+ YangSyntaxErrorException {
return parseYangSources(yangSourcesDirectoryPath, null, statementParserMode);
}
public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath,
- final Set<QName> supportedFeatures, final StatementParserMode statementParserMode) throws SourceException,
- ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
+ final Set<QName> supportedFeatures, final StatementParserMode statementParserMode) throws ReactorException,
+ URISyntaxException, IOException, YangSyntaxErrorException {
final URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
final File testSourcesDir = new File(resourceDir.toURI());
return parseYangSources(statementParserMode, supportedFeatures, testSourcesDir.listFiles(YANG_FILE_FILTER));
}
- public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath, final StatementParserMode statementParserMode)
- throws URISyntaxException, SAXException, IOException, ReactorException {
- final URL resourceDir = StmtTestUtils.class.getResource(yinSourcesDirectoryPath);
- final File[] files = new File(resourceDir.toURI()).listFiles(YIN_FILE_FILTER);
- final StatementStreamSource[] sources = new StatementStreamSource[files.length];
- for (int i = 0; i < files.length; i++) {
- final SourceIdentifier identifier = YinTextSchemaSource.identifierFromFilename(files[i].getName());
-
- sources[i] = YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
- YinTextSchemaSource.delegateForByteSource(identifier, Files.asByteSource(files[i]))));
- }
-
- return parseYinSources(statementParserMode, sources);
- }
-
- public static SchemaContext parseYinSources(final StatementParserMode statementParserMode,
- final StatementStreamSource... sources)
- throws ReactorException {
-
- final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
- .newBuild(statementParserMode);
- reactor.addSources(sources);
-
- return reactor.buildEffective();
- }
-
- public static Module findImportedModule(final SchemaContext context, final Module rootModule,
- final String importedModuleName) {
- ModuleImport requestedModuleImport = null;
- final Set<ModuleImport> rootImports = rootModule.getImports();
- for (final ModuleImport moduleImport : rootImports) {
- if (moduleImport.getModuleName().equals(importedModuleName)) {
- requestedModuleImport = moduleImport;
- break;
- }
- }
-
- return context.findModule(requestedModuleImport.getModuleName(), requestedModuleImport.getRevision())
- .orElse(null);
- }
-
public static SchemaContext parseYangSources(final String yangFilesDirectoryPath,
final String yangLibsDirectoryPath)
throws URISyntaxException, ReactorException, IOException, YangSyntaxErrorException {
return reactor.buildEffective();
}
+
+ public static SchemaContext parseYinSources(final String yinSourcesDirectoryPath,
+ final StatementParserMode statementParserMode) throws URISyntaxException, SAXException, IOException,
+ ReactorException {
+ final URL resourceDir = StmtTestUtils.class.getResource(yinSourcesDirectoryPath);
+ final File[] files = new File(resourceDir.toURI()).listFiles(YIN_FILE_FILTER);
+ final StatementStreamSource[] sources = new StatementStreamSource[files.length];
+ for (int i = 0; i < files.length; i++) {
+ final SourceIdentifier identifier = YinTextSchemaSource.identifierFromFilename(files[i].getName());
+
+ sources[i] = YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(
+ YinTextSchemaSource.delegateForByteSource(identifier, Files.asByteSource(files[i]))));
+ }
+
+ return parseYinSources(statementParserMode, sources);
+ }
+
+ public static SchemaContext parseYinSources(final StatementParserMode statementParserMode,
+ final StatementStreamSource... sources) throws ReactorException {
+
+ final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
+ .newBuild(statementParserMode);
+ reactor.addSources(sources);
+
+ return reactor.buildEffective();
+ }
+
+ public static Module findImportedModule(final SchemaContext context, final Module rootModule,
+ final String importedModuleName) {
+ ModuleImport requestedModuleImport = null;
+ final Set<ModuleImport> rootImports = rootModule.getImports();
+ for (final ModuleImport moduleImport : rootImports) {
+ if (moduleImport.getModuleName().equals(importedModuleName)) {
+ requestedModuleImport = moduleImport;
+ break;
+ }
+ }
+
+ return context.findModule(requestedModuleImport.getModuleName(), requestedModuleImport.getRevision())
+ .orElse(null);
+ }
}
import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
public class SubstatementValidatorTest {
-
+ @SuppressWarnings("checkstyle:regexpSinglelineJava")
private final PrintStream stdout = System.out;
private final ByteArrayOutputStream output = new ByteArrayOutputStream();
import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinStatementStreamSource;
import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YinTextToDomTransformer;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
final BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
for (String resourceName : resourceNames) {
- reactor.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(refClass, resourceName)));
+ reactor.addSource(YangStatementStreamSource.create(YangTextSchemaSource.forResource(refClass,
+ resourceName)));
}
return reactor.buildEffective();
return reactor.buildEffective();
}
- public static Module loadYinModule(final YinTextSchemaSource source) throws ReactorException, SAXException, IOException {
+ public static Module loadYinModule(final YinTextSchemaSource source) throws ReactorException, SAXException,
+ IOException {
final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(YinStatementStreamSource.create(YinTextToDomTransformer.transformSource(source)));
SchemaContext ctx = reactor.buildEffective();
return result;
}
- public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws SourceException,
- ReactorException {
+ public static SchemaContext parseYangSources(final StatementStreamSource... sources) throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
.newBuild();
}
public static SchemaContext parseYangSources(final File... files)
- throws SourceException, ReactorException, IOException, YangSyntaxErrorException {
+ throws ReactorException, IOException, YangSyntaxErrorException {
StatementStreamSource[] sources = new StatementStreamSource[files.length];
}
public static SchemaContext parseYangSources(final Collection<File> files)
- throws SourceException, ReactorException, IOException, YangSyntaxErrorException {
+ throws ReactorException, IOException, YangSyntaxErrorException {
return parseYangSources(files.toArray(new File[files.size()]));
}
public static SchemaContext parseYangSources(final String yangSourcesDirectoryPath)
- throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
+ throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
File testSourcesDir = new File(resourceDir.toURI());
}
public static SchemaContext parseYangSource(final String yangSourceFilePath)
- throws SourceException, ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
+ throws ReactorException, URISyntaxException, IOException, YangSyntaxErrorException {
URL resourceFile = StmtTestUtils.class.getResource(yangSourceFilePath);
File testSourcesFile = new File(resourceFile.toURI());
assertNotNull(rangeConstraints);
assertEquals(1, rangeConstraints.size());
- final DataSchemaNode dataNode = context.getDataChildByName(QName.create("urn:opendaylight.foo", "2013-10-08", "id-decimal64"));
+ final DataSchemaNode dataNode = context.getDataChildByName(QName.create("urn:opendaylight.foo", "2013-10-08",
+ "id-decimal64"));
assertNotNull(dataNode);
assertTrue(dataNode instanceof LeafSchemaNode);
try {
final SchemaContext result = reactor.buildEffective();
fail("effective build should fail due to union in list; this is not allowed");
- } catch (Exception e) {
+ } catch (ReactorException e) {
assertEquals(SomeModifiersUnresolvedException.class, e.getClass());
assertTrue(e.getCause() instanceof SourceException);
assertTrue(e.getCause().getMessage().startsWith("union is not a YANG statement or use of extension"));
context = TestUtils.loadModules(getClass().getResource("/grouping-test").toURI());
}
- /**
+ /*
* Structure of testing model:
*
* notification pcreq
public class YangParserNegativeTest {
+ @SuppressWarnings("checkstyle:regexpSinglelineJava")
private final PrintStream stdout = System.out;
private final ByteArrayOutputStream output = new ByteArrayOutputStream();
private String testLog;
TestUtils.loadModuleResources(getClass(), "/negative-scenario/testfile4.yang");
fail("ReactorException should be thrown");
} catch (final ReactorException e) {
- assertTrue(e.getCause().getMessage().contains("Error in module 'test4' in the refine of uses " +
- "'Relative{path=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for" +
- " the target 'LEAF_LIST'."));
+ assertTrue(e.getCause().getMessage().contains("Error in module 'test4' in the refine of uses "
+ + "'Relative{path=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for"
+ + " the target 'LEAF_LIST'."));
}
}
TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container.yang");
fail("SourceException should be thrown");
} catch (final ReactorException e) {
- final String expected = "Error in module 'container': cannot add '(urn:simple.container" +
- ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared";
+ final String expected = "Error in module 'container': cannot add '(urn:simple.container.demo)foo'. "
+ + "Node name collision: '(urn:simple.container.demo)foo' already declared";
assertTrue(e.getCause().getMessage().contains(expected));
}
}
TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container-list.yang");
fail("SourceException should be thrown");
} catch (final ReactorException e) {
- final String expected = "Error in module 'container-list': cannot add '(urn:simple.container" +
- ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared";
+ final String expected = "Error in module 'container-list': cannot add '(urn:simple.container.demo)foo'. "
+ + "Node name collision: '(urn:simple.container.demo)foo' already declared";
assertTrue(e.getCause().getMessage().contains(expected));
}
}
TestUtils.loadModuleResources(getClass(), "/negative-scenario/duplicity/container-leaf.yang");
fail("SourceException should be thrown");
} catch (final ReactorException e) {
- final String expected = "Error in module 'container-leaf': cannot add '(urn:simple.container" +
- ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared";
+ final String expected = "Error in module 'container-leaf': cannot add '(urn:simple.container.demo)foo'. "
+ + "Node name collision: '(urn:simple.container.demo)foo' already declared";
assertTrue(e.getCause().getMessage().contains(expected));
}
}
"/negative-scenario/duplicity/augment0.yang",
"/negative-scenario/duplicity/augment1.yang");
testLog = output.toString();
- assertTrue(testLog.contains("An augment cannot add node named 'id' because this name is already used in target"));
+ assertTrue(testLog.contains(
+ "An augment cannot add node named 'id' because this name is already used in target"));
}
@Test
"/negative-scenario/duplicity/augment0.yang",
"/negative-scenario/duplicity/augment2.yang");
testLog = output.toString();
- assertTrue(testLog.contains("An augment cannot add node named 'delta' because this name is already used in target"));
+ assertTrue(testLog.contains(
+ "An augment cannot add node named 'delta' because this name is already used in target"));
}
@Test
QName.create(testModule.getQNameModule(), "data"));
assertNotNull("'anyxml data not found'", data);
assertFalse(data.equals(null));
- assertEquals("AnyXmlEffectiveStatementImpl[qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data, " +
- "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data]}]",
+ assertEquals("AnyXmlEffectiveStatementImpl[qname=(urn:opendaylight:simple-nodes?revision=2013-07-30)data, "
+ + "path=AbsoluteSchemaPath{path=[(urn:opendaylight:simple-nodes?revision=2013-07-30)data]}]",
data.toString());
// test SchemaNode args
// child nodes
// total size = 8: defined 6, inserted by uses 2
assertEquals(8, nodes.getChildNodes().size());
- final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create(testModule.getQNameModule(), "added"));
+ final LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName(QName.create(
+ testModule.getQNameModule(), "added"));
assertEquals(createPath("nodes", "added"), added.getPath());
assertEquals(createPath("mytype"), added.getType().getPath());
- final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create(testModule.getQNameModule(), "links"));
+ final ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName(QName.create(
+ testModule.getQNameModule(), "links"));
assertFalse(links.isUserOrdered());
final Set<GroupingDefinition> groupings = nodes.getGroupings();
assertEquals(0, ifEntry.getGroupings().size());
assertEquals(0, ifEntry.getUses().size());
- final LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(), "ifIndex"));
+ final LeafSchemaNode ifIndex = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(),
+ "ifIndex"));
assertEquals(ifEntry.getKeyDefinition().get(0), ifIndex.getQName());
assertTrue(ifIndex.getType() instanceof UnsignedIntegerTypeDefinition);
assertEquals("minutes", ifIndex.getUnits());
- final LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(), "ifMtu"));
+ final LeafSchemaNode ifMtu = (LeafSchemaNode) ifEntry.getDataChildByName(QName.create(bar.getQNameModule(),
+ "ifMtu"));
assertEquals(BaseTypes.int32Type(), ifMtu.getType());
}
@Test
public void testTypedefRangesResolving() throws ParseException {
- final LeafSchemaNode int32Leaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "int32-leaf"));
+ final LeafSchemaNode int32Leaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
+ "int32-leaf"));
final IntegerTypeDefinition leafType = (IntegerTypeDefinition) int32Leaf.getType();
assertEquals(QName.create(FOO, "int32-ext2"), leafType.getQName());
@Test
public void testTypedefPatternsResolving() {
- final LeafSchemaNode stringleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "string-leaf"));
+ final LeafSchemaNode stringleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
+ "string-leaf"));
assertTrue(stringleaf.getType() instanceof StringTypeDefinition);
final StringTypeDefinition type = (StringTypeDefinition) stringleaf.getType();
@Test
public void testTypedefDecimal1() {
- final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "decimal-leaf"));
+ final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
+ "decimal-leaf"));
assertTrue(testleaf.getType() instanceof DecimalTypeDefinition);
final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType();
@Test
public void testTypedefDecimal2() {
- final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "decimal-leaf2"));
+ final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
+ "decimal-leaf2"));
assertTrue(testleaf.getType() instanceof DecimalTypeDefinition);
final DecimalTypeDefinition type = (DecimalTypeDefinition) testleaf.getType();
@Test
public void testTypedefUnion() {
- final LeafSchemaNode unionleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "union-leaf"));
+ final LeafSchemaNode unionleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
+ "union-leaf"));
assertTrue(unionleaf.getType() instanceof UnionTypeDefinition);
final UnionTypeDefinition type = (UnionTypeDefinition) unionleaf.getType();
@Test
public void testNestedUnionResolving() {
- final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "custom-union-leaf"));
+ final LeafSchemaNode testleaf = (LeafSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(),
+ "custom-union-leaf"));
assertTrue(testleaf.getType() instanceof UnionTypeDefinition);
final UnionTypeDefinition type = (UnionTypeDefinition) testleaf.getType();
@Test
public void testChoice() {
- final ContainerSchemaNode transfer = (ContainerSchemaNode) foo.getDataChildByName(QName.create(foo.getQNameModule(), "transfer"));
- final ChoiceSchemaNode how = (ChoiceSchemaNode) transfer.getDataChildByName(QName.create(foo.getQNameModule(), "how"));
+ final ContainerSchemaNode transfer = (ContainerSchemaNode) foo.getDataChildByName(
+ QName.create(foo.getQNameModule(), "transfer"));
+ final ChoiceSchemaNode how = (ChoiceSchemaNode) transfer.getDataChildByName(
+ QName.create(foo.getQNameModule(), "how"));
final Set<ChoiceCaseNode> cases = how.getCases();
assertEquals(5, cases.size());
ChoiceCaseNode input = null;
@Test
public void testUnknownNode() {
- final ContainerSchemaNode network = (ContainerSchemaNode) baz.getDataChildByName(QName.create(baz.getQNameModule(), "network"));
+ final ContainerSchemaNode network = (ContainerSchemaNode) baz.getDataChildByName(
+ QName.create(baz.getQNameModule(), "network"));
final List<UnknownSchemaNode> unknownNodes = network.getUnknownSchemaNodes();
assertEquals(1, unknownNodes.size());
final UnknownSchemaNode unknownNode = unknownNodes.get(0);
assertEquals(0, notification.getGroupings().size());
assertEquals(0, notification.getUses().size());
- final LeafSchemaNode eventClass = (LeafSchemaNode) notification.getDataChildByName(QName.create(baz.getQNameModule(), "event-class"));
+ final LeafSchemaNode eventClass = (LeafSchemaNode) notification.getDataChildByName(
+ QName.create(baz.getQNameModule(), "event-class"));
assertTrue(eventClass.getType() instanceof StringTypeDefinition);
- final LeafSchemaNode severity = (LeafSchemaNode) notification.getDataChildByName(QName.create(baz.getQNameModule(), "severity"));
+ final LeafSchemaNode severity = (LeafSchemaNode) notification.getDataChildByName(
+ QName.create(baz.getQNameModule(), "severity"));
assertTrue(severity.getType() instanceof StringTypeDefinition);
}
private static void checkOrder(final Collection<Module> modules) {
final Iterator<Module> it = modules.iterator();
- Module m = it.next();
- assertEquals("m2", m.getName());
- m = it.next();
- assertEquals("m4", m.getName());
- m = it.next();
- assertEquals("m6", m.getName());
- m = it.next();
- assertEquals("m8", m.getName());
- m = it.next();
- assertEquals("m7", m.getName());
- m = it.next();
- assertEquals("m5", m.getName());
- m = it.next();
- assertEquals("m3", m.getName());
- m = it.next();
- assertEquals("m1", m.getName());
+ Module module = it.next();
+ assertEquals("m2", module.getName());
+ module = it.next();
+ assertEquals("m4", module.getName());
+ module = it.next();
+ assertEquals("m6", module.getName());
+ module = it.next();
+ assertEquals("m8", module.getName());
+ module = it.next();
+ assertEquals("m7", module.getName());
+ module = it.next();
+ assertEquals("m5", module.getName());
+ module = it.next();
+ assertEquals("m3", module.getName());
+ module = it.next();
+ assertEquals("m1", module.getName());
}
private static void assertSetEquals(final Set<Module> s1, final Set<Module> s2) {
}
@Test
- public void unknownStatementsInStatementsTest() throws ReactorException {
+ public void unknownStatementsInStatementsTest() {
final StatementStreamSource yangFile1 = sourceForResource(
"/yang-grammar-test/stmtsep-in-statements.yang");
// TODO: change test or create new module in order to respect new statement parser validations
try {
final SchemaContext result = reactor.buildEffective();
- } catch (final Exception e) {
+ } catch (final ReactorException e) {
assertEquals(SomeModifiersUnresolvedException.class, e.getClass());
assertTrue(e.getCause() instanceof SourceException);
assertTrue(e.getCause().getMessage().startsWith("aaa is not a YANG statement or use of extension"));
import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
import org.opendaylight.yangtools.yang.model.util.type.BaseTypes;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
private static final StatementStreamSource TYPEFILE4 = sourceForResource(
"/semantic-statement-parser/identityreftest.yang");
- private static final QNameModule types2Module = QNameModule.create(URI.create("types2"));
+ private static final QNameModule TYPES2_MODULE = QNameModule.create(URI.create("types2"));
- private static final QName lfDecimal = QName.create(types2Module, "lf-decimal");
- private static final QName lfMyString = QName.create(types2Module, "lf-my-string");
- private static final QName lfInt8 = QName.create(types2Module, "lf-int8");
- private static final QName lfInt16 = QName.create(types2Module, "lf-int16");
- private static final QName lfInt32 = QName.create(types2Module, "lf-int32");
- private static final QName lfInt64 = QName.create(types2Module, "lf-int64");
- private static final QName lfUInt8 = QName.create(types2Module, "lf-uint8");
- private static final QName lfUInt16 = QName.create(types2Module, "lf-uint16");
- private static final QName lfUInt32 = QName.create(types2Module, "lf-uint32");
- private static final QName lfUInt64 = QName.create(types2Module, "lf-uint64");
- private static final QName lfBool = QName.create(types2Module, "lf-bool");
+ private static final QName LF_DECIMAL = QName.create(TYPES2_MODULE, "lf-decimal");
+ private static final QName LF_MY_STRING = QName.create(TYPES2_MODULE, "lf-my-string");
+ private static final QName LF_INT8 = QName.create(TYPES2_MODULE, "lf-int8");
+ private static final QName LF_INT16 = QName.create(TYPES2_MODULE, "lf-int16");
+ private static final QName LF_INT32 = QName.create(TYPES2_MODULE, "lf-int32");
+ private static final QName LF_INT64 = QName.create(TYPES2_MODULE, "lf-int64");
+ private static final QName LF_UINT8 = QName.create(TYPES2_MODULE, "lf-uint8");
+ private static final QName LF_UINT16 = QName.create(TYPES2_MODULE, "lf-uint16");
+ private static final QName LF_UINT32 = QName.create(TYPES2_MODULE, "lf-uint32");
+ private static final QName LF_UINT64 = QName.create(TYPES2_MODULE, "lf-uint64");
+ private static final QName LF_BOOL = QName.create(TYPES2_MODULE, "lf-bool");
@Test
- public void readAndParseYangFileTest() throws SourceException, ReactorException {
+ public void readAndParseYangFileTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
reactor.addSources(TYPEFILE1, TYPEFILE2, TYPEFILE3, TYPEFILE4);
SchemaContext result = reactor.buildEffective();
assertNotNull(result);
- final LeafSchemaNode lfDecimalNode = (LeafSchemaNode) result.getDataChildByName(lfDecimal);
+ final LeafSchemaNode lfDecimalNode = (LeafSchemaNode) result.getDataChildByName(LF_DECIMAL);
assertNotNull(lfDecimalNode);
assertTrue(lfDecimalNode.getType() instanceof DecimalTypeDefinition);
final DecimalTypeDefinition lfDecimalNodeType = (DecimalTypeDefinition) lfDecimalNode.getType();
assertEquals(2, lfDecimalNodeType.getFractionDigits().intValue());
- final LeafSchemaNode lfInt8Node = (LeafSchemaNode) result.getDataChildByName(lfInt8);
+ final LeafSchemaNode lfInt8Node = (LeafSchemaNode) result.getDataChildByName(LF_INT8);
assertNotNull(lfInt8Node);
assertEquals(BaseTypes.int8Type().getClass(), lfInt8Node.getType().getClass());
- final LeafSchemaNode lfInt16Node = (LeafSchemaNode) result.getDataChildByName(lfInt16);
+ final LeafSchemaNode lfInt16Node = (LeafSchemaNode) result.getDataChildByName(LF_INT16);
assertNotNull(lfInt16Node);
assertEquals(BaseTypes.int16Type().getClass(), lfInt16Node.getType().getClass());
- final LeafSchemaNode lfInt32Node = (LeafSchemaNode) result.getDataChildByName(lfInt32);
+ final LeafSchemaNode lfInt32Node = (LeafSchemaNode) result.getDataChildByName(LF_INT32);
assertNotNull(lfInt32Node);
assertEquals(BaseTypes.int32Type().getClass(), lfInt32Node.getType().getClass());
- final LeafSchemaNode lfInt64Node = (LeafSchemaNode) result.getDataChildByName(lfInt64);
+ final LeafSchemaNode lfInt64Node = (LeafSchemaNode) result.getDataChildByName(LF_INT64);
assertNotNull(lfInt64Node);
assertEquals(BaseTypes.int64Type().getClass(), lfInt64Node.getType().getClass());
- final LeafSchemaNode lfUInt8Node = (LeafSchemaNode) result.getDataChildByName(lfUInt8);
+ final LeafSchemaNode lfUInt8Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT8);
assertNotNull(lfUInt8Node);
assertEquals(BaseTypes.uint8Type().getClass(), lfUInt8Node.getType().getClass());
- final LeafSchemaNode lfUInt16Node = (LeafSchemaNode) result.getDataChildByName(lfUInt16);
+ final LeafSchemaNode lfUInt16Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT16);
assertNotNull(lfUInt16Node);
assertEquals(BaseTypes.uint16Type().getClass(), lfUInt16Node.getType().getClass());
- final LeafSchemaNode lfUInt32Node = (LeafSchemaNode) result.getDataChildByName(lfUInt32);
+ final LeafSchemaNode lfUInt32Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT32);
assertNotNull(lfUInt32Node);
assertEquals(BaseTypes.uint32Type().getClass(), lfUInt32Node.getType().getClass());
- final LeafSchemaNode lfUInt64Node = (LeafSchemaNode) result.getDataChildByName(lfUInt64);
+ final LeafSchemaNode lfUInt64Node = (LeafSchemaNode) result.getDataChildByName(LF_UINT64);
assertNotNull(lfUInt64Node);
assertEquals(BaseTypes.uint64Type().getClass(), lfUInt64Node.getType().getClass());
- final LeafSchemaNode lfBoolNode = (LeafSchemaNode) result.getDataChildByName(lfBool);
+ final LeafSchemaNode lfBoolNode = (LeafSchemaNode) result.getDataChildByName(LF_BOOL);
assertNotNull(lfBoolNode);
assertEquals(BaseTypes.booleanType().getClass(), lfBoolNode.getType().getClass());
}
import org.junit.Test;
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;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
private static final StatementStreamSource FILE4 = sourceForResource("/semantic-statement-parser/model/foo.yang");
@Test
- public void readAndParseYangFileTest() throws SourceException, ReactorException {
+ public void readAndParseYangFileTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, TYPEFILE1, TYPEFILE2, TYPEFILE3);
- addSources(reactor, FILE1, FILE2, FILE3, FILE4);
+ reactor.addSources(TYPEFILE1, TYPEFILE2, TYPEFILE3);
+ reactor.addSources(FILE1, FILE2, FILE3, FILE4);
SchemaContext result = reactor.buildEffective();
assertNotNull(result);
}
-
- private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) {
- for (StatementStreamSource source : sources) {
- reactor.addSource(source);
- }
- }
}
@Test
public void borderCaseValidMajorTest() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/border-case/border-case-valid-major",
- StatementParserMode.SEMVER_MODE);
+ SchemaContext context = StmtTestUtils.parseYangSources(
+ "/openconfig-version/border-case/border-case-valid-major", StatementParserMode.SEMVER_MODE);
assertNotNull(context);
- Module foo = context.findModules(new URI("foo")).iterator().next();
- Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next();
+ Module foo = context.findModules(URI.create("foo")).iterator().next();
+ Module semVer = context.findModules(URI.create("http://openconfig.net/yang/openconfig-ext")).iterator().next();
assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
@Test
public void borderCaseValidMinorTest() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/border-case/border-case-valid-minor",
- StatementParserMode.SEMVER_MODE);
+ SchemaContext context = StmtTestUtils.parseYangSources(
+ "/openconfig-version/border-case/border-case-valid-minor", StatementParserMode.SEMVER_MODE);
assertNotNull(context);
- Module foo = context.findModules(new URI("foo")).iterator().next();
- Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next();
+ Module foo = context.findModules(URI.create("foo")).iterator().next();
+ Module semVer = context.findModules(URI.create("http://openconfig.net/yang/openconfig-ext")).iterator().next();
assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
@Test
public void borderCaseValidPatchTest() throws Exception {
- SchemaContext context = StmtTestUtils.parseYangSources("/openconfig-version/border-case/border-case-valid-patch",
- StatementParserMode.SEMVER_MODE);
+ SchemaContext context = StmtTestUtils.parseYangSources(
+ "/openconfig-version/border-case/border-case-valid-patch", StatementParserMode.SEMVER_MODE);
assertNotNull(context);
- Module foo = context.findModules(new URI("foo")).iterator().next();
- Module semVer = context.findModules(new URI("http://openconfig.net/yang/openconfig-ext")).iterator().next();
+ Module foo = context.findModules(URI.create("foo")).iterator().next();
+ Module semVer = context.findModules(URI.create("http://openconfig.net/yang/openconfig-ext")).iterator().next();
assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion().get());
assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion().get());
@Test
public void basicImportErrTest2() throws Exception {
try {
- StmtTestUtils.parseYangSources("/openconfig-version/basic-import-invalid-2", StatementParserMode.SEMVER_MODE);
+ StmtTestUtils.parseYangSources("/openconfig-version/basic-import-invalid-2",
+ StatementParserMode.SEMVER_MODE);
fail("Test should fail due to invalid openconfig version");
} catch (ReactorException e) {
assertTrue(e.getCause().getCause().getMessage()
final AugmentationSchema augment = augmentIterator.next();
assertNotNull(augment);
assertTrue(augment.getTargetPath().toString().contains(
- "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, " +
- "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module, " +
- "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)configuration"));
+ "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)modules, "
+ + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)module, "
+ + "(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)configuration"));
assertEquals(1, augment.getChildNodes().size());
final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName(QName.create(
ExtensionDefinition extension = extIterator.next();
assertEquals("name", extension.getArgument());
assertEquals("java-class", extension.getQName().getLocalName());
- assertEquals("YANG language extension carrying the fully-qualified name of\n" +
- "a Java class. Code generation tools use the provided reference\n" +
- "to tie a specific construct to its Java representation.", extension.getDescription());
+ assertEquals("YANG language extension carrying the fully-qualified name of\n"
+ + "a Java class. Code generation tools use the provided reference\n"
+ + "to tie a specific construct to its Java representation.", extension.getDescription());
extension = extIterator.next();
assertEquals("name", extension.getArgument());
assertEquals("required-identity", extension.getQName().getLocalName());
- assertEquals("YANG language extension which indicates that a particular\n" +
- "leafref, which points to a identityref, should additionally\n" +
- "require the target node is actually set to a descendant to\n" +
- "of a particular identity.\n" +
- "\n" +
- "This is a workaround to two YANG deficiencies:\n" +
- "1) not being able to leafref instances of identityref\n" +
- "2) not being able to refine an identityref\n" +
- "\n" +
- "This extension takes one argument, name, which MUST be the name\n" +
- "of an identity. Furthermore, that identity MUST be based,\n" +
- "directly or indirectly, on the identity, which is referenced by\n" +
- "the leaf reference, which is annotated with this extension.", extension.getDescription());
+ assertEquals("YANG language extension which indicates that a particular\n"
+ + "leafref, which points to a identityref, should additionally\n"
+ + "require the target node is actually set to a descendant to\n"
+ + "of a particular identity.\n"
+ + "\n"
+ + "This is a workaround to two YANG deficiencies:\n"
+ + "1) not being able to leafref instances of identityref\n"
+ + "2) not being able to refine an identityref\n"
+ + "\n"
+ + "This extension takes one argument, name, which MUST be the name\n"
+ + "of an identity. Furthermore, that identity MUST be based,\n"
+ + "directly or indirectly, on the identity, which is referenced by\n"
+ + "the leaf reference, which is annotated with this extension.", extension.getDescription());
extension = extIterator.next();
assertNull(extension.getArgument());
assertEquals("inner-state-bean", extension.getQName().getLocalName());
- assertEquals("YANG language extension which indicates that a particular\n" +
- "list located under module's state should be treated as a list\n" +
- "of child state beans instead of just an ordinary list attribute", extension.getDescription());
+ assertEquals("YANG language extension which indicates that a particular\n"
+ + "list located under module's state should be treated as a list\n"
+ + "of child state beans instead of just an ordinary list attribute", extension.getDescription());
extension = extIterator.next();
assertEquals("name", extension.getArgument());
assertEquals("provided-service", extension.getQName().getLocalName());
- assertEquals("YANG language extension which indicates that a particular\n" +
- "module provides certain service. This extension can be placed\n" +
- "on identities that are based on module-type. Zero or more services\n" +
- "can be provided.\n" +
- "This extension takes one argument - name - which MUST be the name\n" +
- "of an identity. Furthermore, this identity MUST be based on\n" +
- "service-type.", extension.getDescription());
+ assertEquals("YANG language extension which indicates that a particular\n"
+ + "module provides certain service. This extension can be placed\n"
+ + "on identities that are based on module-type. Zero or more services\n"
+ + "can be provided.\n"
+ + "This extension takes one argument - name - which MUST be the name\n"
+ + "of an identity. Furthermore, this identity MUST be based on\n"
+ + "service-type.", extension.getDescription());
extension = extIterator.next();
assertEquals("java-prefix", extension.getArgument());
assertEquals("java-name-prefix", extension.getQName().getLocalName());
- assertEquals("YANG language extension carrying java simple class name prefix\n" +
- "that will be taken into account when generating java code from\n" +
- "identities that are based on module-type.", extension.getDescription());
+ assertEquals("YANG language extension carrying java simple class name prefix\n"
+ + "that will be taken into account when generating java code from\n"
+ + "identities that are based on module-type.", extension.getDescription());
}
}
final Iterator<GroupingDefinition> groupingsIterator = groupings.iterator();
final GroupingDefinition grouping = groupingsIterator.next();
assertEquals("service-ref", grouping.getQName().getLocalName());
- assertEquals("Type of references to a particular service instance. This type\n" +
- "can be used when defining module configuration to refer to a\n" +
- "particular service instance. Containers using this grouping\n" +
- "should not define anything else. The run-time implementation\n" +
- "is expected to inject a reference to the service as the value\n" +
- "of the container.", grouping.getDescription());
+ assertEquals("Type of references to a particular service instance. This type\n"
+ + "can be used when defining module configuration to refer to a\n"
+ + "particular service instance. Containers using this grouping\n"
+ + "should not define anything else. The run-time implementation\n"
+ + "is expected to inject a reference to the service as the value\n"
+ + "of the container.", grouping.getDescription());
final Collection<DataSchemaNode> children = grouping.getChildNodes();
assertEquals(2, children.size());
@Before
public void init() throws URISyntaxException, ReactorException, SAXException, IOException {
- context = TestUtils.loadYinModules(getClass().getResource
- ("/semantic-statement-parser/yin/include-belongs-to-test").toURI());
+ context = TestUtils.loadYinModules(getClass().getResource(
+ "/semantic-statement-parser/yin/include-belongs-to-test").toURI());
assertEquals(1, context.getModules().size());
}
testModule.getQNameModule(), "modules"));
assertNotNull(container);
- final ListSchemaNode list = (ListSchemaNode) container.getDataChildByName(QName.create(testModule.getQNameModule(),
- "module"));
+ final ListSchemaNode list = (ListSchemaNode) container.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "module"));
assertNotNull(list);
final List<QName> keys = list.getKeyDefinition();
assertEquals(1, keys.size());
assertNotNull(testModule);
assertEquals("IETF NETCONF (Network Configuration) Working Group", testModule.getOrganization());
- assertEquals("WG Web: <http://tools.ietf.org/wg/netconf/>\n" +
- "WG List: <mailto:netconf@ietf.org>\n" +
- "\n" +
- "WG Chair: Mehmet Ersue\n" +
- " <mailto:mehmet.ersue@nsn.com>\n" +
- "\n" +
- "WG Chair: Bert Wijnen\n" +
- " <mailto:bertietf@bwijnen.net>\n" +
- "\n" +
- "Editor: Mark Scott\n" +
- " <mailto:mark.scott@ericsson.com>\n" +
- "\n" +
- "Editor: Martin Bjorklund\n" +
- " <mailto:mbj@tail-f.com>", testModule.getContact());
- assertEquals("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n" +
- "Copyright (c) 2010 IETF Trust and the persons identified as\n" + "authors of the code. All rights " +
- "reserved.\n" + "\n" + "Redistribution and use in source and binary forms, with or\n" + "without " +
- "modification, is permitted pursuant to, and subject\n" + "to the license terms contained in, the " +
- "Simplified BSD\n" + "License set forth in Section 4.c of the IETF Trust's\n" + "Legal Provisions " +
- "Relating to IETF Documents\n" + "(http://trustee.ietf.org/license-info).\n" + "\n" + "This version " +
- "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices.",
+ assertEquals("WG Web: <http://tools.ietf.org/wg/netconf/>\n"
+ + "WG List: <mailto:netconf@ietf.org>\n"
+ + "\n"
+ + "WG Chair: Mehmet Ersue\n"
+ + " <mailto:mehmet.ersue@nsn.com>\n"
+ + "\n"
+ + "WG Chair: Bert Wijnen\n"
+ + " <mailto:bertietf@bwijnen.net>\n"
+ + "\n"
+ + "Editor: Mark Scott\n"
+ + " <mailto:mark.scott@ericsson.com>\n"
+ + "\n"
+ + "Editor: Martin Bjorklund\n"
+ + " <mailto:mbj@tail-f.com>", testModule.getContact());
+ assertEquals("NETCONF Monitoring Module.\n" + "All elements in this module are read-only.\n" + "\n"
+ + "Copyright (c) 2010 IETF Trust and the persons identified as\n" + "authors of the code. All rights "
+ + "reserved.\n" + "\n" + "Redistribution and use in source and binary forms, with or\n" + "without "
+ + "modification, is permitted pursuant to, and subject\n" + "to the license terms contained in, the "
+ + "Simplified BSD\n" + "License set forth in Section 4.c of the IETF Trust's\n" + "Legal Provisions "
+ + "Relating to IETF Documents\n" + "(http://trustee.ietf.org/license-info).\n" + "\n" + "This version "
+ + "of this YANG module is part of RFC 6022; see\n" + "the RFC itself for full legal notices.",
testModule.getDescription());
}
}
RpcDefinition rpc = rpcs.iterator().next();
assertEquals("get-schema", rpc.getQName().getLocalName());
- assertEquals("This operation is used to retrieve a schema from the\n" +
- "NETCONF server.\n" +
- "\n" +
- "Positive Response:\n" +
- "The NETCONF server returns the requested schema.\n" +
- "\n" +
- "Negative Response:\n" +
- "If requested schema does not exist, the <error-tag> is\n" +
- "'invalid-value'.\n" +
- "\n" +
- "If more than one schema matches the requested parameters, the\n" +
- "<error-tag> is 'operation-failed', and <error-app-tag> is\n" +
- "'data-not-unique'.", rpc.getDescription());
+ assertEquals("This operation is used to retrieve a schema from the\n"
+ + "NETCONF server.\n"
+ + "\n"
+ + "Positive Response:\n"
+ + "The NETCONF server returns the requested schema.\n"
+ + "\n"
+ + "Negative Response:\n"
+ + "If requested schema does not exist, the <error-tag> is\n"
+ + "'invalid-value'.\n"
+ + "\n"
+ + "If more than one schema matches the requested parameters, the\n"
+ + "<error-tag> is 'operation-failed', and <error-app-tag> is\n"
+ + "'data-not-unique'.", rpc.getDescription());
ContainerSchemaNode input = rpc.getInput();
assertNotNull(input);
@Test
public void readAndParseYinFileTestModel() throws SourceException, ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-
- addSources(reactor, YIN_FILE, EXT_FILE, EXT_USE_FILE);
+ reactor.addSources(YIN_FILE, EXT_FILE, EXT_USE_FILE);
SchemaContext result = reactor.buildEffective();
assertNotNull(result);
}
@Test(expected = SomeModifiersUnresolvedException.class)
public void readAndParseInvalidYinFileTest() throws ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, INVALID_YIN_FILE);
+ reactor.addSources(INVALID_YIN_FILE);
SchemaContext result = reactor.buildEffective();
assertNotNull(result);
}
// parsing yin file with duplicate key name in a list statement
public void readAndParseInvalidYinFileTest2() {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, INVALID_YIN_FILE_2);
+ reactor.addSources(INVALID_YIN_FILE_2);
try {
reactor.buildEffective();
public void testModulesSize() {
assertEquals(context.getModules().size(), 9);
}
-
- private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final
- StatementStreamSource... sources) {
- for (StatementStreamSource source : sources) {
- reactor.addSource(source);
- }
- }
-
}
\ No newline at end of file
final Iterator<AugmentationSchema> augmentIterator = augmentations.iterator();
final AugmentationSchema augment = augmentIterator.next();
- final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName(QName.create(testModule.getQNameModule(),
- "main-impl"));
+ final ChoiceCaseNode caseNode = (ChoiceCaseNode) augment.getDataChildByName(
+ QName.create(testModule.getQNameModule(), "main-impl"));
assertNotNull(caseNode);
final ContainerSchemaNode container = (ContainerSchemaNode) caseNode.getDataChildByName(QName.create(
assertEquals(1, container.getUses().size());
final UsesNode usesNode = container.getUses().iterator().next();
assertNotNull(usesNode);
- assertTrue(usesNode
- .getGroupingPath()
- .toString()
- .contains(
- "[(urn:opendaylight:params:xml:ns:yang:controller:" + "config?revision=2013-04-05)service-ref]"));
+ assertTrue(usesNode.getGroupingPath().toString()
+ .contains("[(urn:opendaylight:params:xml:ns:yang:controller:config?revision=2013-04-05)service-ref]"));
assertEquals(1, usesNode.getRefines().size());
}
}