X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-data-codec-gson%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fdata%2Fcodec%2Fgson%2FAnyXmlSupportTest.java;h=7dfd241d47745c3c1cd9e15d16158eaa1417f951;hb=4a8280dbad8a080d4b5253e25fc68ec279a3d99d;hp=75f562234671ece061216304ddfb25739b6bb83b;hpb=968b41a1c1f7f9f435248015926cdaa063b277f5;p=yangtools.git diff --git a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AnyXmlSupportTest.java b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AnyXmlSupportTest.java index 75f5622346..7dfd241d47 100644 --- a/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AnyXmlSupportTest.java +++ b/yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/AnyXmlSupportTest.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.yangtools.yang.data.codec.gson; import static org.junit.Assert.assertEquals; @@ -119,7 +118,6 @@ public class AnyXmlSupportTest { final DOMSource Lf12AnyActualValue = getParsedAnyXmlValue(transformedInput, LF12_ANY); final DOMSource Lf12AnyExpectedValue = createLf12AnyXmlCompositeValue("ns:complex:json", "lf12-any"); verifyTransformedAnyXmlNodeValue(Lf12AnyExpectedValue, Lf12AnyActualValue); - // lf13-any check final DOMSource Lf13AnyActualValue = getParsedAnyXmlValue(transformedInput, LF13_ANY); final DOMSource Lf13AnyExpectedValue = createLf13AnyXmlCompositeValue("ns:complex:json", "lf13-any"); @@ -135,15 +133,37 @@ public class AnyXmlSupportTest { SchemaPath.ROOT); final JsonParser parser = new JsonParser(); - final JsonElement expected = parser.parse(inputJson); + final String expectedJson = loadTextFile("/bug8927/json/composite.json"); + final JsonElement expected = parser.parse(expectedJson); final JsonElement actual = parser.parse(serializationResult); assertTrue(expected.equals(actual)); } @Test - public void bug8927Test() throws Exception { + public void bug8927TestComplexArrayWithOthers() throws Exception { + executebug8927Test("/bug8927/xml/complex_array_with_other_elements.xml", + "/bug8927/json/complex_array_with_other_elements.json"); + } + + @Test + public void bug8927TestComplexArray() throws Exception { + executebug8927Test("/bug8927/xml/complex_array.xml", "/bug8927/json/complex_array.json"); + } + + @Test + public void bug8927TestScalarArrayWithOthers() throws Exception { + executebug8927Test("/bug8927/xml/scalar_array_with_other_elements.xml", + "/bug8927/json/scalar_array_with_other_elements.json"); + } + + @Test + public void bug8927TestScalarArray() throws Exception { + executebug8927Test("/bug8927/xml/scalar_array.xml", "/bug8927/json/scalar_array.json"); + } + + private void executebug8927Test(final String inputXmlFile, final String expectedJsonFile) throws Exception { final InputStream resourceAsStream = YangModeledAnyXmlSupportTest.class - .getResourceAsStream("/bug8927/xml/input.xml"); + .getResourceAsStream(inputXmlFile); final NormalizedNodeResult result = new NormalizedNodeResult(); loadXmlToNormalizedNodes(resourceAsStream, result, schemaContext); @@ -154,12 +174,10 @@ public class AnyXmlSupportTest { .getChild(new NodeIdentifier(QName.create("bug8927.test", "2017-01-01", "foo"))); assertTrue(data.isPresent()); final String jsonOutput = normalizedNodesToJsonString(data.get(), schemaContext, SchemaPath.ROOT); - final JsonParser parser = new JsonParser(); final JsonElement expextedJson = parser - .parse(new FileReader(new File(getClass().getResource("/bug8927/json/expected.json").toURI()))); + .parse(new FileReader(new File(getClass().getResource(expectedJsonFile).toURI()))); final JsonElement serializedJson = parser.parse(jsonOutput); - assertEquals(expextedJson, serializedJson); }