Search in sources :

Example 1 with EchoRequestMessageBuilder

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));
}
Also used : EchoReplyInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput) EchoRequestMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Example 2 with EchoRequestMessageBuilder

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);
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) DisconnectEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder) ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) SwitchIdleEventBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Example 3 with EchoRequestMessageBuilder

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();
}
Also used : EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder)

Example 4 with EchoRequestMessageBuilder

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);
}
Also used : EchoRequestMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 5 with EchoRequestMessageBuilder

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();
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ExperimenterMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder) PacketInMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder) DataObject(org.opendaylight.yangtools.yang.binding.DataObject) PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) HelloMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) EchoRequestMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder) Test(org.junit.Test)

Aggregations

EchoRequestMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessageBuilder)6 Test (org.junit.Test)5 EchoRequestMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoRequestMessage)2 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)2 ExperimenterMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterMessageBuilder)2 FlowRemovedMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder)2 HelloMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessageBuilder)2 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)2 PacketInMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketInMessageBuilder)2 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)2 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)2 ByteBuf (io.netty.buffer.ByteBuf)1 EchoReplyInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.EchoReplyInput)1 DisconnectEventBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEventBuilder)1 SwitchIdleEventBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SwitchIdleEventBuilder)1