Search in sources :

Example 76 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class GroupingResolverTest method testGetExtension.

/**
 * test of method {@link GroupingResolver#getExtension(Augmentable)}.
 */
@Test
public void testGetExtension() {
    GroupingResolver<GeneralExtensionListGrouping, Match> eqGroup = new GroupingResolver<>(GeneralExtensionListGrouping.class);
    eqGroup.add(GeneralAugMatchNodesNodeTableFlow.class);
    eqGroup.add(GeneralAugMatchRpcAddFlow.class);
    MatchBuilder mb1 = new MatchBuilder();
    ExtensionList extension1 = new ExtensionListBuilder().setExtensionKey(JoachimTheBig.class).build();
    GeneralAugMatchNodesNodeTableFlow odlxxx1 = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(Collections.singletonList(extension1)).build();
    Match match1 = mb1.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx1).build();
    MatchBuilder mb2 = new MatchBuilder();
    ExtensionList extension2 = new ExtensionListBuilder().setExtensionKey(JoachimTheTiny.class).build();
    GeneralAugMatchNodesNodeTableFlow odlxxx2 = new GeneralAugMatchNodesNodeTableFlowBuilder().setExtensionList(Collections.singletonList(extension2)).build();
    Match match2 = mb2.addAugmentation(GeneralAugMatchNodesNodeTableFlow.class, odlxxx2).build();
    Assert.assertEquals(JoachimTheBig.class, eqGroup.getExtension(match1).get().getExtensionList().get(0).getExtensionKey());
    Assert.assertEquals(JoachimTheTiny.class, eqGroup.getExtension(match2).get().getExtensionList().get(0).getExtensionKey());
}
Also used : GeneralAugMatchNodesNodeTableFlow(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlow) ExtensionListBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionListBuilder) GeneralAugMatchNodesNodeTableFlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralAugMatchNodesNodeTableFlowBuilder) ExtensionList(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.general.extension.list.grouping.ExtensionList) GeneralExtensionListGrouping(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.general.rev140714.GeneralExtensionListGrouping) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) Match(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match) Test(org.junit.Test)

Example 77 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class GetConfigReplyMessageFactoryTest method test.

/**
 * Testing {@link GetConfigReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 00 03");
    GetConfigOutput builtByFactory = BufferHelper.deserialize(factory, bb);
    Assert.assertEquals("Wrong switchConfigFlag", 0x01, builtByFactory.getFlags().getIntValue());
    Assert.assertEquals("Wrong missSendLen", 0x03, builtByFactory.getMissSendLen().intValue());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) GetConfigOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetConfigOutput) DefaultDeserializerFactoryTest(org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest) Test(org.junit.Test)

Example 78 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class HelloMessageFactoryTest method testWithoutPadding.

/**
 * Testing {@link HelloMessageFactory} for correct length without padding.
 */
@Test
public void testWithoutPadding() {
    ByteBuf bb = BufferHelper.buildBuffer(// type
    "00 01 " + // length
    "00 08 " + // bitmap 1
    "00 00 00 11");
    HelloMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    List<Elements> element = createElement(4, HelloElementType.VERSIONBITMAP.getIntValue());
    Assert.assertEquals("Wrong type", element.get(0).getType(), builtByFactory.getElements().get(0).getType());
    Assert.assertEquals("Wrong versionBitmap", element.get(0).getVersionBitmap(), builtByFactory.getElements().get(0).getVersionBitmap());
}
Also used : HelloMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloMessage) ByteBuf(io.netty.buffer.ByteBuf) Elements(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.hello.Elements) DefaultDeserializerFactoryTest(org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest) Test(org.junit.Test)

