X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fit%2Fpax%2FIdentityRefNetconfTest.java;h=981f1148e48520f300e6af00810054380285f31c;hp=96a9effcfc7cdfc4ccf9b28995b26a9eea5ef148;hb=89d7fe2df7cef882f71e1fcdb46d2a44811f0ad3;hpb=b23703bef6c3aaafe2dc83608a03b738ad42f945 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 index 96a9effcfc..981f1148e4 100644 --- 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 @@ -1,10 +1,10 @@ /* - * 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 - */ +* 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.junit.Assert.fail; @@ -19,14 +19,14 @@ import static org.ops4j.pax.exam.CoreOptions.options; import static org.ops4j.pax.exam.CoreOptions.streamBundle; import static org.ops4j.pax.exam.CoreOptions.systemPackages; import static org.ops4j.pax.exam.CoreOptions.systemProperty; -import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.util.HashedWheelTimer; +import io.netty.util.Timer; import java.io.IOException; import java.net.InetSocketAddress; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import javax.inject.Inject; import javax.xml.parsers.ParserConfigurationException; import org.junit.Assert; @@ -35,11 +35,15 @@ 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.NetconfClientDispatcher; +import org.opendaylight.controller.netconf.client.NetconfClientDispatcherImpl; +import org.opendaylight.controller.netconf.client.SimpleNetconfClientSessionListener; +import org.opendaylight.controller.netconf.client.conf.NetconfClientConfiguration; +import org.opendaylight.controller.netconf.client.conf.NetconfClientConfigurationBuilder; import org.opendaylight.controller.netconf.client.test.TestingNetconfClient; import org.opendaylight.controller.netconf.util.test.XmlFileLoader; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.protocol.framework.NeverReconnectStrategy; import org.ops4j.pax.exam.Configuration; import org.ops4j.pax.exam.Option; import org.ops4j.pax.exam.junit.PaxExam; @@ -52,6 +56,9 @@ import org.xml.sax.SAXException; import com.google.common.base.Preconditions; import com.google.common.base.Throwables; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.util.concurrent.GlobalEventExecutor; + @Ignore @RunWith(PaxExam.class) public class IdentityRefNetconfTest { @@ -59,7 +66,11 @@ public class IdentityRefNetconfTest { public static final int CLIENT_CONNECTION_TIMEOUT_MILLIS = 15000; // Wait for controller to start - @Inject + + // FIXME move this (pax) test to different module + // pax jars contain guava classes that clash with real guava dependencies in non-pax tests + // + //@Inject @Filter(timeout = 60 * 1000) BindingAwareBroker broker; @@ -101,8 +112,8 @@ public class IdentityRefNetconfTest { mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena").versionAsInProject(), - mavenBundle("org.opendaylight.controller.thirdparty", "nagasena-rta").versionAsInProject()); + mavenBundle("org.openexi", "nagasena").versionAsInProject(), + mavenBundle("org.openexi", "nagasena-rta").versionAsInProject()); } @@ -118,15 +129,15 @@ public class IdentityRefNetconfTest { 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 (TestingNetconfClient netconfClient = new TestingNetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) { + NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup(); + Timer timer = new HashedWheelTimer(); + NetconfClientDispatcherImpl clientDispatcher = new NetconfClientDispatcherImpl(nettyThreadgroup, nettyThreadgroup, timer); + try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", clientDispatcher, getClientConfiguration(tcpAddress))) { sendMessage(edit, netconfClient); sendMessage(commit, netconfClient); sendMessage(getConfig, netconfClient, "id-test", @@ -138,6 +149,9 @@ public class IdentityRefNetconfTest { clientDispatcher.close(); } catch (Exception e) { fail(Throwables.getStackTraceAsString(e)); + } finally { + nettyThreadgroup.shutdownGracefully().get(); + timer.stop(); } } @@ -157,4 +171,14 @@ public class IdentityRefNetconfTest { ParserConfigurationException { return XmlFileLoader.xmlFileToNetconfMessage(fileName); } + + public NetconfClientConfiguration getClientConfiguration(final InetSocketAddress tcpAddress) { + final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create(); + b.withAddress(tcpAddress); + b.withSessionListener(new SimpleNetconfClientSessionListener()); + b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, + CLIENT_CONNECTION_TIMEOUT_MILLIS)); + b.withConnectionTimeoutMillis(CLIENT_CONNECTION_TIMEOUT_MILLIS); + return b.build(); + } }