summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src/test/java/io/fd
diff options
context:
space:
mode:
Diffstat (limited to 'v3po/v3po2vpp/src/test/java/io/fd')
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java15
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java28
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizerTest.java57
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java20
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java21
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java48
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java51
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java17
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java25
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java21
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java40
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidatorTest.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java7
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java8
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java8
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ListReaderCustomizerTest.java53
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ReaderCustomizerTest.java94
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java27
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java53
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java30
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java22
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java31
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java4
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java2
33 files changed, 163 insertions, 557 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java
index f3cee8127..75999e5a4 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/AclCustomizerTest.java
@@ -24,16 +24,14 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -50,17 +48,10 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.InputAclSetInterface;
import org.openvpp.jvpp.core.dto.InputAclSetInterfaceReply;
import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class AclCustomizerTest {
+public class AclCustomizerTest extends WriterCustomizerTest {
@Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
- @Mock
private VppClassifierContextManager classifyTableContext;
private NamingContext interfaceContext;
@@ -73,7 +64,7 @@ public class AclCustomizerTest {
private static final int ACL_TABLE_INDEX = 0;
private static final String ACL_TABLE_NAME = "table0";
- @Before
+ @Override
public void setUp() throws Exception {
initMocks(this);
interfaceContext = new NamingContext("generatedInterfaceName", IFC_TEST_INSTANCE);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java
index 8eaf2397a..cf92ab91f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/GreCustomizerTest.java
@@ -32,24 +32,19 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.net.InetAddresses;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
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.interfaces.rev140508.Interfaces;
@@ -63,9 +58,8 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.GreAddDelTunnel;
import org.openvpp.jvpp.core.dto.GreAddDelTunnelReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class GreCustomizerTest {
+public class GreCustomizerTest extends WriterCustomizerTest {
private static final String IFC_TEST_INSTANCE = "ifc-test-instance";
private final String IFACE_NAME = "eth0";
@@ -75,27 +69,13 @@ public class GreCustomizerTest {
private static final byte ADD_GRE = 1;
private static final byte DEL_GRE = 0;
- @Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
-
private GreCustomizer customizer;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
InterfaceTypeTestUtils.setupWriteContext(writeContext,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.GreTunnel.class);
- // TODO HONEYCOMB-116 create base class for tests using vppApi
- NamingContext namingContext = new NamingContext("generateInterfaceNAme", IFC_TEST_INSTANCE);
- final ModificationCache toBeReturned = new ModificationCache();
- doReturn(toBeReturned).when(writeContext).getModificationCache();
- doReturn(mappingContext).when(writeContext).getMappingContext();
-
- customizer = new GreCustomizer(api, namingContext);
+ customizer = new GreCustomizer(api, new NamingContext("generateInterfaceNAme", IFC_TEST_INSTANCE));
}
private void whenGreAddDelTunnelThenSuccess()
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizerTest.java
index 3748a9738..caac8a37b 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ProxyArpCustomizerTest.java
@@ -16,34 +16,37 @@
package io.fd.honeycomb.translate.v3po.interfaces;
-import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
-import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
-import org.junit.Before;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-
-public class ProxyArpCustomizerTest {
-
- @Mock
- private FutureJVppCore vppApi;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
-
- private ProxyArpCustomizer proxyArpCustomizer;
- private NamingContext namingContext;
-
- @Before
- protected void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- namingContext = new NamingContext("generatedSubInterfaceName", "test-instance");
- doReturn(mappingContext).when(writeContext).getMappingContext();
-
- proxyArpCustomizer = new ProxyArpCustomizer(vppApi, namingContext);
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppInterfaceAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.interfaces._interface.ProxyArp;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class ProxyArpCustomizerTest extends WriterCustomizerTest {
+
+ private ProxyArpCustomizer customizer;
+
+ @Override
+ public void setUp() throws Exception {
+ customizer = new ProxyArpCustomizer(api, new NamingContext("generatedSubInterfaceName", "test-instance"));
+ }
+
+ @Test(expected = WriteFailedException.UpdateFailedException.class)
+ public void testUpdate() throws Exception {
+ final ProxyArp dataBefore = mock(ProxyArp.class);
+ final ProxyArp dataAfter = mock(ProxyArp.class);
+ customizer.updateCurrentAttributes(getProxyArpId("eth0"), dataBefore, dataAfter, writeContext);
+ }
+
+ private InstanceIdentifier<ProxyArp> getProxyArpId(final String eth0) {
+ return InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(eth0)).augmentation(
+ VppInterfaceAugmentation.class).child(ProxyArp.class);
}
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java
index 73c0dc76b..366d9429e 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/RewriteCustomizerTest.java
@@ -22,22 +22,18 @@ import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TagRewriteOperation;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
@@ -54,16 +50,8 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewrite;
import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class RewriteCustomizerTest {
-
- @Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
+public class RewriteCustomizerTest extends WriterCustomizerTest {
private NamingContext namingContext;
private RewriteCustomizer customizer;
@@ -75,11 +63,9 @@ public class RewriteCustomizerTest {
private static final int VLAN_IF_INDEX = 11;
private InstanceIdentifier<Rewrite> VLAN_IID;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE);
- doReturn(mappingContext).when(writeContext).getMappingContext();
customizer = new RewriteCustomizer(api, namingContext);
VLAN_IID = getVlanTagRewriteId(IF_NAME, VLAN_IF_ID);
ContextTestUtils.mockMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_TEST_INSTANCE);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
index 1a1028197..c370a97ea 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/SubInterfaceCustomizerTest.java
@@ -24,22 +24,18 @@ import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.CVlan;
import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.Dot1qTagVlanType;
import org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.Dot1qVlanId;
@@ -68,16 +64,8 @@ import org.openvpp.jvpp.core.dto.CreateSubif;
import org.openvpp.jvpp.core.dto.CreateSubifReply;
import org.openvpp.jvpp.core.dto.SwInterfaceSetFlags;
import org.openvpp.jvpp.core.dto.SwInterfaceSetFlagsReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class SubInterfaceCustomizerTest {
-
- @Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
+public class SubInterfaceCustomizerTest extends WriterCustomizerTest {
private NamingContext namingContext;
private SubInterfaceCustomizer customizer;
@@ -102,12 +90,9 @@ public class SubInterfaceCustomizerTest {
CTAG_ANY = generateTag((short) 1, CVlan.class, new Dot1qTag.VlanId(Dot1qTag.VlanId.Enumeration.Any));
}
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE);
- doReturn(mappingContext).when(writeContext).getMappingContext();
- // TODO HONEYCOMB-116 create base class for tests using vppApi
customizer = new SubInterfaceCustomizer(api, namingContext);
ContextTestUtils.mockMapping(mappingContext, SUB_IFACE_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE);
ContextTestUtils.mockMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_ID, IFC_TEST_INSTANCE);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java
index 9bf86c537..fedc59e79 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/TapCustomizerTest.java
@@ -23,16 +23,11 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import java.util.concurrent.CompletableFuture;
-import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
@@ -49,32 +44,17 @@ import org.openvpp.jvpp.core.dto.TapDelete;
import org.openvpp.jvpp.core.dto.TapDeleteReply;
import org.openvpp.jvpp.core.dto.TapModify;
import org.openvpp.jvpp.core.dto.TapModifyReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class TapCustomizerTest {
+public class TapCustomizerTest extends WriterCustomizerTest {
private static final String IFC_TEST_INSTANCE = "ifc-test-instance";
-
- @Mock
- private FutureJVppCore vppApi;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
-
private TapCustomizer tapCustomizer;
- @Before
+ @Override
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
InterfaceTypeTestUtils.setupWriteContext(writeContext,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap.class);
- final NamingContext ctx = new NamingContext("ifcintest", IFC_TEST_INSTANCE);
- final ModificationCache toBeReturned = new ModificationCache();
- doReturn(toBeReturned).when(writeContext).getModificationCache();
- doReturn(mappingContext).when(writeContext).getMappingContext();
-
- tapCustomizer = new TapCustomizer(vppApi, ctx);
+ tapCustomizer = new TapCustomizer(api, new NamingContext("ifcintest", IFC_TEST_INSTANCE));
}
@Test
@@ -91,12 +71,12 @@ public class TapCustomizerTest {
reply.complete(t);
return reply;
}
- }).when(vppApi).tapConnect(any(TapConnect.class));
+ }).when(api).tapConnect(any(TapConnect.class));
tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
tapCustomizer.writeCurrentAttributes(getTapId("tap2"), getTapData("tap2", "ff:ff:ff:ff:ff:ff"), writeContext);
- verify(vppApi, times(2)).tapConnect(any(TapConnect.class));
+ verify(api, times(2)).tapConnect(any(TapConnect.class));
verify(mappingContext).put(eq(ContextTestUtils.getMappingIid("tap", IFC_TEST_INSTANCE)), eq(
ContextTestUtils.getMapping("tap", 0).get()));
verify(mappingContext).put(eq(ContextTestUtils.getMappingIid("tap2", IFC_TEST_INSTANCE)), eq(
@@ -109,21 +89,21 @@ public class TapCustomizerTest {
final TapConnectReply t = new TapConnectReply();
t.swIfIndex = 0;
reply.complete(t);
- doReturn(reply).when(vppApi).tapConnect(any(TapConnect.class));
+ doReturn(reply).when(api).tapConnect(any(TapConnect.class));
final CompletableFuture<TapModifyReply> replyModif = new CompletableFuture<>();
final TapModifyReply tmodif = new TapModifyReply();
tmodif.swIfIndex = 0;
replyModif.complete(tmodif);
- doReturn(replyModif).when(vppApi).tapModify(any(TapModify.class));
+ doReturn(replyModif).when(api).tapModify(any(TapModify.class));
tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
ContextTestUtils.mockMapping(mappingContext, "tap", 1, IFC_TEST_INSTANCE);
tapCustomizer.updateCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), getTapData("tap", "ff:ff:ff:ff:ff:f1"), writeContext);
- verify(vppApi).tapConnect(any(TapConnect.class));
- verify(vppApi).tapModify(any(TapModify.class));
+ verify(api).tapConnect(any(TapConnect.class));
+ verify(api).tapModify(any(TapModify.class));
verify(mappingContext).put(eq(ContextTestUtils.getMappingIid("tap", IFC_TEST_INSTANCE)), eq(
ContextTestUtils.getMapping("tap", 0).get()));
@@ -135,19 +115,19 @@ public class TapCustomizerTest {
final TapConnectReply t = new TapConnectReply();
t.swIfIndex = 0;
reply.complete(t);
- doReturn(reply).when(vppApi).tapConnect(any(TapConnect.class));
+ doReturn(reply).when(api).tapConnect(any(TapConnect.class));
final CompletableFuture<TapDeleteReply> replyDelete = new CompletableFuture<>();
final TapDeleteReply tmodif = new TapDeleteReply();
replyDelete.complete(tmodif);
- doReturn(replyDelete).when(vppApi).tapDelete(any(TapDelete.class));
+ doReturn(replyDelete).when(api).tapDelete(any(TapDelete.class));
tapCustomizer.writeCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
ContextTestUtils.mockMapping(mappingContext, "tap", 1, IFC_TEST_INSTANCE);
tapCustomizer.deleteCurrentAttributes(getTapId("tap"), getTapData("tap", "ff:ff:ff:ff:ff:ff"), writeContext);
- verify(vppApi).tapConnect(any(TapConnect.class));
- verify(vppApi).tapDelete(any(TapDelete.class));
+ verify(api).tapConnect(any(TapConnect.class));
+ verify(api).tapDelete(any(TapDelete.class));
verify(mappingContext).delete(eq(ContextTestUtils.getMappingIid("tap", IFC_TEST_INSTANCE)));
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
index f3963e669..1d2fb609d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VhostUserCustomizerTest.java
@@ -30,13 +30,10 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.write.WriteContext;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import io.fd.honeycomb.translate.write.WriteFailedException;
@@ -45,10 +42,8 @@ import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
@@ -65,36 +60,21 @@ import org.openvpp.jvpp.core.dto.DeleteVhostUserIf;
import org.openvpp.jvpp.core.dto.DeleteVhostUserIfReply;
import org.openvpp.jvpp.core.dto.ModifyVhostUserIf;
import org.openvpp.jvpp.core.dto.ModifyVhostUserIfReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class VhostUserCustomizerTest {
-
- @Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
+public class VhostUserCustomizerTest extends WriterCustomizerTest {
private VhostUserCustomizer customizer;
private static final int IFACE_ID = 1;
private static final String IFACE_NAME = "eth0";
private static final InstanceIdentifier<VhostUser> ID =
- InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
- .augmentation(VppInterfaceAugmentation.class).child(VhostUser.class);
+ InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
+ .augmentation(VppInterfaceAugmentation.class).child(VhostUser.class);
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
InterfaceTypeTestUtils.setupWriteContext(writeContext,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser.class);
- final NamingContext namingContext = new NamingContext("generatedInterfaceName", "test-instance");
- final ModificationCache toBeReturned = new ModificationCache();
- doReturn(toBeReturned).when(writeContext).getModificationCache();
- doReturn(mappingContext).when(writeContext).getMappingContext();
-
- // TODO HONEYCOMB-116 create base class for tests using vppApi
- customizer = new VhostUserCustomizer(api, namingContext);
+ customizer = new VhostUserCustomizer(api, new NamingContext("generatedInterfaceName", "test-instance"));
}
private void whenCreateVhostUserIfThenSuccess()
@@ -111,9 +91,9 @@ public class VhostUserCustomizerTest {
* Failure response send
*/
private void whenCreateVhostUserIfThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException {
doReturn(TestHelperUtils.<CreateVhostUserIfReply>createFutureException()).when(api)
- .createVhostUserIf(any(CreateVhostUserIf.class));
+ .createVhostUserIf(any(CreateVhostUserIf.class));
}
private void whenModifyVhostUserIfThenSuccess()
@@ -130,9 +110,9 @@ public class VhostUserCustomizerTest {
* Failure response send
*/
private void whenModifyVhostUserIfThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException {
doReturn(TestHelperUtils.<ModifyVhostUserIfReply>createFutureException()).when(api)
- .modifyVhostUserIf(any(ModifyVhostUserIf.class));
+ .modifyVhostUserIf(any(ModifyVhostUserIf.class));
}
private void whenDeleteVhostUserIfThenSuccess()
@@ -149,12 +129,13 @@ public class VhostUserCustomizerTest {
* Failure response send
*/
private void whenDeleteVhostUserIfThenFailure()
- throws ExecutionException, InterruptedException, VppInvocationException {
+ throws ExecutionException, InterruptedException, VppInvocationException {
doReturn(TestHelperUtils.<DeleteVhostUserIfReply>createFutureException()).when(api)
- .deleteVhostUserIf(any(DeleteVhostUserIf.class));
+ .deleteVhostUserIf(any(DeleteVhostUserIf.class));
}
- private CreateVhostUserIf verifyCreateVhostUserIfWasInvoked(final VhostUser vhostUser) throws VppInvocationException {
+ private CreateVhostUserIf verifyCreateVhostUserIfWasInvoked(final VhostUser vhostUser)
+ throws VppInvocationException {
ArgumentCaptor<CreateVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(CreateVhostUserIf.class);
verify(api).createVhostUserIf(argumentCaptor.capture());
final CreateVhostUserIf actual = argumentCaptor.getValue();
@@ -169,7 +150,7 @@ public class VhostUserCustomizerTest {
}
private ModifyVhostUserIf verifyModifyVhostUserIfWasInvoked(final VhostUser vhostUser, final int swIfIndex)
- throws VppInvocationException {
+ throws VppInvocationException {
ArgumentCaptor<ModifyVhostUserIf> argumentCaptor = ArgumentCaptor.forClass(ModifyVhostUserIf.class);
verify(api).modifyVhostUserIf(argumentCaptor.capture());
final ModifyVhostUserIf actual = argumentCaptor.getValue();
@@ -206,7 +187,7 @@ public class VhostUserCustomizerTest {
customizer.writeCurrentAttributes(ID, vhostUser, writeContext);
verifyCreateVhostUserIfWasInvoked(vhostUser);
verify(mappingContext).put(eq(ContextTestUtils.getMappingIid(IFACE_NAME, "test-instance")), eq(
- ContextTestUtils.getMapping(IFACE_NAME, 0).get()));
+ ContextTestUtils.getMapping(IFACE_NAME, 0).get()));
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java
index 695c2ff3a..d9678621b 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanCustomizerTest.java
@@ -30,23 +30,20 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.net.InetAddresses;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -64,29 +61,21 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.VxlanAddDelTunnel;
import org.openvpp.jvpp.core.dto.VxlanAddDelTunnelReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class VxlanCustomizerTest {
+public class VxlanCustomizerTest extends WriterCustomizerTest {
private static final byte ADD_VXLAN = 1;
private static final byte DEL_VXLAN = 0;
@Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
- @Mock
private DisabledInterfacesManager disableContext;
private VxlanCustomizer customizer;
private String ifaceName;
private InstanceIdentifier<Vxlan> id;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
InterfaceTypeTestUtils.setupWriteContext(writeContext,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel.class);
// TODO HONEYCOMB-116 create base class for tests using vppApi
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
index 07e050ec6..9d6adff6f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/VxlanGpeCustomizerTest.java
@@ -30,23 +30,19 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.net.InetAddresses;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -65,37 +61,24 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.VxlanAddDelTunnelReply;
import org.openvpp.jvpp.core.dto.VxlanGpeAddDelTunnel;
import org.openvpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class VxlanGpeCustomizerTest {
+public class VxlanGpeCustomizerTest extends WriterCustomizerTest {
private static final byte ADD_VXLAN_GPE = 1;
private static final byte DEL_VXLAN_GPE = 0;
@Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
- @Mock
private DisabledInterfacesManager interfaceDisableContext;
private VxlanGpeCustomizer customizer;
private String ifaceName;
private InstanceIdentifier<VxlanGpe> id;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
InterfaceTypeTestUtils.setupWriteContext(writeContext,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeTunnel.class);
- // TODO HONEYCOMB-116 create base class for tests using vppApi
- NamingContext namingContext = new NamingContext("generateInterfaceNAme", "test-instance");
- final ModificationCache toBeReturned = new ModificationCache();
- doReturn(toBeReturned).when(writeContext).getModificationCache();
- doReturn(mappingContext).when(writeContext).getMappingContext();
-
+ NamingContext namingContext = new NamingContext("generateInterfaceName", "test-instance");
customizer = new VxlanGpeCustomizer(api, namingContext, interfaceDisableContext);
ifaceName = "elth0";
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
index a358512e1..f3c9e79f7 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java
@@ -28,17 +28,14 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.interfaces.ip.subnet.validation.SubnetValidationException;
import io.fd.honeycomb.translate.v3po.interfaces.ip.subnet.validation.SubnetValidator;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.Arrays;
import java.util.Collections;
@@ -72,9 +69,8 @@ import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.IpAddressDetailsReplyDump;
import org.openvpp.jvpp.core.dto.SwInterfaceAddDelAddress;
import org.openvpp.jvpp.core.dto.SwInterfaceAddDelAddressReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class Ipv4AddressCustomizerTest {
+public class Ipv4AddressCustomizerTest extends WriterCustomizerTest {
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE_NAME = "eth0";
@@ -84,27 +80,16 @@ public class Ipv4AddressCustomizerTest {
private ArgumentCaptor<List<Address>> addressesCaptor;
@Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
- @Mock
- private FutureJVppCore api;
- @Mock
private SubnetValidator subnetValidator;
private NamingContext interfaceContext;
private Ipv4AddressCustomizer customizer;
- private ModificationCache cache;
@Before
public void setUp() throws Exception {
- initMocks(this);
- doReturn(mappingContext).when(writeContext).getMappingContext();
- interfaceContext = new NamingContext("generatedlIfaceName", IFC_CTX_NAME);
+ interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
customizer = new Ipv4AddressCustomizer(api, interfaceContext, subnetValidator);
- cache = new ModificationCache();
- when(writeContext.getModificationCache()).thenReturn(cache);
CompletableFuture future = new CompletableFuture();
future.complete(new IpAddressDetailsReplyDump());
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
index d7f9c0c1c..dcde0b43d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java
@@ -22,20 +22,16 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.io.BaseEncoding;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.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.inet.types.rev130715.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
@@ -49,45 +45,25 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.core.dto.IpNeighborAddDel;
import org.openvpp.jvpp.core.dto.IpNeighborAddDelReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class Ipv4NeighbourCustomizerTest {
+public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest {
private static final String IFC_CTX_NAME = "ifc-test-instance";
private static final String IFACE_NAME = "parent";
private static final int IFACE_ID = 5;
- @Mock
- private FutureJVppCore jvpp;
-
- @Mock
- private WriteContext context;
-
- @Mock
- private MappingContext mappingContext;
-
- @Mock
- private Mapping mapping;
-
private ArgumentCaptor<IpNeighborAddDel> requestCaptor;
private Ipv4NeighbourCustomizer customizer;
- private NamingContext namingContext;
-
@Before
public void init() {
- MockitoAnnotations.initMocks(this);
- when(context.getMappingContext()).thenReturn(mappingContext);
-
- namingContext = new NamingContext("prefix", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
-
- customizer = new Ipv4NeighbourCustomizer(jvpp,namingContext);
+ customizer = new Ipv4NeighbourCustomizer(api, new NamingContext("prefix", IFC_CTX_NAME));
requestCaptor = ArgumentCaptor.forClass(IpNeighborAddDel.class);
CompletableFuture<IpNeighborAddDelReply> future = new CompletableFuture<>();
future.complete(new IpNeighborAddDelReply());
- when(jvpp.ipNeighborAddDel(Mockito.any(IpNeighborAddDel.class))).thenReturn(future);
+ when(api.ipNeighborAddDel(Mockito.any(IpNeighborAddDel.class))).thenReturn(future);
}
@Test
@@ -103,9 +79,9 @@ public class Ipv4NeighbourCustomizerTest {
Neighbor data = new NeighborBuilder().setIp(noZoneIp).setLinkLayerAddress(mac).build();
- customizer.writeCurrentAttributes(id, data, context);
+ customizer.writeCurrentAttributes(id, data, writeContext);
- verify(jvpp, times(1)).ipNeighborAddDel(requestCaptor.capture());
+ verify(api, times(1)).ipNeighborAddDel(requestCaptor.capture());
IpNeighborAddDel request = requestCaptor.getValue();
@@ -129,9 +105,9 @@ public class Ipv4NeighbourCustomizerTest {
Neighbor data = new NeighborBuilder().setIp(noZoneIp).setLinkLayerAddress(mac).build();
- customizer.deleteCurrentAttributes(id, data, context);
+ customizer.deleteCurrentAttributes(id, data, writeContext);
- verify(jvpp, times(1)).ipNeighborAddDel(requestCaptor.capture());
+ verify(api, times(1)).ipNeighborAddDel(requestCaptor.capture());
IpNeighborAddDel request = requestCaptor.getValue();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidatorTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidatorTest.java
index 3a29a191a..7c3088f99 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidatorTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfaces/ip/subnet/validation/SubnetValidatorTest.java
@@ -21,7 +21,6 @@ import com.google.common.collect.Lists;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.AddressBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.NetmaskBuilder;
@@ -34,7 +33,6 @@ public class SubnetValidatorTest {
@Before
public void init() {
- MockitoAnnotations.initMocks(this);
subnetValidator = new SubnetValidator();
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
index ba056573f..d7f4cdd8d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/AclCustomizerTest.java
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.vppclassifier.VppClassifierContextManager;
import java.util.concurrent.CompletableFuture;
@@ -60,7 +60,7 @@ public class AclCustomizerTest extends ReaderCustomizerTest<Acl, AclBuilder> {
}
@Override
- public void setUpBefore() {
+ public void setUp() {
interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
index 094d464a2..9545a926a 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/GreCustomizerTest.java
@@ -27,7 +27,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -64,7 +64,7 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
}
@Override
- public void setUpBefore() {
+ public void setUp() throws UnknownHostException, VppInvocationException {
interfacesContext = new NamingContext("gre-tunnel", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
@@ -73,10 +73,7 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> {
final Map<Integer, SwInterfaceDetails> map = new HashMap<>();
map.put(0, v);
cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, map);
- }
- @Override
- protected void setUpAfter() throws UnknownHostException, VppInvocationException {
final CompletableFuture<GreTunnelDetailsReplyDump> greTunnelDetailsReplyDumpCompletionStage =
new CompletableFuture<>();
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
index 5a6376a63..b6ef0ece5 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/InterfaceCustomizerTest.java
@@ -28,7 +28,7 @@ import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.InterfaceTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ListReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.util.Arrays;
import java.util.Collections;
@@ -66,7 +66,7 @@ public class InterfaceCustomizerTest extends
}
@Override
- public void setUpBefore() {
+ public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE0_NAME, IFACE0_ID, IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE1_NAME, IFACE1_ID, IFC_CTX_NAME);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
index 27fa372c6..729a13ef4 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/L2CustomizerTest.java
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.util.Collections;
import java.util.HashMap;
@@ -61,7 +61,7 @@ public class L2CustomizerTest extends ReaderCustomizerTest<L2, L2Builder> {
}
@Override
- public void setUpBefore() {
+ public void setUp() {
interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
bridgeDomainContext = new NamingContext("generatedBDName", BD_CTX_NAME);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java
index 884df320f..432469ddc 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/RewriteCustomizerTest.java
@@ -23,7 +23,7 @@ import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TagRewriteOperation;
import java.util.HashMap;
@@ -66,7 +66,7 @@ public class RewriteCustomizerTest extends ReaderCustomizerTest<Rewrite, Rewrite
}
@Override
- public void setUpBefore() {
+ public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
index 13c0631ee..ec1baebe2 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/SubInterfaceCustomizerTest.java
@@ -25,7 +25,7 @@ import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.InterfaceTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ListReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.util.Collections;
import java.util.HashMap;
@@ -65,7 +65,7 @@ public class SubInterfaceCustomizerTest extends
}
@Override
- public void setUpBefore() {
+ public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_INDEX, IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
index a65050a82..40c1e5e69 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanCustomizerTest.java
@@ -27,7 +27,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -64,7 +64,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
}
@Override
- public void setUpBefore() {
+ public void setUp() throws UnknownHostException, VppInvocationException {
interfacesContext = new NamingContext("vxlan-tunnel", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
@@ -73,10 +73,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
final Map<Integer, SwInterfaceDetails> map = new HashMap<>();
map.put(0, v);
cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, map);
- }
- @Override
- protected void setUpAfter() throws UnknownHostException, VppInvocationException {
final CompletableFuture<VxlanTunnelDetailsReplyDump> vxlanTunnelDetailsReplyDumpCompletionStage =
new CompletableFuture<>();
@@ -94,6 +91,7 @@ public class VxlanCustomizerTest extends ReaderCustomizerTest<Vxlan, VxlanBuilde
vxlanTunnelDetailsReplyDumpCompletionStage.complete(value);
doReturn(vxlanTunnelDetailsReplyDumpCompletionStage).when(api).vxlanTunnelDump(any(VxlanTunnelDump.class));
+
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
index 65cf0c8e9..bf33be31d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/VxlanGpeCustomizerTest.java
@@ -27,7 +27,7 @@ import static org.mockito.Mockito.verifyZeroInteractions;
import com.google.common.collect.Lists;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.net.InetAddress;
import java.net.UnknownHostException;
@@ -64,7 +64,7 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
}
@Override
- public void setUpBefore() {
+ public void setUp() throws UnknownHostException, VppBaseCallException {
interfacesContext = new NamingContext("vxlan_gpe_inf", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IF_NAME, IF_INDEX, IFC_CTX_NAME);
@@ -73,10 +73,7 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
final Map<Integer, SwInterfaceDetails> map = new HashMap<>();
map.put(0, v);
cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, map);
- }
- @Override
- protected void setUpAfter() throws UnknownHostException, VppBaseCallException {
final CompletableFuture<VxlanGpeTunnelDetailsReplyDump> vxlanGpeTunnelDetailsReplyDumpCompletionStage =
new CompletableFuture<>();
@@ -95,6 +92,7 @@ public class VxlanGpeCustomizerTest extends ReaderCustomizerTest<VxlanGpe, Vxlan
vxlanGpeTunnelDetailsReplyDumpCompletionStage.complete(value);
doReturn(vxlanGpeTunnelDetailsReplyDumpCompletionStage).when(api).vxlanGpeTunnelDump(any(VxlanGpeTunnelDump.class));
+
}
@Test
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
index 744cce0b5..73e500fa5 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/interfacesstate/ip/Ipv4AddressCustomizerTest.java
@@ -29,7 +29,7 @@ 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.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ListReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
import java.util.Arrays;
@@ -70,7 +70,7 @@ public class Ipv4AddressCustomizerTest extends ListReaderCustomizerTest<Address,
}
@Override
- public void setUpBefore() {
+ public void setUp() {
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE_2_NAME, IFACE_2_ID, IFC_CTX_NAME);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ListReaderCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ListReaderCustomizerTest.java
deleted file mode 100644
index 936e82c16..000000000
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ListReaderCustomizerTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.honeycomb.translate.v3po.test;
-
-import static org.junit.Assert.assertNotNull;
-
-import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
-import org.junit.Test;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.Identifiable;
-import org.opendaylight.yangtools.yang.binding.Identifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * Generic test for classes implementing {@link ListReaderCustomizer} interface.
- *
- * @param <D> Specific DataObject derived type (Identifiable), that is handled by this customizer
- * @param <K> Specific Identifier for handled type (D)
- * @param <B> Specific Builder for handled type (D)
- */
-public abstract class ListReaderCustomizerTest<D extends DataObject & Identifiable<K>, K extends Identifier<D>, B extends Builder<D>> extends
- ReaderCustomizerTest<D, B> {
-
-
- protected ListReaderCustomizerTest(Class<D> dataObjectClass) {
- super(dataObjectClass);
- }
-
- @Override
- protected ListReaderCustomizer<D, K, B> getCustomizer() {
- return ListReaderCustomizer.class.cast(super.getCustomizer());
- }
-
- @Test
- public void testGetBuilder() throws Exception {
- assertNotNull(getCustomizer().getBuilder(InstanceIdentifier.create(dataObjectClass)));
- }
-}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ReaderCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ReaderCustomizerTest.java
deleted file mode 100644
index 8aeebaba4..000000000
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ReaderCustomizerTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.honeycomb.translate.v3po.test;
-
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.MockitoAnnotations.initMocks;
-
-import io.fd.honeycomb.translate.read.ReadContext;
-import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-
-/**
- * Generic test for classes implementing {@link ReaderCustomizer} interface.
- *
- * @param <D> Specific DataObject derived type (Identifiable), that is handled by this customizer
- * @param <B> Specific Builder for handled type (D)
- */
-public abstract class ReaderCustomizerTest<D extends DataObject, B extends Builder<D>> {
-
- @Mock
- protected FutureJVppCore api;
- protected ModificationCache cache;
- @Mock
- protected ReadContext ctx;
- @Mock
- protected MappingContext mappingContext;
-
- protected final Class<D> dataObjectClass;
- private ReaderCustomizer<D, B> customizer;
-
- protected ReaderCustomizerTest(Class<D> dataObjectClass) {
- this.dataObjectClass = dataObjectClass;
- }
-
- @Before
- public void setUpParent() throws Exception {
- initMocks(this);
- cache = new ModificationCache();
- doReturn(cache).when(ctx).getModificationCache();
- doReturn(mappingContext).when(ctx).getMappingContext();
-
- setUpBefore();
- customizer = initCustomizer();
- setUpAfter();
- }
-
- /**
- * Optional setup for subclasses. Invoked before customizer is initialized.
- */
- protected void setUpBefore() {
-
- }
-
- /**
- * Optional setup for subclasses. Invoked after customizer is initialized.
- */
- protected void setUpAfter() throws Exception {
-
- }
-
- protected abstract ReaderCustomizer<D, B> initCustomizer();
-
- protected ReaderCustomizer<D, B> getCustomizer() {
- return customizer;
- }
-
- @Test
- public void testGetBuilder() throws Exception {
- assertNotNull(customizer.getBuilder(InstanceIdentifier.create(dataObjectClass)));
- }
-}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
index 9f7ab9efb..efd485f10 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java
@@ -24,19 +24,15 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
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.Ipv4AddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
@@ -52,9 +48,8 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.BdIpMacAddDel;
import org.openvpp.jvpp.core.dto.BdIpMacAddDelReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class ArpTerminationTableEntryCustomizerTest {
+public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest {
private static final String BD_CTX_NAME = "bd-test-instance";
private static final String IFC_CTX_NAME = "ifc-test-instance";
@@ -62,16 +57,6 @@ public class ArpTerminationTableEntryCustomizerTest {
private static final int BD_ID = 111;
private static final String IFACE_NAME = "eth0";
private static final int IFACE_ID = 123;
-
- @Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
-
- private NamingContext bdContext;
-
private ArpTerminationTableEntryCustomizer customizer;
private byte[] ipAddressRaw;
private byte[] physAddressRaw;
@@ -80,13 +65,9 @@ public class ArpTerminationTableEntryCustomizerTest {
private ArpTerminationTableEntry entry;
private InstanceIdentifier<ArpTerminationTableEntry> id;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
- doReturn(mappingContext).when(writeContext).getMappingContext();
- bdContext = new NamingContext("generatedBdName", BD_CTX_NAME);
-
- customizer = new ArpTerminationTableEntryCustomizer(api, bdContext);
+ customizer = new ArpTerminationTableEntryCustomizer(api, new NamingContext("generatedBdName", BD_CTX_NAME));
ipAddressRaw = new byte[] {1, 2, 3, 4};
physAddressRaw = new byte[] {1, 2, 3, 4, 5, 6};
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
index aa238cd10..d08192c87 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/BridgeDomainCustomizerTest.java
@@ -23,52 +23,30 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
-import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomain;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.bridge.domains.BridgeDomainBuilder;
import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.BridgeDomainAddDel;
import org.openvpp.jvpp.core.dto.BridgeDomainAddDelReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class BridgeDomainCustomizerTest {
+public class BridgeDomainCustomizerTest extends WriterCustomizerTest {
private static final String BD_CTX_NAME = "bd-test-instance";
-
private static final byte ADD_OR_UPDATE_BD = (byte) 1;
- private static final byte ZERO = 0;
-
- @Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext ctx;
- @Mock
- private MappingContext mappingContext;
-
private BridgeDomainCustomizer customizer;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
- // TODO HONEYCOMB-116 create base class for tests using vppApi
- final ModificationCache toBeReturned = new ModificationCache();
- doReturn(toBeReturned).when(ctx).getModificationCache();
- doReturn(mappingContext).when(ctx).getMappingContext();
-
customizer = new BridgeDomainCustomizer(api, new NamingContext("generatedBDName", BD_CTX_NAME));
}
@@ -137,11 +115,11 @@ public class BridgeDomainCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
- customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx);
+ customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
verify(mappingContext).put(
- ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
+ ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
}
@Test
@@ -153,11 +131,11 @@ public class BridgeDomainCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
- customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx);
+ customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
verify(mappingContext).put(
- ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
+ ContextTestUtils.getMappingIid(bdName, BD_CTX_NAME), ContextTestUtils.getMapping(bdName, bdId).get());
}
@Test
@@ -170,7 +148,7 @@ public class BridgeDomainCustomizerTest {
whenBridgeDomainAddDelThenFailure();
try {
- customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx);
+ customizer.writeCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
} catch (WriteFailedException.CreateFailedException e) {
verifyBridgeDomainAddOrUpdateWasInvoked(bd, bdId);
return;
@@ -187,7 +165,7 @@ public class BridgeDomainCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
- customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx);
+ customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
verifyBridgeDomainDeleteWasInvoked(bdId);
}
@@ -199,7 +177,7 @@ public class BridgeDomainCustomizerTest {
ContextTestUtils.mockEmptyMapping(mappingContext, bdName, BD_CTX_NAME);
try {
- customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx);
+ customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
} catch (IllegalArgumentException e) {
verify(api, never()).bridgeDomainAddDel(any(BridgeDomainAddDel.class));
return;
@@ -217,7 +195,7 @@ public class BridgeDomainCustomizerTest {
whenBridgeDomainAddDelThenFailure();
try {
- customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, ctx);
+ customizer.deleteCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bd, writeContext);
} catch (WriteFailedException.DeleteFailedException e) {
verifyBridgeDomainDeleteWasInvoked(bdId);
return;
@@ -247,7 +225,8 @@ public class BridgeDomainCustomizerTest {
whenBridgeDomainAddDelThenSuccess();
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), dataBefore, dataAfter, ctx);
+ .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), dataBefore, dataAfter,
+ writeContext);
verifyBridgeDomainAddOrUpdateWasInvoked(dataAfter, bdId);
}
@@ -260,7 +239,8 @@ public class BridgeDomainCustomizerTest {
try {
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter, ctx);
+ .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter,
+ writeContext);
} catch (IllegalArgumentException e) {
verify(api, never()).bridgeDomainAddDel(any(BridgeDomainAddDel.class));
return;
@@ -280,7 +260,8 @@ public class BridgeDomainCustomizerTest {
try {
customizer
- .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter, ctx);
+ .updateCurrentAttributes(BridgeDomainTestUtils.bdIdentifierForName(bdName), bdBefore, bdAfter,
+ writeContext);
} catch (WriteFailedException.UpdateFailedException e) {
verifyBridgeDomainAddOrUpdateWasInvoked(bdAfter, bdId);
return;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
index c74423aba..1f15788f0 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vpp/L2FibEntryCustomizerTest.java
@@ -23,19 +23,15 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
-import static org.mockito.MockitoAnnotations.initMocks;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.write.WriteContext;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.L2FibFilter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.l2.fib.attributes.L2FibTable;
@@ -51,9 +47,8 @@ import org.openvpp.jvpp.VppInvocationException;
import org.openvpp.jvpp.core.dto.L2FibAddDel;
import org.openvpp.jvpp.core.dto.L2FibAddDelReply;
import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class L2FibEntryCustomizerTest {
+public class L2FibEntryCustomizerTest extends WriterCustomizerTest {
private static final String BD_CTX_NAME = "bd-test-instance";
private static final String IFC_CTX_NAME = "ifc-test-instance";
@@ -62,28 +57,17 @@ public class L2FibEntryCustomizerTest {
private static final String IFACE_NAME = "eth0";
private static final int IFACE_ID = 123;
- @Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext mappingContext;
-
- private NamingContext bdContext;
- private NamingContext interfaceContext;
-
private L2FibEntryCustomizer customizer;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
- doReturn(mappingContext).when(writeContext).getMappingContext();
- bdContext = new NamingContext("generatedBdName", BD_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
- interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME);
- customizer = new L2FibEntryCustomizer(api, bdContext, interfaceContext);
+ customizer = new L2FibEntryCustomizer(
+ api,
+ new NamingContext("generatedBdName", BD_CTX_NAME),
+ new NamingContext("generatedIfaceName", IFC_CTX_NAME));
}
private static InstanceIdentifier<L2FibEntry> getL2FibEntryId(final PhysAddress address) {
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java
index d1bda8793..ee05d284f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionReaderTest.java
@@ -26,7 +26,7 @@ import static org.mockito.Mockito.when;
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.v3po.test.ListReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -47,7 +47,7 @@ import org.openvpp.jvpp.core.dto.ClassifySessionDetailsReplyDump;
import org.openvpp.jvpp.core.dto.ClassifySessionDump;
public class ClassifySessionReaderTest extends
- ListReaderCustomizerTest<ClassifySession, ClassifySessionKey, ClassifySessionBuilder> {
+ ListReaderCustomizerTest<ClassifySession, ClassifySessionKey, ClassifySessionBuilder> {
private static final String MATCH_1 = "00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00";
private static final String MATCH_2 = "00:00:00:00:00:00:01:02:03:04:05:07:00:00:00:00";
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java
index d7d7ded25..b24d93662 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifySessionWriterTest.java
@@ -25,16 +25,13 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -54,33 +51,24 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.ClassifyAddDelSession;
import org.openvpp.jvpp.core.dto.ClassifyAddDelSessionReply;
import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class ClassifySessionWriterTest {
+public class ClassifySessionWriterTest extends WriterCustomizerTest {
private static final int TABLE_INDEX = 123;
private static final String TABLE_NAME = "table123";
@Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext ctx;
- @Mock
private VppClassifierContextManager classfierContext;
private ClassifySessionWriter customizer;
private static final int SESSION_INDEX = 456;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
- doReturn(ctx).when(writeContext).getMappingContext();
customizer = new ClassifySessionWriter(api, classfierContext);
- when(classfierContext.containsTable(TABLE_NAME, ctx)).thenReturn(true);
- when(classfierContext.getTableIndex(TABLE_NAME, ctx)).thenReturn(TABLE_INDEX);
+ when(classfierContext.containsTable(TABLE_NAME, mappingContext)).thenReturn(true);
+ when(classfierContext.getTableIndex(TABLE_NAME, mappingContext)).thenReturn(TABLE_INDEX);
final ClassifyTable table = mock(ClassifyTable.class);
when(table.getClassifierNode()).thenReturn(new VppNodeName("ip4-classifier"));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java
index d4a8c4363..198cfbee9 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableReaderTest.java
@@ -28,7 +28,7 @@ import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ListReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.junit.Test;
@@ -48,7 +48,7 @@ import org.openvpp.jvpp.core.dto.ClassifyTableInfo;
import org.openvpp.jvpp.core.dto.ClassifyTableInfoReply;
public class ClassifyTableReaderTest extends
- ListReaderCustomizerTest<ClassifyTable, ClassifyTableKey, ClassifyTableBuilder> {
+ ListReaderCustomizerTest<ClassifyTable, ClassifyTableKey, ClassifyTableBuilder> {
private static final int TABLE_INDEX_1 = 1;
private static final String TABLE_NAME_1 = "table1";
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java
index af91ead8c..c49767d90 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppclassifier/ClassifyTableWriterTest.java
@@ -25,15 +25,12 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import static org.mockito.MockitoAnnotations.initMocks;
-import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.v3po.test.TestHelperUtils;
-import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import io.fd.honeycomb.translate.write.WriteFailedException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
@@ -50,29 +47,20 @@ import org.openvpp.jvpp.VppBaseCallException;
import org.openvpp.jvpp.core.dto.ClassifyAddDelTable;
import org.openvpp.jvpp.core.dto.ClassifyAddDelTableReply;
import org.openvpp.jvpp.core.dto.L2InterfaceVlanTagRewriteReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class ClassifyTableWriterTest {
+public class ClassifyTableWriterTest extends WriterCustomizerTest {
private static final int TABLE_INDEX = 123;
private static final String TABLE_NAME = "table123";
@Mock
- private FutureJVppCore api;
- @Mock
- private WriteContext writeContext;
- @Mock
- private MappingContext ctx;
- @Mock
private VppClassifierContextManager classifierContext;
private ClassifyTableWriter customizer;
- @Before
+ @Override
public void setUp() throws Exception {
- initMocks(this);
customizer = new ClassifyTableWriter(api, classifierContext);
- doReturn(ctx).when(writeContext).getMappingContext();
}
private static ClassifyTable generateClassifyTable(final String name) {
@@ -155,7 +143,8 @@ public class ClassifyTableWriterTest {
customizer.writeCurrentAttributes(id, classifyTable, writeContext);
verifyClassifyAddDelTableAddWasInvoked(generateClassifyAddDelTable((byte) 1, TABLE_INDEX));
- verify(classifierContext).addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), ctx);
+ verify(classifierContext)
+ .addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext);
}
@Test
@@ -171,7 +160,7 @@ public class ClassifyTableWriterTest {
assertTrue(e.getCause() instanceof VppBaseCallException);
verifyClassifyAddDelTableAddWasInvoked(generateClassifyAddDelTable((byte) 1, TABLE_INDEX));
verify(classifierContext, times(0))
- .addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), ctx);
+ .addTable(TABLE_INDEX, classifyTable.getName(), classifyTable.getClassifierNode(), mappingContext);
return;
}
fail("WriteFailedException.CreateFailedException was expected");
@@ -182,8 +171,8 @@ public class ClassifyTableWriterTest {
final ClassifyTable classifyTable = generateClassifyTable(TABLE_NAME);
final InstanceIdentifier<ClassifyTable> id = getClassifyTableId(TABLE_NAME);
- when(classifierContext.containsTable(TABLE_NAME, ctx)).thenReturn(true);
- when(classifierContext.getTableIndex(TABLE_NAME, ctx)).thenReturn(TABLE_INDEX);
+ when(classifierContext.containsTable(TABLE_NAME, mappingContext)).thenReturn(true);
+ when(classifierContext.getTableIndex(TABLE_NAME, mappingContext)).thenReturn(TABLE_INDEX);
whenClassifyAddDelTableThenSuccess();
customizer.deleteCurrentAttributes(id, classifyTable, writeContext);
@@ -196,8 +185,8 @@ public class ClassifyTableWriterTest {
final ClassifyTable classifyTable = generateClassifyTable(TABLE_NAME);
final InstanceIdentifier<ClassifyTable> id = getClassifyTableId(TABLE_NAME);
- when(classifierContext.containsTable(TABLE_NAME, ctx)).thenReturn(true);
- when(classifierContext.getTableIndex(TABLE_NAME, ctx)).thenReturn(TABLE_INDEX);
+ when(classifierContext.containsTable(TABLE_NAME, mappingContext)).thenReturn(true);
+ when(classifierContext.getTableIndex(TABLE_NAME, mappingContext)).thenReturn(TABLE_INDEX);
whenClassifyAddDelTableThenFailure();
try {
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java
index bcd6a36f6..67e612868 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/BridgeDomainCustomizerTest.java
@@ -20,7 +20,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ListReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
import java.util.Collections;
import java.util.List;
@@ -41,7 +41,7 @@ public class BridgeDomainCustomizerTest
}
@Override
- public void setUpBefore() {
+ public void setUp() {
bdContext = new NamingContext("generatedBdName", "bd-test-instance");
interfacesContext = new NamingContext("generatedIfaceName", "ifc-test-instance");
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
index 4ccaa636b..29908442d 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/L2FibEntryCustomizerTest.java
@@ -24,8 +24,8 @@ import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import io.fd.honeycomb.translate.v3po.test.ContextTestUtils;
-import io.fd.honeycomb.translate.v3po.test.ListReaderCustomizerTest;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
@@ -63,7 +63,7 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest<L2FibEntr
}
@Override
- public void setUpBefore() {
+ public void setUp() {
bdContext = new NamingContext("generatedBdName", BD_CTX_NAME);
ContextTestUtils.mockMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME);
interfacesContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java
index 1e0ff2429..8af2683d1 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/vppstate/VersionCustomizerTest.java
@@ -22,7 +22,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.honeycomb.translate.v3po.test.ReaderCustomizerTest;
+import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest;
import java.util.concurrent.CompletableFuture;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VppStateBuilder;