diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-02-23 08:38:18 +0100 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2017-02-23 08:39:34 +0100 |
commit | 210b21cf903da53b91cf8143be9a5be295139f17 (patch) | |
tree | 85c53470923f0f4eda9e9516ed1d353a079ee5f1 /routing/routing-impl/src/test | |
parent | 27922cc77498479eabe58cf82647b31aa880a0cc (diff) |
HC2VPP-83 - table id setup for special routes
Added primary/secondary table id setup for special v4/v6 routes
Change-Id: Id3ef3d383b5ad7b5b905a04f7f594fdf4b7a4104
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'routing/routing-impl/src/test')
5 files changed, 78 insertions, 50 deletions
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java index 7c3ddee2e..47f53494b 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java @@ -72,9 +72,11 @@ public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProd final int isDrop, final int isReceive, final int isUnreach, - final int isProhibit) { + final int isProhibit, + final int protocolTableId, + final int secondaryTableId) { // verifiaction of special request that has only destination address and flag - return desiredResult(add, ipv6, 0, destinationAddress, destinationPrefixLength, null, 0, 0, 0, 1, 0, 0, 0, + return desiredResult(add, ipv6, 0, destinationAddress, destinationPrefixLength, null, 0, 0, protocolTableId, 1, secondaryTableId, 0, 0, isDrop, isReceive, isUnreach, isProhibit); } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java index 9cefb345a..a34b3debb 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java @@ -17,6 +17,8 @@ package io.fd.hc2vpp.routing.write; +import static io.fd.hc2vpp.routing.Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY; +import static io.fd.hc2vpp.routing.Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY; import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_INDEX; import static io.fd.hc2vpp.routing.helpers.InterfaceTestHelper.INTERFACE_NAME; import static org.junit.Assert.assertTrue; @@ -28,7 +30,6 @@ import com.google.common.collect.ImmutableList; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.MultiNamingContext; import io.fd.hc2vpp.common.translate.util.NamingContext; -import io.fd.hc2vpp.routing.Ipv4RouteData; import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper; import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper; import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper; @@ -57,6 +58,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class Ipv4RouteCustomizerTest extends WriterCustomizerTest implements ClassifyTableTestHelper, RoutingRequestTestHelper, SchemaContextTestHelper { + private static final int ROUTE_PROTOCOL_INDEX = 1; @Captor private ArgumentCaptor<IpAddDelRoute> requestCaptor; @@ -89,7 +91,7 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest namesFactory = new Ipv4RouteNamesFactory(interfaceContext, routingProtocolContext); defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context"); - defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); + defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, ROUTE_PROTOCOL_INDEX, "routing-protocol-context"); addMapping(classifyManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); whenAddRouteThenSuccess(api); } @@ -103,8 +105,8 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest customizer.writeCurrentAttributes(validId, route1, writeContext); verifyInvocation(1, ImmutableList - .of(desiredFlaglessResult(1, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 1, 0, + .of(desiredFlaglessResult(1, 0, 0, FIRST_ADDRESS_AS_ARRAY, 24, + SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); } @@ -119,11 +121,11 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest customizer.writeCurrentAttributes(validId, route1, writeContext); verifyInvocation(2, ImmutableList.of( - desiredFlaglessResult(1, 0, 1, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, + desiredFlaglessResult(1, 0, 1, FIRST_ADDRESS_AS_ARRAY, 24, + FIRST_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1), - desiredFlaglessResult(1, 0, 1, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 3, 1, 1, 0, + desiredFlaglessResult(1, 0, 1, FIRST_ADDRESS_AS_ARRAY, 24, + SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 3, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); @@ -148,7 +150,7 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest customizer.writeCurrentAttributes(validId, route1, writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0)), api, + .of(desiredSpecialResult(1, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, requestCaptor); } @@ -173,9 +175,9 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest throws WriteFailedException { customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, 1L), writeContext); verifyInvocation(1, ImmutableList - .of(desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, - 0, 1, 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); + .of(desiredFlaglessResult(0, 0, 0, FIRST_ADDRESS_AS_ARRAY, 24, + SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, + 0, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); } @Test @@ -188,11 +190,11 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest customizer.deleteCurrentAttributes(validId, route1, writeContext); verifyInvocation(2, ImmutableList.of( - desiredFlaglessResult(0, 0, 1, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, + desiredFlaglessResult(0, 0, 1, FIRST_ADDRESS_AS_ARRAY, 24, + FIRST_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1), - desiredFlaglessResult(0, 0, 1, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, - new byte[]{-64, -88, 2, 2}, INTERFACE_INDEX, 3, 1, 1, 0, + desiredFlaglessResult(0, 0, 1, FIRST_ADDRESS_AS_ARRAY, 24, + new byte[]{-64, -88, 2, 2}, INTERFACE_INDEX, 3, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); verify(routeHopContext, times(1)) @@ -214,7 +216,7 @@ public class Ipv4RouteCustomizerTest extends WriterCustomizerTest customizer.deleteCurrentAttributes(validId, getIpv4RouteWithId(route, 1L), writeContext); verifyInvocation(1, - ImmutableList.of(desiredSpecialResult(0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0)), api, + ImmutableList.of(desiredSpecialResult(0, 0, FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, requestCaptor); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java index 6ba973340..15c836411 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java @@ -52,6 +52,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class Ipv6RouteCustomizerTest extends WriterCustomizerTest implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper { + private static final int ROUTE_PROTOCOL_INDEX = 1; @Captor private ArgumentCaptor<IpAddDelRoute> requestCaptor; @@ -86,7 +87,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context"); addMapping(classifyManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); - defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); + defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, ROUTE_PROTOCOL_INDEX, "routing-protocol-context"); } @Test @@ -97,7 +98,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); verifyInvocation(1, ImmutableList .of(desiredFlaglessResult(1, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, - Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, + Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); } @@ -110,10 +111,10 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest verifyInvocation(2, ImmutableList.of( desiredFlaglessResult(1, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, - Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, + Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1), desiredFlaglessResult(1, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64, - Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, + Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, ROUTE_PROTOCOL_INDEX, 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor); } @@ -139,7 +140,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(0, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0)), api, + .of(desiredSpecialResult(0, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, requestCaptor); } @@ -180,7 +181,7 @@ public class Ipv6RouteCustomizerTest extends WriterCustomizerTest customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext); verifyInvocation(1, ImmutableList - .of(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0)), api, + .of(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, ROUTE_PROTOCOL_INDEX, 0)), api, requestCaptor); } } diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java index 253a1b1a9..d93a4bf1c 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java @@ -16,11 +16,8 @@ package io.fd.hc2vpp.routing.write.factory; -import static org.junit.Assert.assertEquals; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Prohibit; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Receive; -import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Unreachable; - +import io.fd.hc2vpp.common.test.util.NamingContextHelper; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.Ipv4RouteData; import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper; import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper; @@ -42,10 +39,17 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicas import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes; +import static io.fd.hc2vpp.routing.write.factory.SpecialNextHopRequestFactory.forContexts; +import static org.junit.Assert.assertEquals; +import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.*; + @RunWith(HoneycombTestRunner.class) public class SpecialNextHopRequestFactoryIpv4Test implements RouteRequestProducer, RoutingRequestTestHelper, ClassifyTableTestHelper, - SchemaContextTestHelper { + SchemaContextTestHelper,NamingContextHelper { + + private static final String PARENT_PROTOCOL_4 = "parent-protocol-4"; + private static final int PARENT_PROTOCOL_4_INDEX = 4; @Mock private VppClassifierContextManager classifierContextManager; @@ -53,14 +57,21 @@ public class SpecialNextHopRequestFactoryIpv4Test @Mock private MappingContext mappingContext; + private NamingContext interfaceContext; + private NamingContext routingProtocolContextContext; + private SpecialNextHopRequestFactory factory; @Before public void init() { MockitoAnnotations.initMocks(this); - factory = SpecialNextHopRequestFactory.forClassifierContext(classifierContextManager); + + interfaceContext = new NamingContext("iface", "interface-context"); + routingProtocolContextContext = new NamingContext("routingProtocol", "routing-protocol-context"); + factory = forContexts(classifierContextManager, interfaceContext, routingProtocolContextContext); addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); + defineMapping(mappingContext, PARENT_PROTOCOL_4, PARENT_PROTOCOL_4_INDEX, "routing-protocol-context"); } @Test @@ -68,10 +79,10 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, SpecialNextHopGrouping.SpecialNextHop.Blackhole); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); } @Test @@ -79,9 +90,9 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Receive); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Receive); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); } @Test @@ -89,9 +100,9 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Unreachable); + factory.createIpv4SpecialHopRequest(true, PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Unreachable); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); } @Test @@ -99,9 +110,9 @@ public class SpecialNextHopRequestFactoryIpv4Test @InjectTestData(resourcePath = "/ipv4/specialhop/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Prohibit); + factory.createIpv4SpecialHopRequest(true,PARENT_PROTOCOL_4, extractSingleRoute(routes, 1L), mappingContext, Prohibit); - assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1), request); + assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1, PARENT_PROTOCOL_4_INDEX, DEFAULT_VNI), request); } private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) { diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java index d5f504094..fcd97da54 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java @@ -16,12 +16,15 @@ package io.fd.hc2vpp.routing.write.factory; +import static io.fd.hc2vpp.routing.write.trait.RouteRequestProducer.DEFAULT_VNI; import static org.junit.Assert.assertEquals; import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Blackhole; import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Prohibit; import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Receive; import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.SpecialNextHopGrouping.SpecialNextHop.Unreachable; +import io.fd.hc2vpp.common.test.util.NamingContextHelper; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.routing.Ipv6RouteData; import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper; import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper; @@ -43,7 +46,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev @RunWith(HoneycombTestRunner.class) public class SpecialNextHopRequestFactoryIpv6Test - implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper { + implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper, NamingContextHelper { + + private static final String PARENT_PROTOCOL_6 = "parent-protocol-6"; + private static final int PARENT_PROTOCOL_6_INDEX = 6; @Mock private VppClassifierContextManager classifierContextManager; @@ -51,14 +57,20 @@ public class SpecialNextHopRequestFactoryIpv6Test @Mock private MappingContext mappingContext; + private NamingContext interfaceContext; + private NamingContext routingProtocolContextContext; + private SpecialNextHopRequestFactory factory; @Before public void init() { MockitoAnnotations.initMocks(this); - factory = SpecialNextHopRequestFactory.forClassifierContext(classifierContextManager); + interfaceContext = new NamingContext("iface", "interface-context"); + routingProtocolContextContext = new NamingContext("routingProtocol", "routing-protocol-context"); + factory = SpecialNextHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContextContext); addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext); + defineMapping(mappingContext, PARENT_PROTOCOL_6, PARENT_PROTOCOL_6_INDEX, "routing-protocol-context"); } @Test @@ -66,9 +78,9 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Blackhole); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Blackhole); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0), + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); } @@ -77,9 +89,9 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Receive); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Receive); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); } @Test @@ -87,9 +99,9 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Unreachable); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Unreachable); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); } @Test @@ -97,9 +109,9 @@ public class SpecialNextHopRequestFactoryIpv6Test @InjectTestData(resourcePath = "/ipv6/specialhop/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH) StaticRoutes routes) { final IpAddDelRoute request = - factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Prohibit); + factory.createIpv6SpecialHopRequest(true, PARENT_PROTOCOL_6, extractSingleRoute(routes, 1L), mappingContext, Prohibit); - assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1), request); + assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1, PARENT_PROTOCOL_6_INDEX, DEFAULT_VNI), request); } private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) { |