Example usage for io.netty.buffer Unpooled EMPTY_BUFFER

List of usage examples for io.netty.buffer Unpooled EMPTY_BUFFER

Introduction

In this page you can find the example usage for io.netty.buffer Unpooled EMPTY_BUFFER.

Prototype

ByteBuf EMPTY_BUFFER

To view the source code for io.netty.buffer Unpooled EMPTY_BUFFER.

Click Source Link

Document

A buffer whose capacity is 0 .

Usage

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testEndPointsObjectIPv4() throws IOException, PCEPDeserializerException {
    final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
    final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };

    final PCEPEndPointsIpv4ObjectParser parser = new PCEPEndPointsIpv4ObjectParser();
    final ByteBuf result = Unpooled
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject1IPv4.bin"));

    final EndpointsObjBuilder builder = new EndpointsObjBuilder();
    builder.setProcessingRule(true);/*  www.  j  a v a2  s .c  o  m*/
    builder.setIgnore(false);
    builder.setAddressFamily(
            new Ipv4CaseBuilder()
                    .setIpv4(new Ipv4Builder()
                            .setSourceIpv4Address(
                                    Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
                            .setDestinationIpv4Address(
                                    Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(destIPBytes)))
                            .build())
                    .build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testEndPointsObjectIPv6() throws IOException, PCEPDeserializerException {
    final byte[] destIPBytes = { (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC,
            (byte) 0xA1, (byte) 0xB6, (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00,
            (byte) 0x00, (byte) 0x00, (byte) 0x00, };
    final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
            (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
            (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };

    final PCEPEndPointsIpv6ObjectParser parser = new PCEPEndPointsIpv6ObjectParser();
    final ByteBuf result = Unpooled
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPEndPointsObject2IPv6.bin"));

    final EndpointsObjBuilder builder = new EndpointsObjBuilder();
    builder.setProcessingRule(true);//from  ww w.  j  ava  2  s .  c om
    builder.setIgnore(false);
    builder.setAddressFamily(
            new Ipv6CaseBuilder()
                    .setIpv6(new Ipv6Builder()
                            .setSourceIpv6Address(
                                    Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
                            .setDestinationIpv6Address(
                                    Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(destIPBytes)))
                            .build())
                    .build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin"));

    final ErrorObjectBuilder builder = new ErrorObjectBuilder();
    builder.setProcessingRule(true);//from w  ww. j a  v a 2 s .  co  m
    builder.setIgnore(true);
    builder.setType((short) 1);
    builder.setValue((short) 1);

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPErrorObject3.bin"));

    builder.setType((short) 7);
    builder.setValue((short) 0);
    builder.setTlvs(new TlvsBuilder()
            .setReqMissing(new ReqMissingBuilder().setRequestId(new RequestId(0x00001155L)).build()).build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
    final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled/*w ww  . j  a va2 s  .c  o m*/
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));

    final LspaBuilder builder = new LspaBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setExcludeAny(new AttributeFilter(0L));
    builder.setIncludeAny(new AttributeFilter(0L));
    builder.setIncludeAll(new AttributeFilter(0L));
    builder.setHoldPriority((short) 0);
    builder.setSetupPriority((short) 0);
    builder.setLocalProtectionDesired(false);
    builder.setTlvs(
            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder()
                    .build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject2UpperBounds.bin"));

    builder.setExcludeAny(new AttributeFilter(0xFFFFFFFFL));
    builder.setIncludeAny(new AttributeFilter(0xFFFFFFFFL));
    builder.setIncludeAll(new AttributeFilter(0xFFFFFFFFL));
    builder.setHoldPriority((short) 0xFF);
    builder.setSetupPriority((short) 0xFF);
    builder.setLocalProtectionDesired(true);

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testMetricObject() throws IOException, PCEPDeserializerException {
    final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
    ByteBuf result = Unpooled/*ww  w  .j ava  2 s  . com*/
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin"));

    final MetricBuilder builder = new MetricBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setComputed(false);
    builder.setBound(false);
    builder.setMetricType((short) 1);
    builder.setValue(new Float32(new byte[] { 0, 0, 0, 0 }));

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    result = Unpooled
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPMetricObject2UpperBounds.bin"));

    builder.setComputed(true);
    builder.setBound(false);
    builder.setMetricType((short) 2);
    builder.setValue(new Float32(new byte[] { (byte) 0x4f, (byte) 0x70, (byte) 0x00, (byte) 0x00 }));

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry, this.viTlvRegistry);
    ByteBuf result = Unpooled/*  w ww .  j a  va  2  s. co  m*/
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));

    final NoPathBuilder builder = new NoPathBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setNatureOfIssue((short) 1);
    builder.setUnsatisfiedConstraints(true);
    builder.setTlvs(
            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder()
                    .build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject2WithTLV.bin"));

    builder.setNatureOfIssue((short) 0);
    builder.setUnsatisfiedConstraints(false);

    final NoPathVectorBuilder b = new NoPathVectorBuilder();
    b.setFlags(
            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.NoPathVectorTlv.Flags(
                    false, true, false, true, false, true, true, true));
    builder.setTlvs(
            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder()
                    .setNoPathVector(b.build()).build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry,
            this.viTlvRegistry);
    ByteBuf result = Unpooled//from   w ww.  j a v a2s . c  om
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin"));

    final CNotificationBuilder builder = new CNotificationBuilder();
    builder.setProcessingRule(true);
    builder.setIgnore(true);
    builder.setType((short) 0xff);
    builder.setValue((short) 0xff);

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    result = Unpooled
            .wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject1WithTlv.bin"));

    builder.setType((short) 2);
    builder.setValue((short) 1);
    builder.setTlvs(
            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.c.notification.TlvsBuilder()
                    .setOverloadDuration(new OverloadDurationBuilder().setDuration(0xff0000a2L).build())
                    .build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
    final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry,
            this.viTlvRegistry);
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin"));

    final RpBuilder builder = new RpBuilder();
    builder.setProcessingRule(true);//from www. java 2  s. co  m
    builder.setIgnore(true);
    builder.setReoptimization(true);
    builder.setBiDirectional(false);
    builder.setLoose(true);
    builder.setMakeBeforeBreak(true);
    builder.setOrder(false);
    builder.setPathKey(false);
    builder.setSupplyOf(false);
    builder.setFragmentation(false);
    builder.setP2mp(false);
    builder.setEroCompression(false);
    builder.setPriority((short) 5);
    builder.setRequestId(new RequestId(0xdeadbeefL));
    builder.setTlvs(
            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder()
                    .build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRPObject2.bin"));

    builder.setReoptimization(false);
    builder.setFragmentation(true);
    builder.setEroCompression(true);

    final OrderBuilder b = new OrderBuilder();
    b.setDelete(0xffffffffL);
    b.setSetup(1L);

    builder.setTlvs(
            new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder()
                    .setOrder(b.build()).build());

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testSvecObject() throws IOException, PCEPDeserializerException {
    final PCEPSvecObjectParser parser = new PCEPSvecObjectParser();
    ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));

    final SvecBuilder builder = new SvecBuilder();
    builder.setProcessingRule(false);// ww  w. j  ava 2  s  .  com
    builder.setIgnore(false);
    builder.setLinkDiverse(false);
    builder.setNodeDiverse(false);
    builder.setSrlgDiverse(false);
    builder.setRequestsIds(Lists.newArrayList(new RequestId(0xFFL)));

    assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
            result.slice(4, result.readableBytes() - 4)));
    ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject1_10ReqIDs.bin"));

    builder.setProcessingRule(true);
    builder.setLinkDiverse(true);
    builder.setSrlgDiverse(true);

    final List<RequestId> requestIDs = Lists.newArrayList();
    requestIDs.add(new RequestId(0xFFFFFFFFL));
    requestIDs.add(new RequestId(0x00000001L));
    requestIDs.add(new RequestId(0x01234567L));
    requestIDs.add(new RequestId(0x89ABCDEFL));
    requestIDs.add(new RequestId(0xFEDCBA98L));
    requestIDs.add(new RequestId(0x76543210L));
    requestIDs.add(new RequestId(0x15825266L));
    requestIDs.add(new RequestId(0x48120BBEL));
    requestIDs.add(new RequestId(0x25FB7E52L));
    requestIDs.add(new RequestId(0xB2F2546BL));

    builder.setRequestsIds(requestIDs);

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
    buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}

From source file:org.opendaylight.protocol.pcep.impl.PCEPObjectParserTest.java

License:Open Source License

@Test
public void testClassTypeObject() throws PCEPDeserializerException {
    final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
    final ByteBuf result = Unpooled.wrappedBuffer(
            new byte[] { (byte) 0x16, (byte) 0x12, (byte) 0x00, (byte) 0x08, 0, 0, 0, (byte) 0x04 });

    final ClassTypeBuilder builder = new ClassTypeBuilder();
    builder.setProcessingRule(true);//  w ww . j  a v  a 2s .  c  om
    builder.setIgnore(false);
    builder.setClassType(new ClassType((short) 4));

    assertEquals(builder.build(),
            parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
    final ByteBuf buf = Unpooled.buffer();
    parser.serializeObject(builder.build(), buf);
    assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));

    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), null);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
    try {
        parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
        fail();
    } catch (final IllegalArgumentException e) {
        assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
    }
}