Search in sources :

Example 96 with Message

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());
}
Also used : FlowWildcardsV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowWildcardsV10) ByteBuf(io.netty.buffer.ByteBuf) MatchV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.v10.grouping.MatchV10) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 97 with Message

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());
}
Also used : HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) Elements(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements) ByteBuf(io.netty.buffer.ByteBuf) HelloInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInputBuilder) Test(org.junit.Test)

Example 98 with Message

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));
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 99 with Message

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()));
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Example 100 with Message

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));
}
Also used : MultipartRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder) MultipartRequestFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags) ByteBuf(io.netty.buffer.ByteBuf) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)202 ByteBuf (io.netty.buffer.ByteBuf)184 ArrayList (java.util.ArrayList)109 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)53 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)45 MatchEntryBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntryBuilder)44 BigInteger (java.math.BigInteger)37 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)26 MultipartRequestInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput)25 MultipartRequestInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInputBuilder)25 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)22 PCEPDeserializerException (org.opendaylight.protocol.pcep.spi.PCEPDeserializerException)21 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Update)21 List (java.util.List)18 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)18 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)17 Object (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object)17 Message (org.eclipse.bpmn2.Message)16 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)15 Message (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message)15