From: Maros Marsalek Date: Fri, 21 Feb 2014 10:48:44 +0000 (+0100) Subject: Integration test added to netconf-it to test identity (de)serialization. X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~388^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=945be3c7c8b24bc20c3d5bc60816600fd2aae41c;hp=2e92a15f60261432cde594d86f033802f7410e17 Integration test added to netconf-it to test identity (de)serialization. Change-Id: I637011107edea916aaab35e8d2298bbbbabed653 Signed-off-by: Maros Marsalek --- diff --git a/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModule.java b/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModule.java index b000f11e4e..398bba99bd 100644 --- a/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModule.java +++ b/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModule.java @@ -31,15 +31,16 @@ public final class IdentityTestModule extends org.opendaylight.controller.config @Override public java.lang.AutoCloseable createInstance() { - System.err.println(getAfi()); - System.err.println(getAfiIdentity()); + org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass()); + logger.info("Afi: {}", getAfi()); + logger.info("Afi class: {}", getAfiIdentity()); - getAfiIdentity(); for (Identities identities : getIdentities()) { - identities.resolveAfi(); - identities.resolveSafi(); + logger.info("Identities Afi class: {}", identities.resolveAfi()); + logger.info("Identities Safi class: {}", identities.resolveSafi()); + } - getIdentitiesContainer().resolveAfi(); + logger.info("IdentityContainer Afi class: {}", getIdentitiesContainer().resolveAfi()); return new AutoCloseable() { @Override diff --git a/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModuleStub.txt b/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModuleStub.txt index a81159ea24..7fa0c10eb2 100644 --- a/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModuleStub.txt +++ b/opendaylight/config/yang-test/src/main/java/org/opendaylight/controller/config/yang/test/impl/IdentityTestModuleStub.txt @@ -1,12 +1,13 @@ - System.err.println(getAfi()); - System.err.println(getAfiIdentity()); + org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(getClass()); + logger.info("Afi: {}", getAfi()); + logger.info("Afi class: {}", getAfiIdentity()); - getAfiIdentity(); for (Identities identities : getIdentities()) { - identities.resolveAfi(); - identities.resolveSafi(); + logger.info("Identities Afi class: {}", identities.resolveAfi()); + logger.info("Identities Safi class: {}", identities.resolveSafi()); + } - getIdentitiesContainer().resolveAfi(); + logger.info("IdentityContainer Afi class: {}", getIdentitiesContainer().resolveAfi()); return new AutoCloseable() { @Override diff --git a/opendaylight/md-sal/sal-binding-it/pom.xml b/opendaylight/md-sal/sal-binding-it/pom.xml index 9bc8a48214..213e4f47f7 100644 --- a/opendaylight/md-sal/sal-binding-it/pom.xml +++ b/opendaylight/md-sal/sal-binding-it/pom.xml @@ -132,32 +132,33 @@ + + + + org.opendaylight.yangtools.thirdparty xtend-lib-osgi 2.4.3 - test org.opendaylight.controller sal-binding-broker-impl - provided org.ops4j.pax.exam pax-exam-container-native - test + compile org.ops4j.pax.exam pax-exam-junit4 - test + compile org.opendaylight.controller config-netconf-connector - test org.opendaylight.controller @@ -207,12 +208,11 @@ org.ops4j.pax.exam pax-exam-link-mvn - test + compile equinoxSDK381 org.eclipse.osgi - test org.slf4j @@ -229,7 +229,6 @@ org.mockito mockito-all - test org.opendaylight.controller.model diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index 9b0c7ab08a..388e3f7e92 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -28,11 +28,6 @@ yang-store-api test - - ${project.groupId} - yang-test - test - ${project.groupId} netconf-api @@ -74,6 +69,12 @@ netconf-monitoring test + + ${project.groupId} + sal-binding-it + ${mdsal.version} + test + ${project.groupId} netconf-mapping-api @@ -96,6 +97,12 @@ test test-jar + + org.opendaylight.controller + yang-test + ${config.version} + test + ${project.groupId} yang-store-impl @@ -155,6 +162,19 @@ + + org.ops4j.pax.exam + maven-paxexam-plugin + 1.2.4 + + + generate-config + + generate-depends-file + + + + diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java new file mode 100644 index 0000000000..4e536c43bd --- /dev/null +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java @@ -0,0 +1,138 @@ +/* + * 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 + */ +package org.opendaylight.controller.netconf.it.pax; + +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.CoreOptions.systemProperty; + +import javax.inject.Inject; +import javax.xml.parsers.ParserConfigurationException; + +import com.google.common.base.Preconditions; +import io.netty.channel.nio.NioEventLoopGroup; +import org.junit.Assert; +import org.junit.Test; +import org.junit.matchers.JUnitMatchers; +import org.junit.runner.RunWith; +import org.opendaylight.controller.netconf.api.NetconfMessage; +import org.opendaylight.controller.netconf.client.NetconfClient; +import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; +import org.opendaylight.controller.netconf.util.xml.XmlUtil; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.options.DefaultCompositeOption; +import org.ops4j.pax.exam.util.Filter; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +import java.io.IOException; +import java.io.InputStream; +import java.net.InetSocketAddress; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; + +@RunWith(PaxExam.class) +public class IdentityRefNetconfTest { + + public static final int CLIENT_CONNECTION_TIMEOUT_MILLIS = 5000; + + // Wait for controller to start + @Inject + @Filter(timeout = 60 * 1000) + BindingAwareBroker broker; + + @Configuration + public Option[] config() { + return options( + systemProperty("osgi.console").value("2401"), + systemProperty("osgi.bundles.defaultStartLevel").value("4"), + systemProperty("pax.exam.osgi.unresolved.fail").value("true"), + + testingModules(), + loggingModules(), + mdSalCoreBundles(), + bindingAwareSalBundles(), configMinumumBundles(), baseModelBundles(), flowCapableModelBundles(), + junitAndMockitoBundles()); + } + + private Option loggingModules() { + return new DefaultCompositeOption( + mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), + mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), + mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), + mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject()); + } + + private Option testingModules() { + return new DefaultCompositeOption( + mavenBundle("org.opendaylight.controller", "yang-test").versionAsInProject()); + } + + private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 18383); + + @Test + public void testIdRef() throws Exception { + Preconditions.checkNotNull(broker, "Controller not initialized"); + + NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup(); + NetconfClientDispatcher clientDispatcher = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup, + CLIENT_CONNECTION_TIMEOUT_MILLIS); + + NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml"); + NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml"); + NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml"); + + try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) { + sendMessage(edit, netconfClient); + sendMessage(commit, netconfClient); + sendMessage(getConfig, netconfClient, "id-test", + "prefix:test-identity1", + "prefix:test-identity2", + "prefix:test-identity2", + "prefix:test-identity1"); + } + + clientDispatcher.close(); + } + + private void sendMessage(NetconfMessage edit, NetconfClient netconfClient, String... containingResponse) + throws ExecutionException, InterruptedException, TimeoutException { + NetconfMessage response = netconfClient.sendRequest(edit).get(); + if (containingResponse == null) { + Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString("")); + } else { + for (String resp : containingResponse) { + Assert.assertThat(XmlUtil.toString(response.getDocument()), JUnitMatchers.containsString(resp)); + } + } + } + + public static NetconfMessage xmlFileToNetconfMessage(final String fileName) throws IOException, SAXException, + ParserConfigurationException { + return new NetconfMessage(xmlFileToDocument(fileName)); + } + + public static Document xmlFileToDocument(final String fileName) throws IOException, SAXException, + ParserConfigurationException { + // TODO xml messages from netconf-util test-jar cannot be loaded here(in OSGi), since test jar is not a bundle + try (InputStream resourceAsStream = IdentityRefNetconfTest.class.getClassLoader().getResourceAsStream(fileName)) { + Preconditions.checkNotNull(resourceAsStream); + final Document doc = XmlUtil.readXmlToDocument(resourceAsStream); + return doc; + } + } +} diff --git a/opendaylight/netconf/netconf-it/src/test/resources/controller.xml b/opendaylight/netconf/netconf-it/src/test/resources/controller.xml new file mode 100644 index 0000000000..664a30daa5 --- /dev/null +++ b/opendaylight/netconf/netconf-it/src/test/resources/controller.xml @@ -0,0 +1,181 @@ + + + + + + urn:opendaylight:params:xml:ns:yang:controller:config:test:types?module=test-types&revision=2013-11-27 + urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05 + urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28 + urn:opendaylight:params:xml:ns:yang:controller:test:impl?module=config-test-impl&revision=2013-04-03 + urn:opendaylight:params:xml:ns:yang:controller:test?module=config-test&revision=2013-06-13 + + + + + + prefix:impl-identity-test + id-test + + prefix:test-identity2 + + + prefix:test-identity2 + prefix:test-identity1 + + + prefix:test-identity1 + prefix:test-identity2 + + prefix:test-identity1 + + + prefix:binding-broker-impl + binding-broker-impl + + prefix:binding-notification-service + ref_binding-notification-broker + + + prefix:binding-data-broker + ref_binding-data-broker + + + + prefix:runtime-generated-mapping + runtime-mapping-singleton + + + prefix:binding-notification-broker + binding-notification-broker + + + prefix:binding-data-broker + binding-data-broker + + prefix:dom-broker-osgi-registry + ref_dom-broker + + + prefix:binding-dom-mapping-service + ref_runtime-mapping-singleton + + + + prefix:logback + singleton + + DEBUG + console + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + DEBUG + ROOT + console + + + + prefix:schema-service-singleton + yang-schema-service + + + prefix:hash-map-data-store + hash-map-data-store + + + prefix:dom-broker-impl + dom-broker + + prefix:dom-data-store + ref_hash-map-data-store + + + + + + prefix:schema-service + + ref_yang-schema-service + /modules/module[type='schema-service-singleton'][name='yang-schema-service'] + + + + prefix:dom-data-store + + ref_hash-map-data-store + /modules/module[type='hash-map-data-store'][name='hash-map-data-store'] + + + + prefix:dom-broker-osgi-registry + + ref_dom-broker + /modules/module[type='dom-broker-impl'][name='dom-broker'] + + + + prefix:testing + + ref_id-test + /modules/module[type='impl-identity-test'][name='id-test'] + + + + prefix:binding-dom-mapping-service + + ref_runtime-mapping-singleton + /modules/module[type='runtime-generated-mapping'][name='runtime-mapping-singleton'] + + + + prefix:binding-data-consumer-broker + + ref_binding-data-broker + /modules/module[type='binding-data-broker'][name='binding-data-broker'] + + + + prefix:binding-rpc-registry + + ref_binding-broker-impl + /modules/module[type='binding-broker-impl'][name='binding-broker-impl'] + + + + prefix:binding-notification-service + + ref_binding-notification-broker + /modules/module[type='binding-notification-broker'][name='binding-notification-broker'] + + + + prefix:binding-broker-osgi-registry + + ref_binding-broker-impl + /modules/module[type='binding-broker-impl'][name='binding-broker-impl'] + + + + prefix:binding-notification-subscription-service + + ref_binding-notification-broker + /modules/module[type='binding-notification-broker'][name='binding-notification-broker'] + + + + prefix:binding-data-broker + + ref_binding-data-broker + /modules/module[type='binding-data-broker'][name='binding-data-broker'] + + + + + + + + diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml new file mode 100644 index 0000000000..ffdf132153 --- /dev/null +++ b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/commit.xml @@ -0,0 +1,3 @@ + + + diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/editConfig_identities.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/editConfig_identities.xml new file mode 100644 index 0000000000..cf9f3e5ccd --- /dev/null +++ b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/editConfig_identities.xml @@ -0,0 +1,37 @@ + + + + + + + set + + merge + + + + + test-impl:impl-identity-test + + id-test + + prefix:test-identity1 + prefix:test-identity2 + + + prefix:test-identity2 + prefix:test-identity1 + + + prefix:test-identity2 + + prefix:test-identity1 + + + + + + + + + diff --git a/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml new file mode 100644 index 0000000000..39efb4961b --- /dev/null +++ b/opendaylight/netconf/netconf-it/src/test/resources/netconfMessages/getConfig.xml @@ -0,0 +1,7 @@ + + + + + + +