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.OxmIpv6ExtHdrSerializerTest.java

License:Open Source License

/**
 * Test correct serialization//from  ww  w. j a  v  a 2  s .co m
 */
@Test
public void testSerializeWithoutMask() {
    MatchEntryBuilder builder = prepareIpv6ExtHdrMatchEntry(false,
            new Ipv6ExthdrFlags(true, false, true, false, true, false, true, false, true));

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

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

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

License:Open Source License

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

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

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

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

License:Open Source License

/**
 * Test correct header serialization//  w  w  w .  j a  va  2 s.  co m
 */
@Test
public void testSerializeHeaderWithoutMask() {
    MatchEntryBuilder builder = prepareIpv6ExtHdrHeader(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.OxmIpv6ExtHdrSerializerTest.java

License:Open Source License

/**
 * Test correct header serialization/*ww w  . ja va 2s  .  c om*/
 */
@Test
public void testSerializeHeaderWithMask() {
    MatchEntryBuilder builder = prepareIpv6ExtHdrHeader(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.match.OxmIpv6NdSllSerializerTest.java

License:Open Source License

/**
 * Test correct serialization/*from   w  ww . j  a  v  a2 s .  co  m*/
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareMatchEntry("00:01:02:03:04:05");

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

    checkHeader(buffer, false);
    byte[] address = new byte[6];
    buffer.readBytes(address);
    Assert.assertArrayEquals("Wrong address", new byte[] { 0, 1, 2, 3, 4, 5 }, address);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

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

License:Open Source License

/**
 * Test correct serialization//from   w w  w  .jav  a 2  s.co  m
 */
@Test
public void testSerializeWithoutMask() {
    MatchEntryBuilder builder = prepareMatchEntry(false, "aaaa:bbbb:1111:2222::");

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

    checkHeader(buffer, false);
    Assert.assertEquals("Wrong ipv6 address", 43690, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 48059, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 4369, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 8738, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

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

License:Open Source License

/**
 * Test correct serialization//w  w  w . j a v  a  2s  .  c om
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareMatchEntry(false, "::aaaa:bbbb:1111:2222");

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

    checkHeader(buffer, false);
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 0, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 43690, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 48059, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 4369, buffer.readUnsignedShort());
    Assert.assertEquals("Wrong ipv6 address", 8738, buffer.readUnsignedShort());
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

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

License:Open Source License

/**
 * Test correct serialization// www .  j ava2s  .c om
 */
@Test
public void testSerializeWithoutMask() {
    MatchEntryBuilder builder = prepareMatchEntry(false, new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 });

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

    checkHeader(buffer, false);
    byte[] address = new byte[8];
    buffer.readBytes(address);
    Assert.assertArrayEquals("Wrong address", new byte[] { 0, 1, 2, 3, 4, 5, 6, 7 }, address);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

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

License:Open Source License

/**
 * Test correct serialization/*www.j av  a2 s.  co m*/
 */
@Test
public void testSerializeWithMask() {
    MatchEntryBuilder builder = prepareMatchEntry(true, new byte[] { 8, 9, 10, 11, 12, 13, 14, 15 });

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

    checkHeader(buffer, true);

    byte[] address = new byte[8];
    buffer.readBytes(address);
    Assert.assertArrayEquals("Wrong address", new byte[] { 8, 9, 10, 11, 12, 13, 14, 15 }, address);
    byte[] tmp = new byte[8];
    buffer.readBytes(tmp);
    Assert.assertArrayEquals("Wrong mask", new byte[] { 30, 30, 25, 25, 15, 15, 0, 0 }, tmp);
    assertTrue("Unexpected data", buffer.readableBytes() == 0);
}

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

License:Open Source License

/**
 * Test correct serialization/*from ww  w. j a v  a  2 s.  c o m*/
 */
@Test
public void testSerialize() {
    MatchEntryBuilder builder = prepareMplsBosMatchEntry(true);

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

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