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=d0af29e913fa633381c176ff1796a2fbd3f41c29;hp=5008d28bbfb26ea0e8d9ef8ab2b1814e8736671d;hb=bdcd6c4baea3357499a1fcdff459259b56373baa;hpb=aefe82b158bc1694fe633053d04f2364bcbe67d9 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 5008d28bbf..d0af29e913 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 @@ -9,8 +9,11 @@ package org.opendaylight.controller.sal.restconf.impl.xml.to.cnsn.test; 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; @@ -29,9 +32,12 @@ public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader { @Test public void testXmlLeafrefToCnSn() { - CompositeNode compositeNode = TestUtils.readInputToCnSn("/xml-to-cnsn/leafref/xml/data.xml", false, + Node node = TestUtils.readInputToCnSn("/xml-to-cnsn/leafref/xml/data.xml", false, XmlToCompositeNodeProvider.INSTANCE); - assertNotNull(compositeNode); + assertTrue(node instanceof CompositeNode); + CompositeNode compositeNode = (CompositeNode)node; + + assertNotNull(dataSchemaNode); TestUtils.normalizeCompositeNode(compositeNode, modules, schemaNodePath); @@ -52,4 +58,27 @@ public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader { assertEquals("121", lf2.getValue()); } + @Test + public void testXmlBlankInput() throws Exception { + InputStream inputStream = new ByteArrayInputStream("".getBytes()); + Node node = + XmlToCompositeNodeProvider.INSTANCE.readFrom(null, null, null, null, null, inputStream); + + assertNull( node ); + } + + @Test + public void testXmlBlankInputUnmarkableStream() throws Exception { + InputStream inputStream = new ByteArrayInputStream("".getBytes()) { + @Override + public boolean markSupported() { + return false; + } + }; + Node node = + XmlToCompositeNodeProvider.INSTANCE.readFrom(null, null, null, null, null, inputStream); + + assertNull( node ); + } + }