import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(ip4PrefixBytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
@Test
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(ip6PrefixBytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
@Test
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(asNumberBytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
@Test
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(unnumberedBytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
@Test
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(pathKey32Bytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
@Test
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(pathKey128Bytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
@Test
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(labelBytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
@Test
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
assertArrayEquals(exrsBytes, ByteArray.getAllBytes(buff));
+
+ try {
+ parser.parseSubobject(null, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
+ try {
+ parser.parseSubobject(Unpooled.EMPTY_BUFFER, true);
+ fail();
+ } catch (final IllegalArgumentException e) {
+ assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
+ }
}
}