List of usage examples for io.netty.buffer UnpooledByteBufAllocator DEFAULT
UnpooledByteBufAllocator DEFAULT
To view the source code for io.netty.buffer UnpooledByteBufAllocator DEFAULT.
Click Source Link
From source file:org.opendaylight.openflowjava.protocol.impl.util.MatchSerializerTest.java
License:Open Source License
/** * Test for correct serialization of Ipv4Address match entry */// w w w . j a v a 2 s . c o m @Test public void testIpv6Flabel() { Match match = buildIpv6FLabelMatch(0x0f9e8dL, false, null); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MatchSerializer.encodeMatch(match, out); Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong field and mask", 28 << 1, out.readUnsignedByte()); out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); byte[] label = new byte[4]; out.readBytes(label); LOG.debug("label: " + ByteBufUtils.bytesToHexString(label)); Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[] { 0, 0x0f, (byte) 0x9e, (byte) 0x8d }, label); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.MatchSerializerTest.java
License:Open Source License
/** * Test for correct serialization of Ipv4Address match entry with mask *//* w w w . j a v a2 s . c o m*/ @Test public void testIpv6FlabelWithMask() { Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[] { 0, 0x0c, 0x7b, 0x6a }); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MatchSerializer.encodeMatch(match, out); Assert.assertEquals("Wrong type", 1, out.readUnsignedShort()); out.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES); Assert.assertEquals("Wrong class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong field and mask", 28 << 1 | 1, out.readUnsignedByte()); out.skipBytes(EncodeConstants.SIZE_OF_BYTE_IN_BYTES); byte[] labelAndMask = new byte[8]; out.readBytes(labelAndMask); LOG.debug("label: " + ByteBufUtils.bytesToHexString(labelAndMask)); Assert.assertArrayEquals("Wrong ipv6FLabel", new byte[] { 0, 0x0f, (byte) 0x9e, (byte) 0x8d, 0, 0x0c, 0x7b, 0x6a }, labelAndMask); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.MatchSerializerTest.java
License:Open Source License
/** * Test for correct serialization of Ipv4Address match entry with wrong mask *//*from w ww . ja v a 2s .c om*/ @Test public void testIpv6FlabelWithMaskBad() { Match match = buildIpv6FLabelMatch(0x0f9e8dL, true, new byte[] { 0x0c, 0x7b, 0x6a }); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); try { MatchSerializer.encodeMatch(match, out); Assert.fail("incorrect length of mask ignored"); } catch (IllegalArgumentException e) { //expected } }
From source file:org.opendaylight.openflowjava.protocol.impl.util.MatchSerializerTest2.java
License:Open Source License
/** * Testing serialization of match//from w w w .j a v a 2 s .co m */ @Test public void testEmptyMatch() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MatchSerializer.encodeMatch(match, out); Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong match length", 4, out.readUnsignedShort()); Assert.assertTrue("Wrong padding", out.readableBytes() == 4); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.MatchSerializerTest2.java
License:Open Source License
/** * Testing serialization of match//from w w w. ja va 2 s. c om */ @Test public void test() { MatchBuilder builder = new MatchBuilder(); builder.setType(OxmMatchType.class); List<MatchEntries> entries = new ArrayList<>(); MatchEntriesBuilder entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(Nxm0Class.class); entryBuilder.setOxmMatchField(InPort.class); entryBuilder.setHasMask(false); PortNumberMatchEntryBuilder portNumberBuilder = new PortNumberMatchEntryBuilder(); portNumberBuilder.setPortNumber(new PortNumber(42L)); entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(Nxm1Class.class); entryBuilder.setOxmMatchField(InPhyPort.class); entryBuilder.setHasMask(false); portNumberBuilder = new PortNumberMatchEntryBuilder(); portNumberBuilder.setPortNumber(new PortNumber(43L)); entryBuilder.addAugmentation(PortNumberMatchEntry.class, portNumberBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Metadata.class); entryBuilder.setHasMask(true); MetadataMatchEntryBuilder metadataBuilder = new MetadataMatchEntryBuilder(); metadataBuilder.setMetadata(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(ExperimenterClass.class); entryBuilder.setOxmMatchField(EthDst.class); entryBuilder.setHasMask(true); MacAddressMatchEntryBuilder macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 5 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthSrc.class); entryBuilder.setHasMask(true); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(EthType.class); entryBuilder.setHasMask(false); EthTypeMatchEntryBuilder ethBuilder = new EthTypeMatchEntryBuilder(); ethBuilder.setEthType(new EtherType(46)); entryBuilder.addAugmentation(EthTypeMatchEntry.class, ethBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(VlanVid.class); entryBuilder.setHasMask(true); VlanVidMatchEntryBuilder vidBuilder = new VlanVidMatchEntryBuilder(); vidBuilder.setCfiBit(true); vidBuilder.setVlanVid(45); entryBuilder.addAugmentation(VlanVidMatchEntry.class, vidBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 9 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(VlanPcp.class); entryBuilder.setHasMask(true); VlanPcpMatchEntryBuilder pcpBuilder = new VlanPcpMatchEntryBuilder(); pcpBuilder.setVlanPcp((short) 14); entryBuilder.addAugmentation(VlanPcpMatchEntry.class, pcpBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpDscp.class); entryBuilder.setHasMask(false); DscpMatchEntryBuilder dscpBuilder = new DscpMatchEntryBuilder(); dscpBuilder.setDscp(new Dscp((short) 48)); entryBuilder.addAugmentation(DscpMatchEntry.class, dscpBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpEcn.class); entryBuilder.setHasMask(false); EcnMatchEntryBuilder ecnBuilder = new EcnMatchEntryBuilder(); ecnBuilder.setEcn((short) 49); entryBuilder.addAugmentation(EcnMatchEntry.class, ecnBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(IpProto.class); entryBuilder.setHasMask(false); ProtocolNumberMatchEntryBuilder protoBuilder = new ProtocolNumberMatchEntryBuilder(); protoBuilder.setProtocolNumber((short) 50); entryBuilder.addAugmentation(ProtocolNumberMatchEntry.class, protoBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv4Src.class); entryBuilder.setHasMask(true); Ipv4AddressMatchEntryBuilder ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.1")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 14 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv4Dst.class); entryBuilder.setHasMask(true); ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.2")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 15 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TcpSrc.class); entryBuilder.setHasMask(false); PortMatchEntryBuilder portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6653)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TcpDst.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6654)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(UdpSrc.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6655)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(UdpDst.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6656)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(SctpSrc.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6657)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(SctpDst.class); entryBuilder.setHasMask(false); portBuilder = new PortMatchEntryBuilder(); portBuilder.setPort( new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber( 6658)); entryBuilder.addAugmentation(PortMatchEntry.class, portBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv4Type.class); entryBuilder.setHasMask(false); Icmpv4TypeMatchEntryBuilder icmpv4typeBuilder = new Icmpv4TypeMatchEntryBuilder(); icmpv4typeBuilder.setIcmpv4Type((short) 51); entryBuilder.addAugmentation(Icmpv4TypeMatchEntry.class, icmpv4typeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv4Code.class); entryBuilder.setHasMask(false); Icmpv4CodeMatchEntryBuilder icmpv4CodeBuilder = new Icmpv4CodeMatchEntryBuilder(); icmpv4CodeBuilder.setIcmpv4Code((short) 52); entryBuilder.addAugmentation(Icmpv4CodeMatchEntry.class, icmpv4CodeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpOp.class); entryBuilder.setHasMask(false); OpCodeMatchEntryBuilder opBuilder = new OpCodeMatchEntryBuilder(); opBuilder.setOpCode(53); entryBuilder.addAugmentation(OpCodeMatchEntry.class, opBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpSpa.class); entryBuilder.setHasMask(true); ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.4")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 16 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpTpa.class); entryBuilder.setHasMask(true); ipv4Builder = new Ipv4AddressMatchEntryBuilder(); ipv4Builder.setIpv4Address(new Ipv4Address("10.0.0.5")); entryBuilder.addAugmentation(Ipv4AddressMatchEntry.class, ipv4Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 17 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpSha.class); entryBuilder.setHasMask(true); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("00:01:02:03:04:05")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 4, 0, 0, 6 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(ArpTha.class); entryBuilder.setHasMask(true); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("00:00:00:00:00:03")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 6, 0, 0, 4 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Src.class); entryBuilder.setHasMask(true); Ipv6AddressMatchEntryBuilder ipv6Builder = new Ipv6AddressMatchEntryBuilder(); ipv6Builder.setIpv6Address(new Ipv6Address("0:0:0:0:0:0:0:1")); entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Dst.class); entryBuilder.setHasMask(true); ipv6Builder = new Ipv6AddressMatchEntryBuilder(); ipv6Builder.setIpv6Address(new Ipv6Address("0:0:1:0:1:0:0:1")); entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Flabel.class); entryBuilder.setHasMask(true); Ipv6FlabelMatchEntryBuilder flabelBuilder = new Ipv6FlabelMatchEntryBuilder(); flabelBuilder.setIpv6Flabel(new Ipv6FlowLabel(58L)); entryBuilder.addAugmentation(Ipv6FlabelMatchEntry.class, flabelBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 1, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv6Type.class); entryBuilder.setHasMask(false); Icmpv6TypeMatchEntryBuilder icmpv6TypeBuilder = new Icmpv6TypeMatchEntryBuilder(); icmpv6TypeBuilder.setIcmpv6Type((short) 59); entryBuilder.addAugmentation(Icmpv6TypeMatchEntry.class, icmpv6TypeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Icmpv6Code.class); entryBuilder.setHasMask(false); Icmpv6CodeMatchEntryBuilder icmpv6CodeBuilder = new Icmpv6CodeMatchEntryBuilder(); icmpv6CodeBuilder.setIcmpv6Code((short) 60); entryBuilder.addAugmentation(Icmpv6CodeMatchEntry.class, icmpv6CodeBuilder.build()); entries.add(entryBuilder.build()); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdTarget.class); entryBuilder.setHasMask(false); ipv6Builder = new Ipv6AddressMatchEntryBuilder(); ipv6Builder.setIpv6Address(new Ipv6Address("F:0:0::0:0:0:1")); entryBuilder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6Builder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(ExperimenterClass.class); entryBuilder.setOxmMatchField(Ipv6NdSll.class); entryBuilder.setHasMask(false); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("01:00:03:00:00:06")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6NdTll.class); entryBuilder.setHasMask(false); macBuilder = new MacAddressMatchEntryBuilder(); macBuilder.setMacAddress(new MacAddress("04:00:02:00:00:08")); entryBuilder.addAugmentation(MacAddressMatchEntry.class, macBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsLabel.class); entryBuilder.setHasMask(false); MplsLabelMatchEntryBuilder labelBuilder = new MplsLabelMatchEntryBuilder(); labelBuilder.setMplsLabel(61L); entryBuilder.addAugmentation(MplsLabelMatchEntry.class, labelBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsTc.class); entryBuilder.setHasMask(false); TcMatchEntryBuilder tcBuilder = new TcMatchEntryBuilder(); tcBuilder.setTc((short) 62); entryBuilder.addAugmentation(TcMatchEntry.class, tcBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(MplsBos.class); entryBuilder.setHasMask(false); BosMatchEntryBuilder bosBuilder = new BosMatchEntryBuilder(); bosBuilder.setBos(true); entryBuilder.addAugmentation(BosMatchEntry.class, bosBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(PbbIsid.class); entryBuilder.setHasMask(true); IsidMatchEntryBuilder isidBuilder = new IsidMatchEntryBuilder(); isidBuilder.setIsid(64L); entryBuilder.addAugmentation(IsidMatchEntry.class, isidBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 1, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(TunnelId.class); entryBuilder.setHasMask(true); metadataBuilder = new MetadataMatchEntryBuilder(); metadataBuilder.setMetadata(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }); entryBuilder.addAugmentation(MetadataMatchEntry.class, metadataBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); entryBuilder = new MatchEntriesBuilder(); entryBuilder.setOxmClass(OpenflowBasicClass.class); entryBuilder.setOxmMatchField(Ipv6Exthdr.class); entryBuilder.setHasMask(true); PseudoFieldMatchEntryBuilder pseudoBuilder = new PseudoFieldMatchEntryBuilder(); pseudoBuilder.setPseudoField(new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true)); entryBuilder.addAugmentation(PseudoFieldMatchEntry.class, pseudoBuilder.build()); maskBuilder = new MaskMatchEntryBuilder(); maskBuilder.setMask(new byte[] { 0, 2 }); entryBuilder.addAugmentation(MaskMatchEntry.class, maskBuilder.build()); entries.add(entryBuilder.build()); builder.setMatchEntries(entries); Match match = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MatchSerializer.encodeMatch(match, out); Assert.assertEquals("Wrong match type", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong match length", 428, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 0, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 42, out.readUnsignedInt()); Assert.assertEquals("Wrong match entry class", 1, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 43, out.readUnsignedInt()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 5, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); Assert.assertEquals("Wrong match entry class", 0xFFFF, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 7, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); byte[] array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 1, 0, 3, 0, 0, 6 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 5 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 9, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 4, 0, 2, 0, 0, 8 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 2 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 10, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 46, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 13, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 4141, out.readUnsignedShort()); array = new byte[2]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 9 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 14, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 14, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 16, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 48, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 18, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 49, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 20, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 50, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 23, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 1 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 14 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 25, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 2 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 15 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 26, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6653, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 28, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6654, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 30, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6655, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 32, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6656, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 34, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6657, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 36, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 6658, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 38, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 51, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 40, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 52, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 42, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 2, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 53, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 45, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 4 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 16 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 47, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 10, 0, 0, 5 }, array); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 17 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 49, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 1, 2, 3, 4, 5 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 4, 0, 0, 6 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 51, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 12, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 3 }, array); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 6, 0, 0, 4 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 53, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 55, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 32, out.readUnsignedByte()); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1 }, array); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 57, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 8, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 58, out.readUnsignedInt()); array = new byte[4]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 1, 0, 2 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 58, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 59, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 60, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 60, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 62, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); array = new byte[16]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 }, array); Assert.assertEquals("Wrong match entry class", 0xFFFF, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 64, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 1, 0, 3, 0, 0, 6 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 66, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); array = new byte[6]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 4, 0, 2, 0, 0, 8 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 68, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 61, out.readUnsignedInt()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 70, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 62, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 72, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 75, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 6, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 64, out.readUnsignedMedium()); array = new byte[3]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry mask", new byte[] { 0, 1, 2 }, array); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 77, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 16, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1L, out.readLong()); Assert.assertEquals("Wrong match entry mask", 2L, out.readLong()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & hasMask", 79, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 358, out.readUnsignedShort()); array = new byte[2]; out.readBytes(array); Assert.assertArrayEquals("Wrong match entry value", new byte[] { 0, 2 }, array); Assert.assertTrue("Wrong padding", out.readableBytes() == 4); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.OF10ActionsSerializerTest.java
License:Open Source License
/** * Testing correct serialization of actions (OF v1.0) *///from w w w . j a va 2 s . c o m @Test public void test() { List<Action> actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); actionBuilder.setType(Output.class); PortActionBuilder portBuilder = new PortActionBuilder(); portBuilder.setPort(new PortNumber(42L)); actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); MaxLengthActionBuilder maxLen = new MaxLengthActionBuilder(); maxLen.setMaxLength(32); actionBuilder.addAugmentation(MaxLengthAction.class, maxLen.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetVlanVid.class); VlanVidActionBuilder vlanBuilder = new VlanVidActionBuilder(); vlanBuilder.setVlanVid(15); actionBuilder.addAugmentation(VlanVidAction.class, vlanBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetVlanPcp.class); VlanPcpActionBuilder pcpBuilder = new VlanPcpActionBuilder(); pcpBuilder.setVlanPcp((short) 16); actionBuilder.addAugmentation(VlanPcpAction.class, pcpBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(StripVlan.class); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetDlSrc.class); DlAddressActionBuilder dlBuilder = new DlAddressActionBuilder(); dlBuilder.setDlAddress(new MacAddress("00:00:00:02:03:04")); actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetDlDst.class); dlBuilder = new DlAddressActionBuilder(); dlBuilder.setDlAddress(new MacAddress("00:00:00:01:02:03")); actionBuilder.addAugmentation(DlAddressAction.class, dlBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetNwSrc.class); IpAddressActionBuilder ipBuilder = new IpAddressActionBuilder(); ipBuilder.setIpAddress(new Ipv4Address("10.0.0.1")); actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetNwDst.class); ipBuilder = new IpAddressActionBuilder(); ipBuilder.setIpAddress(new Ipv4Address("10.0.0.3")); actionBuilder.addAugmentation(IpAddressAction.class, ipBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetNwTos.class); NwTosActionBuilder tosBuilder = new NwTosActionBuilder(); tosBuilder.setNwTos((short) 204); actionBuilder.addAugmentation(NwTosAction.class, tosBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetTpSrc.class); portBuilder = new PortActionBuilder(); portBuilder.setPort(new PortNumber(6653L)); actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(SetTpDst.class); portBuilder = new PortActionBuilder(); portBuilder.setPort(new PortNumber(6633L)); actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(Enqueue.class); portBuilder = new PortActionBuilder(); portBuilder.setPort(new PortNumber(6613L)); actionBuilder.addAugmentation(PortAction.class, portBuilder.build()); QueueIdActionBuilder queueBuilder = new QueueIdActionBuilder(); queueBuilder.setQueueId(400L); actionBuilder.addAugmentation(QueueIdAction.class, queueBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); actionBuilder.setType(Experimenter.class); ExperimenterActionBuilder expBuilder = new ExperimenterActionBuilder(); expBuilder.setExperimenter(500L); actionBuilder.addAugmentation(ExperimenterAction.class, expBuilder.build()); actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); OF10ActionsSerializer.encodeActionsV10(out, actions); 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.assertEquals("Wrong action type", 65535, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong vendor-id", 500, out.readUnsignedInt()); Assert.assertTrue("Written more bytes than needed", out.readableBytes() == 0); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializerTest.java
License:Open Source License
/** * Testing correct serialization of ofp_match *///from ww w .ja v a 2 s . c o m @Test public void test() { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MatchV10Builder builder = new MatchV10Builder(); builder.setWildcards(new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, true)); builder.setNwSrcMask((short) 24); builder.setNwDstMask((short) 16); builder.setInPort(6653); builder.setDlSrc(new MacAddress("01:01:01:01:01:01")); builder.setDlDst(new MacAddress("02:02:02:02:02:02")); builder.setDlVlan(128); builder.setDlVlanPcp((short) 2); builder.setDlType(15); builder.setNwTos((short) 14); builder.setNwProto((short) 85); builder.setNwSrc(new Ipv4Address("1.1.1.2")); builder.setNwDst(new Ipv4Address("32.16.8.1")); builder.setTpSrc(2048); builder.setTpDst(4096); MatchV10 match = builder.build(); OF10MatchSerializer.encodeMatchV10(out, match); Assert.assertEquals("Wrong wildcards", 2361553, out.readUnsignedInt()); Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort()); byte[] dlSrc = new byte[6]; out.readBytes(dlSrc); Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc)); byte[] dlDst = new byte[6]; out.readBytes(dlDst); Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst)); Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort()); Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte()); out.skipBytes(1); Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort()); Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte()); Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte()); out.skipBytes(2); Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt()); Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt()); Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort()); Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort()); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.OF10MatchSerializerTest.java
License:Open Source License
/** * Testing correct serialization of ofp_match *///ww w .j av a2 s . com @Test public void test2() { ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MatchV10Builder builder = new MatchV10Builder(); builder.setWildcards(new FlowWildcardsV10(true, true, true, true, true, true, true, true, true, true)); builder.setNwSrcMask((short) 0); builder.setNwDstMask((short) 0); builder.setInPort(6653); builder.setDlSrc(new MacAddress("01:01:01:01:01:01")); builder.setDlDst(new MacAddress("02:02:02:02:02:02")); builder.setDlVlan(128); builder.setDlVlanPcp((short) 2); builder.setDlType(15); builder.setNwTos((short) 14); builder.setNwProto((short) 85); builder.setNwSrc(new Ipv4Address("1.1.1.2")); builder.setNwDst(new Ipv4Address("32.16.8.1")); builder.setTpSrc(2048); builder.setTpDst(4096); MatchV10 match = builder.build(); OF10MatchSerializer.encodeMatchV10(out, match); Assert.assertEquals("Wrong wildcards", 3678463, out.readUnsignedInt()); Assert.assertEquals("Wrong in-port", 6653, out.readUnsignedShort()); byte[] dlSrc = new byte[6]; out.readBytes(dlSrc); Assert.assertEquals("Wrong dl-src", "01:01:01:01:01:01", ByteBufUtils.macAddressToString(dlSrc)); byte[] dlDst = new byte[6]; out.readBytes(dlDst); Assert.assertEquals("Wrong dl-dst", "02:02:02:02:02:02", ByteBufUtils.macAddressToString(dlDst)); Assert.assertEquals("Wrong dl-vlan", 128, out.readUnsignedShort()); Assert.assertEquals("Wrong dl-vlan-pcp", 2, out.readUnsignedByte()); out.skipBytes(1); Assert.assertEquals("Wrong dl-type", 15, out.readUnsignedShort()); Assert.assertEquals("Wrong nw-tos", 14, out.readUnsignedByte()); Assert.assertEquals("Wrong nw-proto", 85, out.readUnsignedByte()); out.skipBytes(2); Assert.assertEquals("Wrong nw-src", 16843010, out.readUnsignedInt()); Assert.assertEquals("Wrong nw-dst", 537921537, out.readUnsignedInt()); Assert.assertEquals("Wrong tp-src", 2048, out.readUnsignedShort()); Assert.assertEquals("Wrong tp-dst", 4096, out.readUnsignedShort()); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.OF13ActionsSerializerTest.java
License:Open Source License
/** * Testing correct serialization of actions *//*from w w w .j a v a 2 s . c om*/ @Test public void test() { List<Action> actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); OutputActionBuilder outputBuilder = new OutputActionBuilder(); outputBuilder.setPort(new PortNumber(42L)); outputBuilder.setMaxLength(52); caseBuilder.setOutputAction(outputBuilder.build()); actionBuilder.setActionChoice(caseBuilder.build()); 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(); SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder(); SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder(); List<MatchEntry> entries = new ArrayList<>(); 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()); entries.add(matchBuilder.build()); setFieldBuilder.setMatchEntry(entries); 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()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ListSerializer.serializeList(actions, TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong action port", 42, out.readUnsignedInt()); Assert.assertEquals("Wrong action max-length", 52, out.readUnsignedShort()); out.skipBytes(6); Assert.assertEquals("Wrong action type", 11, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 12, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 15, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action mpls-ttl", 4, out.readUnsignedByte()); out.skipBytes(3); Assert.assertEquals("Wrong action type", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 17, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 16, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 18, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 19, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 17, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 20, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 18, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 21, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action queue-id", 1234, out.readUnsignedInt()); Assert.assertEquals("Wrong action type", 22, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action group", 555, out.readUnsignedInt()); Assert.assertEquals("Wrong action type", 23, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action nw-ttl", 8, out.readUnsignedByte()); out.skipBytes(3); Assert.assertEquals("Wrong action type", 24, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 16, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry class", 0x8000, out.readUnsignedShort()); Assert.assertEquals("Wrong match entry field & mask", 0, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry length", 4, out.readUnsignedByte()); Assert.assertEquals("Wrong match entry value", 1, out.readUnsignedInt()); out.skipBytes(4); Assert.assertEquals("Wrong action type", 26, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); Assert.assertEquals("Wrong action ethertype", 19, out.readUnsignedShort()); out.skipBytes(2); Assert.assertEquals("Wrong action type", 27, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 8, out.readUnsignedShort()); out.skipBytes(4); Assert.assertTrue("Unread data", out.readableBytes() == 0); }
From source file:org.opendaylight.openflowjava.protocol.impl.util.OF13ActionsSerializerTest.java
License:Open Source License
/** * Testing correct serialization of actions *//*from w ww . ja v a2s. c o m*/ @Test public void testHeaders() { List<Action> actions = new ArrayList<>(); ActionBuilder actionBuilder = new ActionBuilder(); OutputActionCaseBuilder caseBuilder = new OutputActionCaseBuilder(); OutputActionBuilder outputBuilder = new OutputActionBuilder(); outputBuilder.setPort(new PortNumber(42L)); outputBuilder.setMaxLength(52); caseBuilder.setOutputAction(outputBuilder.build()); actionBuilder.setActionChoice(caseBuilder.build()); actions.add(actionBuilder.build()); actionBuilder = new ActionBuilder(); SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder(); SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder(); List<MatchEntry> entries = new ArrayList<>(); 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()); entries.add(matchBuilder.build()); setFieldBuilder.setMatchEntry(entries); setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build()); actionBuilder.setActionChoice(setFieldCaseBuilder.build()); actions.add(actionBuilder.build()); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); ListSerializer.serializeHeaderList(actions, TypeKeyMakerFactory.createActionKeyMaker(EncodeConstants.OF13_VERSION_ID), registry, out); Assert.assertEquals("Wrong action type", 0, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); Assert.assertEquals("Wrong action type", 25, out.readUnsignedShort()); Assert.assertEquals("Wrong action length", 4, out.readUnsignedShort()); Assert.assertTrue("Unread data", out.readableBytes() == 0); }