use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput in project openflowplugin by opendaylight.
the class EchoReplyMessageFactoryTest method testWithDataFieldSet.
/**
* Testing {@link EchoReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testWithDataFieldSet() {
byte[] data = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07 };
ByteBuf bb = BufferHelper.buildBuffer(data);
EchoOutput builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput in project openflowplugin by opendaylight.
the class SalEchoServiceImpl method transform.
private Future<RpcResult<SendEchoOutput>> transform(final ListenableFuture<RpcResult<EchoOutput>> rpcResultListenableFuture) {
return Futures.transform(rpcResultListenableFuture, input -> {
Preconditions.checkNotNull(input, "echoOutput value is never expected to be NULL");
final RpcResult<SendEchoOutput> rpcOutput;
if (input.isSuccessful()) {
final SendEchoOutput sendEchoOutput = new SendEchoOutputBuilder().setData(input.getResult().getData()).build();
rpcOutput = RpcResultBuilder.success(sendEchoOutput).build();
} else {
rpcOutput = RpcResultBuilder.<SendEchoOutput>failed().withRpcErrors(input.getErrors()).build();
}
return rpcOutput;
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput in project openflowplugin by opendaylight.
the class SystemNotificationsListenerImplTest method testOnSwitchIdleEvent2.
/**
* First encounter of idle event, echo not receive.
*/
@Test
public void testOnSwitchIdleEvent2() throws Exception {
final SettableFuture<RpcResult<EchoOutput>> echoReply = SettableFuture.create();
Mockito.when(connectionAdapter.echo(Matchers.any(EchoInput.class))).thenReturn(echoReply);
Mockito.when(connectionAdapter.isAlive()).thenReturn(true);
Mockito.when(connectionAdapter.disconnect()).thenReturn(Futures.<Boolean>immediateFailedFuture(new Exception("unit exception")));
SwitchIdleEvent notification = new SwitchIdleEventBuilder().setInfo("wake up, device sleeps").build();
systemNotificationsListener.onSwitchIdleEvent(notification);
Thread.sleep(SystemNotificationsListenerImpl.MAX_ECHO_REPLY_TIMEOUT + SAFE_TIMEOUT);
verifyCommonInvocations();
Mockito.verify(connectionAdapter, Mockito.timeout(SAFE_TIMEOUT)).echo(Matchers.any(EchoInput.class));
Mockito.verify(connectionAdapter).disconnect();
Mockito.verify(connectionContext).changeStateToTimeouting();
Mockito.verify(connectionContext).closeConnection(true);
Mockito.verify(connectionContext, Mockito.atLeastOnce()).getSafeNodeIdForLOG();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoOutput in project openflowplugin by opendaylight.
the class SystemNotificationsListenerImplTest method testOnSwitchIdleEvent1.
/**
* First encounter of idle event, echo received successfully.
*/
@Test
public void testOnSwitchIdleEvent1() throws Exception {
final Future<RpcResult<EchoOutput>> echoReply = Futures.immediateFuture(RpcResultBuilder.success(new EchoOutputBuilder().setXid(0L).build()).build());
Mockito.when(connectionAdapter.echo(Matchers.any(EchoInput.class))).thenReturn(echoReply);
SwitchIdleEvent notification = new SwitchIdleEventBuilder().setInfo("wake up, device sleeps").build();
systemNotificationsListener.onSwitchIdleEvent(notification);
// make sure that the idle notification processing thread started
Thread.sleep(SAFE_TIMEOUT);
verifyCommonInvocations();
Mockito.verify(connectionAdapter, Mockito.timeout(SAFE_TIMEOUT)).echo(Matchers.any(EchoInput.class));
Mockito.verify(connectionAdapter, Mockito.never()).disconnect();
Mockito.verify(connectionContext).changeStateToTimeouting();
Mockito.verify(connectionContext).changeStateToWorking();
}
Aggregations