use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder in project openflowplugin by opendaylight.
the class ErrorMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
ErrorMessageBuilder builder = new ErrorMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(10);
builder.setCode(20);
byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
builder.setData(data);
ErrorMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 28);
Assert.assertEquals("Wrong Type", message.getType().intValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong Code", message.getCode().intValue(), serializedBuffer.readShort());
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.ErrorMessageBuilder in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerFullImplTest method testOnErrorMessage.
/**
* Test method for
* {@link OpenflowProtocolListenerFullImpl#onErrorMessage(
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage)}.
*/
@Test
public void testOnErrorMessage() {
ErrorMessage errorMessage = new ErrorMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build();
ofProtocolListener.onErrorMessage(errorMessage);
Mockito.verify(deviceReplyProcessor).processReply(Matchers.any(ErrorMessage.class));
}
Aggregations