Search in sources :

Example 91 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 GetAsyncReplyMessageFactoryTest method testGetAsyncReplyMessage.

/**
 * Testing {@link GetAsyncReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testGetAsyncReplyMessage() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 07 " + "00 00 00 00 " + "00 00 00 07 " + "00 00 00 00 " + "00 00 00 0F " + "00 00 00 00");
    GetAsyncOutput builtByFactory = BufferHelper.deserialize(asyncFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong packetInMask", createPacketInMask(), builtByFactory.getPacketInMask());
    Assert.assertEquals("Wrong portStatusMask", createPortStatusMask(), builtByFactory.getPortStatusMask());
    Assert.assertEquals("Wrong flowRemovedMask", createFlowRemovedMask(), builtByFactory.getFlowRemovedMask());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) GetAsyncOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetAsyncOutput) Test(org.junit.Test)

Example 92 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 MultipartReplyExperimenterTest method testMultipartReplyExperimenter.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyExperimenter() {
    Mockito.when(registry.getDeserializer(Matchers.<MessageCodeKey>any())).thenReturn(vendorDeserializer);
    factory.injectDeserializerRegistry(registry);
    ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + // expID, expType
    "00 00 00 01 00 00 00 02");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    Mockito.verify(vendorDeserializer).deserialize(bb);
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 93 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 MultipartReplyGroupFeaturesTest method testMultipartReplyGroupFeatures2.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO
 * (with different group types and capabilities).
 */
@Test
public void testMultipartReplyGroupFeatures2() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 08 00 01 00 00 00 00 " + // types
    "00 00 00 00 " + // capabilities
    "00 00 00 00 " + // max groups
    "00 00 00 01 " + // max groups
    "00 00 00 02 " + // max groups
    "00 00 00 03 " + // max groups
    "00 00 00 04 " + // actions bitmap (all actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00 " + // actions bitmap (no actions included)
    "00 00 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 8, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyGroupFeaturesCase messageCase = (MultipartReplyGroupFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyGroupFeatures message = messageCase.getMultipartReplyGroupFeatures();
    Assert.assertEquals("Wrong group types", new GroupTypes(false, false, false, false), message.getTypes());
    Assert.assertEquals("Wrong capabilities", new GroupCapabilities(false, false, false, false), message.getCapabilities());
}
Also used : MultipartReplyGroupFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupFeaturesCase) GroupTypes(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes) GroupCapabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyGroupFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 94 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 BarrierReplyMessageFactoryTest method testVersions.

/**
 * Testing of {@link BarrierReplyMessageFactory} for correct header version.
 */
@Test
public void testVersions() {
    List<Byte> versions = new ArrayList<>(Arrays.asList(EncodeConstants.OF13_VERSION_ID, EncodeConstants.OF14_VERSION_ID, EncodeConstants.OF15_VERSION_ID));
    ByteBuf bb = BufferHelper.buildBuffer();
    testHeaderVersions(versions, bb);
    // OFP v1.0 need to be tested separately cause of different message type value
    messageCodeKey = new MessageCodeKey(EncodeConstants.OF10_VERSION_ID, 19, BarrierOutput.class);
    testHeaderVersions(Collections.singletonList(EncodeConstants.OF10_VERSION_ID), bb);
}
Also used : MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) BarrierOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput) DefaultDeserializerFactoryTest(org.opendaylight.openflowjava.protocol.impl.util.DefaultDeserializerFactoryTest) Test(org.junit.Test)

Example 95 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 ErrorMessageFactoryTest method testWithoutData2.

/**
 * Test of {@link ErrorMessageFactory} for correct translation into POJO
 * - not existing code used.
 */
@Test
public void testWithoutData2() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 FF FF");
    ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 01 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 02 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 2, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADACTION", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 03 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADINSTRUCTION", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 04 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 4, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADMATCH", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 05 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 5, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 06 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 6, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "GROUPMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 07 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 7, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "PORTMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 08 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 8, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "TABLEMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 09 FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 9, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "QUEUEOPFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0A FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "SWITCHCONFIGFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0B FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 11, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "ROLEREQUESTFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0C FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "METERMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0D FF FF");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 13, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 65535, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "TABLEFEATURESFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) 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