Example 79 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartReplyMeterBodyMulti.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyMeterBodyMulti() {
    ByteBuf bb = BufferHelper.buildBuffer("00 09 00 01 00 00 00 00 " + // meterId_0
    "00 00 00 09 " + // len_0
    "00 58 " + // pad_0
    "00 00 00 00 00 00 " + // flowCount_0
    "00 00 00 07 " + // packetInCount_0
    "FF 01 01 01 01 01 01 01 " + // byteInCount_0
    "FF 01 01 01 01 01 01 01 " + // durationSec_0
    "00 00 00 05 " + // durationNsec_0
    "00 00 00 05 " + // packetBandCount_01
    "FF 01 01 01 01 01 01 01 " + // byteBandCount_01
    "FF 01 01 01 01 01 01 01 " + // packetBandCount_02
    "FF 02 02 02 02 02 02 02 " + // byteBandCount_02
    "FF 02 02 02 02 02 02 02 " + // packetBandCount_03
    "FF 03 03 03 03 03 03 03 " + // byteBandCount_03
    "FF 03 03 03 03 03 03 03 " + // meterId_1
    "00 00 00 08 " + // len_1
    "00 58 " + // pad_1
    "00 00 00 00 00 00 " + // flowCount_1
    "00 00 00 07 " + // packetInCount_1
    "FF 01 01 01 01 01 01 01 " + // byteInCount_1
    "FF 01 01 01 01 01 01 01 " + // durationSec_1
    "00 00 00 05 " + // durationNsec_1
    "00 00 00 05 " + // packetBandCount_11
    "FF 01 01 01 01 01 01 01 " + // byteBandCount_11
    "FF 01 01 01 01 01 01 01 " + // packetBandCount_12
    "FF 02 02 02 02 02 02 02 " + // byteBandCount_12
    "FF 02 02 02 02 02 02 02 " + // packetBandCount_13
    "FF 03 03 03 03 03 03 03 " + // byteBandCount_13
    "FF 03 03 03 03 03 03 03");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 9, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyMeterCase messageCase = (MultipartReplyMeterCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyMeter message = messageCase.getMultipartReplyMeter();
    Assert.assertEquals("Wrong meterId", 9, message.getMeterStats().get(0).getMeterId().getValue().intValue());
    Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(0).getFlowCount().intValue());
    Assert.assertEquals("Wrong packetInCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(0).getPacketInCount());
    Assert.assertEquals("Wrong byteInCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(0).getByteInCount());
    Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(0).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(0).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetBandCount_01", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(0).getMeterBandStats().get(0).getPacketBandCount());
    Assert.assertEquals("Wrong byteBandCount_01", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(0).getMeterBandStats().get(0).getByteBandCount());
    Assert.assertEquals("Wrong packetBandCount_02", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getMeterStats().get(0).getMeterBandStats().get(1).getPacketBandCount());
    Assert.assertEquals("Wrong byteBandCount_02", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getMeterStats().get(0).getMeterBandStats().get(1).getByteBandCount());
    Assert.assertEquals("Wrong packetBandCount_03", new BigInteger(1, new byte[] { (byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }), message.getMeterStats().get(0).getMeterBandStats().get(2).getPacketBandCount());
    Assert.assertEquals("Wrong byteBandCount_03", new BigInteger(1, new byte[] { (byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }), message.getMeterStats().get(0).getMeterBandStats().get(2).getByteBandCount());
    Assert.assertEquals("Wrong meterId", 8, message.getMeterStats().get(1).getMeterId().getValue().intValue());
    Assert.assertEquals("Wrong flowCount", 7, message.getMeterStats().get(1).getFlowCount().intValue());
    Assert.assertEquals("Wrong packetInCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(1).getPacketInCount());
    Assert.assertEquals("Wrong byteInCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(1).getByteInCount());
    Assert.assertEquals("Wrong durationSec", 5, message.getMeterStats().get(1).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 5, message.getMeterStats().get(1).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetBandCount_01", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(1).getMeterBandStats().get(0).getPacketBandCount());
    Assert.assertEquals("Wrong byteBandCount_01", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getMeterStats().get(1).getMeterBandStats().get(0).getByteBandCount());
    Assert.assertEquals("Wrong packetBandCount_02", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getMeterStats().get(1).getMeterBandStats().get(1).getPacketBandCount());
    Assert.assertEquals("Wrong byteBandCount_02", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getMeterStats().get(1).getMeterBandStats().get(1).getByteBandCount());
    Assert.assertEquals("Wrong packetBandCount_03", new BigInteger(1, new byte[] { (byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }), message.getMeterStats().get(1).getMeterBandStats().get(2).getPacketBandCount());
    Assert.assertEquals("Wrong byteBandCount_03", new BigInteger(1, new byte[] { (byte) 0xFF, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03 }), message.getMeterStats().get(1).getMeterBandStats().get(2).getByteBandCount());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMeter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter._case.MultipartReplyMeter) MultipartReplyMeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterCase) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 80 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class MultipartReplyMessageFactoryTest method testMultipartReplyGroupBody.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyGroupBody() {
    ByteBuf bb = BufferHelper.buildBuffer("00 06 00 01 00 00 00 00 " + // length
    "00 48 " + // pad1
    "00 00 " + // groupId
    "00 00 00 10 " + // refCount
    "00 00 00 12 " + // pad2
    "00 00 00 00 " + // packetCount
    "FF 01 01 01 01 01 01 01 " + // byteCount
    "FF 01 01 01 01 01 01 01 " + // durationSec
    "00 00 00 08 " + // durationNsec
    "00 00 00 09 " + // packetCountBucket
    "FF 01 01 01 01 01 01 01 " + // byteCountBucket
    "FF 01 01 01 01 01 01 01 " + // packetCountBucket_2
    "FF 02 02 02 02 02 02 02 " + // byteCountBucket_2
    "FF 02 02 02 02 02 02 02 " + // length_2
    "00 48 " + // pad1.2
    "00 00 " + // groupId_2
    "00 00 00 10 " + // refCount_2
    "00 00 00 12 " + // pad2.2
    "00 00 00 00 " + // packetCount_2
    "FF 01 01 01 01 01 01 01 " + // byteCount_2
    "FF 01 01 01 01 01 01 01 " + // durationSec_2
    "00 00 00 08 " + // durationNsec_2
    "00 00 00 09 " + // packetCountBucket_1.2
    "FF 01 01 01 01 01 01 01 " + // byteCountBucket_1.2
    "FF 01 01 01 01 01 01 01 " + // packetCountBucket_2.2
    "FF 02 02 02 02 02 02 02 " + // byteCountBucket_2.2
    "FF 02 02 02 02 02 02 02");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(multipartFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0x06, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyGroupCase messageCase = (MultipartReplyGroupCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyGroup message = messageCase.getMultipartReplyGroup();
    Assert.assertEquals("Wrong groupId", 16, message.getGroupStats().get(0).getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong refCount", 18, message.getGroupStats().get(0).getRefCount().intValue());
    Assert.assertEquals("Wrong packetCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCount", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getByteCount());
    Assert.assertEquals("Wrong durationSec", 8, message.getGroupStats().get(0).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec", 9, message.getGroupStats().get(0).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(0).getBucketStats().get(0).getByteCount());
    Assert.assertEquals("Wrong packetCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(0).getBucketStats().get(1).getByteCount());
    Assert.assertEquals("Wrong groupId_2", 16, message.getGroupStats().get(1).getGroupId().getValue().intValue());
    Assert.assertEquals("Wrong refCount_2", 18, message.getGroupStats().get(1).getRefCount().intValue());
    Assert.assertEquals("Wrong packetCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCount_2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getByteCount());
    Assert.assertEquals("Wrong durationSec_2", 8, message.getGroupStats().get(1).getDurationSec().intValue());
    Assert.assertEquals("Wrong durationNsec_2", 9, message.getGroupStats().get(1).getDurationNsec().intValue());
    Assert.assertEquals("Wrong packetCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_1.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 }), message.getGroupStats().get(1).getBucketStats().get(0).getByteCount());
    Assert.assertEquals("Wrong packetCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getPacketCount());
    Assert.assertEquals("Wrong byteCountBucket_2.2", new BigInteger(1, new byte[] { (byte) 0xFF, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 }), message.getGroupStats().get(1).getBucketStats().get(1).getByteCount());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupCase) MultipartReplyGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group._case.MultipartReplyGroup) BigInteger(java.math.BigInteger) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)454 ByteBuf (io.netty.buffer.ByteBuf)138 ArrayList (java.util.ArrayList)71 BigInteger (java.math.BigInteger)58 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)54 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)45 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)38 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)35 InetAddress (java.net.InetAddress)33 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)33 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)32 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)28 Inet4Address (java.net.Inet4Address)27 Inet6Address (java.net.Inet6Address)27 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)27 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)26 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)26