use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder in project bgpcep by opendaylight.
the class RegistryTest method testRegistry.
@Test
public void testRegistry() throws PCEPDeserializerException {
this.regs.add(this.ctx.registerXROSubobjectParser(2, this.xroParser));
this.regs.add(this.ctx.registerXROSubobjectSerializer(AsNumberCase.class, this.xroSerializer));
this.regs.add(this.ctx.registerRROSubobjectParser(3, this.rroParser));
this.regs.add(this.ctx.registerRROSubobjectSerializer(LabelCase.class, this.rroSerializer));
this.regs.add(this.ctx.registerEROSubobjectParser(4, this.eroParser));
this.regs.add(this.ctx.registerEROSubobjectSerializer(IpPrefixCase.class, this.eroSerializer));
this.regs.add(this.ctx.registerTlvParser(1, this.tlvParser));
this.regs.add(this.ctx.registerTlvSerializer(OfList.class, this.tlvSerializer));
this.regs.add(this.ctx.registerObjectParser(5, 1, this.objectParser));
this.regs.add(this.ctx.registerObjectSerializer(Rp.class, this.objectSerializer));
this.regs.add(this.ctx.registerMessageParser(6, this.msgParser));
this.regs.add(this.ctx.registerMessageSerializer(Keepalive.class, this.msgSerializer));
this.regs.add(this.ctx.registerLabelParser(7, this.labelParser));
this.regs.add(this.ctx.registerLabelSerializer(Type1LabelCase.class, this.labelSerializer));
this.regs.add(this.ctx.registerVendorInformationObjectParser(new EnterpriseNumber(10L), this.objectParser));
this.regs.add(this.ctx.registerVendorInformationObjectSerializer(EnterpriseSpecificInformation.class, this.objectSerializer));
this.regs.add(this.ctx.registerVendorInformationTlvParser(new EnterpriseNumber(12L), this.tlvParser));
this.regs.add(this.ctx.registerVendorInformationTlvSerializer(EnterpriseSpecificInformation.class, this.tlvSerializer));
final ByteBuf buffer = Unpooled.buffer();
this.ctx.getXROSubobjectHandlerRegistry().parseSubobject(2, buffer, false);
this.ctx.getXROSubobjectHandlerRegistry().serializeSubobject(new SubobjectBuilder().setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
this.ctx.getEROSubobjectHandlerRegistry().parseSubobject(3, buffer, true);
this.ctx.getEROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder().setSubobjectType(new AsNumberCaseBuilder().build()).build(), buffer);
this.ctx.getRROSubobjectHandlerRegistry().parseSubobject(4, buffer);
this.ctx.getRROSubobjectHandlerRegistry().serializeSubobject(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.reported.route.object.rro.SubobjectBuilder().setSubobjectType(new IpPrefixCaseBuilder().build()).build(), buffer);
this.ctx.getLabelHandlerRegistry().parseLabel(1, buffer);
this.ctx.getLabelHandlerRegistry().serializeLabel(true, false, new Type1LabelCaseBuilder().build(), buffer);
this.ctx.getTlvHandlerRegistry().parseTlv(2, buffer);
this.ctx.getTlvHandlerRegistry().serializeTlv(new OfListBuilder().build(), buffer);
this.ctx.getObjectHandlerRegistry().parseObject(4, 1, new ObjectHeaderImpl(true, false), buffer);
this.ctx.getObjectHandlerRegistry().serializeObject(new OpenBuilder().build(), buffer);
this.ctx.getMessageHandlerRegistry().parseMessage(6, buffer, Collections.emptyList());
this.ctx.getMessageHandlerRegistry().serializeMessage(new KeepaliveBuilder().build(), buffer);
this.ctx.getVendorInformationObjectRegistry().parseVendorInformationObject(new EnterpriseNumber(10L), new ObjectHeaderImpl(true, false), buffer);
this.ctx.getVendorInformationObjectRegistry().serializeVendorInformationObject(this.esi, buffer);
this.ctx.getVendorInformationTlvRegistry().parseVendorInformationTlv(new EnterpriseNumber(12L), buffer);
this.ctx.getVendorInformationTlvRegistry().serializeVendorInformationTlv(this.viTlv, buffer);
this.activator.start(this.ctx);
this.activator.close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder in project bgpcep by opendaylight.
the class PCEPEROSubobjectParserTest method testEROEXRSSubobject.
@Test
public void testEROEXRSSubobject() throws Exception {
final EROExplicitExclusionRouteSubobjectParser parser = new EROExplicitExclusionRouteSubobjectParser(this.ctx.getXROSubobjectHandlerRegistry());
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setLoose(true);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.Exrs> list = Lists.newArrayList();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder builder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.explicit.route.subobjects.subobject.type.exrs._case.exrs.ExrsBuilder();
builder.setMandatory(true);
builder.setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build());
list.add(builder.build());
subs.setSubobjectType(new ExrsCaseBuilder().setExrs(new ExrsBuilder().setExrs(list).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(exrsBytes, 2)), true));
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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method setUp.
@Before
public void setUp() throws Exception {
this.ctx = new SimplePCEPExtensionProviderContext();
this.act = new BaseParserExtensionActivator();
this.viObjAct = new TestVendorInformationActivator();
this.act.start(this.ctx);
this.viObjAct.start(this.ctx);
this.objectRegistry = this.ctx.getObjectHandlerRegistry();
final RpBuilder rpBuilder = new RpBuilder();
rpBuilder.setProcessingRule(true);
rpBuilder.setIgnore(false);
rpBuilder.setReoptimization(false);
rpBuilder.setBiDirectional(false);
rpBuilder.setLoose(true);
rpBuilder.setMakeBeforeBreak(false);
rpBuilder.setOrder(false);
rpBuilder.setPathKey(false);
rpBuilder.setSupplyOf(false);
rpBuilder.setFragmentation(false);
rpBuilder.setP2mp(false);
rpBuilder.setEroCompression(false);
rpBuilder.setPriority((short) 1);
rpBuilder.setRequestId(new RequestId(10L));
rpBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder().build());
this.rpTrue = rpBuilder.build();
rpBuilder.setProcessingRule(false);
this.rpFalse = rpBuilder.build();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder openBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder();
openBuilder.setProcessingRule(false);
openBuilder.setIgnore(false);
openBuilder.setDeadTimer((short) 1);
openBuilder.setKeepalive((short) 1);
openBuilder.setSessionId((short) 0);
openBuilder.setVersion(new ProtocolVersion((short) 1));
openBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder().build());
this.open = openBuilder.build();
final NoPathBuilder npbuilder = new NoPathBuilder();
npbuilder.setProcessingRule(false);
npbuilder.setIgnore(false);
npbuilder.setNatureOfIssue((short) 0);
npbuilder.setUnsatisfiedConstraints(false);
npbuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build());
this.noPath = npbuilder.build();
final LspaBuilder lspaBuilder = new LspaBuilder();
lspaBuilder.setProcessingRule(false);
lspaBuilder.setIgnore(false);
lspaBuilder.setLocalProtectionDesired(false);
lspaBuilder.setHoldPriority((short) 0);
lspaBuilder.setSetupPriority((short) 0);
lspaBuilder.setExcludeAny(new AttributeFilter(0L));
lspaBuilder.setIncludeAll(new AttributeFilter(0L));
lspaBuilder.setIncludeAny(new AttributeFilter(0L));
lspaBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder().build());
this.lspa = lspaBuilder.build();
final MetricBuilder mBuilder = new MetricBuilder();
mBuilder.setIgnore(false);
mBuilder.setProcessingRule(false);
mBuilder.setComputed(false);
mBuilder.setBound(false);
mBuilder.setMetricType((short) 1);
mBuilder.setValue(new Float32(new byte[4]));
this.metrics = new MetricsBuilder().setMetric(mBuilder.build()).build();
this.eroASSubobject = new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber(0xFFFFL)).build()).build();
final IroBuilder iroBuilder = new IroBuilder();
iroBuilder.setIgnore(false);
iroBuilder.setProcessingRule(false);
final List<Subobject> iroSubs = Lists.newArrayList();
iroSubs.add(new SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
iroBuilder.setSubobject(iroSubs);
this.iro = iroBuilder.build();
final EroBuilder eroBuilder = new EroBuilder();
eroBuilder.setIgnore(false);
eroBuilder.setProcessingRule(false);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.Subobject> eroSubs = Lists.newArrayList();
eroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.explicit.route.object.ero.SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
eroBuilder.setSubobject(eroSubs);
this.ero = eroBuilder.build();
final OfBuilder ofBuilder = new OfBuilder();
ofBuilder.setIgnore(false);
ofBuilder.setProcessingRule(false);
ofBuilder.setCode(new OfId(0));
ofBuilder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.of.object.of.TlvsBuilder().build());
this.of = ofBuilder.build();
final Ipv4Builder afi = new Ipv4Builder();
afi.setSourceIpv4Address(new Ipv4Address("255.255.255.255"));
afi.setDestinationIpv4Address(new Ipv4Address("255.255.255.255"));
final EndpointsObjBuilder epBuilder = new EndpointsObjBuilder();
epBuilder.setIgnore(false);
epBuilder.setProcessingRule(true);
epBuilder.setAddressFamily(new Ipv4CaseBuilder().setIpv4(afi.build()).build());
this.endpoints = epBuilder.build();
final SvecBuilder sBuilder = new SvecBuilder();
sBuilder.setIgnore(false);
sBuilder.setProcessingRule(false);
sBuilder.setLinkDiverse(false);
sBuilder.setNodeDiverse(false);
sBuilder.setSrlgDiverse(false);
sBuilder.setRequestsIds(Lists.newArrayList(new RequestId(1L)));
this.svec = sBuilder.build();
this.viObjects = Lists.newArrayList();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationObject viObj = new VendorInformationObjectBuilder().setEnterpriseNumber(new EnterpriseNumber(0L)).setEnterpriseSpecificInformation(esInfo).build();
this.viObjects.add(viObj);
this.monitoring = new MonitoringBuilder().setMonitoringId(100L).setFlags(new Flags(false, false, false, false, false)).setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.monitoring.object.monitoring.TlvsBuilder().build()).build();
this.pccIdReq = new PccIdReqBuilder().setIpAddress(new IpAddress(new Ipv4Address("127.0.0.1"))).build();
this.pceId = new PceIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("127.0.0.2"))).build();
final ProcTimeBuilder procTimeBuilder = new ProcTimeBuilder();
procTimeBuilder.setEstimated(false);
procTimeBuilder.setCurrentProcTime(1L);
procTimeBuilder.setMinProcTime(2L);
procTimeBuilder.setMaxProcTime(3L);
procTimeBuilder.setAverageProcTime(4L);
procTimeBuilder.setVarianceProcTime(5L);
this.procTime = procTimeBuilder.build();
this.overload = new OverloadBuilder().setDuration(120).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder in project bgpcep by opendaylight.
the class PCEPXROSubobjectParserTest method testXROAsNumberSubobject.
@Test
public void testXROAsNumberSubobject() throws PCEPDeserializerException {
final XROAsNumberSubobjectParser parser = new XROAsNumberSubobjectParser();
final SubobjectBuilder subs = new SubobjectBuilder();
subs.setMandatory(true);
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);
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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.AsNumberCaseBuilder in project bgpcep by opendaylight.
the class EROSubobjectParserTest method testEROAsNumberSubobject.
@Test
public void testEROAsNumberSubobject() throws RSVPParsingException {
final EROAsNumberSubobjectParser parser = new EROAsNumberSubobjectParser();
final SubobjectContainerBuilder subs = new SubobjectContainerBuilder();
subs.setLoose(true);
subs.setSubobjectType(new AsNumberCaseBuilder().setAsNumber(new AsNumberBuilder().setAsNumber(new AsNumber(0x64L)).build()).build());
assertEquals(subs.build(), parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(AS_NUMBER_BYTES, 2)), true));
final ByteBuf buff = Unpooled.buffer();
parser.serializeSubobject(subs.build(), buff);
Assert.assertArrayEquals(AS_NUMBER_BYTES, 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());
}
}
Aggregations