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());
}
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());
}
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());
}
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());
}
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);
}
Aggregations