summaryrefslogtreecommitdiffstats
path: root/routing/routing-impl/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'routing/routing-impl/src/test')
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteData.java23
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java91
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java82
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java92
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java110
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/ClassifyTableTestHelper.java35
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/InterfaceTestHelper.java25
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java168
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java45
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java265
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java287
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java225
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java64
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java220
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java186
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java95
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java110
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java119
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java126
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java95
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java96
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java112
-rw-r--r--routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java111
-rw-r--r--routing/routing-impl/src/test/resources/init/config-data.json109
-rw-r--r--routing/routing-impl/src/test/resources/init/state-data.json109
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithClassifier.json31
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithoutClassifier.json30
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithClassifier.json17
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithoutClassifier.json16
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/specialHopRouteBlackhole.json13
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/specialHopRouteProhibited.json13
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/specialHopRouteReceive.json13
-rw-r--r--routing/routing-impl/src/test/resources/ipv4/specialHopRouteUnreachable.json13
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithClassifier.json31
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithoutClassifier.json30
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithClassifier.json17
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithoutClassifier.json16
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/specialHopRouteBlackhole.json13
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/specialHopRouteProhibited.json13
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/specialHopRouteReceive.json13
-rw-r--r--routing/routing-impl/src/test/resources/ipv6/specialHopRouteUnreachable.json13
-rw-r--r--routing/routing-impl/src/test/resources/routing.json4
42 files changed, 3296 insertions, 0 deletions
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteData.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteData.java
new file mode 100644
index 000000000..71072ba9a
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteData.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing;
+
+
+public class Ipv4RouteData {
+ public static final byte[] FIRST_ADDRESS_AS_ARRAY = {-64, -88, 2, 1};
+ public static final byte[] SECOND_ADDRESS_AS_ARRAY = {-64, -88, 2, 2};
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java
new file mode 100644
index 000000000..1fc8152eb
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv4RouteNamesFactoryTest.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing;
+
+import static org.junit.Assert.assertEquals;
+
+import io.fd.hc2vpp.common.test.util.NamingContextHelper;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.routing.naming.Ipv4RouteNamesFactory;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.dto.IpFibDetails;
+import io.fd.vpp.jvpp.core.types.FibPath;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+@RunWith(HoneycombTestRunner.class)
+public class Ipv4RouteNamesFactoryTest
+ implements RoutingRequestTestHelper, SchemaContextTestHelper, NamingContextHelper {
+
+ @Mock
+ private MappingContext mappingContext;
+
+ private NamingContext interfaceContext;
+ private NamingContext routingProtocolContext;
+ private IpFibDetails vppRoute;
+ private FibPath vppPath;
+ private Ipv4RouteNamesFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ interfaceContext = new NamingContext("interface-", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol-", "routing-protocol-context");
+ vppRoute = new IpFibDetails();
+ vppRoute.address = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ vppRoute.addressLength = 24;
+ vppRoute.tableId = 1;
+
+ vppPath = new FibPath();
+ vppPath.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ vppPath.swIfIndex = 2;
+ vppPath.weight = 3;
+
+ factory = new Ipv4RouteNamesFactory(interfaceContext, routingProtocolContext);
+ defineMapping(mappingContext, "iface", 2, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ }
+
+ @Test
+ public void testUniqueRouteName(
+ @InjectTestData(resourcePath = "/ipv4/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes data) {
+ assertEquals("tst-protocol_19216821_24",
+ factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, getIpv4RouteWithId(data, 1L)));
+ assertEquals("tst-protocol_19216821_24", factory.uniqueRouteName(vppRoute, mappingContext));
+ }
+
+ @Test
+ public void testUniqueRouteHopName() {
+ assertEquals("iface_19216821_3", factory.uniqueRouteHopName(new NextHopBuilder()
+ .setAddress(new Ipv4Address("192.168.2.1"))
+ .setWeight((short) 3)
+ .setOutgoingInterface("iface")
+ .build()));
+ assertEquals("iface_19216821_3", factory.uniqueRouteHopName(vppPath, mappingContext));
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java
new file mode 100644
index 000000000..808252844
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteData.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder;
+
+public class Ipv6RouteData {
+
+ public static final Ipv6Prefix
+ FIRST_ADDRESS_AS_V6_PREFIX = new Ipv6Prefix("2001:0db8:0a0b:12f0:0000:0000:0000:0001/64");
+
+ public static final byte[] FIRST_ADDRESS_AS_ARRAY = {32, 1, 13, -72, 10, 11, 18, -16, 0, 0, 0, 0, 0, 0, 0, 1};
+
+ public static final Ipv6Address
+ SECOND_ADDRESS_AS_ADDRESS = new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0002");
+
+ public static final byte[] SECOND_ADDRESS_AS_ARRAY = {32, 1, 13, -72, 10, 11, 18, -16, 0, 0, 0, 0, 0, 0, 0, 2};
+
+
+ public static final Route IPV6_ROUTE_WITH_CLASSIFIER_BLACKHOLE_HOP = new RouteBuilder()
+ .setDestinationPrefix(FIRST_ADDRESS_AS_V6_PREFIX)
+ /*.setNextHopOptions(new SpecialNextHopBuilder()
+ .setSpecialNextHop(SpecialNextHopGrouping.SpecialNextHop.Blackhole)
+ /*.addAugmentation(SpecialNextHop2.class, new SpecialNextHop2Builder()
+ .setPrimaryVrf(new VniReference(2L))
+ .setAutoCreateVrf(true)
+ .setClassifyTable(CLASSIFY_TABLE_NAME)
+ .build())
+ .build())*/
+ .build();
+
+ public static final Route IPV6_ROUTE_WITHOUT_CLASSIFIER_BLACKHOLE_HOP = new RouteBuilder()
+ .setDestinationPrefix(FIRST_ADDRESS_AS_V6_PREFIX)
+ /*.setNextHopOptions(new SpecialNextHopBuilder()
+ .setSpecialNextHop(SpecialNextHopGrouping.SpecialNextHop.Blackhole)
+ /* .addAugmentation(SpecialNextHop2.class, new SpecialNextHop2Builder()
+ .setPrimaryVrf(new VniReference(2L))
+ .setAutoCreateVrf(true)
+ .build())
+ .build())*/
+ .build();
+
+ public static final Route IPV6_ROUTE_WITH_CLASSIFIER_RECEIVE_HOP = new RouteBuilder()
+ .setDestinationPrefix(FIRST_ADDRESS_AS_V6_PREFIX)
+ /*.setNextHopOptions(new SpecialNextHopBuilder()
+ .setSpecialNextHop(SpecialNextHopGrouping.SpecialNextHop.Blackhole)
+ /*.addAugmentation(SpecialNextHop2.class, new SpecialNextHop2Builder()
+ .setPrimaryVrf(new VniReference(2L))
+ .setAutoCreateVrf(true)
+ .setClassifyTable(CLASSIFY_TABLE_NAME)
+ .build())
+ .build())*/
+ .build();
+
+ public static final Route IPV6_ROUTE_WITHOUT_CLASSIFIER_RECEIVE_HOP = new RouteBuilder()
+ .setDestinationPrefix(FIRST_ADDRESS_AS_V6_PREFIX)
+ /*.setNextHopOptions(new SpecialNextHopBuilder()
+ .setSpecialNextHop(SpecialNextHopGrouping.SpecialNextHop.Blackhole)
+ /*.addAugmentation(SpecialNextHop2.class, new SpecialNextHop2Builder()
+ .setPrimaryVrf(new VniReference(2L))
+ .setAutoCreateVrf(true)
+ .build())
+ .build())*/
+ .build();
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java
new file mode 100644
index 000000000..4f95ae328
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/Ipv6RouteNamesFactoryTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing;
+
+import static io.fd.hc2vpp.routing.Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY;
+import static org.junit.Assert.assertEquals;
+
+import io.fd.hc2vpp.common.test.util.NamingContextHelper;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.routing.naming.Ipv6RouteNamesFactory;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.dto.Ip6FibDetails;
+import io.fd.vpp.jvpp.core.types.FibPath;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+@RunWith(HoneycombTestRunner.class)
+public class Ipv6RouteNamesFactoryTest implements RoutingRequestTestHelper, SchemaContextTestHelper,
+ NamingContextHelper {
+
+ @Mock
+ private MappingContext mappingContext;
+
+ private NamingContext interfaceContext;
+ private NamingContext routingProtocolContext;
+ private Ip6FibDetails vppRoute;
+ private FibPath vppPath;
+ private Ipv6RouteNamesFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ interfaceContext = new NamingContext("interface-", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol-", "routing-protocol-context");
+ vppRoute = new Ip6FibDetails();
+ vppRoute.address = FIRST_ADDRESS_AS_ARRAY;
+ vppRoute.addressLength = 64;
+ vppRoute.tableId = 1;
+
+ vppPath = new FibPath();
+ vppPath.nextHop = FIRST_ADDRESS_AS_ARRAY;
+ vppPath.swIfIndex = 2;
+ vppPath.weight = 3;
+ factory = new Ipv6RouteNamesFactory(interfaceContext, routingProtocolContext);
+ defineMapping(mappingContext, "iface", 2, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ }
+
+ @Test
+ public void testUniqueRouteName(
+ @InjectTestData(resourcePath = "/ipv6/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes data) {
+ assertEquals("tst-protocol_2001db8a0b12f01_64",
+ factory.uniqueRouteName(ROUTE_PROTOCOL_NAME, getIpv6RouteWithId(data, 1L)));
+ assertEquals("tst-protocol_2001db8a0b12f01_64", factory.uniqueRouteName(vppRoute, mappingContext));
+ }
+
+ @Test
+ public void testUniqueRouteHopName() {
+ assertEquals("iface_2001db8a0b12f01_3", factory.uniqueRouteHopName(new NextHopBuilder()
+ .setAddress(new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001"))
+ .setWeight((short) 3)
+ .setOutgoingInterface("iface")
+ .build()));
+ assertEquals("iface_2001db8a0b12f01_3",
+ factory.uniqueRouteHopName(vppPath, mappingContext));
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java
new file mode 100644
index 000000000..670f7afe3
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/RoutingModuleTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.Matchers.empty;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import com.google.inject.testing.fieldbinder.Bind;
+import com.google.inject.testing.fieldbinder.BoundFieldModule;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.routing.read.RoutingStateReaderFactory;
+import io.fd.hc2vpp.routing.write.RoutingWriterFactory;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.translate.impl.read.registry.CompositeReaderRegistryBuilder;
+import io.fd.honeycomb.translate.impl.write.registry.FlatWriterRegistryBuilder;
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+
+public class RoutingModuleTest {
+
+ @Named("honeycomb-context")
+ @Bind
+ @Mock
+ private DataBroker honeycombContext;
+
+ @Named("honeycomb-initializer")
+ @Bind
+ @Mock
+ private DataBroker honeycombInitializer;
+
+ @Named("interface-context")
+ @Bind
+ private NamingContext interfaceContext;
+
+ @Named("classify-table-context")
+ @Bind
+ @Mock
+ private VppClassifierContextManager classifierContextManager;
+
+ @Bind
+ @Mock
+ private FutureJVppCore futureJVppCore;
+
+ @Inject
+ private Set<ReaderFactory> readerFactories = new HashSet<>();
+
+ @Inject
+ private Set<WriterFactory> writerFactories = new HashSet<>();
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ interfaceContext = new NamingContext("interfaceContext", "interfaceContext");
+ Guice.createInjector(new RoutingModule(), BoundFieldModule.of(this)).injectMembers(this);
+ }
+
+ @Test
+ public void testReaderFactories() throws Exception {
+ assertThat(readerFactories, is(not(empty())));
+
+ // Test registration process (all dependencies present, topological order of readers does exist, etc.)
+ final CompositeReaderRegistryBuilder registryBuilder = new CompositeReaderRegistryBuilder();
+ readerFactories.stream().forEach(factory -> factory.init(registryBuilder));
+ assertNotNull(registryBuilder.build());
+ assertEquals(1, readerFactories.size());
+ assertTrue(readerFactories.iterator().next() instanceof RoutingStateReaderFactory);
+ }
+
+ @Test
+ public void testWriterFactories() throws Exception {
+ assertThat(writerFactories, is(not(empty())));
+
+ // Test registration process (all dependencies present, topological order of writers does exist, etc.)
+ final FlatWriterRegistryBuilder registryBuilder = new FlatWriterRegistryBuilder();
+ writerFactories.stream().forEach(factory -> factory.init(registryBuilder));
+ assertNotNull(registryBuilder.build());
+ assertEquals(1, writerFactories.size());
+ assertTrue(writerFactories.iterator().next() instanceof RoutingWriterFactory);
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/ClassifyTableTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/ClassifyTableTestHelper.java
new file mode 100644
index 000000000..8e8f50c3d
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/ClassifyTableTestHelper.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.helpers;
+
+
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.translate.MappingContext;
+
+public interface ClassifyTableTestHelper {
+
+ String CLASSIFY_TABLE_NAME = "classify-table-one";
+ int CLASSIFY_TABLE_INDEX = 2;
+
+ default void addMapping(final VppClassifierContextManager classifyManager, final String name, final int index,
+ final MappingContext mappingContext) {
+ when(classifyManager.containsTable(name, mappingContext)).thenReturn(true);
+ when(classifyManager.getTableIndex(name, mappingContext)).thenReturn(index);
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/InterfaceTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/InterfaceTestHelper.java
new file mode 100644
index 000000000..95561e621
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/InterfaceTestHelper.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.helpers;
+
+import io.fd.hc2vpp.common.test.util.NamingContextHelper;
+
+public interface InterfaceTestHelper extends NamingContextHelper {
+
+ String INTERFACE_NAME = "iface";
+ int INTERFACE_INDEX = 3;
+}
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
new file mode 100644
index 000000000..bcb8e6800
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.helpers;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.util.FutureProducer;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.routing.trait.RouteMapper;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRouteReply;
+import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.List;
+import org.mockito.ArgumentCaptor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.StaticRoutes1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProducer, RouteMapper {
+
+ String ROUTE_PROTOCOL_NAME = "tst-protocol";
+ String ROUTE_NAME = "tst-route";
+ String STATIC_ROUTE_PATH = "/ietf-routing:routing" +
+ "/ietf-routing:routing-instance[ietf-routing:name='" + ROUTE_PROTOCOL_NAME + "']" +
+ "/ietf-routing:routing-protocols" +
+ "/ietf-routing:routing-protocol[ietf-routing:name='" + ROUTE_NAME + "']" +
+ "/ietf-routing:static-routes";
+
+ default IpAddDelRoute desiredFlaglessResult(final int add, final int ipv6, final int isMultipath,
+ final byte[] destinationAddress,
+ final int destinationPrefixLength,
+ final byte[] nextHopAddr,
+ final int nextHopIndex,
+ final int nextHopWeight,
+ final int vrfId,
+ final int createVrfIfNeeded,
+ final int secondaryVrfId,
+ final int classifyTableIndex,
+ final int classifyTableIndexSet) {
+
+ // verification of flagless request, so setting them to 0
+ return desiredResult(add, ipv6, isMultipath, destinationAddress, destinationPrefixLength, nextHopAddr,
+ nextHopIndex, nextHopWeight, vrfId, createVrfIfNeeded, secondaryVrfId, classifyTableIndex,
+ classifyTableIndexSet, 0, 0, 0, 0);
+ }
+
+ default IpAddDelRoute desiredSpecialResult(final int add, final int ipv6,
+ final byte[] destinationAddress,
+ final int destinationPrefixLength,
+ final int isDrop,
+ final int isReceive,
+ final int isUnreach,
+ final int isProhibit) {
+ // 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,
+ isDrop, isReceive, isUnreach, isProhibit);
+ }
+
+ default IpAddDelRoute desiredResult(final int add, final int ipv6, final int isMultipath,
+ final byte[] destinationAddress,
+ final int destinationPrefixLength,
+ final byte[] nextHopAddr,
+ final int nextHopIndex,
+ final int nextHopWeight,
+ final int vrfId,
+ final int createVrfIfNeeded,
+ final int secondaryVrfId,
+ final int classifyTableIndex,
+ final int classifyTableIndexSet,
+ final int isDrop,
+ final int isLocal,
+ final int isUnreach,
+ final int isProhibit) {
+ final IpAddDelRoute request = new IpAddDelRoute();
+
+ request.isAdd = toByte(add);
+ request.isIpv6 = toByte(ipv6);
+ request.isMultipath = toByte(isMultipath);
+ request.dstAddress = destinationAddress;
+ request.dstAddressLength = toByte(destinationPrefixLength);
+ request.nextHopAddress = nextHopAddr;
+ request.nextHopSwIfIndex = nextHopIndex;
+ request.nextHopWeight = toByte(nextHopWeight);
+ request.classifyTableIndex = classifyTableIndexSet;
+ request.tableId = vrfId;
+ request.nextHopTableId = secondaryVrfId;
+ request.createVrfIfNeeded = toByte(createVrfIfNeeded);
+ request.classifyTableIndex = classifyTableIndex;
+ request.isClassify = toByte(classifyTableIndexSet);
+ // special hop flags
+ request.isDrop = toByte(isDrop);
+ request.isLocal = toByte(isLocal);
+ request.isUnreach = toByte(isUnreach);
+ request.isProhibit = toByte(isProhibit);
+ return request;
+ }
+
+ default void verifyInvocation(final int nrOfInvocations, final List<IpAddDelRoute> desiredRequests, final
+ FutureJVppCore api, final ArgumentCaptor<IpAddDelRoute> requestCaptor) {
+ verify(api, times(nrOfInvocations)).ipAddDelRoute(requestCaptor.capture());
+
+ final List<IpAddDelRoute> actualRequests = requestCaptor.getAllValues();
+
+ for (int i = 0; i < nrOfInvocations; i++) {
+ assertEquals(actualRequests.get(i), desiredRequests.get(i));
+ }
+ }
+
+ default void verifyNotInvoked(final FutureJVppCore api) {
+ verify(api, times(0)).ipAddDelRoute(any());
+ }
+
+ default void whenAddRouteThenSuccess(final FutureJVppCore api) {
+ when(api.ipAddDelRoute(any())).thenReturn(future(new IpAddDelRouteReply()));
+ }
+
+ default Route getIpv4RouteWithId(final StaticRoutes staticRoutes, final long id) {
+ return staticRoutes.getAugmentation(StaticRoutes1.class)
+ .getIpv4()
+ .getRoute()
+ .stream()
+ .filter(route -> route.getId() == id)
+ .collect(RWUtils.singleItemCollector());
+ }
+
+ default NextHop getHopWithId(
+ final Route route, final int id) {
+ return org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList.class
+ .cast(route.getNextHopOptions())
+ .getNextHopList()
+ .getNextHop()
+ .stream()
+ .filter(nextHop -> nextHop.getKey().getId().intValue() == id)
+ .collect(RWUtils.singleItemCollector());
+ }
+
+ default org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route getIpv6RouteWithId(
+ final StaticRoutes staticRoutes, final long id) {
+ return staticRoutes.getAugmentation(
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.StaticRoutes1.class)
+ .getIpv6()
+ .getRoute()
+ .stream()
+ .filter(route -> route.getId() == id)
+ .collect(RWUtils.singleItemCollector());
+ }
+
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java
new file mode 100644
index 000000000..118595aa6
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/SchemaContextTestHelper.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.helpers;
+
+import com.google.common.collect.ImmutableSet;
+import io.fd.honeycomb.test.tools.annotations.InjectablesProcessor;
+import io.fd.honeycomb.test.tools.annotations.SchemaContextProvider;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+
+public interface SchemaContextTestHelper extends InjectablesProcessor {
+
+ @SchemaContextProvider
+ default ModuleInfoBackedContext getSchemaContext() {
+ return provideSchemaContextFor(ImmutableSet.of(
+ // Default ietf-ip
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.$YangModuleInfoImpl
+ .getInstance(),
+ // Default ietf-routing
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.$YangModuleInfoImpl
+ .getInstance(),
+ // Ipv4 augmentations
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.$YangModuleInfoImpl
+ .getInstance(),
+ // Ipv4 augmentations
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.$YangModuleInfoImpl
+ .getInstance(),
+ // Vpp routing
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev161214.$YangModuleInfoImpl
+ .getInstance()));
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java
new file mode 100644
index 000000000..814345f0e
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv4RouteCustomizerTest.java
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.read;
+
+import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
+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.RoutingConfiguration;
+import io.fd.hc2vpp.routing.naming.Ipv4RouteNamesFactory;
+import io.fd.hc2vpp.routing.trait.RouteMapper;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.vpp.jvpp.core.dto.IpFibDetails;
+import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump;
+import io.fd.vpp.jvpp.core.types.FibPath;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.StaticRoutes2;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.NextHopOptions;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SimpleNextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.SpecialNextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey;
+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.state.routing.instance.RoutingProtocols;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class Ipv4RouteCustomizerTest extends ListReaderCustomizerTest<Route, RouteKey, RouteBuilder>
+ implements RouteMapper {
+
+ private final InstanceIdentifier<Ipv4> ipv4InstanceIdentifier = InstanceIdentifier.create(RoutingProtocols.class)
+ .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME))
+ .child(StaticRoutes.class)
+ .augmentation(StaticRoutes2.class)
+ .child(Ipv4.class);
+ private DumpCacheManager<IpFibDetailsReplyDump, Void> manager;
+ @Mock
+ private RoutingConfiguration configuration;
+ @Mock
+ private MultiNamingContext routeHopContext;
+ @Mock
+ private EntityDumpExecutor<IpFibDetailsReplyDump, Void> executor;
+ private NamingContext interfaceContext = new NamingContext("ifaces", "interface-context");
+ private NamingContext routesContext = new NamingContext("routes", "route-context");
+ private NamingContext routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ private InstanceIdentifier<Route> routeIdSpecialHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(1L));
+ private InstanceIdentifier<Route> routeIdSimpleHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(2L));
+ private InstanceIdentifier<Route> routeIdListHop = ipv4InstanceIdentifier.child(Route.class, new RouteKey(3L));
+
+
+ public Ipv4RouteCustomizerTest() {
+ super(Route.class, Ipv4Builder.class);
+ }
+
+ @Override
+ public void setUp() throws ReadFailedException {
+ manager = new DumpCacheManager.DumpCacheManagerBuilder<IpFibDetailsReplyDump, Void>()
+ .withExecutor(executor)
+ .acceptOnly(IpFibDetailsReplyDump.class)
+ .build();
+
+ final IpFibDetailsReplyDump replyDump = replyDump();
+ when(executor.executeDump(routeIdSpecialHop, EntityDumpExecutor.NO_PARAMS)).thenReturn(replyDump);
+ when(executor.executeDump(routeIdSimpleHop, EntityDumpExecutor.NO_PARAMS)).thenReturn(replyDump);
+ when(executor.executeDump(routeIdListHop, EntityDumpExecutor.NO_PARAMS)).thenReturn(replyDump);
+
+ IpFibDetails listRoute = replyDump.ipFibDetails.get(2);
+ final Ipv4RouteNamesFactory factory = new Ipv4RouteNamesFactory(interfaceContext, routingProtocolContext);
+
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ defineMapping(mappingContext, "iface-1", 1, "interface-context");
+ defineMapping(mappingContext, factory.uniqueRouteName(replyDump.ipFibDetails.get(0), mappingContext), 1,
+ "route-context");
+ defineMapping(mappingContext, factory.uniqueRouteName(replyDump.ipFibDetails.get(1), mappingContext), 2,
+ "route-context");
+
+ String listRouteName = factory.uniqueRouteName(listRoute, mappingContext);
+ defineMapping(mappingContext, listRouteName, 3, "route-context");
+
+ when(routeHopContext.getChildIndex(listRouteName, factory.uniqueRouteHopName(listRoute.path[0], mappingContext),
+ mappingContext)).thenReturn(0);
+ when(routeHopContext.getChildIndex(listRouteName, factory.uniqueRouteHopName(listRoute.path[1], mappingContext),
+ mappingContext)).thenReturn(1);
+ }
+
+ private IpFibDetailsReplyDump replyDump() {
+ IpFibDetailsReplyDump replyDump = new IpFibDetailsReplyDump();
+
+ // first is special
+ IpFibDetails detail1 = new IpFibDetails();
+ detail1.tableId = 1;
+ detail1.address = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ detail1.addressLength = 24;
+
+ FibPath path1 = new FibPath();
+ path1.isLocal = 1;
+ detail1.path = new FibPath[]{path1};
+
+
+ //second is simple
+ IpFibDetails detail2 = new IpFibDetails();
+ detail2.tableId = 1;
+ detail2.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail2.addressLength = 22;
+ detail2.path = new FibPath[]{};
+
+ FibPath path2 = new FibPath();
+ path2.weight = 3;
+ path2.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path2.afi = 0;
+ path2.swIfIndex = 1;
+ detail2.path = new FibPath[]{path2};
+
+ // third is list
+ IpFibDetails detail3 = new IpFibDetails();
+ detail3.tableId = 1;
+ detail3.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail3.addressLength = 16;
+
+ FibPath path3 = new FibPath();
+ path3.swIfIndex = 1;
+ path3.weight = 1;
+ path3.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path3.afi = 0;
+
+ FibPath path4 = new FibPath();
+ path4.swIfIndex = 1;
+ path4.weight = 2;
+ path4.nextHop = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY;
+ path4.afi = 0;
+
+ detail3.path = new FibPath[]{path3, path4};
+
+ replyDump.ipFibDetails = Arrays.asList(detail1, detail2, detail3);
+ return replyDump;
+ }
+
+ @Test
+ public void getAllIds() throws Exception {
+ final List<RouteKey> keys = getCustomizer().getAllIds(routeIdSpecialHop, ctx);
+
+ assertThat(keys, hasSize(3));
+ assertThat(keys, hasItems(new RouteKey(1L), new RouteKey(2L), new RouteKey(3L)));
+ }
+
+ @Test
+ public void readCurrentAttributesSpecialHop() throws Exception {
+ final RouteBuilder builder = new RouteBuilder();
+ getCustomizer().readCurrentAttributes(routeIdSpecialHop, builder, ctx);
+
+ assertEquals(1, builder.getId().intValue());
+ assertEquals(1, builder.getKey().getId().intValue());
+ assertEquals(new Ipv4Prefix("192.168.2.1/24"), builder.getDestinationPrefix());
+
+ NextHopOptions hopOptions = builder.getNextHopOptions();
+ assertTrue(hopOptions instanceof SpecialNextHop);
+
+ SpecialNextHop hop = SpecialNextHop.class.cast(hopOptions);
+ assertEquals(SpecialNextHopGrouping.SpecialNextHop.Receive, hop.getSpecialNextHop());
+ }
+
+ @Test
+ public void readCurrentAttributesSimpleHop() throws Exception {
+ final RouteBuilder builder = new RouteBuilder();
+ getCustomizer().readCurrentAttributes(routeIdSimpleHop, builder, ctx);
+
+ assertEquals(2, builder.getId().intValue());
+ assertEquals(2, builder.getKey().getId().intValue());
+ assertEquals(new Ipv4Prefix("192.168.2.2/22"), builder.getDestinationPrefix());
+
+ NextHopOptions hopOptions = builder.getNextHopOptions();
+ assertTrue(hopOptions instanceof SimpleNextHop);
+
+ SimpleNextHop hop = SimpleNextHop.class.cast(hopOptions);
+ assertEquals("192.168.2.1", hop.getNextHop().getValue());
+ assertEquals("iface-1", hop.getOutgoingInterface());
+ }
+
+ @Test
+ public void readCurrentAttributesListHop() throws Exception {
+
+ final RouteBuilder builder = new RouteBuilder();
+ getCustomizer().readCurrentAttributes(routeIdListHop, builder, ctx);
+
+ assertEquals(3, builder.getId().intValue());
+ assertEquals(3, builder.getKey().getId().intValue());
+ assertEquals(new Ipv4Prefix("192.168.2.2/16"), builder.getDestinationPrefix());
+
+ NextHopOptions hopOptions = builder.getNextHopOptions();
+ assertTrue(hopOptions instanceof NextHopList);
+
+ NextHopList hop = NextHopList.class.cast(hopOptions);
+ List<NextHop> hops = hop.getNextHopList().getNextHop();
+
+ assertThat(hops, hasSize(2));
+
+ assertTrue(areEqual(hops.get(0), desiredHop(0L, "192.168.2.1", 1, "iface-1")));
+ assertTrue(areEqual(hops.get(1), desiredHop(1L, "192.168.2.2", 2, "iface-1")));
+ }
+
+ private boolean areEqual(final NextHop first, final NextHop second) {
+ return new EqualsBuilder()
+ .append(true, first.getAddress().getValue().equals(second.getAddress().getValue()))
+ .append(true, first.getId().equals(second.getId()))
+ .append(true, first.getKey().equals(second.getKey()))
+ .append(true, first.getOutgoingInterface().equals(second.getOutgoingInterface()))
+ .isEquals();
+ }
+
+ private NextHop desiredHop(final long id, final String address, final int weight, final String iface) {
+ return new NextHopBuilder()
+ .setAddress(new Ipv4Address(address))
+ .setWeight((short) weight)
+ .setOutgoingInterface(iface)
+ .setId(id)
+ .setKey(new NextHopKey(id))
+ .build();
+ }
+
+ @Override
+ protected ReaderCustomizer<Route, RouteBuilder> initCustomizer() {
+ return new Ipv4RouteCustomizer(manager, configuration, routeHopContext, interfaceContext,
+ routesContext, routingProtocolContext);
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java
new file mode 100644
index 000000000..a026b5777
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/Ipv6RouteCustomizerTest.java
@@ -0,0 +1,287 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.read;
+
+import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.MultiNamingContext;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.routing.Ipv6RouteData;
+import io.fd.hc2vpp.routing.RoutingConfiguration;
+import io.fd.hc2vpp.routing.naming.Ipv6RouteNamesFactory;
+import io.fd.hc2vpp.routing.trait.RouteMapper;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.vpp.jvpp.core.dto.Ip6FibDetails;
+import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump;
+import io.fd.vpp.jvpp.core.types.FibPath;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.StaticRoutes2;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.RouteKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.NextHopOptions;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SimpleNextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.SpecialNextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.state.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHopKey;
+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.state.routing.instance.RoutingProtocols;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class Ipv6RouteCustomizerTest extends ListReaderCustomizerTest<Route, RouteKey, RouteBuilder>
+ implements RouteMapper {
+
+ private static final String ROUTING_PROTOCOL_PREFIX = "route-p-";
+ private DumpCacheManager<Ip6FibDetailsReplyDump, Void> manager;
+
+ @Mock
+ private RoutingConfiguration configuration;
+
+ @Mock
+ private MultiNamingContext routeHopContext;
+
+ @Mock
+ private EntityDumpExecutor<Ip6FibDetailsReplyDump, Void> executor;
+
+ @Mock
+ private ModificationCache cache;
+
+ private NamingContext interfaceContext;
+ private NamingContext routesContext;
+ private NamingContext routingProtocolContext;
+
+ private InstanceIdentifier<Route> routeIdSpecialHop;
+ private InstanceIdentifier<Route> routeIdSimpleHop;
+ private InstanceIdentifier<Route> routeIdListHop;
+ private Ipv6RouteNamesFactory factory;
+
+ public Ipv6RouteCustomizerTest() {
+ super(Route.class, Ipv6Builder.class);
+ }
+
+ @Override
+ public void setUp() throws ReadFailedException {
+ manager = new DumpCacheManager.DumpCacheManagerBuilder<Ip6FibDetailsReplyDump, Void>()
+ .withExecutor(executor)
+ .acceptOnly(Ip6FibDetailsReplyDump.class)
+ .build();
+
+ interfaceContext = new NamingContext("ifaces", "interface-context");
+ routesContext = new NamingContext("routes", "route-context");
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+
+ final InstanceIdentifier<Ipv6> ipv6InstanceIdentifier = InstanceIdentifier.create(RoutingProtocols.class)
+ .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME))
+ .child(StaticRoutes.class)
+ .augmentation(StaticRoutes2.class)
+ .child(Ipv6.class);
+
+ routeIdSpecialHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(1L));
+ routeIdSimpleHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(2L));
+ routeIdListHop = ipv6InstanceIdentifier.child(Route.class, new RouteKey(3L));
+
+ factory = new Ipv6RouteNamesFactory(interfaceContext, routingProtocolContext);
+
+
+ final Ip6FibDetailsReplyDump replyDump = replyDump();
+ when(executor.executeDump(routeIdSpecialHop, EntityDumpExecutor.NO_PARAMS)).thenReturn(replyDump);
+ when(executor.executeDump(routeIdSimpleHop, EntityDumpExecutor.NO_PARAMS)).thenReturn(replyDump);
+ when(executor.executeDump(routeIdListHop, EntityDumpExecutor.NO_PARAMS)).thenReturn(replyDump);
+
+ defineMapping(mappingContext, "iface-1", 1, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ defineMapping(mappingContext, factory.uniqueRouteName(replyDump.ip6FibDetails.get(0), mappingContext), 1,
+ "route-context");
+ defineMapping(mappingContext, factory.uniqueRouteName(replyDump.ip6FibDetails.get(1), mappingContext), 2,
+ "route-context");
+
+ Ip6FibDetails listRoute = replyDump.ip6FibDetails.get(2);
+ String listRouteName = factory.uniqueRouteName(listRoute, mappingContext);
+ defineMapping(mappingContext, listRouteName, 3, "route-context");
+
+ when(routeHopContext.getChildIndex(listRouteName, factory.uniqueRouteHopName(listRoute.path[0], mappingContext),
+ mappingContext))
+ .thenReturn(0);
+ when(routeHopContext.getChildIndex(listRouteName, factory.uniqueRouteHopName(listRoute.path[1], mappingContext),
+ mappingContext))
+ .thenReturn(1);
+ }
+
+ private Ip6FibDetailsReplyDump replyDump() {
+ Ip6FibDetailsReplyDump replyDump = new Ip6FibDetailsReplyDump();
+
+ // first is special
+ Ip6FibDetails detail1 = new Ip6FibDetails();
+ detail1.tableId = 1;
+ detail1.address = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY;
+ detail1.addressLength = 24;
+
+ FibPath path1 = new FibPath();
+ path1.isLocal = 1;
+ detail1.path = new FibPath[]{path1};
+
+
+ //second is simple
+ Ip6FibDetails detail2 = new Ip6FibDetails();
+ detail2.tableId = 1;
+ detail2.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail2.addressLength = 22;
+ detail2.path = new FibPath[]{};
+
+ FibPath path2 = new FibPath();
+ path2.weight = 3;
+ path2.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path2.afi = 0;
+ path2.swIfIndex = 1;
+ detail2.path = new FibPath[]{path2};
+
+ // third is list
+ Ip6FibDetails detail3 = new Ip6FibDetails();
+ detail3.tableId = 1;
+ detail3.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail3.addressLength = 16;
+
+ FibPath path3 = new FibPath();
+ path3.swIfIndex = 1;
+ path3.weight = 1;
+ path3.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path3.afi = 0;
+
+ FibPath path4 = new FibPath();
+ path4.swIfIndex = 1;
+ path4.weight = 2;
+ path4.nextHop = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY;
+ path4.afi = 0;
+
+ detail3.path = new FibPath[]{path3, path4};
+
+ replyDump.ip6FibDetails = Arrays.asList(detail1, detail2, detail3);
+ return replyDump;
+ }
+
+ @Test
+ public void getAllIds() throws Exception {
+ final List<RouteKey> keys = getCustomizer().getAllIds(routeIdSpecialHop, ctx);
+
+ assertThat(keys, hasSize(3));
+ assertThat(keys, hasItems(new RouteKey(1L), new RouteKey(2L), new RouteKey(3L)));
+ }
+
+ @Test
+ public void readCurrentAttributesSpecialHop() throws Exception {
+ final RouteBuilder builder = new RouteBuilder();
+ getCustomizer().readCurrentAttributes(routeIdSpecialHop, builder, ctx);
+
+ assertEquals(1, builder.getId().intValue());
+ assertEquals(1, builder.getKey().getId().intValue());
+ assertEquals("2001:db8:a0b:12f0:0:0:0:1/24", builder.getDestinationPrefix().getValue());
+
+ NextHopOptions hopOptions = builder.getNextHopOptions();
+ assertTrue(hopOptions instanceof SpecialNextHop);
+
+ SpecialNextHop hop = SpecialNextHop.class.cast(hopOptions);
+ assertEquals(SpecialNextHopGrouping.SpecialNextHop.Receive, hop.getSpecialNextHop());
+ }
+
+ @Test
+ public void readCurrentAttributesSimpleHop() throws Exception {
+ final RouteBuilder builder = new RouteBuilder();
+ getCustomizer().readCurrentAttributes(routeIdSimpleHop, builder, ctx);
+
+ assertEquals(2, builder.getId().intValue());
+ assertEquals(2, builder.getKey().getId().intValue());
+ assertEquals("2001:db8:a0b:12f0:0:0:0:2/22", builder.getDestinationPrefix().getValue());
+
+ NextHopOptions hopOptions = builder.getNextHopOptions();
+ assertTrue(hopOptions instanceof SimpleNextHop);
+
+ SimpleNextHop hop = SimpleNextHop.class.cast(hopOptions);
+ assertEquals("2001:db8:a0b:12f0::1", hop.getNextHop().getValue());
+ assertEquals("iface-1", hop.getOutgoingInterface());
+ }
+
+ @Test
+ public void readCurrentAttributesListHop() throws Exception {
+
+
+ final RouteBuilder builder = new RouteBuilder();
+ getCustomizer().readCurrentAttributes(routeIdListHop, builder, ctx);
+
+ assertEquals(3, builder.getId().intValue());
+ assertEquals(3, builder.getKey().getId().intValue());
+ assertEquals("2001:db8:a0b:12f0:0:0:0:2/16", builder.getDestinationPrefix().getValue());
+
+ NextHopOptions hopOptions = builder.getNextHopOptions();
+ assertTrue(hopOptions instanceof NextHopList);
+
+ NextHopList hop = NextHopList.class.cast(hopOptions);
+ List<NextHop> hops = hop.getNextHopList().getNextHop();
+
+ assertThat(hops, hasSize(2));
+
+ assertTrue(areEqual(hops.get(0), desiredHop(0L, "2001:db8:a0b:12f0::1", 1, "iface-1")));
+ assertTrue(areEqual(hops.get(1), desiredHop(1L, "2001:db8:a0b:12f0::2", 2, "iface-1")));
+ }
+
+ private boolean areEqual(final NextHop first, final NextHop second) {
+ return new EqualsBuilder()
+ .append(true, first.getAddress().getValue().equals(second.getAddress().getValue()))
+ .append(true, first.getId().equals(second.getId()))
+ .append(true, first.getKey().equals(second.getKey()))
+ .append(true, first.getOutgoingInterface().equals(second.getOutgoingInterface()))
+ .isEquals();
+ }
+
+ private NextHop desiredHop(final long id, final String address, final int weight, final String iface) {
+ return new NextHopBuilder()
+ .setAddress(new Ipv6Address(address))
+ .setWeight((short) weight)
+ .setOutgoingInterface(iface)
+ .setId(id)
+ .setKey(new NextHopKey(id))
+ .build();
+ }
+
+ @Override
+ protected ReaderCustomizer<Route, RouteBuilder> initCustomizer() {
+ return new Ipv6RouteCustomizer(manager, configuration, routeHopContext,
+ interfaceContext, routesContext, routingProtocolContext);
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java
new file mode 100644
index 000000000..1d0057cf2
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingProtocolCustomizerTest.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.read;
+
+import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.core.IsCollectionContaining.hasItems;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.hc2vpp.routing.Ipv4RouteData;
+import io.fd.hc2vpp.routing.Ipv6RouteData;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.util.read.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor;
+import io.fd.vpp.jvpp.core.dto.Ip6FibDetails;
+import io.fd.vpp.jvpp.core.dto.Ip6FibDetailsReplyDump;
+import io.fd.vpp.jvpp.core.dto.IpFibDetails;
+import io.fd.vpp.jvpp.core.dto.IpFibDetailsReplyDump;
+import io.fd.vpp.jvpp.core.types.FibPath;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocols;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.RoutingProtocolsBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocol;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.state.routing.instance.routing.protocols.RoutingProtocolKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class RoutingProtocolCustomizerTest
+ extends ListReaderCustomizerTest<RoutingProtocol, RoutingProtocolKey, RoutingProtocolBuilder>
+ implements ByteDataTranslator {
+
+ private static final String VPP_PROTOCOL_PREFIX = "vpp-protocol";
+
+ @Mock
+ private EntityDumpExecutor<IpFibDetailsReplyDump, Void> ipv4Executor;
+
+ @Mock
+ private EntityDumpExecutor<Ip6FibDetailsReplyDump, Void> ipv6Executor;
+ private DumpCacheManager<IpFibDetailsReplyDump, Void> ipv4RoutesDumpManager;
+ private DumpCacheManager<Ip6FibDetailsReplyDump, Void> ipv6RoutesDumpManager;
+
+ private NamingContext routingProtocolContext;
+
+ public RoutingProtocolCustomizerTest() {
+ super(RoutingProtocol.class, RoutingProtocolsBuilder.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ when(ipv4Executor.executeDump(any(), any())).thenReturn(replyDumpIpv4());
+ when(ipv6Executor.executeDump(any(), any())).thenReturn(replyDumpIpv6());
+ when(ctx.getModificationCache()).thenReturn(cache);
+
+ ipv4RoutesDumpManager = new DumpCacheManager.DumpCacheManagerBuilder<IpFibDetailsReplyDump, Void>()
+ .withExecutor(ipv4Executor)
+ .acceptOnly(IpFibDetailsReplyDump.class)
+ .build();
+
+ ipv6RoutesDumpManager = new DumpCacheManager.DumpCacheManagerBuilder<Ip6FibDetailsReplyDump, Void>()
+ .withExecutor(ipv6Executor)
+ .acceptOnly(Ip6FibDetailsReplyDump.class)
+ .build();
+
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ defineMapping(mappingContext, "tst-protocol-2", 2, "routing-protocol-context");
+ defineMapping(mappingContext, "tst-protocol-3", 3, "routing-protocol-context");
+ }
+
+ @Test
+ public void getAllIds() throws Exception {
+ final List<RoutingProtocolKey> keys =
+ getCustomizer().getAllIds(InstanceIdentifier.create(RoutingProtocol.class), ctx);
+
+ assertThat(keys, hasSize(3));
+ assertThat(keys, hasItems(new RoutingProtocolKey(ROUTE_PROTOCOL_NAME), new RoutingProtocolKey("tst-protocol-2"),
+ new RoutingProtocolKey("tst-protocol-3")));
+ }
+
+ @Test
+ public void readCurrentAttributes() throws Exception {
+ final InstanceIdentifier<RoutingProtocol> identifier = InstanceIdentifier.create(RoutingProtocols.class)
+ .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME));
+
+ final RoutingProtocolBuilder builder = new RoutingProtocolBuilder();
+ getCustomizer().readCurrentAttributes(identifier, builder, ctx);
+
+ assertEquals(ROUTE_PROTOCOL_NAME, builder.getName());
+ assertEquals(ROUTE_PROTOCOL_NAME, builder.getKey().getName());
+ assertEquals(Static.class, builder.getType());
+ }
+
+ @Override
+ protected ReaderCustomizer<RoutingProtocol, RoutingProtocolBuilder> initCustomizer() {
+ return new RoutingProtocolCustomizer(routingProtocolContext, ipv4RoutesDumpManager, ipv6RoutesDumpManager);
+ }
+
+ private Ip6FibDetailsReplyDump replyDumpIpv6() {
+ Ip6FibDetailsReplyDump replyDump = new Ip6FibDetailsReplyDump();
+
+ // first is special
+ Ip6FibDetails detail1 = new Ip6FibDetails();
+ detail1.tableId = 1;
+ detail1.address = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY;
+ detail1.addressLength = 24;
+
+ FibPath path1 = new FibPath();
+ path1.isLocal = 1;
+ detail1.path = new FibPath[]{path1};
+
+
+ //second is simple
+ Ip6FibDetails detail2 = new Ip6FibDetails();
+ detail2.tableId = 2;
+ detail2.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail2.addressLength = 22;
+ detail2.path = new FibPath[]{};
+
+ FibPath path2 = new FibPath();
+ path2.weight = 3;
+ path2.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path2.afi = 0;
+ path2.swIfIndex = 1;
+ detail2.path = new FibPath[]{path2};
+
+ // third is list
+ Ip6FibDetails detail3 = new Ip6FibDetails();
+ detail3.tableId = 1;
+ detail3.address = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail3.addressLength = 16;
+
+ FibPath path3 = new FibPath();
+ path3.swIfIndex = 1;
+ path3.weight = 1;
+ path3.nextHop = Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path3.afi = 0;
+
+ FibPath path4 = new FibPath();
+ path4.swIfIndex = 1;
+ path4.weight = 2;
+ path4.nextHop = Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY;
+ path4.afi = 0;
+
+ detail3.path = new FibPath[]{path3, path4};
+
+ replyDump.ip6FibDetails = Arrays.asList(detail1, detail2, detail3);
+ return replyDump;
+ }
+
+ private IpFibDetailsReplyDump replyDumpIpv4() {
+ IpFibDetailsReplyDump replyDump = new IpFibDetailsReplyDump();
+
+ // first is special
+ IpFibDetails detail1 = new IpFibDetails();
+ detail1.tableId = 1;
+ detail1.address = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ detail1.addressLength = 24;
+
+ FibPath path1 = new FibPath();
+ path1.isLocal = 1;
+ detail1.path = new FibPath[]{path1};
+
+
+ //second is simple
+ IpFibDetails detail2 = new IpFibDetails();
+ detail2.tableId = 3;
+ detail2.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail2.addressLength = 22;
+ detail2.path = new FibPath[]{};
+
+ FibPath path2 = new FibPath();
+ path2.weight = 3;
+ path2.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path2.afi = 0;
+ path2.swIfIndex = 1;
+ detail2.path = new FibPath[]{path2};
+
+ // third is list
+ IpFibDetails detail3 = new IpFibDetails();
+ detail3.tableId = 1;
+ detail3.address = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY;
+ detail3.addressLength = 16;
+
+ FibPath path3 = new FibPath();
+ path3.swIfIndex = 1;
+ path3.weight = 1;
+ path3.nextHop = Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY;
+ path3.afi = 0;
+
+ FibPath path4 = new FibPath();
+ path4.swIfIndex = 1;
+ path4.weight = 2;
+ path4.nextHop = Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY;
+ path4.afi = 0;
+
+ detail3.path = new FibPath[]{path3, path4};
+
+ replyDump.ipFibDetails = Arrays.asList(detail1, detail2, detail3);
+ return replyDump;
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java
new file mode 100644
index 000000000..7bece735b
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/read/RoutingStateCustomizerTest.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.read;
+
+
+import static org.junit.Assert.assertEquals;
+
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.spi.read.Initialized;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Routing;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.RoutingState;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+@RunWith(HoneycombTestRunner.class)
+public class RoutingStateCustomizerTest implements SchemaContextTestHelper {
+
+ @InjectTestData(resourcePath = "/init/config-data.json")
+ private Routing config;
+
+ @InjectTestData(resourcePath = "/init/state-data.json")
+ private RoutingState state;
+
+ @Mock
+ private ReadContext readContext;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void testInit() {
+ final InstanceIdentifier<RoutingState> identifier = InstanceIdentifier.create(RoutingState.class);
+ final Initialized<? extends DataObject> initilized =
+ new RoutingStateCustomizer().init(identifier, state, readContext);
+
+ final Routing initializedRouting = Routing.class.cast(initilized.getData());
+
+ assertEquals(config, initializedRouting);
+ }
+}
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
new file mode 100644
index 000000000..13b434716
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv4RouteCustomizerTest.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.write;
+
+
+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;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+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;
+import io.fd.hc2vpp.routing.naming.Ipv4RouteNamesFactory;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.StaticRoutes1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.RouteBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+@RunWith(HoneycombTestRunner.class)
+public class Ipv4RouteCustomizerTest extends WriterCustomizerTest
+ implements ClassifyTableTestHelper, RoutingRequestTestHelper, SchemaContextTestHelper {
+
+ @Captor
+ private ArgumentCaptor<IpAddDelRoute> requestCaptor;
+
+ @Mock
+ private VppClassifierContextManager classifyManager;
+
+ @Mock
+ private MultiNamingContext routeHopContext;
+
+ private Ipv4RouteCustomizer customizer;
+ private InstanceIdentifier<Route> validId;
+ private Ipv4RouteNamesFactory namesFactory;
+ private NamingContext routingProtocolContext;
+
+ @Override
+ protected void setUpTest() throws Exception {
+ NamingContext interfaceContext = new NamingContext("interface", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ customizer = new Ipv4RouteCustomizer(api, interfaceContext,
+ new NamingContext("route", "route-context"),
+ routingProtocolContext, routeHopContext, classifyManager);
+
+ validId = InstanceIdentifier.create(RoutingProtocols.class)
+ .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME))
+ .child(StaticRoutes.class)
+ .augmentation(StaticRoutes1.class)
+ .child(Ipv4.class)
+ .child(Route.class);
+
+ namesFactory = new Ipv4RouteNamesFactory(interfaceContext, routingProtocolContext);
+
+ defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ addMapping(classifyManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext);
+ whenAddRouteThenSuccess(api);
+ }
+
+ @Test
+ public void testWriteSingleHop(
+ @InjectTestData(resourcePath = "/ipv4/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ final Route route1 = getIpv4RouteWithId(route, 1L);
+ noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context");
+
+ 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,
+ CLASSIFY_TABLE_INDEX, 1)),
+ api, requestCaptor);
+ }
+
+ @Test
+ public void testWriteHopList(
+ @InjectTestData(resourcePath = "/ipv4/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ final Route route1 = getIpv4RouteWithId(route, 1L);
+ noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context");
+
+ 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,
+ 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,
+ CLASSIFY_TABLE_INDEX, 1)), api,
+ requestCaptor);
+
+ verify(routeHopContext, times(1))
+ .addChild(
+ namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), 1,
+ namesFactory.uniqueRouteHopName(getHopWithId(route1, 1)),
+ mappingContext);
+ verify(routeHopContext, times(1))
+ .addChild(
+ namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), 2,
+ namesFactory.uniqueRouteHopName(getHopWithId(route1, 2)),
+ mappingContext);
+ }
+
+ @Test
+ public void testWriteSpecialHop(
+ @InjectTestData(resourcePath = "/ipv4/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ final Route route1 = getIpv4RouteWithId(route, 1L);
+ noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context");
+
+ customizer.writeCurrentAttributes(validId, route1, writeContext);
+ verifyInvocation(1, ImmutableList
+ .of(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0)), api,
+ requestCaptor);
+ }
+
+ @Test
+ public void testUpdate(
+ @InjectTestData(resourcePath = "/ipv4/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route) {
+ try {
+ customizer.updateCurrentAttributes(validId, new RouteBuilder().build(), getIpv4RouteWithId(route, 1L),
+ writeContext);
+ } catch (WriteFailedException e) {
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
+ verifyNotInvoked(api);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+
+ @Test
+ public void testDeleteSingleHop(
+ @InjectTestData(resourcePath = "/ipv4/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ 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);
+ }
+
+ @Test
+ public void testDeleteHopList(
+ @InjectTestData(resourcePath = "/ipv4/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ final Route route1 = getIpv4RouteWithId(route, 1L);
+ noMappingDefined(mappingContext, namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1), "route-context");
+
+ 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,
+ 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,
+ CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor);
+
+ verify(routeHopContext, times(1))
+ .removeChild(
+ namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1),
+ namesFactory.uniqueRouteHopName(getHopWithId(route1, 1)),
+ mappingContext);
+ verify(routeHopContext, times(1))
+ .removeChild(
+ namesFactory.uniqueRouteName(ROUTE_PROTOCOL_NAME, route1),
+ namesFactory.uniqueRouteHopName(getHopWithId(route1, 2)),
+ mappingContext);
+ }
+
+ @Test
+ public void testDeleteSpecialHop(
+ @InjectTestData(resourcePath = "/ipv4/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ 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,
+ 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
new file mode 100644
index 000000000..c776ca7f7
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/Ipv6RouteCustomizerTest.java
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.write;
+
+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;
+import static org.junit.Assert.fail;
+
+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.Ipv6RouteData;
+import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.StaticRoutes1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.RoutingProtocols;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolKey;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+@RunWith(HoneycombTestRunner.class)
+public class Ipv6RouteCustomizerTest extends WriterCustomizerTest
+ implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper {
+
+ @Captor
+ private ArgumentCaptor<IpAddDelRoute> requestCaptor;
+
+ @Mock
+ private VppClassifierContextManager classifyManager;
+
+ @Mock
+ private MultiNamingContext routeHopContext;
+
+ private NamingContext interfaceContext;
+ private NamingContext routeContext;
+ private NamingContext routingProtocolContext;
+ private Ipv6RouteCustomizer customizer;
+
+ private InstanceIdentifier<Route> validId;
+
+ @Override
+ protected void setUpTest() throws Exception {
+ interfaceContext = new NamingContext("interface", "interface-context");
+ routeContext = new NamingContext("interface", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ customizer =
+ new Ipv6RouteCustomizer(api, interfaceContext, routeContext, routingProtocolContext, routeHopContext,
+ classifyManager);
+
+ validId = InstanceIdentifier.create(RoutingProtocols.class)
+ .child(RoutingProtocol.class, new RoutingProtocolKey(ROUTE_PROTOCOL_NAME))
+ .child(StaticRoutes.class)
+ .augmentation(StaticRoutes1.class)
+ .child(Ipv6.class)
+ .child(Route.class);
+
+ 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");
+ }
+
+ @Test
+ public void testWriteSingleHop(
+ @InjectTestData(resourcePath = "/ipv6/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ whenAddRouteThenSuccess(api);
+ 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,
+ 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor);
+ }
+
+ @Test
+ public void testWriteHopList(
+ @InjectTestData(resourcePath = "/ipv6/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ whenAddRouteThenSuccess(api);
+ customizer.writeCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext);
+ 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,
+ 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,
+ CLASSIFY_TABLE_INDEX, 1)), api,
+ requestCaptor);
+ }
+
+ @Test
+ public void testUpdate() {
+ try {
+ customizer.updateCurrentAttributes(validId, Ipv6RouteData.IPV6_ROUTE_WITH_CLASSIFIER_BLACKHOLE_HOP,
+ Ipv6RouteData.IPV6_ROUTE_WITH_CLASSIFIER_RECEIVE_HOP, writeContext);
+ } catch (WriteFailedException e) {
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
+ verifyNotInvoked(api);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test
+ public void testDeleteSpecialHop(
+ @InjectTestData(resourcePath = "/ipv6/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ whenAddRouteThenSuccess(api);
+ 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,
+ requestCaptor);
+ }
+
+ @Test
+ public void testDeleteSingleHop(
+ @InjectTestData(resourcePath = "/ipv6/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ whenAddRouteThenSuccess(api);
+ customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext);
+ verifyInvocation(1, ImmutableList
+ .of(desiredFlaglessResult(0, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64,
+ Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1,
+ 1, 0, CLASSIFY_TABLE_INDEX, 1)), api, requestCaptor);
+ }
+
+ @Test
+ public void testDeleteHopList(
+ @InjectTestData(resourcePath = "/ipv6/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ whenAddRouteThenSuccess(api);
+ customizer.deleteCurrentAttributes(validId, getIpv6RouteWithId(route, 1L), writeContext);
+ verifyInvocation(2,
+ ImmutableList.of(
+ desiredFlaglessResult(0, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64,
+ Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0,
+ CLASSIFY_TABLE_INDEX, 1),
+ desiredFlaglessResult(0, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64,
+ Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0,
+ CLASSIFY_TABLE_INDEX, 1)), api,
+ requestCaptor);
+ }
+
+ @Test
+ public void testWriteSpecialHop(
+ @InjectTestData(resourcePath = "/ipv6/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH) StaticRoutes route)
+ throws WriteFailedException {
+ whenAddRouteThenSuccess(api);
+ 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,
+ requestCaptor);
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java
new file mode 100644
index 000000000..68fcba5ac
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingInstanceCustomizerTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package io.fd.hc2vpp.routing.write;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.routing.RoutingConfiguration;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstance;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.RoutingInstanceBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class RoutingInstanceCustomizerTest extends WriterCustomizerTest {
+
+ private static final String VALID_NAME = "valid-name";
+ private static final String INVALID_NAME = "invalid-name";
+
+ @Mock
+ private RoutingConfiguration configuration;
+
+ private RoutingInstanceCustomizer customizer;
+ private InstanceIdentifier<RoutingInstance> id;
+
+ private RoutingInstance validData;
+ private RoutingInstance invalidData;
+
+ @Override
+ protected void setUpTest() throws Exception {
+ customizer = new RoutingInstanceCustomizer(configuration);
+
+ when(configuration.getDefaultRoutingInstanceName()).thenReturn(VALID_NAME);
+
+ id = InstanceIdentifier.create(RoutingInstance.class);
+ validData = new RoutingInstanceBuilder().setName(VALID_NAME).build();
+ invalidData = new RoutingInstanceBuilder().setName(INVALID_NAME).build();
+ }
+
+ @Test
+ public void writeCurrentAttributesValid() throws Exception {
+ try {
+ customizer.writeCurrentAttributes(id, validData, writeContext);
+ } catch (Exception e) {
+ fail("Test should passed without exception");
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void writeCurrentAttributesInvalid() throws Exception {
+ customizer.writeCurrentAttributes(id, invalidData, writeContext);
+ }
+
+ @Test
+ public void updateCurrentAttributes() throws Exception {
+ try {
+ customizer.updateCurrentAttributes(id, validData, validData, writeContext);
+ } catch (WriteFailedException.UpdateFailedException e) {
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
+ return;
+ }
+ fail("Test should throw WriteFailedException.UpdateFailedException");
+ }
+
+ @Test
+ public void deleteCurrentAttributesValid() throws Exception {
+ try {
+ customizer.deleteCurrentAttributes(id, validData, writeContext);
+ } catch (Exception e) {
+ fail("Test should passed without exception");
+ }
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void deleteCurrentAttributesInvalid() throws Exception {
+ customizer.deleteCurrentAttributes(id, invalidData, writeContext);
+ }
+
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java
new file mode 100644
index 000000000..d734aab66
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.write;
+
+import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import io.fd.hc2vpp.common.test.write.WriterCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Direct;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.Static;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocol;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.RoutingProtocolBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev161214.RoutingProtocolVppAttr;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev161214.RoutingProtocolVppAttrBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev161214.VniReference;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.vpp.routing.rev161214.routing.routing.instance.routing.protocols.routing.protocol.VppProtocolAttributesBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class RoutingProtocolCustomizerTest extends WriterCustomizerTest {
+
+ private InstanceIdentifier<RoutingProtocol> validId;
+ private RoutingProtocol validData;
+ private RoutingProtocol invalidData;
+ private RoutingProtocolCustomizer customizer;
+ private NamingContext routingProtocolContext;
+
+ @Before
+ public void init() {
+ validId = InstanceIdentifier.create(RoutingProtocol.class);
+ validData = new RoutingProtocolBuilder()
+ .setName(ROUTE_PROTOCOL_NAME)
+ .setType(Static.class)
+ .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder()
+ .setVppProtocolAttributes(new VppProtocolAttributesBuilder()
+ .setPrimaryVrf(new VniReference(1L))
+ .build())
+ .build())
+ .build();
+
+ invalidData = new RoutingProtocolBuilder()
+ .setType(Direct.class)
+ .build();
+
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ customizer = new RoutingProtocolCustomizer(routingProtocolContext);
+ }
+
+ @Test
+ public void testWriteIsStatic() throws WriteFailedException {
+ noMappingDefined(mappingContext, ROUTE_PROTOCOL_NAME, "routing-protocol-context");
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ fail("Test should have passed without throwing exception");
+ }
+ }
+
+ @Test
+ public void testWriteIsStaticAllreadyExist() throws WriteFailedException {
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ try {
+ customizer.writeCurrentAttributes(validId, validData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof IllegalStateException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test
+ public void testWriteIsntStatic() throws WriteFailedException {
+ try {
+ customizer.writeCurrentAttributes(validId, invalidData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e instanceof IllegalArgumentException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+
+ @Test
+ public void testUpdate() throws WriteFailedException {
+ try {
+ customizer.updateCurrentAttributes(validId, validData, validData, writeContext);
+ } catch (Exception e) {
+ assertTrue(e.getCause() instanceof UnsupportedOperationException);
+ return;
+ }
+ fail("Test should have thrown exception");
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java
new file mode 100644
index 000000000..43d01abbf
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv4Test.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.write.factory;
+
+
+import static org.junit.Assert.assertEquals;
+
+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.InterfaceTestHelper;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.NextHopList;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.route.next.hop.options.next.hop.list.next.hop.list.NextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+@RunWith(HoneycombTestRunner.class)
+public class MultipathHopRequestFactoryIpv4Test
+ implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper, InterfaceTestHelper {
+
+ @Mock
+ private VppClassifierContextManager classifierContextManager;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ @InjectTestData(resourcePath = "/ipv4/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv4StaticRoutesWithClassifier;
+
+ @InjectTestData(resourcePath = "/ipv4/multiHopRouteWithoutClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv4StaticRoutesWithoutClassifier;
+
+ private Route ipv4MutlipathRouteWithClassifier;
+ private NextHop ipv4nextHopWithClassifier;
+
+ private Route ipv4MutlipathRouteWithoutClassifier;
+ private NextHop ipv4nextHopWithoutClassifier;
+
+ private NamingContext interfaceContext;
+ private NamingContext routingProtocolContext;
+ private MultipathHopRequestFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ interfaceContext = new NamingContext("interface", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ factory = MultipathHopRequestFactory
+ .forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
+
+ addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext);
+ defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+
+ ipv4MutlipathRouteWithClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithClassifier, 1L);
+ final List<NextHop> ipv4HopsClassified =
+ NextHopList.class.cast(ipv4MutlipathRouteWithClassifier.getNextHopOptions()).getNextHopList()
+ .getNextHop();
+ ipv4nextHopWithClassifier =
+ ipv4HopsClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get();
+
+ ipv4MutlipathRouteWithoutClassifier = getIpv4RouteWithId(ipv4StaticRoutesWithoutClassifier, 1L);
+ final List<NextHop> ipv4HopsNonClassified =
+ NextHopList.class.cast(ipv4MutlipathRouteWithClassifier.getNextHopOptions()).getNextHopList()
+ .getNextHop();
+ ipv4nextHopWithoutClassifier =
+ ipv4HopsNonClassified.stream().filter(nextHop -> nextHop.getId() == 1L).findFirst().get();
+ }
+
+ @Test
+ public void testIpv4WithClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv4MultipathHopRequest(false, ROUTE_PROTOCOL_NAME, ipv4MutlipathRouteWithClassifier,
+ ipv4nextHopWithClassifier,
+ mappingContext);
+
+ assertEquals(desiredFlaglessResult(0, 0, 1, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24,
+ Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, CLASSIFY_TABLE_INDEX, 1), request);
+ }
+
+ @Test
+ public void testIpv4WithoutClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv4MultipathHopRequest(false, ROUTE_PROTOCOL_NAME, ipv4MutlipathRouteWithoutClassifier,
+ ipv4nextHopWithoutClassifier,
+ mappingContext);
+
+ assertEquals(
+ desiredFlaglessResult(0, 0, 1, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24,
+ Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, 0, 0), request);
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java
new file mode 100644
index 000000000..9fc5fae65
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/MultipathHopRequestFactoryIpv6Test.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.write.factory;
+
+import static org.junit.Assert.assertEquals;
+
+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.InterfaceTestHelper;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.NextHopList;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.route.next.hop.options.next.hop.list.next.hop.list.NextHop;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+@RunWith(HoneycombTestRunner.class)
+public class MultipathHopRequestFactoryIpv6Test
+ implements RoutingRequestTestHelper, ClassifyTableTestHelper, InterfaceTestHelper, SchemaContextTestHelper {
+
+ @Mock
+ private VppClassifierContextManager classifierContextManager;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ @InjectTestData(resourcePath = "/ipv6/multiHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv6StaticRoutesWithClassifier;
+
+ @InjectTestData(resourcePath = "/ipv6/multiHopRouteWithoutClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv6StaticRoutesWithoutClassifier;
+
+ private Route ipv6MultipathRouteWithClassifier;
+ private NextHop ipv6nextHopForClassified;
+
+ private Route ipv6MultipathRouteWithoutClassifier;
+ private NextHop ipv6nextHopForNonClassified;
+
+ private NamingContext interfaceContext;
+ private NamingContext routingProtocolContext;
+ private MultipathHopRequestFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ interfaceContext = new NamingContext("interface", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ factory = MultipathHopRequestFactory
+ .forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
+
+ addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext);
+ defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+
+ ipv6MultipathRouteWithClassifier = getIpv6RouteWithId(ipv6StaticRoutesWithClassifier, 1L);
+ ipv6MultipathRouteWithoutClassifier = getIpv6RouteWithId(ipv6StaticRoutesWithoutClassifier, 1L);
+
+ final List<NextHop> ipv6HopsClassified =
+ NextHopList.class.cast(ipv6MultipathRouteWithClassifier.getNextHopOptions()).getNextHopList()
+ .getNextHop();
+
+ final List<NextHop> ipv6HopsNonClassified =
+ NextHopList.class.cast(ipv6MultipathRouteWithoutClassifier.getNextHopOptions()).getNextHopList()
+ .getNextHop();
+
+ ipv6nextHopForClassified = ipv6HopsClassified.stream()
+ .filter(nextHop -> nextHop.getId() == 1L)
+ .findFirst().get();
+ ipv6nextHopForNonClassified = ipv6HopsNonClassified.stream()
+ .filter(nextHop -> nextHop.getId() == 1L)
+ .findFirst().get();
+ }
+
+ @Test
+ public void testIpv6WithClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv6MultipathHopRequest(false, ROUTE_PROTOCOL_NAME, ipv6MultipathRouteWithClassifier,
+ ipv6nextHopForClassified,
+ mappingContext);
+
+ assertEquals(
+ desiredFlaglessResult(0, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64,
+ Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, CLASSIFY_TABLE_INDEX, 1),
+ request);
+ }
+
+ @Test
+ public void testIpv6WithoutClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv6MultipathHopRequest(false, ROUTE_PROTOCOL_NAME, ipv6MultipathRouteWithoutClassifier,
+ ipv6nextHopForNonClassified,
+ mappingContext);
+
+ assertEquals(
+ desiredFlaglessResult(0, 1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64,
+ Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 2, 1, 1, 0, 0, 0), request);
+ }
+
+
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java
new file mode 100644
index 000000000..cfb352daa
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv4Test.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.write.factory;
+
+import static org.junit.Assert.assertEquals;
+
+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.InterfaceTestHelper;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.StaticRoutes1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+@RunWith(HoneycombTestRunner.class)
+public class SimpleHopRequestFactoryIpv4Test
+ implements RoutingRequestTestHelper, ClassifyTableTestHelper, InterfaceTestHelper, SchemaContextTestHelper {
+ @Mock
+ private VppClassifierContextManager classifierContextManager;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ @InjectTestData(resourcePath = "/ipv4/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv4StaticRouteWithClassifier;
+
+ @InjectTestData(resourcePath = "/ipv4/simpleHopRouteWithoutClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv4StaticRouteWithoutClassifier;
+
+ private NamingContext interfaceContext;
+ private NamingContext routingProtocolContext;
+ private SimpleHopRequestFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ interfaceContext = new NamingContext("interface", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ factory =
+ SimpleHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
+
+ addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext);
+ defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ }
+
+ @Test
+ public void testIpv4WithClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv4SimpleHopRequest(false, ROUTE_PROTOCOL_NAME,
+ getIpv4RouteWithId(ipv4StaticRouteWithClassifier, 1L),
+ mappingContext);
+
+ assertEquals(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), request);
+ }
+
+ @Test
+ public void testIpv4WithoutClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv4SimpleHopRequest(false, ROUTE_PROTOCOL_NAME,
+ ipv4StaticRouteWithoutClassifier.getAugmentation(StaticRoutes1.class).getIpv4().getRoute()
+ .get(0), mappingContext);
+
+ assertEquals(
+ desiredFlaglessResult(0, 0, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24,
+ Ipv4RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 1, 0, 0, 0), request);
+ }
+}
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java
new file mode 100644
index 000000000..e95a66775
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SimpleHopRequestFactoryIpv6Test.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.hc2vpp.routing.write.factory;
+
+import static org.junit.Assert.assertEquals;
+
+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.InterfaceTestHelper;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.StaticRoutes1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+@RunWith(HoneycombTestRunner.class)
+public class SimpleHopRequestFactoryIpv6Test
+ implements RoutingRequestTestHelper, ClassifyTableTestHelper, InterfaceTestHelper, SchemaContextTestHelper {
+
+ @Mock
+ private VppClassifierContextManager classifierContextManager;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ @InjectTestData(resourcePath = "/ipv6/simpleHopRouteWithClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv6StaticRouteWithClassifier;
+
+ @InjectTestData(resourcePath = "/ipv6/simpleHopRouteWithoutClassifier.json", id = STATIC_ROUTE_PATH)
+ private StaticRoutes ipv6StaticRouteWithoutClassifier;
+
+ private NamingContext interfaceContext;
+ private NamingContext routingProtocolContext;
+ private SimpleHopRequestFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ interfaceContext = new NamingContext("interface", "interface-context");
+ routingProtocolContext = new NamingContext("routing-protocol", "routing-protocol-context");
+ factory =
+ SimpleHopRequestFactory.forContexts(classifierContextManager, interfaceContext, routingProtocolContext);
+
+ addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext);
+ defineMapping(mappingContext, INTERFACE_NAME, INTERFACE_INDEX, "interface-context");
+ defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context");
+ }
+
+ @Test
+ public void testIpv6WithClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv6SimpleHopRequest(false, ROUTE_PROTOCOL_NAME,
+ ipv6StaticRouteWithClassifier.getAugmentation(StaticRoutes1.class).getIpv6().getRoute().get(0),
+ mappingContext);
+
+ assertEquals(desiredFlaglessResult(0, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64,
+ Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1,
+ 1, 0, CLASSIFY_TABLE_INDEX, 1), request);
+ }
+
+ @Test
+ public void testIpv6WithoutClassifier() {
+ final IpAddDelRoute request =
+ factory.createIpv6SimpleHopRequest(false, ROUTE_PROTOCOL_NAME,
+ ipv6StaticRouteWithoutClassifier.getAugmentation(StaticRoutes1.class).getIpv6().getRoute()
+ .get(0),
+ mappingContext);
+
+ assertEquals(desiredFlaglessResult(0, 1, 0, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 64,
+ Ipv6RouteData.SECOND_ADDRESS_AS_ARRAY, INTERFACE_INDEX, 0, 1, 1, 0, 0, 0), request);
+ }
+}
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
new file mode 100644
index 000000000..dd93de59a
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv4Test.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.routing.Ipv4RouteData;
+import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.routing.write.trait.RouteRequestProducer;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.StaticRoutes1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv4.unicast.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv4.Route;
+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;
+
+@RunWith(HoneycombTestRunner.class)
+public class SpecialNextHopRequestFactoryIpv4Test
+ implements RouteRequestProducer, RoutingRequestTestHelper, ClassifyTableTestHelper,
+ SchemaContextTestHelper {
+
+ @Mock
+ private VppClassifierContextManager classifierContextManager;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ private SpecialNextHopRequestFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ factory = SpecialNextHopRequestFactory.forClassifierContext(classifierContextManager);
+
+ addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext);
+ }
+
+ @Test
+ public void testIpv4WithClassifierBlackhole(
+ @InjectTestData(resourcePath = "/ipv4/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext,
+ SpecialNextHopGrouping.SpecialNextHop.Blackhole);
+
+ assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0), request);
+ }
+
+ @Test
+ public void testIpv4WithClassifierReceive(
+ @InjectTestData(resourcePath = "/ipv4/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Receive);
+
+ assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0), request);
+ }
+
+ @Test
+ public void testIpv4WithClassifierUnreach(
+ @InjectTestData(resourcePath = "/ipv4/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Unreachable);
+
+ assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0), request);
+ }
+
+ @Test
+ public void testIpv4WithClassifierProhibited(
+ @InjectTestData(resourcePath = "/ipv4/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv4SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Prohibit);
+
+ assertEquals(desiredSpecialResult(1, 0, Ipv4RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1), request);
+ }
+
+ private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) {
+ return staticRoutes.getAugmentation(StaticRoutes1.class).getIpv4().getRoute().stream()
+ .filter(route -> route.getId() == id)
+ .collect(RWUtils.singleItemCollector());
+ }
+}
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
new file mode 100644
index 000000000..b129eef59
--- /dev/null
+++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/factory/SpecialNextHopRequestFactoryIpv6Test.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+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.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.routing.Ipv6RouteData;
+import io.fd.hc2vpp.routing.helpers.ClassifyTableTestHelper;
+import io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper;
+import io.fd.hc2vpp.routing.helpers.SchemaContextTestHelper;
+import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.test.tools.annotations.InjectTestData;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.vpp.jvpp.core.dto.IpAddDelRoute;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.StaticRoutes1;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ipv6.unicast.routing.rev140525.routing.routing.instance.routing.protocols.routing.protocol._static.routes.ipv6.Route;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev140524.routing.routing.instance.routing.protocols.routing.protocol.StaticRoutes;
+
+@RunWith(HoneycombTestRunner.class)
+public class SpecialNextHopRequestFactoryIpv6Test
+ implements RoutingRequestTestHelper, ClassifyTableTestHelper, SchemaContextTestHelper {
+
+ @Mock
+ private VppClassifierContextManager classifierContextManager;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ private SpecialNextHopRequestFactory factory;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ factory = SpecialNextHopRequestFactory.forClassifierContext(classifierContextManager);
+
+ addMapping(classifierContextManager, CLASSIFY_TABLE_NAME, CLASSIFY_TABLE_INDEX, mappingContext);
+ }
+
+ @Test
+ public void testIpv6Blackhole(
+ @InjectTestData(resourcePath = "/ipv6/specialHopRouteBlackhole.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Blackhole);
+
+ assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 1, 0, 0, 0),
+ request);
+ }
+
+ @Test
+ public void testIpv6Receive(
+ @InjectTestData(resourcePath = "/ipv6/specialHopRouteReceive.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Receive);
+
+ assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 1, 0, 0), request);
+ }
+
+ @Test
+ public void testIpv6Unreach(
+ @InjectTestData(resourcePath = "/ipv6/specialHopRouteUnreachable.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Unreachable);
+
+ assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 1, 0), request);
+ }
+
+ @Test
+ public void testIpv6Prohibited(
+ @InjectTestData(resourcePath = "/ipv6/specialHopRouteProhibited.json", id = STATIC_ROUTE_PATH)
+ StaticRoutes routes) {
+ final IpAddDelRoute request =
+ factory.createIpv6SpecialHopRequest(true, extractSingleRoute(routes, 1L), mappingContext, Prohibit);
+
+ assertEquals(desiredSpecialResult(1, 1, Ipv6RouteData.FIRST_ADDRESS_AS_ARRAY, 24, 0, 0, 0, 1), request);
+ }
+
+ private Route extractSingleRoute(final StaticRoutes staticRoutes, final long id) {
+ return staticRoutes.getAugmentation(StaticRoutes1.class).getIpv6().getRoute().stream()
+ .filter(route -> route.getId() == id).collect(
+ RWUtils.singleItemCollector());
+ }
+
+}
diff --git a/routing/routing-impl/src/test/resources/init/config-data.json b/routing/routing-impl/src/test/resources/init/config-data.json
new file mode 100644
index 000000000..05a888b30
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/init/config-data.json
@@ -0,0 +1,109 @@
+{
+ "routing": {
+ "routing-instance": {
+ "name": "routing-3",
+ "router-id": "192.168.2.1",
+ "routing-protocols": {
+ "routing-protocol": [
+ {
+ "name": "test-routing-protocol",
+ "type": "static",
+ "vpp-protocol-attributes": {
+ "primary-vrf": "1"
+ },
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.3/32",
+ "next-hop": "192.168.2.8",
+ "outgoing-interface": "local0",
+ "vpp-ipv4-route": {
+ "secondary-vrf": "1"
+ }
+ },
+ {
+ "id": 2,
+ "destination-prefix": "192.168.2.4/32",
+ "vpp-ipv4-route": {
+ "secondary-vrf": "1"
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "192.168.2.5",
+ "outgoing-interface": "local0",
+ "weight": "1"
+ },
+ {
+ "id": "2",
+ "address": "192.168.2.6",
+ "outgoing-interface": "local0",
+ "weight": "2"
+ }
+ ]
+ }
+ },
+ {
+ "id": 3,
+ "destination-prefix": "192.168.2.5/32",
+ "special-next-hop": "receive"
+ }
+ ]
+ },
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64",
+ "next-hop": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "vpp-ipv6-route": {
+ "secondary-vrf": "1"
+ }
+ },
+ {
+ "id": 2,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0008/64",
+ "vpp-ipv6-route": {
+ "secondary-vrf": "1"
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0003",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "weight": "1"
+ },
+ {
+ "id": "2",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0004",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "weight": "2"
+ },
+ {
+ "id": "3",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0005",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "weight": "3"
+ }
+ ]
+ }
+ },
+ {
+ "id": 3,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0005/32",
+ "special-next-hop": "receive"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/init/state-data.json b/routing/routing-impl/src/test/resources/init/state-data.json
new file mode 100644
index 000000000..7830c8e0a
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/init/state-data.json
@@ -0,0 +1,109 @@
+{
+ "routing-state": {
+ "routing-instance": {
+ "name": "routing-3",
+ "router-id": "192.168.2.1",
+ "routing-protocols": {
+ "routing-protocol": [
+ {
+ "name": "test-routing-protocol",
+ "type": "static",
+ "vpp-protocol-state-attributes": {
+ "primary-vrf": "1"
+ },
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.3/32",
+ "next-hop": "192.168.2.8",
+ "outgoing-interface": "local0",
+ "vpp-ipv4-route-state": {
+ "secondary-vrf": "1"
+ }
+ },
+ {
+ "id": 2,
+ "destination-prefix": "192.168.2.4/32",
+ "vpp-ipv4-route-state": {
+ "secondary-vrf": "1"
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "192.168.2.5",
+ "outgoing-interface": "local0",
+ "weight": "1"
+ },
+ {
+ "id": "2",
+ "address": "192.168.2.6",
+ "outgoing-interface": "local0",
+ "weight": "2"
+ }
+ ]
+ }
+ },
+ {
+ "id": 3,
+ "destination-prefix": "192.168.2.5/32",
+ "special-next-hop": "receive"
+ }
+ ]
+ },
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64",
+ "next-hop": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "vpp-ipv6-route-state": {
+ "secondary-vrf": "1"
+ }
+ },
+ {
+ "id": 2,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0008/64",
+ "vpp-ipv6-route-state": {
+ "secondary-vrf": "1"
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0003",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "weight": "1"
+ },
+ {
+ "id": "2",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0004",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "weight": "2"
+ },
+ {
+ "id": "3",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0005",
+ "outgoing-interface": "GigabitEthernet0/8/0",
+ "weight": "3"
+ }
+ ]
+ }
+ },
+ {
+ "id": 3,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0005/32",
+ "special-next-hop": "receive"
+ }
+ ]
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithClassifier.json
new file mode 100644
index 000000000..99c987e03
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithClassifier.json
@@ -0,0 +1,31 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "vpp-ipv4-route": {
+ "classify-table": "classify-table-one"
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "192.168.2.1",
+ "outgoing-interface": "iface",
+ "weight": "2"
+ },
+ {
+ "id": "2",
+ "address": "192.168.2.2",
+ "outgoing-interface": "iface",
+ "weight": "3"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithoutClassifier.json
new file mode 100644
index 000000000..d4d4a0693
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/multiHopRouteWithoutClassifier.json
@@ -0,0 +1,30 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "vpp-ipv4-route": {
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "192.168.2.1",
+ "outgoing-interface": "iface",
+ "weight": "2"
+ },
+ {
+ "id": "2",
+ "address": "192.168.2.2",
+ "outgoing-interface": "iface",
+ "weight": "3"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithClassifier.json
new file mode 100644
index 000000000..d00d9a06a
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithClassifier.json
@@ -0,0 +1,17 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "vpp-ipv4-route": {
+ "classify-table": "classify-table-one"
+ },
+ "next-hop": "192.168.2.2",
+ "outgoing-interface": "iface"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithoutClassifier.json
new file mode 100644
index 000000000..0ef7cf765
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/simpleHopRouteWithoutClassifier.json
@@ -0,0 +1,16 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "vpp-ipv4-route": {
+ },
+ "next-hop": "192.168.2.2",
+ "outgoing-interface": "iface"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv4/specialHopRouteBlackhole.json b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteBlackhole.json
new file mode 100644
index 000000000..b2ddc238b
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteBlackhole.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "special-next-hop": "blackhole"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv4/specialHopRouteProhibited.json b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteProhibited.json
new file mode 100644
index 000000000..fe9faf44c
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteProhibited.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "special-next-hop": "prohibit"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv4/specialHopRouteReceive.json b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteReceive.json
new file mode 100644
index 000000000..c967aa542
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteReceive.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "special-next-hop": "receive"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv4/specialHopRouteUnreachable.json b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteUnreachable.json
new file mode 100644
index 000000000..bae467fbd
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv4/specialHopRouteUnreachable.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv4": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "192.168.2.1/24",
+ "special-next-hop": "unreachable"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithClassifier.json
new file mode 100644
index 000000000..c8b1e208e
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithClassifier.json
@@ -0,0 +1,31 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64",
+ "vpp-ipv6-route": {
+ "classify-table": "classify-table-one"
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "iface",
+ "weight": "2"
+ },
+ {
+ "id": "2",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "iface",
+ "weight": "2"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithoutClassifier.json
new file mode 100644
index 000000000..2e44ebcf5
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/multiHopRouteWithoutClassifier.json
@@ -0,0 +1,30 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64",
+ "vpp-ipv6-route": {
+ },
+ "next-hop-list": {
+ "next-hop": [
+ {
+ "id": "1",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "iface",
+ "weight": "2"
+ },
+ {
+ "id": "2",
+ "address": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "iface",
+ "weight": "2"
+ }
+ ]
+ }
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithClassifier.json b/routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithClassifier.json
new file mode 100644
index 000000000..c011a8d01
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithClassifier.json
@@ -0,0 +1,17 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64",
+ "vpp-ipv6-route": {
+ "classify-table": "classify-table-one"
+ },
+ "next-hop": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "iface"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithoutClassifier.json b/routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithoutClassifier.json
new file mode 100644
index 000000000..1cb663ca7
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/simpleHopRouteWithoutClassifier.json
@@ -0,0 +1,16 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/64",
+ "vpp-ipv6-route": {
+ },
+ "next-hop": "2001:0db8:0a0b:12f0:0000:0000:0000:0002",
+ "outgoing-interface": "iface"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/ipv6/specialHopRouteBlackhole.json b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteBlackhole.json
new file mode 100644
index 000000000..1cc319107
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteBlackhole.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24",
+ "special-next-hop": "blackhole"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv6/specialHopRouteProhibited.json b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteProhibited.json
new file mode 100644
index 000000000..d69e817d7
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteProhibited.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24",
+ "special-next-hop": "prohibit"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv6/specialHopRouteReceive.json b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteReceive.json
new file mode 100644
index 000000000..50d447de0
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteReceive.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24",
+ "special-next-hop": "receive"
+ }
+ ]
+ }
+ }
+}
diff --git a/routing/routing-impl/src/test/resources/ipv6/specialHopRouteUnreachable.json b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteUnreachable.json
new file mode 100644
index 000000000..c874549d1
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/ipv6/specialHopRouteUnreachable.json
@@ -0,0 +1,13 @@
+{
+ "static-routes": {
+ "ipv6": {
+ "route": [
+ {
+ "id": 1,
+ "destination-prefix": "2001:0db8:0a0b:12f0:0000:0000:0000:0001/24",
+ "special-next-hop": "unreachable"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/routing/routing-impl/src/test/resources/routing.json b/routing/routing-impl/src/test/resources/routing.json
new file mode 100644
index 000000000..95f85414f
--- /dev/null
+++ b/routing/routing-impl/src/test/resources/routing.json
@@ -0,0 +1,4 @@
+{
+ "default-routing-instance-name": "vpp-routing-instance",
+ "learned-route-name-prefix": "learned-route"
+} \ No newline at end of file