use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class OF10MatchDeserializerTest method test.
/**
* Testing correct deserialization of ofp_match.
*/
@Test
public void test() {
ByteBuf message = BufferHelper.buildBuffer("00 24 08 91 00 20 AA BB CC DD EE FF " + "AA BB CC DD EE FF 00 05 10 00 00 08 07 06 00 00 10 11 12 13 01 02 03 04 " + "50 50 20 20");
// skip XID
message.skipBytes(4);
MatchV10 match = matchDeserializer.deserialize(message);
Assert.assertEquals("Wrong wildcards", new FlowWildcardsV10(false, false, true, false, false, true, false, true, true, false), match.getWildcards());
Assert.assertEquals("Wrong srcMask", 24, match.getNwSrcMask().shortValue());
Assert.assertEquals("Wrong dstMask", 16, match.getNwDstMask().shortValue());
Assert.assertEquals("Wrong in-port", 32, match.getInPort().intValue());
Assert.assertEquals("Wrong dl-src", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlSrc());
Assert.assertEquals("Wrong dl-dst", new MacAddress("aa:bb:cc:dd:ee:ff"), match.getDlDst());
Assert.assertEquals("Wrong dl-vlan", 5, match.getDlVlan().intValue());
Assert.assertEquals("Wrong dl-vlan-pcp", 16, match.getDlVlanPcp().shortValue());
Assert.assertEquals("Wrong dl-type", 8, match.getDlType().intValue());
Assert.assertEquals("Wrong nw-tos", 7, match.getNwTos().shortValue());
Assert.assertEquals("Wrong nw-proto", 6, match.getNwProto().shortValue());
Assert.assertEquals("Wrong nw-src", new Ipv4Address("16.17.18.19"), match.getNwSrc());
Assert.assertEquals("Wrong nw-dst", new Ipv4Address("1.2.3.4"), match.getNwDst());
Assert.assertEquals("Wrong tp-src", 20560, match.getTpSrc().shortValue());
Assert.assertEquals("Wrong tp-dst", 8224, match.getTpDst().shortValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class HelloInputMessageFactoryTest method testWith64BitVersionBitmap.
/**
* Testing of {@link HelloInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testWith64BitVersionBitmap() throws Exception {
int lengthOfBitmap = 64;
HelloInputBuilder builder = new HelloInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
List<Elements> expectedElement = createElement(lengthOfBitmap);
builder.setElements(expectedElement);
HelloInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
helloFactory.serialize(message, out);
if (LOG.isDebugEnabled()) {
LOG.debug("bytebuf: ", ByteBufUtils.byteBufToHexString(out));
}
BufferHelper.checkHeaderV13(out, (byte) 0, 24);
Elements element = readElement(out).get(0);
Assert.assertEquals("Wrong element type", expectedElement.get(0).getType(), element.getType());
Elements comparation = createComparationElement(lengthOfBitmap).get(0);
Assert.assertArrayEquals("Wrong element bitmap", comparation.getVersionBitmap().toArray(), element.getVersionBitmap().toArray());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestInputAggregateBodyFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestInputAggregateBodyFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(2));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestAggregate());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 48);
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
Assert.assertEquals("Wrong aggregate", message.getMultipartRequestBody(), decodeRequestAggregate(out));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestDescMessageFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestDescMessageFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(0));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestDesc());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 16);
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class MultipartRequestInputFactoryTest method testMultipartRequestFlowInputFactory.
/**
* Testing of {@link MultipartRequestInputFactory} for correct translation from POJO.
*/
@Test
public void testMultipartRequestFlowInputFactory() throws Exception {
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.forValue(1));
builder.setFlags(new MultipartRequestFlags(true));
builder.setMultipartRequestBody(createRequestFlow());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 48);
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort()));
out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE);
Assert.assertEquals("Wrong flow", message.getMultipartRequestBody(), decodeRequestFlow(out));
}
Aggregations