Search in sources :

Example 96 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 testWithIncorrectCodeEnum.

/**
 * Test of {@link ErrorMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithIncorrectCodeEnum() {
    ByteBuf bb = BufferHelper.buildBuffer("00 03 00 10 00 01 02 03");
    ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 16, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADINSTRUCTION", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertArrayEquals("Wrong data", new byte[] { 0x00, 0x01, 0x02, 0x03 }, 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)

Example 97 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 testWithoutData.

/**
 * Test of {@link ErrorMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithoutData() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 00");
    ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "INCOMPATIBLE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 01 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 1, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADREQUEST", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADVERSION", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 02 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 2, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADACTION", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADTYPE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 03 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADINSTRUCTION", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWNINST", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 04 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 4, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "BADMATCH", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADTYPE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 05 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 5, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 06 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 6, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "GROUPMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "GROUPEXISTS", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 07 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 7, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "PORTMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADPORT", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 08 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 8, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "TABLEMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADTABLE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 09 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 9, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "QUEUEOPFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADPORT", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0A 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 10, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "SWITCHCONFIGFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADFLAGS", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0B 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 11, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "ROLEREQUESTFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "STALE", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0C 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 12, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "METERMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 0D 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 13, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "TABLEFEATURESFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "BADTABLE", 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)

Example 98 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 testWithIncorrectTypeEnum.

/**
 * Test of {@link ErrorMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithIncorrectTypeEnum() {
    ByteBuf bb = BufferHelper.buildBuffer("00 20 00 05 00 01 02 03");
    ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 32, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 5, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "UNKNOWN_TYPE", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "UNKNOWN_CODE", builtByFactory.getCodeString());
    Assert.assertArrayEquals("Wrong data", new byte[] { 0x00, 0x01, 0x02, 0x03 }, 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)

Example 99 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 FeaturesReplyMessageFactoryTest method test.

/**
 * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 00 00 00 01 02 03");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
    Assert.assertEquals("Wrong buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
    Assert.assertEquals("Wrong number of tables", 0x01, builtByFactory.getTables().shortValue());
    Assert.assertEquals("Wrong auxiliaryId", 0x01, builtByFactory.getAuxiliaryId().shortValue());
    Assert.assertEquals("Wrong capabilities", new Capabilities(false, false, false, false, false, false, false), builtByFactory.getCapabilities());
    Assert.assertEquals("Wrong reserved", 0x00010203L, builtByFactory.getReserved().longValue());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 100 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 FeaturesReplyMessageFactoryTest method testCapabilities.

/**
 * Testing {@link FeaturesReplyMessageFactory} for correct translation into POJO
 * (capabilities set).
 */
@Test
public void testCapabilities() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 01 00 00 00" + " 00 01 6F 00 01 02 03");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong capabilities", new Capabilities(true, true, true, true, true, true, true), builtByFactory.getCapabilities());
}
Also used : GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) Capabilities(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities) 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