@Test public void test() { deserializedMessage = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV13(deserializedMessage); Assert.assertEquals("Wrong type", MultipartType.forValue(6), deserializedMessage.getType()); Assert.assertEquals( "Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); Assert.assertEquals( "Wrong aggregate", createRequestGroup(), deserializedMessage.getMultipartRequestBody()); }
@Test public void test() { ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00"); MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV10(deserializedMessage); Assert.assertEquals("Wrong type", 0, deserializedMessage.getType().getIntValue()); Assert.assertEquals( "Wrong flags", new MultipartRequestFlags(false), deserializedMessage.getFlags()); Assert.assertEquals( "Wrong body", createMultipartRequestBody(), deserializedMessage.getMultipartRequestBody()); }
@Test public void test() { ByteBuf bb = BufferHelper.buildBuffer("00 05 00 01 00 00 00 00 00 00 08 d0 00 00 08 a3"); MultipartRequestInput deserializedMessage = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV13(deserializedMessage); Assert.assertEquals("Wrong type", MultipartType.forValue(5), deserializedMessage.getType()); Assert.assertEquals( "Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); Assert.assertEquals( "Wrong aggregate", createRequestQueue(), deserializedMessage.getMultipartRequestBody()); }
/** @author [email protected] */ public class MultipartRequestGroupInputMessageFactoryTest { ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 00 00 08 d2 00 00 00 00"); MultipartRequestInputMessageFactory factory; MultipartRequestInput deserializedMessage; @Before public void startUp() { DeserializerRegistry desRegistry = new DeserializerRegistryImpl(); desRegistry.init(); factory = desRegistry.getDeserializer( new MessageCodeKey(EncodeConstants.OF13_VERSION_ID, 18, MultipartRequestInput.class)); } @Test public void test() { deserializedMessage = BufferHelper.deserialize(factory, bb); BufferHelper.checkHeaderV13(deserializedMessage); Assert.assertEquals("Wrong type", MultipartType.forValue(6), deserializedMessage.getType()); Assert.assertEquals( "Wrong flags", new MultipartRequestFlags(true), deserializedMessage.getFlags()); Assert.assertEquals( "Wrong aggregate", createRequestGroup(), deserializedMessage.getMultipartRequestBody()); } private static MultipartRequestGroupCase createRequestGroup() { MultipartRequestGroupCaseBuilder caseBuilder = new MultipartRequestGroupCaseBuilder(); MultipartRequestGroupBuilder builder = new MultipartRequestGroupBuilder(); builder.setGroupId(new GroupId(2258L)); caseBuilder.setMultipartRequestGroup(builder.build()); return caseBuilder.build(); } }
/** Tests {@link OxmIpv6ExtHdrDeserializer#deserialize(ByteBuf)} */ @Test public void test() { ByteBuf buffer = BufferHelper.buildBuffer("80 00 4E 02 01 FF"); buffer.skipBytes(4); // skip XID OxmIpv6ExtHdrDeserializer deserializer = new OxmIpv6ExtHdrDeserializer(); MatchEntry entry = deserializer.deserialize(buffer); Assert.assertEquals("Wrong entry class", OpenflowBasicClass.class, entry.getOxmClass()); Assert.assertEquals("Wrong entry field", Ipv6Exthdr.class, entry.getOxmMatchField()); Assert.assertEquals("Wrong entry hasMask", false, entry.isHasMask()); Assert.assertEquals( "Wrong entry value", new Ipv6ExthdrFlags(true, true, true, true, true, true, true, true, true), ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getPseudoField()); Assert.assertEquals( "Wrong entry mask", null, ((Ipv6ExthdrCase) entry.getMatchEntryValue()).getIpv6Exthdr().getMask()); Assert.assertTrue("Unread data", buffer.readableBytes() == 0); }