X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fit%2FNetconfITSecureTest.java;h=91b543b4de90b2410501e91ddcf8d160d986149b;hb=237237663265bfda9069c66151371ce7697aed59;hp=9a4bc2aa5dee09092f7cf04412383d4f62d00dc1;hpb=d105455084f43d9423b7c0e6af785302e6a3ea93;p=controller.git diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java index 9a4bc2aa5d..91b543b4de 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java @@ -8,9 +8,24 @@ package org.opendaylight.controller.netconf.it; -import com.google.common.base.Optional; import io.netty.channel.ChannelFuture; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; import io.netty.util.HashedWheelTimer; +import java.io.IOException; +import java.io.InputStream; +import java.lang.management.ManagementFactory; +import java.net.InetSocketAddress; +import java.security.KeyManagementException; +import java.security.KeyStoreException; +import java.security.NoSuchAlgorithmException; +import java.security.UnrecoverableKeyException; +import java.security.cert.CertificateException; +import java.util.Collection; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.net.ssl.KeyManagerFactory; +import javax.net.ssl.SSLContext; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -30,27 +45,14 @@ import org.opendaylight.controller.netconf.impl.SessionIdProvider; import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceFactoryListenerImpl; import org.opendaylight.protocol.util.SSLUtil; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import java.io.IOException; -import java.io.InputStream; -import java.lang.management.ManagementFactory; -import java.net.InetSocketAddress; -import java.security.KeyManagementException; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.UnrecoverableKeyException; -import java.security.cert.CertificateException; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.TimeUnit; - public class NetconfITSecureTest extends AbstractConfigTest { private static final InetSocketAddress tlsAddress = new InetSocketAddress("127.0.0.1", 12024); private DefaultCommitNotificationProducer commitNot; private NetconfServerDispatcher dispatchS; + private EventLoopGroup nettyThreadgroup; + @Before public void setUp() throws Exception { @@ -62,27 +64,30 @@ public class NetconfITSecureTest extends AbstractConfigTest { commitNot = new DefaultCommitNotificationProducer(ManagementFactory.getPlatformMBeanServer()); - dispatchS = createDispatcher(Optional.of(getSslContext()), factoriesListener); + nettyThreadgroup = new NioEventLoopGroup(); + + dispatchS = createDispatcher(factoriesListener); ChannelFuture s = dispatchS.createServer(tlsAddress); s.await(); } - private NetconfServerDispatcher createDispatcher(Optional sslC, - NetconfOperationServiceFactoryListenerImpl factoriesListener) { + private NetconfServerDispatcher createDispatcher(NetconfOperationServiceFactoryListenerImpl factoriesListener) { SessionIdProvider idProvider = new SessionIdProvider(); NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new NetconfServerSessionNegotiatorFactory( new HashedWheelTimer(5000, TimeUnit.MILLISECONDS), factoriesListener, idProvider); NetconfServerSessionListenerFactory listenerFactory = new NetconfServerSessionListenerFactory( - factoriesListener, commitNot, idProvider); + factoriesListener, commitNot, idProvider, NetconfITTest.getNetconfMonitoringListenerService()); - return new NetconfServerDispatcher(sslC, serverNegotiatorFactory, listenerFactory); + NetconfServerDispatcher.ServerChannelInitializer serverChannelInitializer = new NetconfServerDispatcher.ServerChannelInitializer( + serverNegotiatorFactory, listenerFactory); + return new NetconfServerDispatcher(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup); } @After public void tearDown() throws Exception { commitNot.close(); - dispatchS.close(); + nettyThreadgroup.shutdownGracefully(); } private SSLContext getSslContext() throws KeyStoreException, NoSuchAlgorithmException, CertificateException, @@ -106,8 +111,8 @@ public class NetconfITSecureTest extends AbstractConfigTest { @Test public void testSecure() throws Exception { - try (NetconfClientDispatcher dispatch = new NetconfClientDispatcher(Optional.of(getSslContext())); - NetconfClient netconfClient = new NetconfClient("tls-client", tlsAddress, 4000, dispatch)) { + NetconfClientDispatcher dispatch = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup); + try (NetconfClient netconfClient = new NetconfClient("tls-client", tlsAddress, 4000, dispatch)) { } }