List of usage examples for io.netty.buffer UnpooledByteBufAllocator DEFAULT
UnpooledByteBufAllocator DEFAULT
To view the source code for io.netty.buffer UnpooledByteBufAllocator DEFAULT.
Click Source Link
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception//w w w .j a v a2s . 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 v a2 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/*from w w w . j a v a2s . 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 a2s. c o 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 . ja v a2s. 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)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception//ww w . j ava 2 s .c om * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestExperimenterMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(0xffff)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestExperimenter()); 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.readUnsignedShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); out.skipBytes(PADDING_IN_MULTIPART_REQUEST_MESSAGE); Assert.assertEquals("Wrong experimenterBody", message.getMultipartRequestBody(), decodeRequestExperimenter(out)); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.MultipartRequestInputFactoryTest.java
License:Open Source License
/** * @throws Exception// w w w.j a va 2 s . c o m * Testing of {@link MultipartRequestInputFactory} for correct translation from POJO */ @Test public void testMultipartRequestDescMessageFactory() throws Exception { MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setType(MultipartType.forValue(0)); builder.setFlags(new MultipartRequestFlags(true)); builder.setMultipartRequestBody(createRequestDesc()); 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.readUnsignedShort()); Assert.assertEquals("Wrong flags", message.getFlags(), decodeMultipartRequestFlags(out.readShort())); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierInputMessageFactoryTest.java
License:Open Source License
/** * Testing of {@link OF10BarrierInputMessageFactory} for correct translation from POJO * @throws Exception /*from w w w .j av a 2 s. c o m*/ */ @Test public void test() throws Exception { BarrierInputBuilder bib = new BarrierInputBuilder(); BufferHelper.setupHeader(bib, EncodeConstants.OF10_VERSION_ID); BarrierInput bi = bib.build(); ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer(); OF10BarrierInputMessageFactory bimf = OF10BarrierInputMessageFactory.getInstance(); bimf.messageToBuffer(EncodeConstants.OF10_VERSION_ID, out, bi); BufferHelper.checkHeaderV10(out, (byte) 18, 8); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10BarrierReplyMessageFactoryTest.java
License:Open Source License
@Test public void testSerialize() throws Exception { BarrierOutputBuilder builder = new BarrierOutputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); BarrierOutput message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 8); }
From source file:org.opendaylight.openflowjava.protocol.impl.serialization.factories.OF10FeaturesReplyMessageFactoryTest.java
License:Open Source License
@Test public void testSerialize() throws Exception { GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setDatapathId(BigInteger.valueOf(1L)); builder.setBuffers(1L);/* w ww. j a va 2s .c o m*/ builder.setTables((short) 1); builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false)); builder.setActionsV10(new ActionTypeV10(true, false, true, false, true, false, true, false, true, false, true, false, true)); builder.setPhyPort(createPorts()); GetFeaturesOutput message = builder.build(); ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer(); factory.serialize(message, serializedBuffer); BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80); Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong()); Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(), serializedBuffer.readUnsignedInt()); Assert.assertEquals("Wrong n tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte()); serializedBuffer.skipBytes(3); Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(), createCapabilities(serializedBuffer.readInt())); Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt())); PhyPort port = message.getPhyPort().get(0); Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort()); byte[] address = new byte[6]; serializedBuffer.readBytes(address); Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase()); byte[] name = new byte[16]; serializedBuffer.readBytes(name); Assert.assertEquals("Wrong name", port.getName(), new String(name).trim()); Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt())); Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt())); Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt())); }