use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.
the class OpenflowProtocolListenerFullImplTest method testOnFlowRemovedMessage.
/**
* Test method for
* {@link OpenflowProtocolListenerFullImpl#onFlowRemovedMessage(
* org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage)}.
*/
@Test
public void testOnFlowRemovedMessage() {
FlowRemovedMessage flowRemovedMessage = new FlowRemovedMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setXid(xid).build();
ofProtocolListener.onFlowRemovedMessage(flowRemovedMessage);
Mockito.verify(deviceReplyProcessor).processFlowRemovedMessage(Matchers.any(FlowRemovedMessage.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage 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.FlowRemovedMessage in project openflowplugin by opendaylight.
the class OF10FlowRemovedMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public FlowRemovedMessage deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
OFDeserializer<MatchV10> matchDeserializer = registry.getDeserializer(new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, EncodeConstants.EMPTY_VALUE, MatchV10.class));
builder.setMatchV10(matchDeserializer.deserialize(rawMessage));
byte[] cookie = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(cookie);
builder.setCookie(new BigInteger(1, cookie));
builder.setPriority(rawMessage.readUnsignedShort());
builder.setReason(FlowRemovedReason.forValue(rawMessage.readUnsignedByte()));
rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE);
builder.setDurationSec(rawMessage.readUnsignedInt());
builder.setDurationNsec(rawMessage.readUnsignedInt());
builder.setIdleTimeout(rawMessage.readUnsignedShort());
rawMessage.skipBytes(PADDING_IN_FLOW_REMOVED_MESSAGE_2);
byte[] packetCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(packetCount);
builder.setPacketCount(new BigInteger(1, packetCount));
byte[] byteCount = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
rawMessage.readBytes(byteCount);
builder.setByteCount(new BigInteger(1, byteCount));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.
the class OF10FlowRemovedMessageFactoryTest method testSerialize.
@Test
public void testSerialize() throws Exception {
FlowRemovedMessageBuilder builder = new FlowRemovedMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
MatchV10Builder matchBuilder = new MatchV10Builder();
matchBuilder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true));
matchBuilder.setNwSrcMask((short) 0);
matchBuilder.setNwDstMask((short) 0);
matchBuilder.setInPort(58);
matchBuilder.setDlSrc(new MacAddress("01:01:01:01:01:01"));
matchBuilder.setDlDst(new MacAddress("ff:ff:ff:ff:ff:ff"));
matchBuilder.setDlVlan(18);
matchBuilder.setDlVlanPcp((short) 5);
matchBuilder.setDlType(42);
matchBuilder.setNwTos((short) 4);
matchBuilder.setNwProto((short) 7);
matchBuilder.setNwSrc(new Ipv4Address("8.8.8.8"));
matchBuilder.setNwDst(new Ipv4Address("16.16.16.16"));
matchBuilder.setTpSrc(6653);
matchBuilder.setTpDst(6633);
builder.setMatchV10(matchBuilder.build());
byte[] cookie = new byte[] { (byte) 0xFF, 0x01, 0x04, 0x01, 0x01, 0x01, 0x04, 0x01 };
builder.setCookie(new BigInteger(1, cookie));
builder.setPriority(1);
builder.setReason(FlowRemovedReason.forValue(1));
builder.setDurationSec(1L);
builder.setDurationNsec(1L);
builder.setIdleTimeout(12);
builder.setPacketCount(BigInteger.valueOf(1L));
builder.setByteCount(BigInteger.valueOf(2L));
FlowRemovedMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 88);
Assert.assertEquals("Wrong wildcards", 3678463, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong inPort", 58, serializedBuffer.readUnsignedShort());
byte[] dlSrc = new byte[6];
serializedBuffer.readBytes(dlSrc);
Assert.assertEquals("Wrong dlSrc", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc));
byte[] dlDst = new byte[6];
serializedBuffer.readBytes(dlDst);
Assert.assertEquals("Wrong dlDst", "FF:FF:FF:FF:FF:FF", ByteBufUtils.macAddressToString(dlDst));
Assert.assertEquals("Wrong dlVlan", 18, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong dlVlanPcp", 5, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(1);
Assert.assertEquals("Wrong dlType", 42, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong nwTos", 4, serializedBuffer.readUnsignedByte());
Assert.assertEquals("Wrong nwProto", 7, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(2);
Assert.assertEquals("Wrong nwSrc", 134744072, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong nwDst", 269488144, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong tpSrc", 6653, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong tpDst", 6633, serializedBuffer.readUnsignedShort());
byte[] cookieRead = new byte[8];
serializedBuffer.readBytes(cookieRead);
Assert.assertArrayEquals("Wrong cookie", cookie, cookieRead);
Assert.assertEquals("Wrong priority", 1, serializedBuffer.readUnsignedShort());
Assert.assertEquals("Wrong reason", 1, serializedBuffer.readUnsignedByte());
serializedBuffer.skipBytes(1);
Assert.assertEquals("Wrong duration", 1L, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong duration nsec", 1L, serializedBuffer.readUnsignedInt());
Assert.assertEquals("Wrong idle timeout", 12, serializedBuffer.readUnsignedShort());
serializedBuffer.skipBytes(2);
Assert.assertEquals("Wrong packet count", 1L, serializedBuffer.readLong());
Assert.assertEquals("Wrong byte count", 2L, serializedBuffer.readLong());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessage in project openflowplugin by opendaylight.
the class FlowRemovedTranslatorTest method testTranslate.
@Test
public void testTranslate() throws Exception {
org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemoved flowRemovedMessage = buildMessage(false);
final FlowRemoved flowRemoved = translator.translate(flowRemovedMessage, deviceInfo, null);
assertEquals(flowRemovedMessage.getCookie(), flowRemoved.getCookie().getValue());
assertEquals(flowRemovedMessage.getPriority(), flowRemoved.getPriority());
assertEquals((long) flowRemovedMessage.getTableId().getValue(), (long) flowRemoved.getTableId());
}
Aggregations