X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-codec-xml%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fcodec%2Fxml%2FXmlToNormalizedNodesTest.java;h=ecde264cda4fe8214c70f3b686e60e7f2f444b02;hb=refs%2Fchanges%2F57%2F70057%2F3;hp=9776bc49e51d0ea2692c6224131a6dd6826168b3;hpb=21b3fb1ea12d1e28115f6c216bbbfd9c80b2216f;p=yangtools.git diff --git a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java index 9776bc49e5..ecde264cda 100644 --- a/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java +++ b/yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java @@ -47,7 +47,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeS import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl; import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; import org.xml.sax.SAXException; @@ -110,7 +109,7 @@ public class XmlToNormalizedNodesTest { @Test public void testComplexXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException, ParserConfigurationException, SAXException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/baz.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/baz.xml"); @@ -120,7 +119,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); xmlParser.parse(reader); xmlParser.flush(); @@ -138,7 +137,7 @@ public class XmlToNormalizedNodesTest { @Test public void testSimpleXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException, ParserConfigurationException, SAXException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/foo.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/foo.xml"); @@ -148,7 +147,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); xmlParser.parse(reader); final NormalizedNode transformedInput = result.getResult(); @@ -158,7 +157,7 @@ public class XmlToNormalizedNodesTest { @Test public void shouldFailOnDuplicateLeaf() throws ReactorException, XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/foo.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo.xml"); @@ -168,7 +167,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); try { xmlParser.parse(reader); fail("IllegalStateException should have been thrown because of duplicate leaf."); @@ -181,7 +180,7 @@ public class XmlToNormalizedNodesTest { @Test public void shouldFailOnDuplicateAnyXml() throws ReactorException, XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/foo.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-2.xml"); @@ -191,7 +190,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); try { xmlParser.parse(reader); fail("IllegalStateException should have been thrown because of duplicate anyxml"); @@ -203,7 +202,7 @@ public class XmlToNormalizedNodesTest { @Test public void shouldFailOnDuplicateContainer() throws ReactorException, XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/foo.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/foo.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-3.xml"); @@ -213,7 +212,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); try { xmlParser.parse(reader); fail("IllegalStateException should have been thrown because of duplicate container"); @@ -225,7 +224,7 @@ public class XmlToNormalizedNodesTest { @Test public void shouldFailOnUnterminatedLeafElement() throws ReactorException, XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/baz.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz.xml"); @@ -235,7 +234,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); try { xmlParser.parse(reader); fail("XMLStreamException should have been thrown because of unterminated leaf element."); @@ -248,7 +247,7 @@ public class XmlToNormalizedNodesTest { @Test public void shouldFailOnUnterminatedLeafElement2() throws ReactorException, XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/baz.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-2.xml"); @@ -258,7 +257,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); try { xmlParser.parse(reader); fail("XMLStreamException should have been thrown because of unterminated leaf element."); @@ -271,7 +270,7 @@ public class XmlToNormalizedNodesTest { @Test public void shouldFailOnUnterminatedContainerElement() throws ReactorException, XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/baz.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-4.xml"); @@ -281,7 +280,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); try { xmlParser.parse(reader); fail("XMLStreamException should have been thrown because of unterminated container element."); @@ -294,7 +293,7 @@ public class XmlToNormalizedNodesTest { @Test public void shouldFailOnUnexistingContainerElement() throws ReactorException, XMLStreamException, IOException, ParserConfigurationException, SAXException, URISyntaxException { - SchemaContext schemaContext = YangParserTestUtils.parseYangSources(new YangStatementSourceImpl("/baz.yang", false)); + SchemaContext schemaContext = YangParserTestUtils.parseYangSource("/baz.yang"); final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-3.xml"); @@ -304,7 +303,7 @@ public class XmlToNormalizedNodesTest { final NormalizedNodeResult result = new NormalizedNodeResult(); final NormalizedNodeStreamWriter streamWriter = ImmutableNormalizedNodeStreamWriter.from(result); - final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext); + final XmlParserStream xmlParser = XmlParserStream.create(streamWriter, schemaContext, schemaContext); try { xmlParser.parse(reader); fail("IllegalStateException should have been thrown because of an unexisting container element.");