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 testLspaObject.
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
ByteBuf result = Unpooled.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());
}
}
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 PCEPValidatorTest method testRepWithMonitoring.
@Test
public void testRepWithMonitoring() throws IOException, PCEPDeserializerException {
final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder rBuilder = new RepliesBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRepMon.5.bin"));
final List<Replies> replies4 = Lists.newArrayList();
rBuilder = new RepliesBuilder();
rBuilder.setRp(this.rpTrue);
rBuilder.setMonitoring(this.monitoring);
rBuilder.setPccIdReq(this.pccIdReq);
rBuilder.setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build()));
final List<Paths> paths = Lists.newArrayList();
final PathsBuilder paBuilder = new PathsBuilder();
paBuilder.setEro(this.ero);
paBuilder.setLspa(this.lspa);
paBuilder.setMetrics(Lists.newArrayList(this.metrics));
paBuilder.setIro(this.iro);
paBuilder.setOf(this.of);
paths.add(paBuilder.build());
rBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
replies4.add(rBuilder.build());
builder.setReplies(replies4);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
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 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.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 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.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 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