List of usage examples for io.netty.buffer Unpooled EMPTY_BUFFER
ByteBuf EMPTY_BUFFER
To view the source code for io.netty.buffer Unpooled EMPTY_BUFFER.
Click Source Link
From source file:org.opendaylight.protocol.rsvp.parser.impl.XROSubobjectParserTest.java
License:Open Source License
@Test public void testXROAsNumberSubobject() throws RSVPParsingException { final XROAsNumberSubobjectParser parser = new XROAsNumberSubobjectParser(); final SubobjectContainerBuilder subs = new SubobjectContainerBuilder(); subs.setMandatory(true);/*from ww w. jav a2 s. co m*/ subs.setSubobjectType(new AsNumberCaseBuilder() .setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build()); assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(asNumberBytes, 2)), true)); final ByteBuf buff = Unpooled.buffer(); parser.serializeSubobject(subs.build(), buff); Assert.assertArrayEquals(asNumberBytes, ByteArray.getAllBytes(buff)); try { parser.parseSubobject(null, true); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage()); } try { parser.parseSubobject(Unpooled.EMPTY_BUFFER, true); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage()); } }
From source file:org.opendaylight.protocol.rsvp.parser.impl.XROSubobjectParserTest.java
License:Open Source License
@Test public void testXROPathKey32Subobject() throws RSVPParsingException { final XROPathKey32SubobjectParser parser = new XROPathKey32SubobjectParser(); final SubobjectContainerBuilder subs = new SubobjectContainerBuilder(); subs.setMandatory(true);/*from w w w. j a v a2 s . com*/ final PathKeyBuilder pBuilder = new PathKeyBuilder(); pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x50, (byte) 0x00 })); pBuilder.setPathKey(new PathKey(4660)); subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build()); assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(pathKey32Bytes, 2)), true)); final ByteBuf buff = Unpooled.buffer(); parser.serializeSubobject(subs.build(), buff); Assert.assertArrayEquals(pathKey32Bytes, ByteArray.getAllBytes(buff)); try { parser.parseSubobject(null, true); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage()); } try { parser.parseSubobject(Unpooled.EMPTY_BUFFER, true); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage()); } }
From source file:org.opendaylight.protocol.rsvp.parser.impl.XROSubobjectParserTest.java
License:Open Source License
@Test public void testXROPathKey128Subobject() throws RSVPParsingException { final XROPathKey128SubobjectParser parser128 = new XROPathKey128SubobjectParser(); final XROPathKey32SubobjectParser parser = new XROPathKey32SubobjectParser(); final SubobjectContainerBuilder subs = new SubobjectContainerBuilder(); subs.setMandatory(true);/* ww w. j a v a2 s .c o m*/ final PathKeyBuilder pBuilder = new PathKeyBuilder(); pBuilder.setPceId(new PceId(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0x12, (byte) 0x34, (byte) 0x54, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 })); pBuilder.setPathKey(new PathKey(4660)); subs.setSubobjectType(new PathKeyCaseBuilder().setPathKey(pBuilder.build()).build()); assertEquals(subs.build(), parser128.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(pathKey128Bytes, 2)), true)); final ByteBuf buff = Unpooled.buffer(); parser.serializeSubobject(subs.build(), buff); Assert.assertArrayEquals(pathKey128Bytes, ByteArray.getAllBytes(buff)); try { parser128.parseSubobject(null, true); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage()); } try { parser128.parseSubobject(Unpooled.EMPTY_BUFFER, true); Assert.fail(); } catch (final IllegalArgumentException e) { Assert.assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage()); } }
From source file:org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleEROSubobjectRegistryTest.java
License:Open Source License
@Test public void testUnrecognizedType() throws RSVPParsingException { final int wrongType = 99; assertNull(this.simpleEROSubobjectRegistry.parseSubobject(wrongType, this.input, false)); final ByteBuf output = Unpooled.EMPTY_BUFFER; final SubobjectContainer container = new SubobjectContainerBuilder() .setSubobjectType(new LabelCaseBuilder().build()).build(); this.simpleEROSubobjectRegistry.serializeSubobject(container, output); assertEquals(0, output.readableBytes()); }
From source file:org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleLabelRegistryTest.java
License:Open Source License
@Test public void testUnrecognizedType() throws RSVPParsingException { final int wrongLabelType = 99; assertNull(this.simpleLabelRegistry.parseLabel(wrongLabelType, this.input)); final ByteBuf output = Unpooled.EMPTY_BUFFER; this.simpleLabelRegistry.serializeLabel(false, false, new MockLabel(), output); assertEquals(0, output.readableBytes()); }
From source file:org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleLabelRegistryTest.java
License:Open Source License
@Test public void testParseLabel() throws RSVPParsingException { final LabelType output = this.simpleLabelRegistry.parseLabel(cTypeOne, this.input); assertNotNull(output);/*from w ww. j av a 2s . co m*/ assertTrue(output instanceof MockLabel); final ByteBuf aggregator = Unpooled.EMPTY_BUFFER; this.simpleLabelRegistry.serializeLabel(false, false, output, aggregator); Mockito.verify(this.labelSerializer).serializeLabel(false, false, output, aggregator); }
From source file:org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleRROSubobjectRegistryTest.java
License:Open Source License
@Test public void testUnrecognizedType() throws RSVPParsingException { final int wrongType = 99; assertNull(this.simpleRROSubobjectRegistry.parseSubobject(wrongType, this.input)); final ByteBuf output = Unpooled.EMPTY_BUFFER; final SubobjectContainer container = new SubobjectContainerBuilder() .setSubobjectType(new LabelCaseBuilder().build()).build(); this.simpleRROSubobjectRegistry.serializeSubobject(container, output); assertEquals(0, output.readableBytes()); }
From source file:org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleRSVPObjectRegistryTest.java
License:Open Source License
@Test public void testUnrecognizedType() throws RSVPParsingException { final int wrongType = 99; assertNull(this.simpleRSVPObjectRegistry.parseRSPVTe(wrongType, this.subObjectCTypeOne, this.input)); final ByteBuf output = Unpooled.EMPTY_BUFFER; this.simpleRSVPObjectRegistry.serializeRSPVTe(new SecondaryExplicitRouteObjectBuilder().build(), output); assertEquals(0, output.readableBytes()); }
From source file:org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleRSVPObjectRegistryTest.java
License:Open Source License
@Test public void testParseRSVP() throws RSVPParsingException { final RsvpTeObject output = this.simpleRSVPObjectRegistry.parseRSPVTe(this.subObjectTypeOne, this.subObjectCTypeOne, this.input); assertNotNull(output);// ww w . j ava 2 s . c o m assertTrue(output instanceof SecondaryExplicitRouteObject); final ByteBuf aggregator = Unpooled.EMPTY_BUFFER; this.simpleRSVPObjectRegistry.serializeRSPVTe(output, aggregator); Mockito.verify(this.rsvpTeObjectSerializer).serializeObject(output, aggregator); }
From source file:org.opendaylight.protocol.rsvp.parser.spi.pojo.SimpleXROSubobjectRegistryTest.java
License:Open Source License
@Test public void testUnrecognizedType() throws RSVPParsingException { final int wrongType = 99; assertNull(this.simpleXROSubobjectRegistry.parseSubobject(wrongType, this.input, false)); final ByteBuf output = Unpooled.EMPTY_BUFFER; final SubobjectContainer container = new SubobjectContainerBuilder() .setSubobjectType(new LabelCaseBuilder().build()).build(); this.simpleXROSubobjectRegistry.serializeSubobject(container, output); assertEquals(0, output.readableBytes()); }