Example usage for io.netty.buffer PooledByteBufAllocator DEFAULT

List of usage examples for io.netty.buffer PooledByteBufAllocator DEFAULT

Introduction

In this page you can find the example usage for io.netty.buffer PooledByteBufAllocator DEFAULT.

Prototype

PooledByteBufAllocator DEFAULT

To view the source code for io.netty.buffer PooledByteBufAllocator DEFAULT.

Click Source Link

Usage

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmTcpSrcSerializerTest.java

License:Open Source License

/**
 * Test correct serialization/*from   w  ww.ja  v a2 s . co m*/
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareMatchEntry(512);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, false);
    assertEquals("Wrong value", 512, buffer.readUnsignedShort());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpDstSerializerTest.java

License:Open Source License

/**
 * Test correct serialization//w  w  w.  j  a v a2  s. c o  m
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareMatchEntry(2048);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, false);
    assertEquals("Wrong value", 2048, buffer.readUnsignedShort());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmUdpSrcSerializerTest.java

License:Open Source License

/**
 * Test correct serialization//from   ww w  . j ava2s  .c om
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareMatchEntry(1024);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, false);
    assertEquals("Wrong value", 1024, buffer.readUnsignedShort());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializerTest.java

License:Open Source License

/**
 * Test correct serialization//from w  ww .  j a v  a  2  s.com
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareVlanPcpMatchEntry((short) 42);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, false);
    assertEquals("Wrong value", 42, buffer.readUnsignedByte());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanPcpSerializerTest.java

License:Open Source License

/**
 * Test correct header serialization/*from ww w .  ja  va 2s.c  o  m*/
 */
@Test
public void testSerializeHeader() {
    MatchEntryBuilder builder = prepareVlanPcpHeader(false);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serializeHeader(builder.build(), buffer);

    checkHeader(buffer, false);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializerTest.java

License:Open Source License

/**
 * Test correct serialization//  w  ww . j a va 2s .c  o m
 */
@Test
public void testSerializeWithCfiBitSet() {
    MatchEntryBuilder builder = prepareVlanVidMatchEntry(false, true);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, false);
    assertEquals("Wrong value", 4596, buffer.readUnsignedShort());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializerTest.java

License:Open Source License

/**
 * Test correct serialization//from  w  w  w  . j av  a  2  s  .  co m
 */
@Test
public void testSerializeWithoutCfiBitSet() {
    MatchEntryBuilder builder = prepareVlanVidMatchEntry(true, false);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serialize(builder.build(), buffer);

    checkHeader(buffer, true);
    assertEquals("Wrong value", 500, buffer.readUnsignedShort());
    byte[] tmp = new byte[2];
    buffer.readBytes(tmp);
    Assert.assertArrayEquals("Wrong mask", new byte[] { 15, 15 }, tmp);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializerTest.java

License:Open Source License

/**
 * Test correct header serialization// www  .  ja va2 s  . co m
 */
@Test
public void testSerializeHeaderWithoutMask() {
    MatchEntryBuilder builder = prepareVlanVidHeader(false);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serializeHeader(builder.build(), buffer);

    checkHeader(buffer, false);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.match.OxmVlanVidSerializerTest.java

License:Open Source License

/**
 * Test correct header serialization//from w w  w  . ja v  a2s. co  m
 */
@Test
public void testSerializeHeaderWithMask() {
    MatchEntryBuilder builder = prepareVlanVidHeader(true);

    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    serializer.serializeHeader(builder.build(), buffer);

    checkHeader(buffer, true);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

From source file:org.opendaylight.openflowjava.protocol.impl.serialization.SerializationFactoryTest.java

License:Open Source License

/**
 * Test serializer lookup & serialization
 *///w  w w.j  av  a  2 s.  c om
@Test
public void test() {
    SerializerRegistry registry = new SerializerRegistryImpl();
    registry.init();
    SerializationFactory factory = new SerializationFactory();
    factory.setSerializerTable(registry);
    ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
    HelloInputBuilder helloBuilder = new HelloInputBuilder();
    helloBuilder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    helloBuilder.setXid(123456L);
    helloBuilder.setElements(null);
    factory.messageToBuffer(EncodeConstants.OF10_VERSION_ID, buffer, helloBuilder.build());
    assertEquals("Serialization failed", EncodeConstants.OFHEADER_SIZE, buffer.readableBytes());
}