X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Fxml%2Fto%2Fcnsn%2Ftest%2FXmlToCnSnTest.java;h=e2621d635bc3dab04629beffcb15c3d111b9eb21;hp=f1a18d56a8de60241b64436aa299f2f3c3915de5;hb=c46e223995956f1f759c551163c212947c1e2fb7;hpb=94d0d20b41d64bb6696c2a573ec367fcfddc44e9 diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java index f1a18d56a8..e2621d635b 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/xml/to/cnsn/test/XmlToCnSnTest.java @@ -7,14 +7,21 @@ */ package org.opendaylight.controller.sal.restconf.impl.xml.to.cnsn.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import java.io.ByteArrayInputStream; +import java.io.InputStream; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider; import org.opendaylight.controller.sal.restconf.impl.test.TestUtils; import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader; -import org.opendaylight.yangtools.yang.data.api.*; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.api.SimpleNode; public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader { @@ -34,7 +41,7 @@ public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader { assertEquals("cont", compositeNode.getNodeType().getLocalName()); SimpleNode lf2 = null; - for (Node childNode : compositeNode.getChildren()) { + for (Node childNode : compositeNode.getValue()) { if (childNode instanceof SimpleNode) { if (childNode.getNodeType().getLocalName().equals("lf2")) { lf2 = (SimpleNode) childNode; @@ -45,7 +52,30 @@ public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader { assertNotNull(lf2); assertTrue(lf2.getValue() instanceof String); - assertEquals("121", (String) lf2.getValue()); + assertEquals("121", lf2.getValue()); + } + + @Test + public void testXmlBlankInput() throws Exception { + InputStream inputStream = new ByteArrayInputStream("".getBytes()); + CompositeNode compositeNode = XmlToCompositeNodeProvider.INSTANCE.readFrom(null, null, null, null, null, + inputStream); + + assertNull(compositeNode); + } + + @Test + public void testXmlBlankInputUnmarkableStream() throws Exception { + InputStream inputStream = new ByteArrayInputStream("".getBytes()) { + @Override + public boolean markSupported() { + return false; + } + }; + CompositeNode compositeNode = XmlToCompositeNodeProvider.INSTANCE.readFrom(null, null, null, null, null, + inputStream); + + assertNull(compositeNode); } }