use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder in project bgpcep by opendaylight.
the class SrObjectParserTest method testSrEroObjectWithSubobjects.
@Test
public void testSrEroObjectWithSubobjects() throws PCEPDeserializerException {
final PCEPExplicitRouteObjectParser parser = new PCEPExplicitRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
final EroBuilder builder = new EroBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
final List<Subobject> subobjects = Lists.newArrayList();
final SrEroTypeBuilder srEroSubBuilder = new SrEroTypeBuilder();
srEroSubBuilder.setCFlag(false);
srEroSubBuilder.setMFlag(false);
srEroSubBuilder.setSidType(SidType.Ipv4NodeId);
srEroSubBuilder.setSid(123456L);
srEroSubBuilder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(srEroSubBuilder.build()).setLoose(false);
subobjects.add(subobjBuilder.build());
builder.setSubobject(subobjects);
final ByteBuf result = Unpooled.wrappedBuffer(srEroObjectBytes);
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buffer = Unpooled.buffer();
parser.serializeObject(builder.build(), buffer);
assertArrayEquals(srEroObjectBytes, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder in project bgpcep by opendaylight.
the class SrEroSubobjectParserTest method testSrEroSubobjectUnnumberedNAI.
@Test
public void testSrEroSubobjectUnnumberedNAI() throws PCEPDeserializerException {
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
builder.setSidType(SidType.Unnumbered);
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
builder.setNai(new UnnumberedAdjacencyBuilder().setLocalNodeId(1L).setLocalInterfaceId(2L).setRemoteNodeId(3L).setRemoteInterfaceId(4L).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithUnnumbered, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(srEroSubobjectWithUnnumbered, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder in project bgpcep by opendaylight.
the class SrEroSubobjectParserTest method testSrEroSubobjectWithoutBody.
@Test
public void testSrEroSubobjectWithoutBody() throws PCEPDeserializerException {
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
builder.setSidType(SidType.Ipv4NodeId);
builder.setCFlag(false);
builder.setMFlag(false);
builder.setNai(new IpNodeIdBuilder().setIpAddress(new IpAddress(new Ipv4Address("74.125.43.99"))).build());
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithoutSID, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(srEroSubobjectWithoutSID, ByteArray.getAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder in project bgpcep by opendaylight.
the class SrEroSubobjectParser method parseSubobject.
@Override
public Subobject parseSubobject(final ByteBuf buffer, final boolean loose) throws PCEPDeserializerException {
final SrEroTypeBuilder srEroSubobjectBuilder = new SrEroTypeBuilder(parseSrSubobject(buffer));
final SubobjectBuilder subobjectBuilder = new SubobjectBuilder();
subobjectBuilder.setLoose(loose);
subobjectBuilder.setSubobjectType(srEroSubobjectBuilder.build());
return subobjectBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev171025.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroTypeBuilder in project bgpcep by opendaylight.
the class SrEroSubobjectParserTest method testSrEroSubobjectWithoutNAI.
@Test
public void testSrEroSubobjectWithoutNAI() throws PCEPDeserializerException {
final SrEroTypeBuilder builder = new SrEroTypeBuilder();
builder.setSidType(SidType.Ipv4NodeId);
builder.setSid(123456L);
builder.setCFlag(false);
builder.setMFlag(false);
final SubobjectBuilder subobjBuilder = new SubobjectBuilder().setSubobjectType(builder.build()).setLoose(false);
assertEquals(subobjBuilder.build(), this.parser.parseSubobject(Unpooled.wrappedBuffer(ByteArray.cutBytes(srEroSubobjectWithoutNAI, 2)), false));
final ByteBuf buffer = Unpooled.buffer();
this.parser.serializeSubobject(subobjBuilder.build(), buffer);
assertArrayEquals(srEroSubobjectWithoutNAI, ByteArray.getAllBytes(buffer));
}
Aggregations