use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.
the class DestinationSequenceTest method testEqualsAndHashCode.
@Test
public void testEqualsAndHashCode() {
DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
DestinationSequence otherSeq = null;
assertFalse(seq.equals(otherSeq));
otherSeq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
assertEquals(seq, otherSeq);
assertEquals(seq.hashCode(), otherSeq.hashCode());
Identifier otherId = factory.createIdentifier();
otherId.setValue("otherSeq");
otherSeq = new DestinationSequence(otherId, ref, destination, ProtocolVariation.RM10WSA200408);
assertFalse(seq.equals(otherSeq));
assertNotEquals(seq.hashCode(), otherSeq.hashCode());
}
use of org.geotoolkit.sml.xml.v100.Identifier in project cxf by apache.
the class ManagedRMManagerTest method createTestSourceSequence.
private SourceSequence createTestSourceSequence(Source source, String sid, EndpointReferenceType to, ProtocolVariation protocol, long[] acked) {
Identifier identifier = RMUtils.getWSRMFactory().createIdentifier();
identifier.setValue(sid);
SourceSequence ss = new SourceSequence(identifier, protocol);
ss.setSource(source);
ss.setTarget(to);
List<SequenceAcknowledgement.AcknowledgementRange> ranges = ss.getAcknowledgement().getAcknowledgementRange();
for (int i = 0; i < acked.length; i += 2) {
ranges.add(createAcknowledgementRange(acked[i], acked[i + 1]));
}
return ss;
}
use of org.geotoolkit.sml.xml.v100.Identifier in project bgpcep by opendaylight.
the class LinkstateNlriParser method serializeCommonParts.
private static void serializeCommonParts(final CLinkstateDestinationBuilder builder, final DataContainerNode<? extends PathArgument> linkstate) {
// serialize common parts
final Optional<DataContainerChild<? extends PathArgument, ?>> distinguisher = linkstate.getChild(DISTINGUISHER_NID);
if (distinguisher.isPresent()) {
builder.setDistinguisher(new RouteDistinguisher((BigInteger) distinguisher.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> protocolId = linkstate.getChild(PROTOCOL_ID_NID);
// DOM representation contains values as are in the model, not as are in generated enum
if (protocolId.isPresent()) {
builder.setProtocolId(ProtocolId.forValue(domProtocolIdValue((String) protocolId.get().getValue())));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> identifier = linkstate.getChild(IDENTIFIER_NID);
if (identifier.isPresent()) {
builder.setIdentifier(new Identifier((BigInteger) identifier.get().getValue()));
}
}
use of org.geotoolkit.sml.xml.v100.Identifier in project bgpcep by opendaylight.
the class AbstractNlriTypeCodec method parseTypeNlri.
@Override
public final CLinkstateDestination parseTypeNlri(final ByteBuf nlri) {
final CLinkstateDestinationBuilder builder = new CLinkstateDestinationBuilder();
builder.setProtocolId(ProtocolId.forValue(nlri.readUnsignedByte()));
builder.setIdentifier(new Identifier(BigInteger.valueOf(nlri.readLong())));
builder.setObjectType(parseObjectType(nlri));
return builder.build();
}
use of org.geotoolkit.sml.xml.v100.Identifier in project bgpcep by opendaylight.
the class ParserTest method testBGPNode.
/*
* TEST BGP Node
*
* 00 00 <- withdrawn routes length
00 b1 <- total path attribute length (177)
80 <- attribute flags
0e <- attribute type code (MP reach)
a0 <- attribute length (160)
40 04 <- AFI (16388 - Linkstate)
47 <- SAFI (71 - Linkstate)
04 <- next hop length
19 19 19 01 - nexthop (25.25.25.1)
00 <- reserved
00 01 <- NLRI type (1 - nodeNLRI)
00 31 <- NLRI length (49)
03 <- ProtocolID - OSPF
00 00 00 00 00 00 00 01 <- identifier
01 00 <- local node descriptor type (256)
00 24 <- length (36)
02 00 <- node descriptor type (member AS - 512)
00 04 <- length
00 00 00 64 <- value (100)
02 01 <- node descriptor type (bgpId - 513)
00 04 <- length
19 19 19 01 <- bgpId (25.25.25.1)
02 02 <- node descriptor type (areaId - 514)
00 04 <- length
00 00 00 00 <- value
02 03 <- node descriptor type (routeId - 515)
00 08 <- length
03 03 03 04 0b 0b 0b 03 <- OSPF Router Id
00 01 <- NLRI type (1 - nodeNLRI)
00 2d <- NLRI length (45)
03 <- ProtocolID - OSPF
00 00 00 00 00 00 00 01 <- identifier
01 00 <- local node descriptor type (256)
00 20 <- length (32)
02 00 <- node descriptor type (member AS - 512)
00 04 <- length
00 00 00 64 <- value (100)
02 01 <- node descriptor type (bgpId - 513)
00 04 <- length
19 19 19 01 <- bgpId (25.25.25.1)
02 02 <- node descriptor type (areaId - 514)
00 04 <- length
00 00 00 00 <- value
02 03 <- node descriptor type (routeId - 515)
00 04 <- length
03 03 03 04 <- OSPF Router Id
00 01 <- NLRI type (1 - nodeNLRI)
00 2d <- NLRI length (45)
03 <- ProtocolID - OSPF
00 00 00 00 00 00 00 01 <- identifier
01 00 <- local node descriptor type (256)
00 20 <- length (32)
02 00 <- node descriptor type (member AS - 512)
00 04 <- length
00 00 00 64 <- value (100)
02 01 <- node descriptor type (bgpId - 513)
00 04 <- length
19 19 19 01 <- bgpId (25.25.25.1)
02 02 <- node descriptor type (areaId - 514)
00 04 <- length
00 00 00 00 <- value
02 03 <- node descriptor type (routeId - 515)
00 04 <- length
01 01 01 02 <- OSPF Router Id
40 <- attribute flags
01 <- attribute type (Origin)
01 <- attribute length
00 <- value (IGP)
40 <- attribute flags
02 <- attribute type (AS Path)
00 <- length
40 <- attribute flags
05 <- attribute type (local pref)
04 <- length
00 00 00 64 <- value
*/
@Test
public void testBGPNode() throws Exception {
final byte[] body = ByteArray.cutBytes(INPUT_BYTES.get(2), MessageUtil.COMMON_HEADER_LENGTH);
final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(INPUT_BYTES.get(2), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = ParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength, null);
final UpdateBuilder builder = new UpdateBuilder();
// check fields
assertNull(message.getWithdrawnRoutes());
// attributes
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("25.25.25.1")).build()).build();
final CLinkstateDestinationBuilder clBuilder = new CLinkstateDestinationBuilder();
clBuilder.setIdentifier(new Identifier(Uint64.ONE));
clBuilder.setProtocolId(ProtocolId.Ospf);
final NodeDescriptorsBuilder n = new NodeDescriptorsBuilder().setAsNumber(new AsNumber(Uint32.valueOf(100))).setDomainId(new DomainIdentifier(Uint32.valueOf(0x19191901L))).setAreaId(new AreaIdentifier(Uint32.ZERO));
final List<CLinkstateDestination> linkstates = new ArrayList<>();
final NodeCaseBuilder nCase = new NodeCaseBuilder().setNodeDescriptors(n.setCRouterIdentifier(new OspfPseudonodeCaseBuilder().setOspfPseudonode(new OspfPseudonodeBuilder().setOspfRouterId(Uint32.valueOf(0x03030304L)).setLanInterface(new OspfInterfaceIdentifier(Uint32.valueOf(0x0b0b0b03L))).build()).build()).build());
linkstates.add(clBuilder.setObjectType(nCase.build()).build());
nCase.setNodeDescriptors(n.setCRouterIdentifier(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(Uint32.valueOf(0x03030304L)).build()).build()).build());
linkstates.add(clBuilder.setObjectType(nCase.build()).build());
nCase.setNodeDescriptors(n.setCRouterIdentifier(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(Uint32.valueOf(0x01010102L)).build()).build()).build());
linkstates.add(clBuilder.setObjectType(nCase.build()).build());
final AttributesReachBuilder lsBuilder = new AttributesReachBuilder();
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(LinkstateAddressFamily.class);
mpBuilder.setSafi(LinkstateSubsequentAddressFamily.class);
mpBuilder.setCNextHop(nextHop);
final DestinationLinkstateBuilder dBuilder = new DestinationLinkstateBuilder();
dBuilder.setCLinkstateDestination(linkstates);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationLinkstateCaseBuilder().setDestinationLinkstate(dBuilder.build()).build()).build());
lsBuilder.setMpReachNlri(mpBuilder.build());
// check path attributes
final Attributes attrs = message.getAttributes();
final AttributesBuilder paBuilder = new AttributesBuilder();
paBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
assertEquals(paBuilder.getOrigin(), attrs.getOrigin());
paBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
assertEquals(paBuilder.getAsPath(), attrs.getAsPath());
paBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build());
assertEquals(paBuilder.getLocalPref(), attrs.getLocalPref());
paBuilder.addAugmentation(lsBuilder.build());
paBuilder.setUnrecognizedAttributes(Collections.emptyMap());
final MpReachNlri mp = attrs.augmentation(AttributesReach.class).getMpReachNlri();
assertEquals(mpBuilder.getAfi(), mp.getAfi());
assertEquals(mpBuilder.getSafi(), mp.getSafi());
assertEquals(mpBuilder.getCNextHop(), mp.getCNextHop());
final List<CLinkstateDestination> dests = ((DestinationLinkstateCase) mp.getAdvertizedRoutes().getDestinationType()).getDestinationLinkstate().getCLinkstateDestination();
assertEquals(linkstates.size(), dests.size());
assertEquals(linkstates, dests);
// check API message
builder.setAttributes(paBuilder.build());
assertEquals(builder.build(), message);
final ByteBuf buffer = Unpooled.buffer();
ParserTest.updateParser.serializeMessage(message, buffer);
assertArrayEquals(INPUT_BYTES.get(2), ByteArray.readAllBytes(buffer));
}
Aggregations