use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerFullImplTest method testOnEchoRequestMessage.
/**
* Test method for
* {@link OpenflowProtocolListenerFullImpl#onEchoRequestMessage(
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage)}.
*/
@Test
public void testOnEchoRequestMessage() {
EchoRequestMessage echoRequestMessage = new EchoRequestMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build();
ofProtocolListener.onEchoRequestMessage(echoRequestMessage);
Mockito.verify(connectionAdapter).echoReply(Matchers.any(EchoReplyInput.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder in project openflowplugin by opendaylight.
the class ConnectionAdapterImplTest method testConsume.
/**
* Tests {@link ConnectionAdapterImpl#consume(DataObject)} with notifications.
*/
@Test
public void testConsume() {
DataObject message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
message = new ErrorMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onErrorMessage((ErrorMessage) message);
message = new ExperimenterMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onExperimenterMessage((ExperimenterMessage) message);
message = new FlowRemovedMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onFlowRemovedMessage((FlowRemovedMessage) message);
message = new HelloMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onHelloMessage((HelloMessage) message);
message = new MultipartReplyMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onMultipartReplyMessage((MultipartReplyMessage) message);
message = new PacketInMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPacketInMessage((PacketInMessage) message);
message = new PortStatusMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onPortStatusMessage((PortStatusMessage) message);
message = new SwitchIdleEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onSwitchIdleEvent((SwitchIdleEvent) message);
message = new DisconnectEventBuilder().build();
adapter.consume(message);
verify(systemListener, times(1)).onDisconnectEvent((DisconnectEvent) message);
message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
verify(messageListener, times(1)).onEchoRequestMessage((EchoRequestMessage) message);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder in project openflowplugin by opendaylight.
the class EchoRequestMessageFactory method deserialize.
@Override
public EchoRequestMessage deserialize(ByteBuf rawMessage) {
EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
builder.setVersion(getVersion());
builder.setXid(rawMessage.readUnsignedInt());
byte[] data = new byte[rawMessage.readableBytes()];
rawMessage.readBytes(data);
builder.setData(data);
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder in project openflowplugin by opendaylight.
the class EchoRequestMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
EchoRequestMessageBuilder builder = new EchoRequestMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
builder.setData(data);
EchoRequestMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 24);
byte[] readData = new byte[serializedBuffer.readableBytes()];
serializedBuffer.readBytes(readData);
Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder in project openflowplugin by opendaylight.
the class ConnectionAdapterImplStatisticsTest method testMessagePassCounter.
/**
* Test counter for pass messages to consumer (counter US_MESSAGE_PASS has to be enabled).
*/
@Test
public void testMessagePassCounter() {
if (!statCounters.isCounterEnabled(CounterEventTypes.US_MESSAGE_PASS)) {
Assert.fail("Counter " + CounterEventTypes.US_MESSAGE_PASS + " is not enabled");
}
when(channel.pipeline()).thenReturn(pipeline);
adapter = new ConnectionAdapterImpl(channel, InetSocketAddress.createUnresolved("10.0.0.1", 6653), true, CHANNEL_OUTBOUND_QUEUE_SIZE);
adapter.setMessageListener(messageListener);
adapter.setSystemListener(systemListener);
adapter.setConnectionReadyListener(readyListener);
cache = CacheBuilder.newBuilder().concurrencyLevel(1).expireAfterWrite(RPC_RESPONSE_EXPIRATION, TimeUnit.MINUTES).removalListener(REMOVAL_LISTENER).build();
adapter.setResponseCache(cache);
when(channel.disconnect()).thenReturn(channelFuture);
DataObject message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
message = new ErrorMessageBuilder().build();
adapter.consume(message);
message = new ExperimenterMessageBuilder().build();
adapter.consume(message);
message = new FlowRemovedMessageBuilder().build();
adapter.consume(message);
message = new HelloMessageBuilder().build();
adapter.consume(message);
message = new MultipartReplyMessageBuilder().build();
adapter.consume(message);
message = new PacketInMessageBuilder().build();
adapter.consume(message);
message = new PortStatusMessageBuilder().build();
adapter.consume(message);
message = new EchoRequestMessageBuilder().build();
adapter.consume(message);
Assert.assertEquals("Wrong - bad counter value for ConnectionAdapterImpl consume method", 9, statCounters.getCounter(CounterEventTypes.US_MESSAGE_PASS).getCounterValue());
adapter.disconnect();
}
Aggregations