use of org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator in project bgpcep by opendaylight.
the class PCEPValidatorTest method testUnexpectedRroObjectInPcUpdMsg.
@Test
public void testUnexpectedRroObjectInPcUpdMsg() throws PCEPDeserializerException {
final byte[] badUpdateMsg = { (byte) 0x20, (byte) 0x0b, (byte) 0x00, (byte) 0x50, /* SRP, LSP and ERO objects */
(byte) 0x21, (byte) 0x12, (byte) 0x00, (byte) 0x0c, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x20, (byte) 0x10, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x10, (byte) 0x09, (byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x14, (byte) 0x01, (byte) 0x08, (byte) 0x05, (byte) 0x05, (byte) 0x05, (byte) 0x03, (byte) 0x18, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x08, (byte) 0x04, (byte) 0x18, (byte) 0x00, /* RRO object */
(byte) 0x08, (byte) 0x10, (byte) 0x00, (byte) 0x24, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x00, (byte) 0x83, (byte) 0x20, (byte) 0x20, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x08, (byte) 0x0a, (byte) 0x00, (byte) 0x09, (byte) 0xde, (byte) 0x20, (byte) 0x00, (byte) 0x03, (byte) 0x08, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator()) {
a.start(this.ctx);
final Stateful07PCUpdateRequestMessageParser parser = new Stateful07PCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
final PcerrMessageBuilder errMsgBuilder = new PcerrMessageBuilder();
errMsgBuilder.setErrors(Lists.newArrayList(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType((short) 6).setValue((short) 10).build()).build()));
final PcerrBuilder builder = new PcerrBuilder();
builder.setPcerrMessage(errMsgBuilder.build());
final ByteBuf buf = Unpooled.wrappedBuffer(badUpdateMsg);
final List<Message> errors = Lists.newArrayList();
parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
assertFalse(errors.isEmpty());
assertEquals(builder.build(), errors.get(0));
}
}
use of org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator in project bgpcep by opendaylight.
the class PCEPValidatorTest method testUpdMsg.
@Test
public void testUpdMsg() throws IOException, PCEPDeserializerException {
try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator()) {
a.start(this.ctx);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.2.bin"));
final Stateful07PCUpdateRequestMessageParser parser = new Stateful07PCUpdateRequestMessageParser(this.ctx.getObjectHandlerRegistry());
final PcupdMessageBuilder builder = new PcupdMessageBuilder();
final List<Updates> updates = Lists.newArrayList();
final PathBuilder pBuilder = new PathBuilder();
pBuilder.setEro(this.ero);
pBuilder.setLspa(this.lspa);
updates.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
builder.setUpdates(updates);
assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCUpd.5.bin"));
final List<Updates> updates1 = Lists.newArrayList();
final PathBuilder pBuilder1 = new PathBuilder();
pBuilder1.setEro(this.ero);
pBuilder1.setLspa(this.lspa);
updates1.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
updates1.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder1.build()).build());
builder.setUpdates(updates1);
assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
}
use of org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator in project bgpcep by opendaylight.
the class PCEPValidatorTest method testMissingLspObjectErrorInPcRptMsg.
@Test
public void testMissingLspObjectErrorInPcRptMsg() throws PCEPDeserializerException {
final byte[] statefulMsg = { (byte) 0x20, (byte) 0x0B, (byte) 0x00, (byte) 0x1C, /* srp-object */
(byte) 0x21, (byte) 0x10, (byte) 0x00, (byte) 0x0C, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x001, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, /* sr-ero-object */
(byte) 0x07, (byte) 0x10, (byte) 0x00, (byte) 0x0C, /* ipv4 prefix subobject */
(byte) 0x81, (byte) 0x08, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x16, (byte) 0x00 };
try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator();
StatefulActivator b = new StatefulActivator()) {
a.start(this.ctx);
b.start(this.ctx);
final Stateful07PCReportMessageParser parser = new Stateful07PCReportMessageParser(this.ctx.getObjectHandlerRegistry());
final PcerrMessageBuilder errMsgBuilder = new PcerrMessageBuilder();
errMsgBuilder.setErrors(Lists.newArrayList(new ErrorsBuilder().setErrorObject(new ErrorObjectBuilder().setType((short) 6).setValue((short) 8).build()).build()));
final PcerrBuilder builder = new PcerrBuilder();
builder.setPcerrMessage(errMsgBuilder.build());
final ByteBuf buf = Unpooled.wrappedBuffer(statefulMsg);
final List<Message> errors = Lists.newArrayList();
parser.parseMessage(buf.slice(4, buf.readableBytes() - 4), errors);
assertFalse(errors.isEmpty());
assertEquals(builder.build(), errors.get(0));
}
}
use of org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator in project bgpcep by opendaylight.
the class PCEPValidatorTest method testPcinitMsg.
@Test
public void testPcinitMsg() throws IOException, PCEPDeserializerException {
try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator()) {
a.start(this.ctx);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/Pcinit.bin"));
final CInitiated00PCInitiateMessageParser parser = new CInitiated00PCInitiateMessageParser(this.ctx.getObjectHandlerRegistry());
final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
final RequestsBuilder rBuilder = new RequestsBuilder();
final List<Requests> reqs = Lists.newArrayList();
rBuilder.setSrp(this.srp);
rBuilder.setLsp(this.lspSrp);
rBuilder.setEro(this.ero);
rBuilder.setLspa(this.lspa);
rBuilder.setMetrics(Lists.newArrayList(this.metrics));
rBuilder.setIro(this.iro);
reqs.add(rBuilder.build());
builder.setRequests(reqs);
assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
}
use of org.opendaylight.protocol.pcep.ietf.initiated00.CrabbeInitiatedActivator in project bgpcep by opendaylight.
the class PCEPValidatorTest method testRptMsg.
@Test
public void testRptMsg() throws IOException, PCEPDeserializerException {
try (CrabbeInitiatedActivator a = new CrabbeInitiatedActivator();
StatefulActivator b = new StatefulActivator()) {
a.start(this.ctx);
b.start(this.ctx);
ByteBuf result = Unpooled.wrappedBuffer(PCRT1);
final Stateful07PCReportMessageParser parser = new Stateful07PCReportMessageParser(this.ctx.getObjectHandlerRegistry());
final PcrptMessageBuilder builder = new PcrptMessageBuilder();
final List<Reports> reports = Lists.newArrayList();
reports.add(new ReportsBuilder().setLsp(this.lsp).build());
builder.setReports(reports);
final Message parseResult = parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList());
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parseResult);
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(PCRT2);
final List<Reports> reports1 = Lists.newArrayList();
reports1.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build());
builder.setReports(reports1);
final ByteBuf input = result.slice(4, result.readableBytes() - 4);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input, Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.3.bin"));
final List<Reports> reports2 = Lists.newArrayList();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder pBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder();
pBuilder.setEro(this.ero);
pBuilder.setLspa(this.lspa);
pBuilder.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
pBuilder.setRro(this.rro);
reports2.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
builder.setReports(reports2);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRpt.5.bin"));
final List<Reports> reports3 = Lists.newArrayList();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder pBuilder1 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder();
pBuilder1.setEro(this.ero);
pBuilder1.setLspa(this.lspa);
pBuilder1.setMetrics(Lists.newArrayList(this.metrics, this.metrics));
pBuilder1.setRro(this.rro);
reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder.build()).build());
reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lspSrp).setPath(pBuilder1.build()).build());
builder.setReports(reports3);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(PCRT3);
final List<Reports> reports4 = Lists.newArrayList();
reports4.add(new ReportsBuilder().setLsp(this.lsp).setPath(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.PathBuilder().setEro(this.ero).setLspa(this.lspa).setBandwidth(this.bandwidth).setReoptimizationBandwidth(this.reoptimizationBandwidth).build()).build());
builder.setReports(reports4);
final ByteBuf input2 = result.slice(4, result.readableBytes() - 4);
assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(input2, Collections.emptyList()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
}
Aggregations