X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Fcnsn%2Fto%2Fxml%2Ftest%2FCnSnToXmlWithDataFromSeveralModulesTest.java;h=fd76788b95e5d42adb5e42928ac4cd2a4ad79113;hb=59e32540ae454d8428c25ba9594c5e18f16c81d7;hp=57a149516f077a59fdd531e7857715535579c3e6;hpb=765f74bd08b61de6896411eb1a9d8377a981ec82;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java index 57a149516f..fd76788b95 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/cnsn/to/xml/test/CnSnToXmlWithDataFromSeveralModulesTest.java @@ -1,107 +1,20 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * 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.controller.sal.restconf.impl.cnsn.to.xml.test; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.ws.rs.WebApplicationException; - import org.junit.BeforeClass; -import org.junit.Test; -import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider; -import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper; -import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper; -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.CompositeNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class CnSnToXmlWithDataFromSeveralModulesTest extends YangAndXmlAndDataSchemaLoader { @BeforeClass public static void initialize() { - dataLoad("/xml-to-cnsn/data-of-several-modules/yang",2,"module1","cont_m1"); - } - - @Test - public void dataFromSeveralModulesToXmlTest() throws WebApplicationException, IOException, URISyntaxException { - SchemaContext schemaContext = TestUtils.loadSchemaContext(modules); - String output = TestUtils.writeCompNodeWithSchemaContextToOutput(prepareCnSn(), modules, schemaContext, - StructuredDataToXmlProvider.INSTANCE); - -// String output = -// String.format("" + -// "\n" + -// "\n\t" + -// "\n\t\tlf1 m1 value" + -// "\n\t" + -// "\n" + -// "\n" + -// "\n\t" + -// "\n\t\tlf1 m2 value" + -// "\n\t" + -// "\n" + -// "\n"); - - StringBuilder regex = new StringBuilder(); - regex.append("^"); - - regex.append(".*"); - - - regex.append(".*"); - regex.append(".*xmlns=\"module:one\""); - regex.append(".*>"); - regex.append(".*"); - regex.append(".*<\\/lf1_m1>"); - regex.append(".*<\\/cont_m1>"); - - regex.append(".*"); - regex.append(".*"); - regex.append(".*"); - regex.append(".*<\\/lf1_m2>"); - regex.append(".*<\\/cont_m2>"); - - regex.append(".*<\\/data.*>"); - - regex.append(".*"); - regex.append("$"); - - Pattern ptrn = Pattern.compile(regex.toString(), Pattern.DOTALL); - Matcher matcher = ptrn.matcher(output); - - assertTrue(matcher.find()); - - } - - private CompositeNode prepareCnSn() throws URISyntaxException { - CompositeNodeWrapper data = new CompositeNodeWrapper(new URI("urn:ietf:params:xml:ns:netconf:base:1.0"), "data"); - - URI uriModule1 = new URI("module:one"); - CompositeNodeWrapper cont_m1 = new CompositeNodeWrapper(uriModule1, "cont_m1"); - SimpleNodeWrapper lf1_m1 = new SimpleNodeWrapper(uriModule1, "lf1_m1", "lf1 m1 value"); - cont_m1.addValue(lf1_m1); - CompositeNodeWrapper contB_m1 = new CompositeNodeWrapper(uriModule1, "contB_m1"); - - data.addValue(contB_m1); - data.addValue(cont_m1); - - URI uriModule2 = new URI("module:two"); - CompositeNodeWrapper cont_m2 = new CompositeNodeWrapper(uriModule2, "cont_m2"); - SimpleNodeWrapper lf1_m2 = new SimpleNodeWrapper(uriModule2, "lf1_m2", "lf1 m2 value"); - cont_m2.addValue(lf1_m2); - CompositeNodeWrapper contB_m2 = new CompositeNodeWrapper(uriModule2, "contB_m2"); - data.addValue(contB_m2); - data.addValue(cont_m2); - return data; + dataLoad("/xml-to-cnsn/data-of-several-modules/yang", 2, "module1", "cont_m1"); } }