From: Eliezio Oliveira Date: Mon, 1 Jul 2019 16:53:52 +0000 (+0100) Subject: Fix testtool GetSchema broken since v1.6.0 X-Git-Tag: release/sodium~29 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=d6103349720e8adcf10378e6bfb727105a6444c7;p=netconf.git Fix testtool GetSchema broken since v1.6.0 Offending commit: af7babe Change-Id: Ia43cdcf10b54d9528921675fed321665771bd667 JIRA: NETCONF-624 Signed-off-by: Eliezio Oliveira --- diff --git a/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/monitoring/package-info.java b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/monitoring/package-info.java new file mode 100644 index 0000000000..e65ec07387 --- /dev/null +++ b/netconf/tools/netconf-testtool/src/main/java/org/opendaylight/netconf/test/tool/monitoring/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2013 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 + */ +@XmlSchema( + elementFormDefault = XmlNsForm.QUALIFIED, + xmlns = { + @XmlNs(namespaceURI = MonitoringConstants.EXTENSION_NAMESPACE, prefix = + MonitoringConstants.EXTENSION_NAMESPACE_PREFIX), + @XmlNs(namespaceURI = MonitoringConstants.NAMESPACE, prefix = "") + }, + namespace = MonitoringConstants.NAMESPACE +) +package org.opendaylight.netconf.test.tool.monitoring; + +import javax.xml.bind.annotation.XmlNs; +import javax.xml.bind.annotation.XmlNsForm; +import javax.xml.bind.annotation.XmlSchema; diff --git a/netconf/tools/netconf-testtool/src/test/java/org/opendaylight/netconf/test/tool/TestToolTest.java b/netconf/tools/netconf-testtool/src/test/java/org/opendaylight/netconf/test/tool/TestToolTest.java index c821ad6990..f72671c20e 100644 --- a/netconf/tools/netconf-testtool/src/test/java/org/opendaylight/netconf/test/tool/TestToolTest.java +++ b/netconf/tools/netconf-testtool/src/test/java/org/opendaylight/netconf/test/tool/TestToolTest.java @@ -11,12 +11,15 @@ package org.opendaylight.netconf.test.tool; import static org.junit.Assert.assertNotNull; import static org.xmlunit.assertj.XmlAssert.assertThat; +import com.google.common.collect.ImmutableMap; import io.netty.channel.nio.NioEventLoopGroup; import io.netty.util.HashedWheelTimer; import io.netty.util.concurrent.DefaultThreadFactory; import io.netty.util.concurrent.GlobalEventExecutor; import java.io.File; import java.net.InetSocketAddress; +import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; @@ -39,6 +42,7 @@ import org.opendaylight.netconf.nettyutil.NeverReconnectStrategy; import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler; import org.opendaylight.netconf.test.tool.config.Configuration; import org.opendaylight.netconf.test.tool.config.ConfigurationBuilder; +import org.opendaylight.netconf.test.tool.config.YangResource; import org.w3c.dom.Document; @SuppressWarnings("SameParameterValue") @@ -92,6 +96,10 @@ public class TestToolTest { + " 2014-07-29T13:42:12Z\n" + " \n" + ""; + private static final Map PREFIX_2_URI = ImmutableMap.of( + "base10", "urn:ietf:params:xml:ns:netconf:base:1.0", + "ncmon", "urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring" + ); @BeforeClass public static void setUpClass() { @@ -126,6 +134,27 @@ public class TestToolTest { .areIdentical(); } + @Test + public void shouldSupportGetSchema() + throws Exception { + String getSchema = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""; + Document docResponse = invokeRpc(TCP_SIMULATOR_CONFIG, getSchema); + Set expectedYangResources = Configuration.DEFAULT_YANG_RESOURCES; + assert expectedYangResources.size() > 0; + assertThat(docResponse) + .withNamespaceContext(PREFIX_2_URI) + .valueByXPath("count(//base10:rpc-reply/base10:data/ncmon:netconf-state/ncmon:schemas/ncmon:schema)") + .isEqualTo(expectedYangResources.size()); + } + private Document invokeRpc(Configuration simulatorConfig, String xmlRequest) throws Exception { // GIVEN