use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage 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.EchoRequestMessage in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerInitialImpl method onEchoRequestMessage.
@Override
public void onEchoRequestMessage(final EchoRequestMessage echoRequestMessage) {
if (LOG.isDebugEnabled()) {
LOG.debug("echo request received: {}", echoRequestMessage.getXid());
}
EchoReplyInputBuilder builder = new EchoReplyInputBuilder();
builder.setVersion(echoRequestMessage.getVersion());
builder.setXid(echoRequestMessage.getXid());
builder.setData(echoRequestMessage.getData());
connectionContext.getConnectionAdapter().echoReply(builder.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.
the class EchoRequestMessageFactoryTest method testWithDataFieldSet.
/**
* Testing {@link EchoRequestMessageFactory} 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);
EchoRequestMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.
the class EchoRequestMessageFactoryTest method testWithEmptyDataField.
/**
* Testing {@link EchoRequestMessageFactory} for correct translation into POJO.
*/
@Test
public void testWithEmptyDataField() {
byte[] data = new byte[] {};
ByteBuf bb = BufferHelper.buildBuffer();
EchoRequestMessage builtByFactory = BufferHelper.deserialize(factory, bb);
Assert.assertArrayEquals("Wrong data", data, builtByFactory.getData());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage in project openflowplugin by opendaylight.
the class MockPlugin method onEchoRequestMessage.
@Override
public void onEchoRequestMessage(final EchoRequestMessage notification) {
LOGGER.debug("MockPlugin.onEchoRequestMessage() adapter: {}", adapter);
new Thread(() -> {
LOGGER.debug("MockPlugin.onEchoRequestMessage().run() started adapter: {}", adapter);
EchoReplyInputBuilder replyBuilder = new EchoReplyInputBuilder();
replyBuilder.setVersion((short) 4);
replyBuilder.setXid(notification.getXid());
EchoReplyInput echoReplyInput = replyBuilder.build();
adapter.echoReply(echoReplyInput);
LOGGER.debug("adapter.EchoReply(Input) sent : ", echoReplyInput.toString());
LOGGER.debug("MockPlugin.onEchoRequestMessage().run() finished adapter: {}", adapter);
}).start();
}
Aggregations