use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method removeMapping.
/**
* Tests {@link DataStoreBackEnd#removeMapping} method.
*/
@Test
public void removeMapping() {
final Mapping mapping = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).setOrigin(MappingOrigin.Northbound).build();
dataStoreBackEnd.removeMapping(mapping);
Mockito.verify(wTxMock).delete(Mockito.eq(LogicalDatastoreType.CONFIGURATION), iidCaptorMapping.capture());
// result
MappingKey result = iidCaptorMapping.getValue().firstKeyOf(Mapping.class);
assertEquals("ipv4:" + IPV4_STRING_1, result.getEidUri().getValue());
assertEquals(MappingOrigin.Northbound, result.getOrigin());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method removeXtrIdMappingTest.
/**
* Tests {@link DataStoreBackEnd#addXtrIdMapping} method.
*/
@Test
public void removeXtrIdMappingTest() {
XtrIdMapping xtrIdMapping = new XtrIdMappingBuilder().setXtrIdUri(new XtrIdUri(DUMMY_URI)).setMappingRecord(getDefaultMappingRecordBuilder().build()).build();
dataStoreBackEnd.removeXtrIdMapping(xtrIdMapping);
Mockito.verify(wTxMock).delete(Mockito.eq(LogicalDatastoreType.OPERATIONAL), iidCaptorXtrIdMapping.capture());
// result
XtrIdMappingKey xtrIdResult = iidCaptorXtrIdMapping.getValue().firstKeyOf(XtrIdMapping.class);
MappingKey mappingResult = iidCaptorXtrIdMapping.getValue().firstKeyOf(Mapping.class);
assertEquals(DatatypeConverter.printHexBinary(XTR_ID), xtrIdResult.getXtrIdUri().getValue());
assertEquals(MappingOrigin.Southbound, mappingResult.getOrigin());
assertEquals("ipv4:" + IPV4_STRING_1, mappingResult.getEidUri().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project lispflowmapping by opendaylight.
the class DataStoreBackEndTest method addMappingTest.
/**
* Tests {@link DataStoreBackEnd#addMapping} method.
*/
@Test
public void addMappingTest() {
final Mapping mapping = new MappingBuilder().setMappingRecord(getDefaultMappingRecordBuilder().build()).setOrigin(MappingOrigin.Northbound).build();
dataStoreBackEnd.addMapping(mapping);
Mockito.verify(wTxMock).put(Mockito.eq(LogicalDatastoreType.CONFIGURATION), iidCaptorMapping.capture(), Mockito.eq(mapping), Mockito.eq(true));
// result
MappingKey result = iidCaptorMapping.getValue().firstKeyOf(Mapping.class);
assertEquals("ipv4:" + IPV4_STRING_1, result.getEidUri().getValue());
assertEquals(MappingOrigin.Northbound, result.getOrigin());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project bgpcep by opendaylight.
the class NextHopUtilTest method testParseNextHop.
@Test
public void testParseNextHop() {
CNextHop hop = null;
try {
hop = NextHopUtil.parseNextHop(Unpooled.wrappedBuffer(IPV4B));
} catch (final IllegalArgumentException e) {
fail("This exception should not happen");
}
assertEquals(IPV4, ((Ipv4NextHopCase) hop).getIpv4NextHop().getGlobal());
try {
hop = NextHopUtil.parseNextHop(Unpooled.wrappedBuffer(IPV6B));
} catch (final IllegalArgumentException e) {
fail("This exception should not happen");
}
assertEquals(IPV6, ((Ipv6NextHopCase) hop).getIpv6NextHop().getGlobal());
assertNull(((Ipv6NextHopCase) hop).getIpv6NextHop().getLinkLocal());
try {
hop = NextHopUtil.parseNextHop(Unpooled.wrappedBuffer(IPV6LB));
} catch (final IllegalArgumentException e) {
fail("This exception should not happen");
}
assertEquals(IPV6, ((Ipv6NextHopCase) hop).getIpv6NextHop().getGlobal());
assertEquals(IPV6L, ((Ipv6NextHopCase) hop).getIpv6NextHop().getLinkLocal());
final byte[] wrong = new byte[] { (byte) 0x20, (byte) 0x01, (byte) 0x0d };
try {
NextHopUtil.parseNextHop(Unpooled.wrappedBuffer(wrong));
fail("Exception should happen");
} catch (final IllegalArgumentException e) {
assertEquals("Cannot parse NEXT_HOP attribute. Wrong bytes length: 3", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.endpoints.address.family.ipv4._case.Ipv4 in project bgpcep by opendaylight.
the class BGPParserTest method testGetUpdateMessage4.
/*
* Tests empty AS_PATH, ORIGIN.EGP, LOCAL_PREF, EXTENDED_COMMUNITIES (Ipv4 Addr specific)
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
* 00 4A <- length (73) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
* 00 27 <- total path attribute length (39)
* 40 <- attribute flags
* 01 <- attribute type code (Origin)
* 01 <- attribute length
* 01 <- Origin value (EGP)
* 40 <- attribute flags
* 02 <- attribute type code (As path)
* 00 <- attribute length
* 40 <- attribute flags
* 03 <- attribute type (Next hop)
* 04 <- attribute length
* 03 03 03 03 <- value (3.3.3.3)
* 80 <- attribute flags
* 04 <- attribute type code (Multi exit disc)
* 04 <- attribute length
* 00 00 00 00 <- value
* 40 <- attribute flags
* 05 <- attribute type (Local Pref)
* 04 <- attribute length
* 00 00 00 64 <- value (100)
* c0 <- attribute flags
* 10 <- attribute type (extended community)
* 08 <- attribute length
* 01 04 <- value (type - Ipv4 Address Specific Extended Community)
* c0 a8 01 00 <- value (global adm. 198.162.1.0)
* 12 34 <- value (local adm. 4660)
*
* //NLRI
* 18 0a 1e 03 <- IPv4 Prefix (10.30.3.0 / 24)
* 18 0a 1e 02 <- IPv4 Prefix (10.30.2.0 / 24)
* 18 0a 1e 01 <- IPv4 Prefix (10.30.1.0 / 24)
*/
@Test
public void testGetUpdateMessage4() throws Exception {
final byte[] body = ByteArray.cutBytes(inputBytes.get(3), MessageUtil.COMMON_HEADER_LENGTH);
final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(3), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
final UpdateBuilder builder = new UpdateBuilder();
// check fields
assertNull(message.getWithdrawnRoutes());
// check nlri
final List<Nlri> nlris = Lists.newArrayList();
nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.3.0/24")).build());
nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.2.0/24")).build());
nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.1.0/24")).build());
assertEquals(nlris, message.getNlri());
builder.setNlri(nlris);
// attributes
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("3.3.3.3")).build()).build();
final List<ExtendedCommunities> comms = Lists.newArrayList();
comms.add(new ExtendedCommunitiesBuilder().setTransitive(true).setExtendedCommunity(new RouteTargetIpv4CaseBuilder().setRouteTargetIpv4(new RouteTargetIpv4Builder().setGlobalAdministrator(new Ipv4Address("192.168.1.0")).setLocalAdministrator(4660).build()).build()).build());
// check path attributes
final Attributes attrs = message.getAttributes();
final AttributesBuilder paBuilder = new AttributesBuilder();
paBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Egp).build());
assertEquals(paBuilder.getOrigin(), attrs.getOrigin());
paBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
assertEquals(paBuilder.getAsPath(), attrs.getAsPath());
paBuilder.setCNextHop(nextHop);
assertEquals(paBuilder.getCNextHop(), attrs.getCNextHop());
paBuilder.setMultiExitDisc(new MultiExitDiscBuilder().setMed((long) 0).build());
assertEquals(paBuilder.getMultiExitDisc(), attrs.getMultiExitDisc());
paBuilder.setLocalPref(new LocalPrefBuilder().setPref(100L).build());
assertEquals(paBuilder.getLocalPref(), attrs.getLocalPref());
paBuilder.setExtendedCommunities(comms);
assertEquals(paBuilder.getExtendedCommunities(), attrs.getExtendedCommunities());
paBuilder.setUnrecognizedAttributes(Collections.emptyList());
// check API message
builder.setAttributes(paBuilder.build());
assertEquals(builder.build(), message);
final ByteBuf buffer = Unpooled.buffer();
BGPParserTest.updateParser.serializeMessage(message, buffer);
assertArrayEquals(inputBytes.get(3), ByteArray.readAllBytes(buffer));
}
Aggregations