List of usage examples for io.netty.buffer ByteBuf readShort
public abstract short readShort();
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactoryTest.java
License:Open Source License
@Test public void testFlowSerialize() throws Exception { MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setFlags(new MultipartRequestFlags(true)); builder.setType(MultipartType.forValue(1)); MultipartReplyFlowCaseBuilder flowCase = new MultipartReplyFlowCaseBuilder(); MultipartReplyFlowBuilder flow = new MultipartReplyFlowBuilder(); flow.setFlowStats(createFlowStats()); flowCase.setMultipartReplyFlow(flow.build()); builder.setMultipartReplyBody(flowCase.build()); MultipartReplyMessage message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 192); Assert.assertEquals("Wrong type", MultipartType.OFPMPFLOW.getIntValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort())); serializedBuffer.skipBytes(PADDING); testFlowBody(message.getMultipartReplyBody(), serializedBuffer); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartReplyMessageFactoryTest.java
License:Open Source License
@Test public void testDescSerialize() throws Exception { MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setFlags(new MultipartRequestFlags(true)); builder.setType(MultipartType.forValue(0)); MultipartReplyDescCaseBuilder descCase = new MultipartReplyDescCaseBuilder(); MultipartReplyDescBuilder desc = new MultipartReplyDescBuilder(); desc.setMfrDesc("Test"); desc.setHwDesc("Test"); desc.setSwDesc("Test"); desc.setSerialNum("12345"); desc.setDpDesc("Test"); descCase.setMultipartReplyDesc(desc.build()); builder.setMultipartReplyBody(descCase.build()); MultipartReplyMessage message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 1072); Assert.assertEquals("Wrong type", MultipartType.OFPMPDESC.getIntValue(), serializedBuffer.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort())); serializedBuffer.skipBytes(PADDING); Assert.assertEquals("Wrong desc body", message.getMultipartReplyBody(), decodeDescBody(serializedBuffer)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception/*w w w . j a va2 s . c o m*/ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestInputFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(1)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestFlow()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong flow", message.getMultipartRequestBody(), decodeRequestFlow(out)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception/*from w w w .j ava 2 s.c o m*/ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestInputAggregateBodyFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(2)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestAggregate()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong aggregate", message.getMultipartRequestBody(), decodeRequestAggregate(out)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception/* w w w . j a v a 2 s.c o m*/ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestInputTableFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(3)); builder.setFlags(new MultipartRequestFlags(true)); //multipart request for table does not have body MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception//from w w w. j av a2 s .c o m * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestPortStatsMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(4)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestPortStats()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong portStatsBody", message.getMultipartRequestBody(), decodeRequestPortStats(out)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception/*from w w w . j a va 2 s . c o m*/ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestQueueMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(5)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestQueue()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong queueBody", message.getMultipartRequestBody(), decodeRequestQueue(out)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception// w w w . j av a 2 s .c o m * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestGroupMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(6)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestGroup()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong groupBody", message.getMultipartRequestBody(), decodeRequestGroup(out)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception// w w w . j a v a 2 s . co m * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestMeterMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(9)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestMeter()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong meterBody", message.getMultipartRequestBody(), decodeRequestMeter(out)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception/*from w w w. jav a 2 s. c o m*/ * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestMeterConfigMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(10)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestMeterConfig()); MultipartRequestInput message = builder.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); MultipartRequestInputFactory factory = MultipartRequestInputFactory.getInstance(); factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message); BufferHelper.checkHeaderV13(out, factory.getMessageType(), factory.computeLength(message)); Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong meterConfigBody", message.getMultipartRequestBody(), decodeRequestMeterConfig(out)); }