use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder in project openflowplugin by opendaylight.
the class ActionConvertorV13Test method testToMDSalActions2.
/**
* Test {@link ActionConvertor#convert(List, ActionConvertorData)}}.
*/
// @Test
public void testToMDSalActions2() {
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(52);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
List<Action> actions = new ArrayList<>();
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlOutCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new CopyTtlInCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetMplsTtlCaseBuilder setMplsTtlCaseBuilder = new SetMplsTtlCaseBuilder();
SetMplsTtlActionBuilder setMplsTtlBuilder = new SetMplsTtlActionBuilder();
setMplsTtlBuilder.setMplsTtl((short) 4);
setMplsTtlCaseBuilder.setSetMplsTtlAction(setMplsTtlBuilder.build());
actionBuilder.setActionChoice(setMplsTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecMplsTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushVlanCaseBuilder pushVlanCaseBuilder = new PushVlanCaseBuilder();
PushVlanActionBuilder pushVlanBuilder = new PushVlanActionBuilder();
pushVlanBuilder.setEthertype(new EtherType(new EtherType(16)));
pushVlanCaseBuilder.setPushVlanAction(pushVlanBuilder.build());
actionBuilder.setActionChoice(pushVlanCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopVlanCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushMplsCaseBuilder pushMplsCaseBuilder = new PushMplsCaseBuilder();
PushMplsActionBuilder pushMplsBuilder = new PushMplsActionBuilder();
pushMplsBuilder.setEthertype(new EtherType(new EtherType(17)));
pushMplsCaseBuilder.setPushMplsAction(pushMplsBuilder.build());
actionBuilder.setActionChoice(pushMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
popMplsBuilder.setEthertype(new EtherType(new EtherType(18)));
popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
actionBuilder.setActionChoice(popMplsCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetQueueCaseBuilder setQueueCaseBuilder = new SetQueueCaseBuilder();
SetQueueActionBuilder setQueueBuilder = new SetQueueActionBuilder();
setQueueBuilder.setQueueId(1234L);
setQueueCaseBuilder.setSetQueueAction(setQueueBuilder.build());
actionBuilder.setActionChoice(setQueueCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
GroupCaseBuilder groupCaseBuilder = new GroupCaseBuilder();
GroupActionBuilder groupActionBuilder = new GroupActionBuilder();
groupActionBuilder.setGroupId(555L);
groupCaseBuilder.setGroupAction(groupActionBuilder.build());
actionBuilder.setActionChoice(groupCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTtlCaseBuilder nwTtlCaseBuilder = new SetNwTtlCaseBuilder();
SetNwTtlActionBuilder nwTtlBuilder = new SetNwTtlActionBuilder();
nwTtlBuilder.setNwTtl((short) 8);
nwTtlCaseBuilder.setSetNwTtlAction(nwTtlBuilder.build());
actionBuilder.setActionChoice(nwTtlCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new DecNwTtlCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
MatchEntryBuilder matchBuilder = new MatchEntryBuilder();
matchBuilder.setOxmClass(OpenflowBasicClass.class);
matchBuilder.setOxmMatchField(InPort.class);
matchBuilder.setHasMask(false);
InPortCaseBuilder inPortCaseBuilder = new InPortCaseBuilder();
InPortBuilder inPortBuilder = new InPortBuilder();
inPortBuilder.setPortNumber(new PortNumber(1L));
inPortCaseBuilder.setInPort(inPortBuilder.build());
matchBuilder.setMatchEntryValue(inPortCaseBuilder.build());
List<MatchEntry> entries = new ArrayList<>();
entries.add(matchBuilder.build());
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
setFieldBuilder.setMatchEntry(entries);
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
actionBuilder.setActionChoice(setFieldCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
PushPbbCaseBuilder pushPbbCaseBuilder = new PushPbbCaseBuilder();
PushPbbActionBuilder pushPbbBuilder = new PushPbbActionBuilder();
pushPbbBuilder.setEthertype(new EtherType(new EtherType(19)));
pushPbbCaseBuilder.setPushPbbAction(pushPbbBuilder.build());
actionBuilder.setActionChoice(pushPbbCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new PopPbbCaseBuilder().build());
actions.add(actionBuilder.build());
// Add some unsupported actions and check if they are missing from results
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new SetNwDstCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
actions.add(actionBuilder.build());
ActionResponseConvertorData data = new ActionResponseConvertorData(OFConstants.OFP_VERSION_1_3);
data.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> mdSalActionsOptional = convertorManager.convert(actions, data);
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> mdSalActions = mdSalActionsOptional.orElse(Collections.emptyList());
Assert.assertEquals("Wrong number of output actions", 16, mdSalActions.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action action = mdSalActions.get(0);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.OutputActionCase", action.getImplementedInterface().getName());
OutputActionCase output = (OutputActionCase) action;
Assert.assertEquals("Wrong output port", "42", output.getOutputAction().getOutputNodeConnector().getValue());
Assert.assertEquals("Wrong max length", 52, output.getOutputAction().getMaxLength().intValue());
action = mdSalActions.get(1);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.CopyTtlOutCase", action.getImplementedInterface().getName());
action = mdSalActions.get(2);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.CopyTtlInCase", action.getImplementedInterface().getName());
action = mdSalActions.get(3);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetMplsTtlActionCase", action.getImplementedInterface().getName());
SetMplsTtlActionCase setMplsTtl = (SetMplsTtlActionCase) action;
Assert.assertEquals("Wrong mpls ttl", 4, setMplsTtl.getSetMplsTtlAction().getMplsTtl().intValue());
action = mdSalActions.get(4);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.DecMplsTtlCase", action.getImplementedInterface().getName());
action = mdSalActions.get(5);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushVlanActionCase", action.getImplementedInterface().getName());
PushVlanActionCase pushVlan = (PushVlanActionCase) action;
Assert.assertEquals("Wrong ethertype", 16, pushVlan.getPushVlanAction().getEthernetType().intValue());
action = mdSalActions.get(6);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopVlanActionCase", action.getImplementedInterface().getName());
action = mdSalActions.get(7);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushMplsActionCase", action.getImplementedInterface().getName());
PushMplsActionCase pushMpls = (PushMplsActionCase) action;
Assert.assertEquals("Wrong ethertype", 17, pushMpls.getPushMplsAction().getEthernetType().intValue());
action = mdSalActions.get(8);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopMplsActionCase", action.getImplementedInterface().getName());
PopMplsActionCase popMpls = (PopMplsActionCase) action;
Assert.assertEquals("Wrong ethertype", 18, popMpls.getPopMplsAction().getEthernetType().intValue());
action = mdSalActions.get(9);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetQueueActionCase", action.getImplementedInterface().getName());
SetQueueActionCase setQueue = (SetQueueActionCase) action;
Assert.assertEquals("Wrong queue-id", 1234, setQueue.getSetQueueAction().getQueueId().intValue());
action = mdSalActions.get(10);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.GroupActionCase", action.getImplementedInterface().getName());
GroupActionCase groupAction = (GroupActionCase) action;
Assert.assertEquals("Wrong group-id", 555, groupAction.getGroupAction().getGroupId().intValue());
action = mdSalActions.get(11);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetNwTtlActionCase", action.getImplementedInterface().getName());
SetNwTtlActionCase setNwTtl = (SetNwTtlActionCase) action;
Assert.assertEquals("Wrong nw ttl", 8, setNwTtl.getSetNwTtlAction().getNwTtl().intValue());
action = mdSalActions.get(12);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.DecNwTtlCase", action.getImplementedInterface().getName());
action = mdSalActions.get(13);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.SetFieldCase", action.getImplementedInterface().getName());
SetFieldCase setField = (SetFieldCase) action;
Assert.assertEquals("Wrong in port", "openflow:null:1", setField.getSetField().getInPort().getValue());
action = mdSalActions.get(14);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PushPbbActionCase", action.getImplementedInterface().getName());
PushPbbActionCase pushPbb = (PushPbbActionCase) action;
Assert.assertEquals("Wrong ethertype", 19, pushPbb.getPushPbbAction().getEthernetType().intValue());
action = mdSalActions.get(15);
Assert.assertEquals("Wrong action type", "org.opendaylight.yang.gen.v1.urn.opendaylight.action.types" + ".rev131112.action.action.PopPbbActionCase", action.getImplementedInterface().getName());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder in project openflowplugin by opendaylight.
the class OF10PacketOutInputMessageFactoryTest method createActionList.
private static List<Action> createActionList() {
final List<Action> actions = new ArrayList<>();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(50);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
actions.add(actionBuilder.build());
return actions;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder in project openflowplugin by opendaylight.
the class OF10ActionsSerializerTest method test.
/**
* Testing correct serialization of actions (OF v1.0).
*/
@Test
public void test() {
final List<Action> actions = new ArrayList<>();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(32);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetVlanVidCaseBuilder vlanVidCaseBuilder = new SetVlanVidCaseBuilder();
SetVlanVidActionBuilder vlanVidBuilder = new SetVlanVidActionBuilder();
vlanVidBuilder.setVlanVid(15);
vlanVidCaseBuilder.setSetVlanVidAction(vlanVidBuilder.build());
actionBuilder.setActionChoice(vlanVidCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetVlanPcpCaseBuilder vlanPcpCaseBuilder = new SetVlanPcpCaseBuilder();
SetVlanPcpActionBuilder vlanPcpBuilder = new SetVlanPcpActionBuilder();
vlanPcpBuilder.setVlanPcp((short) 16);
vlanPcpCaseBuilder.setSetVlanPcpAction(vlanPcpBuilder.build());
actionBuilder.setActionChoice(vlanPcpCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetDlSrcCaseBuilder dlSrcCaseBuilder = new SetDlSrcCaseBuilder();
SetDlSrcActionBuilder dlSrcBuilder = new SetDlSrcActionBuilder();
dlSrcBuilder.setDlSrcAddress(new MacAddress("00:00:00:02:03:04"));
dlSrcCaseBuilder.setSetDlSrcAction(dlSrcBuilder.build());
actionBuilder.setActionChoice(dlSrcCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetDlDstCaseBuilder dlDstCaseBuilder = new SetDlDstCaseBuilder();
SetDlDstActionBuilder dlDstBuilder = new SetDlDstActionBuilder();
dlDstBuilder.setDlDstAddress(new MacAddress("00:00:00:01:02:03"));
dlDstCaseBuilder.setSetDlDstAction(dlDstBuilder.build());
actionBuilder.setActionChoice(dlDstCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwSrcCaseBuilder nwSrcCaseBuilder = new SetNwSrcCaseBuilder();
SetNwSrcActionBuilder nwSrcBuilder = new SetNwSrcActionBuilder();
nwSrcBuilder.setIpAddress(new Ipv4Address("10.0.0.1"));
nwSrcCaseBuilder.setSetNwSrcAction(nwSrcBuilder.build());
actionBuilder.setActionChoice(nwSrcCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwDstCaseBuilder nwDstCaseBuilder = new SetNwDstCaseBuilder();
SetNwDstActionBuilder nwDstBuilder = new SetNwDstActionBuilder();
nwDstBuilder.setIpAddress(new Ipv4Address("10.0.0.3"));
nwDstCaseBuilder.setSetNwDstAction(nwDstBuilder.build());
actionBuilder.setActionChoice(nwDstCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetNwTosCaseBuilder tosCaseBuilder = new SetNwTosCaseBuilder();
SetNwTosActionBuilder tosBuilder = new SetNwTosActionBuilder();
tosBuilder.setNwTos((short) 204);
tosCaseBuilder.setSetNwTosAction(tosBuilder.build());
actionBuilder.setActionChoice(tosCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetTpSrcCaseBuilder tpSrcCaseBuilder = new SetTpSrcCaseBuilder();
SetTpSrcActionBuilder tpSrcBuilder = new SetTpSrcActionBuilder();
tpSrcBuilder.setPort(new PortNumber(6653L));
tpSrcCaseBuilder.setSetTpSrcAction(tpSrcBuilder.build());
actionBuilder.setActionChoice(tpSrcCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
SetTpDstCaseBuilder tpDstCaseBuilder = new SetTpDstCaseBuilder();
SetTpDstActionBuilder tpDstBuilder = new SetTpDstActionBuilder();
tpDstBuilder.setPort(new PortNumber(6633L));
tpDstCaseBuilder.setSetTpDstAction(tpDstBuilder.build());
actionBuilder.setActionChoice(tpDstCaseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
EnqueueCaseBuilder enqueueCaseBuilder = new EnqueueCaseBuilder();
EnqueueActionBuilder enqueueBuilder = new EnqueueActionBuilder();
enqueueBuilder.setPort(new PortNumber(6613L));
enqueueBuilder.setQueueId(new QueueId(400L));
enqueueCaseBuilder.setEnqueueAction(enqueueBuilder.build());
actionBuilder.setActionChoice(enqueueCaseBuilder.build());
actions.add(actionBuilder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
ListSerializer.serializeList(actions, TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF10_VERSION_ID), registry, out);
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 42, out.readUnsignedShort());
Assert.assertEquals("Wrong max-length", 32, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 1, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong vlan-vid", 15, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 2, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong vlan-pcp", 16, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
Assert.assertEquals("Wrong action type", 4, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
byte[] data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
out.readBytes(data);
Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:02:03:04"), data);
out.skipBytes(6);
Assert.assertEquals("Wrong action type", 5, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
data = new byte[EncodeConstants.MAC_ADDRESS_LENGTH];
out.readBytes(data);
Assert.assertArrayEquals("Wrong dl-address", ByteBufUtils.macAddressToBytes("00:00:00:01:02:03"), data);
out.skipBytes(6);
Assert.assertEquals("Wrong action type", 6, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(4)", 1, out.readUnsignedByte());
Assert.assertEquals("Wrong action type", 7, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong ip-address(1)", 10, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(2)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(3)", 0, out.readUnsignedByte());
Assert.assertEquals("Wrong ip-address(4)", 3, out.readUnsignedByte());
Assert.assertEquals("Wrong action type", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong nw-tos", 204, out.readUnsignedByte());
out.skipBytes(3);
Assert.assertEquals("Wrong action type", 9, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 6653, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 10, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 6633, out.readUnsignedShort());
out.skipBytes(2);
Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 6613, out.readUnsignedShort());
out.skipBytes(6);
Assert.assertEquals("Wrong queue-id", 400, out.readUnsignedInt());
Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.StripVlanCaseBuilder in project openflowplugin by opendaylight.
the class OF10PacketOutInputMessageFactoryTest method testPacketOutInputMessage.
/**
* Testing of {@link OF10PacketOutInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testPacketOutInputMessage() throws Exception {
PacketOutInputBuilder builder = new PacketOutInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setBufferId(256L);
builder.setInPort(new PortNumber(257L));
final List<Action> actions = new ArrayList<>();
OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder();
OutputActionBuilder outputBuilder = new OutputActionBuilder();
outputBuilder.setPort(new PortNumber(42L));
outputBuilder.setMaxLength(50);
caseBuilder.setOutputAction(outputBuilder.build());
ActionBuilder actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(caseBuilder.build());
actions.add(actionBuilder.build());
actionBuilder = new ActionBuilder();
actionBuilder.setActionChoice(new StripVlanCaseBuilder().build());
builder.setAction(actions);
actions.add(actionBuilder.build());
builder.setAction(actions);
builder.setData(ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14"));
PacketOutInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
packetOutFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 13, 48);
Assert.assertEquals("Wrong BufferId", 256, out.readUnsignedInt());
Assert.assertEquals("Wrong PortNumber", 257, out.readUnsignedShort());
Assert.assertEquals("Wrong actions length", 16, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
Assert.assertEquals("Wrong port", 42, out.readUnsignedShort());
Assert.assertEquals("Wrong maxlength", 50, out.readUnsignedShort());
Assert.assertEquals("Wrong action type", 3, out.readUnsignedShort());
Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort());
out.skipBytes(4);
byte[] readData = new byte[out.readableBytes()];
out.readBytes(readData);
Assert.assertArrayEquals("Wrong data", message.getData(), readData);
Assert.assertTrue("Unread data", out.readableBytes() == 0);
}
Aggregations