import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueHandlerRegistration;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
+import org.opendaylight.openflowplugin.api.openflow.connection.DeviceConnectionStatusProvider;
import org.opendaylight.openflowplugin.api.openflow.connection.HandshakeContext;
import org.opendaylight.openflowplugin.api.openflow.connection.OutboundQueueProvider;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceDisconnectedHandler;
private DeviceDisconnectedHandler deviceDisconnectedHandler;
@Mock
private OutboundQueueProvider outboundQueueProvider;
+ @Mock
+ private DeviceConnectionStatusProvider deviceConnectionStatusProvider;
private ConnectionContextImpl connectionContext;
@Before
- public void setUp() throws Exception {
+ public void setUp() {
Mockito.when(connetionAdapter.getRemoteAddress())
.thenReturn(InetSocketAddress.createUnresolved("ofp-ut.example.org", 4242));
Mockito.when(connetionAdapter.isAlive()).thenReturn(true);
- connectionContext = new ConnectionContextImpl(connetionAdapter);
+ connectionContext = new ConnectionContextImpl(connetionAdapter, deviceConnectionStatusProvider);
connectionContext.setHandshakeContext(handshakeContext);
connectionContext.setNodeId(new NodeId("ut-node:123"));
connectionContext.setOutboundQueueHandleRegistration(outboundQueueRegistration);
}
@Test
- public void testCloseConnection1() throws Exception {
+ public void testCloseConnection1() {
connectionContext.closeConnection(true);
Mockito.verify(outboundQueueRegistration).close();
Mockito.verify(handshakeContext).close();
}
@Test
- public void testCloseConnection2() throws Exception {
+ public void testCloseConnection2() {
connectionContext.closeConnection(false);
Mockito.verify(outboundQueueRegistration).close();
Mockito.verify(handshakeContext).close();
}
@Test
- public void testOnConnectionClosed() throws Exception {
+ public void testOnConnectionClosed() {
connectionContext.onConnectionClosed();
Assert.assertEquals(ConnectionContext.CONNECTION_STATE.RIP, connectionContext.getConnectionState());
Mockito.verify(outboundQueueRegistration).close();
}
@Test
- public void testChangeStateToHandshaking() throws Exception {
+ public void testChangeStateToHandshaking() {
connectionContext.changeStateToHandshaking();
Assert.assertEquals(ConnectionContext.CONNECTION_STATE.HANDSHAKING, connectionContext.getConnectionState());
}
@Test
- public void testChangeStateToTimeouting() throws Exception {
+ public void testChangeStateToTimeouting() {
connectionContext.changeStateToTimeouting();
Assert.assertEquals(ConnectionContext.CONNECTION_STATE.TIMEOUTING, connectionContext.getConnectionState());
}
@Test
- public void testChangeStateToWorking() throws Exception {
+ public void testChangeStateToWorking() {
connectionContext.changeStateToWorking();
Assert.assertEquals(ConnectionContext.CONNECTION_STATE.WORKING, connectionContext.getConnectionState());
}