Search in sources :

Example 21 with ErrorMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.

the class OF10ErrorMessageFactoryTest method testWithData.

/**
 * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithData() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");
    ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 1, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "EPERM", 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 22 with ErrorMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.

the class OF10ErrorMessageFactoryTest method testWithIncorrectCodeEnum.

/**
 * Test of {@link OF10ErrorMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithIncorrectCodeEnum() {
    ByteBuf bb = BufferHelper.buildBuffer("00 03 00 06 00 01 02 03");
    ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 6, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "FLOWMODFAILED", 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 23 with ErrorMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.

the class OF10ErrorMessageFactoryTest 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.checkHeaderV10(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.checkHeaderV10(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.checkHeaderV10(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.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 3, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 0, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "FLOWMODFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "ALLTABLESFULL", builtByFactory.getCodeString());
    Assert.assertNull("Data is not null", builtByFactory.getData());
    bb = BufferHelper.buildBuffer("00 04 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 4, 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 05 00 00");
    builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong type", 5, 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());
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) Test(org.junit.Test)

Example 24 with ErrorMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.

the class ErrorMessageFactoryTest method testWithData.

/**
 * Test of {@link ErrorMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithData() {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 01 00 01 02 03");
    ErrorMessage builtByFactory = BufferHelper.deserialize(errorFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 0, builtByFactory.getType().intValue());
    Assert.assertEquals("Wrong code", 1, builtByFactory.getCode().intValue());
    Assert.assertEquals("Wrong type string", "HELLOFAILED", builtByFactory.getTypeString());
    Assert.assertEquals("Wrong code string", "EPERM", 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 25 with ErrorMessage

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage in project openflowplugin by opendaylight.

the class ErrorMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    ErrorMessageBuilder builder = new ErrorMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setType(10);
    builder.setCode(20);
    byte[] data = ByteBufUtils.hexStringToBytes("00 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14");
    builder.setData(data);
    ErrorMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 28);
    Assert.assertEquals("Wrong Type", message.getType().intValue(), serializedBuffer.readShort());
    Assert.assertEquals("Wrong Code", message.getCode().intValue(), serializedBuffer.readShort());
    byte[] readData = new byte[serializedBuffer.readableBytes()];
    serializedBuffer.readBytes(readData);
    Assert.assertArrayEquals("Wrong data", message.getData(), readData);
}
Also used : ErrorMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder) ErrorMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)17 ErrorMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessage)17 ByteBuf (io.netty.buffer.ByteBuf)14 ErrorMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ErrorMessageBuilder)7 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)6 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)5 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)5 RpcError (org.opendaylight.yangtools.yang.common.RpcError)5 ArrayList (java.util.ArrayList)4 VpnInstance (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstance)4 ExecutionException (java.util.concurrent.ExecutionException)3 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)3 ErrorType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 DeviceRequestFailedException (org.opendaylight.openflowjava.protocol.api.connection.DeviceRequestFailedException)1 VpnInstanceKey (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.instances.VpnInstanceKey)1 AssociateNetworksOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutput)1 AssociateNetworksOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutputBuilder)1 CreateEVPNOutputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.CreateEVPNOutputBuilder)1