use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testSvecObject.
@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);
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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testOpenObjectWOTLV.
@Test
public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
final OpenBuilder builder = new OpenBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
builder.setVersion(new ProtocolVersion((short) 1));
builder.setKeepalive((short) 30);
builder.setDeadTimer((short) 120);
builder.setSessionId((short) 1);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, 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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testRPObjectWithTlv.
@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);
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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testLspaObjectSerializerDefence.
@Test
public void testLspaObjectSerializerDefence() throws IOException, PCEPDeserializerException {
final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
final LspaBuilder builder = new LspaBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setLocalProtectionDesired(false);
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.Src in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testMetricObject.
@Test
public void testMetricObject() throws IOException, PCEPDeserializerException {
final PCEPMetricObjectParser parser = new PCEPMetricObjectParser();
ByteBuf result = Unpooled.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());
}
}
Aggregations