X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fconnection%2FConnectionManagerImplTest.java;h=9a4338ea621c0d1b01336bbe72697f051c2f0531;hb=8d0b3819bc847095e0fc971673c819a717a12305;hp=24bfad6ee099c5213cbc544ea9b9d724994b5994;hpb=afbc7ccdee58d159bf915a1abb94678ff2aca352;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java index 24bfad6ee0..9a4338ea62 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/connection/ConnectionManagerImplTest.java @@ -9,7 +9,11 @@ package org.opendaylight.openflowplugin.impl.connection; import com.google.common.util.concurrent.SettableFuture; import java.math.BigInteger; +import java.net.InetAddress; import java.net.InetSocketAddress; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.TimeUnit; + import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -25,6 +29,9 @@ import org.opendaylight.openflowjava.protocol.api.connection.ConnectionReadyList import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceConnectedHandler; +import org.opendaylight.openflowplugin.openflow.md.core.ThreadPoolLoggingExecutor; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder; @@ -53,16 +60,24 @@ public class ConnectionManagerImplTest { @Captor private ArgumentCaptor ofpListenerAC; + private final static int ECHO_REPLY_TIMEOUT = 500; + /** * before each test method */ @Before public void setUp() { - connectionManagerImpl = new ConnectionManagerImpl(); + final ThreadPoolLoggingExecutor threadPool = new ThreadPoolLoggingExecutor(0, Integer.MAX_VALUE, + 60L, TimeUnit.SECONDS, + new SynchronousQueue<>(), "ofppool"); + + connectionManagerImpl = new ConnectionManagerImpl(ECHO_REPLY_TIMEOUT, threadPool); connectionManagerImpl.setDeviceConnectedHandler(deviceConnectedHandler); final InetSocketAddress deviceAddress = InetSocketAddress.createUnresolved("yahoo", 42); Mockito.when(connection.getRemoteAddress()).thenReturn(deviceAddress); Mockito.when(connection.isAlive()).thenReturn(true); + Mockito.when(connection.barrier(Matchers.any())) + .thenReturn(RpcResultBuilder.success(new BarrierOutputBuilder().build()).buildFuture()); } /** @@ -86,7 +101,7 @@ public class ConnectionManagerImplTest { * @throws InterruptedException */ @Test - public void testOnSwitchConnected1() throws InterruptedException { + public void testOnSwitchConnected1() throws Exception { connectionManagerImpl.onSwitchConnected(connection); Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture()); Mockito.verify(connection).setMessageListener(ofpListenerAC.capture()); @@ -137,7 +152,7 @@ public class ConnectionManagerImplTest { * @throws InterruptedException */ @Test - public void testOnSwitchConnected2() throws InterruptedException { + public void testOnSwitchConnected2() throws Exception { connectionManagerImpl.onSwitchConnected(connection); Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture()); Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());