summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src/test
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-09-23 16:39:09 +0200
committerJan Srnicek <jsrnicek@cisco.com>2016-09-23 16:41:57 +0200
commita7147d16c31d9028c6b5dc557264433de0f11c91 (patch)
tree15816600ab3dfa5eea706ef1b1910b2e13ae66d7 /lisp/lisp2vpp/src/test
parente7a0775b21c2ea6b7bb8efb63b5384df26e27fbb (diff)
HONEYCOMB-145 - Utility Class Refactoring
problematic mockito-all changed to mockito-core( https://github.com/mockito/mockito/issues/324) Translate Utils Splitted to multiple Trait Interfaces Ipv4Translator - Logic for translation of ipv4-based data Ipv6Translator - Logic for translation of ipv6-based data MacTranslator - Logic for translation of mac-based data AddressTranslator - Aggregation trait for Ipv4/Ipv6/Mac JvppReplyConsumer - Logic for extracting replies from jvpp calls ByteDataTranslator - any byte-based conversions Plus some existing utility classes changed to traits Change-Id: I342b625954223966802e65dca0fabf8456c89345 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/test')
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java47
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java44
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java8
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java14
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java8
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java8
6 files changed, 64 insertions, 65 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java
deleted file mode 100755
index 0f06d2984..000000000
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package io.fd.honeycomb.lisp.translate.util;
-
-import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
-import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
-import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-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.Ipv6Address;
-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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
-
-public class EidConverterTest {
-
- @Test
- public void testGetEidType() {
- assertEquals(IPV4, EidConverter
- .getEidType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
- .setAddress(
- new Ipv4Builder().setIpv4(
- new Ipv4Address("192.168.2.1"))
- .build())
- .build()));
-
- assertEquals(IPV6, EidConverter
- .getEidType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
- .setAddress(
- new Ipv6Builder().setIpv6(
- new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001"))
- .build())
- .build()));
-
- assertEquals(MAC, EidConverter
- .getEidType(
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
- .setAddress(
- new MacBuilder().setMac(
- new MacAddress("aa:bb:cc:dd:ee:ff"))
- .build())
- .build()));
- }
-}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java
new file mode 100755
index 000000000..88ad10970
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidTranslatorTest.java
@@ -0,0 +1,44 @@
+package io.fd.honeycomb.lisp.translate.util;
+
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+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.Ipv6Address;
+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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+
+public class EidTranslatorTest implements EidTranslator {
+
+ @Test
+ public void testGetEidType() {
+ assertEquals(IPV4, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build()));
+
+ assertEquals(IPV6, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv6Builder().setIpv6(
+ new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001"))
+ .build())
+ .build()));
+
+ assertEquals(MAC, getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new MacBuilder().setMac(
+ new MacAddress("aa:bb:cc:dd:ee:ff"))
+ .build())
+ .build()));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
index 5f4fdcd97..409f27bbc 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
@@ -25,8 +25,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -48,7 +48,7 @@ import org.openvpp.jvpp.core.dto.LispAddDelLocator;
import org.openvpp.jvpp.core.dto.LispAddDelLocatorReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class InterfaceCustomizerTest extends WriterCustomizerTest {
+public class InterfaceCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator {
@Captor
private ArgumentCaptor<LispAddDelLocator> intfCaptor;
@@ -119,7 +119,7 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest {
assertEquals(2, request.weight);
assertEquals(1, request.priority);
assertEquals(5, request.swIfIndex);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
@Test(expected = UnsupportedOperationException.class)
@@ -167,6 +167,6 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest {
assertEquals(2, request.weight);
assertEquals(1, request.priority);
assertEquals(5, request.swIfIndex);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
index c4bd65295..9887c6351 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
@@ -25,7 +25,8 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.ByteDataTranslator;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -52,7 +53,8 @@ import org.openvpp.jvpp.core.dto.LispAddDelLocalEidReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class LocalMappingCustomizerTest extends WriterCustomizerTest {
+public class LocalMappingCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator, Ipv4Translator {
+
@Captor
private ArgumentCaptor<LispAddDelLocalEid> mappingCaptor;
@@ -136,11 +138,11 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(0, request.eidType);
assertEquals(1, request.isAdd);
assertEquals(25, request.vni);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
@Test(expected = UnsupportedOperationException.class)
@@ -159,10 +161,10 @@ public class LocalMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(0, request.eidType);
assertEquals(0, request.isAdd);
assertEquals(25, request.vni);
- assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ assertEquals("Locator", toString(request.locatorSetName));
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
index 0b2051b43..99818d52e 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -36,7 +36,7 @@ import org.openvpp.jvpp.core.dto.LispAddDelMapResolver;
import org.openvpp.jvpp.core.dto.LispAddDelMapResolverReply;
-public class MapResolverCustomizerTest extends WriterCustomizerTest {
+public class MapResolverCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
private MapResolverCustomizer customizer;
@@ -74,7 +74,7 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest {
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(1, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
@@ -97,7 +97,7 @@ public class MapResolverCustomizerTest extends WriterCustomizerTest {
LispAddDelMapResolver request = resolverCaptor.getValue();
assertEquals(0, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.ipAddress).getValue());
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
index 9eca7cf67..dab387a62 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
@@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.lisp.context.util.EidMappingContext;
-import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.Ipv4Translator;
import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.util.concurrent.ExecutionException;
@@ -52,7 +52,7 @@ import org.openvpp.jvpp.core.dto.LispAddDelRemoteMapping;
import org.openvpp.jvpp.core.dto.LispAddDelRemoteMappingReply;
-public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
+public class RemoteMappingCustomizerTest extends WriterCustomizerTest implements Ipv4Translator {
@Captor
private ArgumentCaptor<LispAddDelRemoteMapping> mappingCaptor;
@@ -117,7 +117,7 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals(1, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(25, request.vni);
}
@@ -141,7 +141,7 @@ public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
assertNotNull(request);
assertEquals(0, request.isAdd);
- assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals("1.2.168.192", arrayToIpv4AddressNoZone(request.eid).getValue());
assertEquals(25, request.vni);
}