summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read')
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitTest.java43
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java55
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java7
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java66
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java69
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java112
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java84
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java67
8 files changed, 491 insertions, 12 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitTest.java
new file mode 100644
index 000000000..0d2a4b645
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LispInitTest.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2017 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.lisp.translate.read;
+
+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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.$YangModuleInfoImpl;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureData;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public interface LispInitTest extends InjectablesProcessor {
+
+ InstanceIdentifier<LispFeatureData> LISP_FTR_IID = InstanceIdentifier.create(Lisp.class)
+ .child(LispFeatureData.class);
+
+ InstanceIdentifier<LispFeatureData> LISP_STATE_FTR_IID = InstanceIdentifier.create(LispState.class)
+ .child(LispFeatureData.class);
+
+ @SchemaContextProvider
+ default ModuleInfoBackedContext schemaContext() {
+ return provideSchemaContextFor(ImmutableSet.of($YangModuleInfoImpl.getInstance(),
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.$YangModuleInfoImpl
+ .getInstance()));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java
index 812ba6eb6..43ec43bec 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocalMappingCustomizerTest.java
@@ -23,12 +23,16 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
+import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
import io.fd.hc2vpp.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
+import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
+import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+import java.nio.charset.StandardCharsets;
import java.util.List;
import org.junit.Test;
import org.mockito.Mock;
@@ -36,6 +40,7 @@ import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping
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.lisp.address.types.rev151105.lisp.address.address.Ipv4;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.HmacKeyType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MappingId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.LocalMappings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.dp.subtable.grouping.LocalMappingsBuilder;
@@ -46,11 +51,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.EidTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.VniTableKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.vni.table.BridgeDomainSubtable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.eid.table.grouping.eid.table.vni.table.VrfSubtable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.hmac.key.grouping.HmacKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
-import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
public class LocalMappingCustomizerTest extends
ListReaderCustomizerTest<LocalMapping, LocalMappingKey, LocalMappingBuilder> implements EidTranslator {
@@ -82,7 +85,6 @@ public class LocalMappingCustomizerTest extends
.child(LocalMappings.class)
.child(LocalMapping.class, new LocalMappingKey(new MappingId("local-mapping")));
- defineDumpData();
defineMappings();
}
@@ -99,6 +101,26 @@ public class LocalMappingCustomizerTest extends
detail.locatorSetIndex = 1;
detail.ttl = 7;
detail.vni = 12;
+ detail.key = "abcdefgh".getBytes(StandardCharsets.UTF_8);
+ detail.keyId = 1;
+
+ replyDump.lispEidTableDetails = ImmutableList.of(detail);
+ when(api.lispEidTableDump(any())).thenReturn(future(replyDump));
+ }
+
+ private void defineDumpDataNoHmacKey() {
+ LispEidTableDetailsReplyDump replyDump = new LispEidTableDetailsReplyDump();
+ LispEidTableDetails detail = new LispEidTableDetails();
+ detail.action = 0;
+ detail.authoritative = 1;
+ detail.context = 4;
+ detail.eid = new byte[]{-64, -88, 2, 1};
+ detail.eidPrefixLen = 32;
+ detail.eidType = (byte) IPV4.getValue();
+ detail.isLocal = 1;
+ detail.locatorSetIndex = 1;
+ detail.ttl = 7;
+ detail.vni = 12;
replyDump.lispEidTableDetails = ImmutableList.of(detail);
when(api.lispEidTableDump(any())).thenReturn(future(replyDump));
@@ -117,7 +139,23 @@ public class LocalMappingCustomizerTest extends
}
@Test
+ public void readCurrentAttributesNoHmacKey() throws ReadFailedException {
+ defineDumpDataNoHmacKey();
+
+ LocalMappingBuilder builder = new LocalMappingBuilder();
+ getCustomizer().readCurrentAttributes(validIdentifier, builder, ctx);
+
+ final LocalMapping mapping = builder.build();
+
+ assertNotNull(mapping);
+ assertEquals(true, compareAddresses(EID_ADDRESS, mapping.getEid().getAddress()));
+ assertEquals("loc-set", mapping.getLocatorSet());
+ assertEquals(HmacKeyType.NoKey, mapping.getHmacKey().getKeyType());
+ }
+
+ @Test
public void readCurrentAttributes() throws Exception {
+ defineDumpData();
LocalMappingBuilder builder = new LocalMappingBuilder();
getCustomizer().readCurrentAttributes(validIdentifier, builder, ctx);
@@ -126,10 +164,15 @@ public class LocalMappingCustomizerTest extends
assertNotNull(mapping);
assertEquals(true, compareAddresses(EID_ADDRESS, mapping.getEid().getAddress()));
assertEquals("loc-set", mapping.getLocatorSet());
+
+ final HmacKey hmacKey = mapping.getHmacKey();
+ assertEquals("abcdefgh", hmacKey.getKey());
+ assertEquals(HmacKeyType.Sha196Key, hmacKey.getKeyType());
}
@Test
public void getAllIds() throws Exception {
+ defineDumpData();
final List<LocalMappingKey> keys = getCustomizer().getAllIds(emptyIdentifier, ctx);
assertEquals(1, keys.size());
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
index 744c57590..b6773d2b2 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/LocatorSetCustomizerTest.java
@@ -54,7 +54,7 @@ import static org.mockito.Mockito.when;
@RunWith(HoneycombTestRunner.class)
public class LocatorSetCustomizerTest
extends InitializingListReaderCustomizerTest<LocatorSet, LocatorSetKey, LocatorSetBuilder>
- implements InjectablesProcessor {
+ implements LispInitTest {
private static final String LOC_1_PATH = "/lisp:lisp-state" +
"/lisp:lisp-feature-data" +
@@ -107,11 +107,6 @@ public class LocatorSetCustomizerTest
assertEquals("loc-set", keys.get(0).getName());
}
- @SchemaContextProvider
- public ModuleInfoBackedContext schemaContext() {
- return provideSchemaContextFor(ImmutableSet.of($YangModuleInfoImpl.getInstance()));
- }
-
@Test
public void testInit(@InjectTestData(resourcePath = "/locator-set.json", id = LOC_1_PATH) LocatorSet locatorSet) {
final LocatorSetKey loc1Key = new LocatorSetKey("loc1");
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
new file mode 100644
index 000000000..9dc1913c5
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRegisterCustomizerTest.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017 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.lisp.translate.read;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.vpp.jvpp.core.dto.ShowLispMapRegisterStateReply;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegister;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.register.grouping.MapRegisterBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MapRegisterCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+ private static final InstanceIdentifier<MapRegister> STATE_IID = LISP_STATE_FTR_IID.child(MapRegister.class);
+ private static final InstanceIdentifier<MapRegister> CONFIG_IID = LISP_FTR_IID.child(MapRegister.class);
+
+ public MapRegisterCustomizerTest() {
+ super(MapRegister.class, LispFeatureDataBuilder.class);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ final ShowLispMapRegisterStateReply reply = new ShowLispMapRegisterStateReply();
+ reply.isEnabled = 1;
+ when(api.showLispMapRegisterState(any())).thenReturn(future(reply));
+ }
+
+ @Test
+ public void testReadCurrentAttributes() throws Exception {
+ final MapRegisterBuilder builder = new MapRegisterBuilder();
+ customizer.readCurrentAttributes(CONFIG_IID, builder, ctx);
+ assertTrue(builder.isEnabled());
+ }
+
+ @Test
+ public void testInit() {
+ final MapRegister data = new MapRegisterBuilder().setEnabled(true).build();
+ invokeInitTest(STATE_IID, data, CONFIG_IID, data);
+ }
+
+ @Override
+ protected ReaderCustomizer initCustomizer() {
+ return new MapRegisterCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
new file mode 100644
index 000000000..85e6231f0
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapRequestModeCustomizerTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2017 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.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapRequestMode.DestinationOnly;
+
+import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
+import io.fd.honeycomb.test.tools.HoneycombTestRunner;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.vpp.jvpp.core.dto.ShowLispMapRequestModeReply;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestMode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.request.mode.grouping.MapRequestModeBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MapRequestModeCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+ private static final InstanceIdentifier<MapRequestMode> STATE_IID = LISP_STATE_FTR_IID.child(MapRequestMode.class);
+ private static final InstanceIdentifier<MapRequestMode> CONFIG_IID = LISP_FTR_IID.child(MapRequestMode.class);
+
+ public MapRequestModeCustomizerTest() {
+ super(MapRequestMode.class, LispFeatureDataBuilder.class);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ final ShowLispMapRequestModeReply reply = new ShowLispMapRequestModeReply();
+ reply.mode = ((byte) DestinationOnly.getIntValue());
+ when(api.showLispMapRequestMode(any())).thenReturn(future(reply));
+ }
+
+ @Test
+ public void testReadCurrentAttributes() throws Exception {
+ final MapRequestModeBuilder builder = new MapRequestModeBuilder();
+ customizer.readCurrentAttributes(CONFIG_IID, builder, ctx);
+ assertEquals(DestinationOnly, builder.getMode());
+ }
+
+ @Test
+ public void testInit() {
+ final MapRequestMode data = new MapRequestModeBuilder().setMode(DestinationOnly).build();
+ invokeInitTest(STATE_IID, data, CONFIG_IID, data);
+ }
+
+ @Override
+ protected ReaderCustomizer initCustomizer() {
+ return new MapRequestModeCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
new file mode 100644
index 000000000..1af22931e
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/MapServerCustomizerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017 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.lisp.translate.read;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.hasSize;
+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.InitializingListReaderCustomizerTest;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.vpp.jvpp.core.dto.LispMapServerDetails;
+import io.fd.vpp.jvpp.core.dto.LispMapServerDetailsReplyDump;
+import io.fd.vpp.jvpp.core.dto.LispMapServerDump;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+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.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.MapServers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.MapServersBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.map.servers.grouping.map.servers.MapServerKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class MapServerCustomizerTest
+ extends InitializingListReaderCustomizerTest<MapServer, MapServerKey, MapServerBuilder>
+ implements LispInitTest {
+
+ private static final MapServerKey
+ SERVER_KEY = new MapServerKey(new IpAddress(new Ipv4Address("192.168.2.1")));
+ private static final InstanceIdentifier<MapServer> STATE_IID = LISP_STATE_FTR_IID.child(MapServers.class)
+ .child(MapServer.class, SERVER_KEY);
+ private static final InstanceIdentifier<MapServer> CONFIG_IID = LISP_FTR_IID.child(MapServers.class)
+ .child(MapServer.class, SERVER_KEY);
+
+ public MapServerCustomizerTest() {
+ super(MapServer.class, MapServersBuilder.class);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ final LispMapServerDetailsReplyDump reply = new LispMapServerDetailsReplyDump();
+ LispMapServerDetails server1 = new LispMapServerDetails();
+ //192.168.2.2
+ server1.ipAddress = new byte[]{-64, -88, 2, 1};
+ server1.isIpv6 = 0;
+
+ LispMapServerDetails server2 = new LispMapServerDetails();
+ //192.168.2.2
+ server2.ipAddress = new byte[]{-64, -88, 2, 2};
+ server2.isIpv6 = 0;
+
+ LispMapServerDetails server3 = new LispMapServerDetails();
+ //2001:0db8:0a0b:12f0:0000:0000:0000:0001
+ server3.ipAddress = new byte[]{32, 1, 13, -72, 10, 11, 18, -16, 0, 0, 0, 0, 0, 0, 0, 1};
+ server3.isIpv6 = 1;
+
+ reply.lispMapServerDetails = Arrays.asList(server1, server2, server3);
+ when(api.lispMapServerDump(any(LispMapServerDump.class))).thenReturn(future(reply));
+ }
+
+ @Test
+ public void testGetAllIds() throws Exception {
+ final List<MapServerKey> allIds = getCustomizer().getAllIds(STATE_IID, ctx);
+ assertThat(allIds, hasSize(3));
+ assertThat(allIds, containsInAnyOrder(
+ new MapServerKey(new IpAddress(new Ipv4AddressNoZone("192.168.2.1"))),
+ new MapServerKey(new IpAddress(new Ipv4AddressNoZone("192.168.2.2"))),
+ new MapServerKey(new IpAddress(new Ipv6AddressNoZone("2001:db8:a0b:12f0::1")))));
+ }
+
+ @Test
+ public void testReadCurrentAttributes() throws Exception {
+ final MapServerBuilder builder = new MapServerBuilder();
+ getCustomizer().readCurrentAttributes(STATE_IID, builder, ctx);
+ assertEquals("192.168.2.1", builder.getIpAddress().getIpv4Address().getValue());
+ }
+
+ @Test
+ public void testInit() {
+ final MapServer data = new MapServerBuilder().setIpAddress(
+ new IpAddress(new Ipv4Address("192.168.2.1"))).build();
+ invokeInitTest(STATE_IID, data, CONFIG_IID, data);
+ }
+
+ @Override
+ protected ReaderCustomizer<MapServer, MapServerBuilder> initCustomizer() {
+ return new MapServerCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
new file mode 100644
index 000000000..107523292
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/PetrCfgCustomizerTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017 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.lisp.translate.read;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.vpp.jvpp.core.dto.ShowLispUsePetrReply;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.use.petr.cfg.grouping.PetrCfgBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class PetrCfgCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+ private static final InstanceIdentifier<PetrCfg> STATE_IID = LISP_STATE_FTR_IID.child(PetrCfg.class);
+ private static final InstanceIdentifier<PetrCfg> CONFIG_IID = LISP_FTR_IID.child(PetrCfg.class);
+
+ public PetrCfgCustomizerTest() {
+ super(PetrCfg.class, LispFeatureDataBuilder.class);
+ }
+
+ private void mockEnabledReply() {
+ final ShowLispUsePetrReply reply = new ShowLispUsePetrReply();
+ reply.address = new byte[]{-64, -88, 2, 1};
+ reply.status = 1;
+ reply.isIp4 = 1;
+ when(api.showLispUsePetr(any())).thenReturn(future(reply));
+ }
+
+ private void mockDisabledReply() {
+ final ShowLispUsePetrReply reply = new ShowLispUsePetrReply();
+ reply.status = 0;
+ when(api.showLispUsePetr(any())).thenReturn(future(reply));
+ }
+
+ @Test
+ public void readCurrentAttributesEnabled() throws Exception {
+ mockEnabledReply();
+ final PetrCfgBuilder builder = new PetrCfgBuilder();
+ getCustomizer().readCurrentAttributes(STATE_IID, builder, ctx);
+ assertEquals("192.168.2.1", builder.getPetrAddress().getIpv4Address().getValue());
+ }
+
+ @Test
+ public void readCurrentAttributesDisabled() throws Exception {
+ mockDisabledReply();
+ final PetrCfgBuilder builder = new PetrCfgBuilder();
+ getCustomizer().readCurrentAttributes(STATE_IID, builder, ctx);
+ assertNull(builder.getPetrAddress());
+ }
+
+ @Test
+ public void testInit() {
+ final PetrCfg data = new PetrCfgBuilder().setPetrAddress(
+ new IpAddress(new Ipv4Address("192.168.2.1"))).build();
+ invokeInitTest(STATE_IID, data, CONFIG_IID, data);
+ }
+
+ @Override
+ protected ReaderCustomizer initCustomizer() {
+ return new PetrCfgCustomizer(api);
+ }
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
new file mode 100644
index 000000000..f5d235358
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RlocProbeCustomizerTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017 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.lisp.translate.read;
+
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
+
+import io.fd.hc2vpp.common.test.read.InitializingReaderCustomizerTest;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.vpp.jvpp.core.dto.ShowLispRlocProbeStateReply;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.lisp.feature.data.grouping.LispFeatureDataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbe;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.rloc.probing.grouping.RlocProbeBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class RlocProbeCustomizerTest extends InitializingReaderCustomizerTest implements LispInitTest {
+ private static final InstanceIdentifier<RlocProbe> STATE_IID = LISP_STATE_FTR_IID.child(RlocProbe.class);
+ private static final InstanceIdentifier<RlocProbe> CONFIG_IID = LISP_FTR_IID.child(RlocProbe.class);
+
+ public RlocProbeCustomizerTest() {
+ super(RlocProbe.class, LispFeatureDataBuilder.class);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ final ShowLispRlocProbeStateReply reply = new ShowLispRlocProbeStateReply();
+ reply.isEnabled = 1;
+ when(api.showLispRlocProbeState(any())).thenReturn(future(reply));
+ }
+
+ @Test
+ public void testInit() {
+ final RlocProbe data = new RlocProbeBuilder().setEnabled(true).build();
+ invokeInitTest(STATE_IID, data, CONFIG_IID, data);
+ }
+
+ @Test
+ public void testReadCurrentAttributes() throws Exception {
+ final RlocProbeBuilder builder = new RlocProbeBuilder();
+ getCustomizer().readCurrentAttributes(CONFIG_IID, builder, ctx);
+ assertTrue(builder.isEnabled());
+ }
+
+
+ @Override
+ protected ReaderCustomizer initCustomizer() {
+ return new RlocProbeCustomizer(api);
+ }
+} \ No newline at end of file