summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlisp/lisp2vpp/pom.xml6
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java38
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java35
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java50
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java40
-rw-r--r--v3po/v3po2vpp/pom.xml6
-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/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
-rw-r--r--vpp-common/pom.xml1
-rw-r--r--vpp-common/vpp-translate-test/pom.xml55
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ListReaderCustomizerTest.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ListReaderCustomizerTest.java)5
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java (renamed from v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ReaderCustomizerTest.java)34
-rw-r--r--vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/write/WriterCustomizerTest.java60
42 files changed, 352 insertions, 551 deletions
diff --git a/lisp/lisp2vpp/pom.xml b/lisp/lisp2vpp/pom.xml
index 3553a2a07..b78ee8526 100755
--- a/lisp/lisp2vpp/pom.xml
+++ b/lisp/lisp2vpp/pom.xml
@@ -99,5 +99,11 @@
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>io.fd.honeycomb.vpp</groupId>
+ <artifactId>vpp-translate-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
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 6dccdfeab..0608c4a04 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,20 +25,16 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
-import io.fd.honeycomb.translate.MappingContext;
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 io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
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.Captor;
-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.MappingBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
@@ -53,17 +49,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 {
-
- @Mock
- private FutureJVppCore fakeJvpp;
-
- @Mock
- private WriteContext writeContext;
-
- @Mock
- private MappingContext mappingContext;
+public class InterfaceCustomizerTest extends WriterCustomizerTest {
@Captor
private ArgumentCaptor<LispAddDelLocator> intfCaptor;
@@ -75,10 +61,8 @@ public class InterfaceCustomizerTest {
private Interface intf;
private InterfaceCustomizer customizer;
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
-
+ @Override
+ public void setUp() {
id = InstanceIdentifier.builder(Lisp.class)
.child(LocatorSets.class)
.child(LocatorSet.class, new LocatorSetKey("Locator"))
@@ -92,18 +76,16 @@ public class InterfaceCustomizerTest {
namingContext = new NamingContext("PREFIX", "INSTANCE");
- customizer = new InterfaceCustomizer(fakeJvpp, namingContext);
+ customizer = new InterfaceCustomizer(api, namingContext);
fakeReply = new LispAddDelLocatorReply();
completeFuture = new CompletableFuture<>();
completeFuture.complete(fakeReply);
- when(writeContext.getMappingContext()).thenReturn(mappingContext);
when(mappingContext.read(Mockito.any()))
.thenReturn(Optional.of((DataObject) new MappingBuilder().setIndex(5).setName("interface").build()));
- when(fakeJvpp.lispAddDelLocator(any(LispAddDelLocator.class))).thenReturn(completeFuture);
-
+ when(api.lispAddDelLocator(any(LispAddDelLocator.class))).thenReturn(completeFuture);
}
@Test(expected = NullPointerException.class)
@@ -136,7 +118,7 @@ public class InterfaceCustomizerTest {
public void testWriteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
customizer.writeCurrentAttributes(id, intf, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelLocator(intfCaptor.capture());
+ verify(api, times(1)).lispAddDelLocator(intfCaptor.capture());
LispAddDelLocator request = intfCaptor.getValue();
@@ -150,13 +132,13 @@ public class InterfaceCustomizerTest {
@Test(expected = UnsupportedOperationException.class)
public void testUpdateCurrentAttributes() throws WriteFailedException {
- new InterfaceCustomizer(fakeJvpp, namingContext)
+ new InterfaceCustomizer(api, namingContext)
.updateCurrentAttributes(null, null, null, null);
}
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
- new InterfaceCustomizer(fakeJvpp, namingContext)
+ new InterfaceCustomizer(api, namingContext)
.deleteCurrentAttributes(null, null, null);
}
@@ -184,7 +166,7 @@ public class InterfaceCustomizerTest {
public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
customizer.deleteCurrentAttributes(id, intf, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelLocator(intfCaptor.capture());
+ verify(api, times(1)).lispAddDelLocator(intfCaptor.capture());
LispAddDelLocator request = intfCaptor.getValue();
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 2b28ce6b9..da9d50e7f 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,19 +25,15 @@ 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.MappingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
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.Captor;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
@@ -57,11 +53,7 @@ import org.openvpp.jvpp.core.dto.LispAddDelLocalEidReply;
import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class LocalMappingCustomizerTest {
-
- @Mock
- private FutureJVppCore fakeJvpp;
-
+public class LocalMappingCustomizerTest extends WriterCustomizerTest {
@Captor
private ArgumentCaptor<LispAddDelLocalEid> mappingCaptor;
@@ -72,13 +64,9 @@ public class LocalMappingCustomizerTest {
private CompletableFuture<LispAddDelLocalEidReply> completeFuture;
private LocalMappingCustomizer customizer;
private EidMappingContext localMappingContext;
- private WriteContext writeContext;
- private MappingContext mappingCtx;
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
+ @Override
+ public void setUp() {
final Eid
eid = new EidBuilder().setAddress(
new Ipv4Builder().setIpv4(
@@ -90,8 +78,6 @@ public class LocalMappingCustomizerTest {
mappingId = new MappingId("REMOTE");
final LocalMappingKey key = new LocalMappingKey(mappingId);
localMappingContext = new EidMappingContext("local");
- mappingCtx = mock(MappingContext.class);
- writeContext = mock(WriteContext.class);
mapping = new LocalMappingBuilder()
.setEid(eid)
@@ -108,11 +94,10 @@ public class LocalMappingCustomizerTest {
fakeReply = new LispAddDelLocalEidReply();
completeFuture = new CompletableFuture<>();
completeFuture.complete(fakeReply);
- customizer = new LocalMappingCustomizer(fakeJvpp, localMappingContext);
+ customizer = new LocalMappingCustomizer(api, localMappingContext);
- when(fakeJvpp.lispAddDelLocalEid(any(LispAddDelLocalEid.class))).thenReturn(completeFuture);
- when(writeContext.getMappingContext()).thenReturn(mappingCtx);
- when(mappingCtx.read(Mockito.any())).thenReturn(com.google.common.base.Optional
+ when(api.lispAddDelLocalEid(any(LispAddDelLocalEid.class))).thenReturn(completeFuture);
+ when(mappingContext.read(Mockito.any())).thenReturn(com.google.common.base.Optional
.of(new LocalMappingBuilder().setKey(key).setId(mappingId).setEid(eid).build()));
}
@@ -147,11 +132,11 @@ public class LocalMappingCustomizerTest {
@Test
public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
//to simulate no mapping
- when(mappingCtx.read(Mockito.any())).thenReturn(com.google.common.base.Optional.absent());
+ when(mappingContext.read(Mockito.any())).thenReturn(com.google.common.base.Optional.absent());
customizer.writeCurrentAttributes(id, mapping, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+ verify(api, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
LispAddDelLocalEid request = mappingCaptor.getValue();
@@ -174,7 +159,7 @@ public class LocalMappingCustomizerTest {
public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
customizer.deleteCurrentAttributes(id, mapping, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+ verify(api, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
LispAddDelLocalEid request = mappingCaptor.getValue();
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
index 9ed1d53cb..1bb695cc0 100755
--- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
@@ -26,16 +26,13 @@ import static org.mockito.Mockito.when;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableList;
-import io.fd.honeycomb.translate.MappingContext;
-import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.v3po.util.NamingContext;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
@@ -48,37 +45,24 @@ import org.openvpp.jvpp.core.dto.LispAddDelLocatorSet;
import org.openvpp.jvpp.core.dto.LispAddDelLocatorSetReply;
import org.openvpp.jvpp.core.dto.LispLocatorSetDetails;
import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
+public class LocatorSetCustomizerTest extends WriterCustomizerTest {
-public class LocatorSetCustomizerTest {
-
- private FutureJVppCore fakeJvpp;
private NamingContext locatorSetContext;
- private MappingContext mappingContext;
- private ModificationCache cache;
- private WriteContext context;
- @Before
- public void init() {
- fakeJvpp = mock(FutureJVppCore.class);
+ @Override
+ public void setUp() {
locatorSetContext = new NamingContext("locator-set", "instance");
- context = mock(WriteContext.class);
- mappingContext = mock(MappingContext.class);
- cache = new ModificationCache();
- when(context.getMappingContext()).thenReturn(mappingContext);
- when(context.getModificationCache()).thenReturn(cache);
}
-
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesNullData() throws WriteFailedException {
- new LocatorSetCustomizer(fakeJvpp, locatorSetContext).writeCurrentAttributes(null, null, null);
+ new LocatorSetCustomizer(api, locatorSetContext).writeCurrentAttributes(null, null, null);
}
@Test(expected = NullPointerException.class)
public void testWriteCurrentAttributesBadData() throws WriteFailedException {
- new LocatorSetCustomizer(fakeJvpp, locatorSetContext)
+ new LocatorSetCustomizer(api, locatorSetContext)
.writeCurrentAttributes(null, mock(LocatorSet.class), null);
}
@@ -101,8 +85,8 @@ public class LocatorSetCustomizerTest {
CompletableFuture<LispAddDelLocatorSetReply> completeFuture = new CompletableFuture<>();
completeFuture.complete(fakeReply);
- when(fakeJvpp.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
- when(context.readAfter(validId)).thenReturn(Optional.of(locatorSet));
+ when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
+ when(writeContext.readAfter(validId)).thenReturn(Optional.of(locatorSet));
final LispLocatorSetDetailsReplyDump reply = new LispLocatorSetDetailsReplyDump();
LispLocatorSetDetails details = new LispLocatorSetDetails();
@@ -111,31 +95,30 @@ public class LocatorSetCustomizerTest {
cache.put(io.fd.honeycomb.lisp.translate.read.LocatorSetCustomizer.LOCATOR_SETS_CACHE_ID, reply);
- new LocatorSetCustomizer(fakeJvpp, locatorSetContext).writeCurrentAttributes(validId, locatorSet, context);
+ new LocatorSetCustomizer(api, locatorSetContext).writeCurrentAttributes(validId, locatorSet, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
+ verify(api, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
LispAddDelLocatorSet request = locatorSetCaptor.getValue();
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
assertEquals(1, request.isAdd);
-
}
@Test(expected = UnsupportedOperationException.class)
public void testUpdateCurrentAttributes() throws WriteFailedException {
- new LocatorSetCustomizer(fakeJvpp, locatorSetContext).updateCurrentAttributes(null, null, null, null);
+ new LocatorSetCustomizer(api, locatorSetContext).updateCurrentAttributes(null, null, null, null);
}
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
- new LocatorSetCustomizer(fakeJvpp, locatorSetContext).deleteCurrentAttributes(null, null, null);
+ new LocatorSetCustomizer(api, locatorSetContext).deleteCurrentAttributes(null, null, null);
}
@Test(expected = NullPointerException.class)
public void testDeleteCurrentAttributesBadData() throws WriteFailedException {
- new LocatorSetCustomizer(fakeJvpp, locatorSetContext)
+ new LocatorSetCustomizer(api, locatorSetContext)
.deleteCurrentAttributes(null, mock(LocatorSet.class), null);
}
@@ -153,17 +136,16 @@ public class LocatorSetCustomizerTest {
CompletableFuture<LispAddDelLocatorSetReply> completeFuture = new CompletableFuture<>();
completeFuture.complete(fakeReply);
- when(fakeJvpp.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
+ when(api.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
- new LocatorSetCustomizer(fakeJvpp, locatorSetContext).deleteCurrentAttributes(null, locatorSet, context);
+ new LocatorSetCustomizer(api, locatorSetContext).deleteCurrentAttributes(null, locatorSet, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
+ verify(api, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
LispAddDelLocatorSet request = locatorSetCaptor.getValue();
assertNotNull(request);
assertEquals("Locator", new String(request.locatorSetName));
assertEquals(0, request.isAdd);
-
}
}
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 7797db1f7..30c168e72 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,22 +24,16 @@ 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.MappingContext;
import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
-import io.fd.honeycomb.translate.write.WriteContext;
import io.fd.honeycomb.translate.write.WriteFailedException;
+import io.fd.honeycomb.vpp.test.write.WriterCustomizerTest;
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.Captor;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.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.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MapReplyAction;
@@ -54,18 +48,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid;
import 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;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.NegativeMappingBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.LocatorBuilder;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.openvpp.jvpp.core.dto.LispAddDelRemoteMapping;
import org.openvpp.jvpp.core.dto.LispAddDelRemoteMappingReply;
-import org.openvpp.jvpp.core.future.FutureJVppCore;
-public class RemoteMappingCustomizerTest {
-
- @Mock
- private FutureJVppCore fakeJvpp;
+public class RemoteMappingCustomizerTest extends WriterCustomizerTest {
@Captor
private ArgumentCaptor<LispAddDelRemoteMapping> mappingCaptor;
@@ -77,14 +65,9 @@ public class RemoteMappingCustomizerTest {
private CompletableFuture<LispAddDelRemoteMappingReply> completeFuture;
private InstanceIdentifier<RemoteMapping> id;
private EidMappingContext remoteMappingContext;
- private WriteContext writeContext;
- private MappingContext mapping;
-
-
- @Before
- public void init() {
- MockitoAnnotations.initMocks(this);
+ @Override
+ public void setUp() {
final Eid eid = new EidBuilder().setAddress(
new Ipv4Builder().setIpv4(
new Ipv4Address("192.168.2.1"))
@@ -94,8 +77,6 @@ public class RemoteMappingCustomizerTest {
mappingId = new MappingId("REMOTE");
final RemoteMappingKey key = new RemoteMappingKey(mappingId);
remoteMappingContext = new EidMappingContext("remote");
- mapping = mock(MappingContext.class);
- writeContext = mock(WriteContext.class);
intf = new RemoteMappingBuilder()
@@ -112,11 +93,10 @@ public class RemoteMappingCustomizerTest {
fakeReply = new LispAddDelRemoteMappingReply();
completeFuture = new CompletableFuture<>();
completeFuture.complete(fakeReply);
- customizer = new RemoteMappingCustomizer(fakeJvpp, remoteMappingContext);
+ customizer = new RemoteMappingCustomizer(api, remoteMappingContext);
- when(fakeJvpp.lispAddDelRemoteMapping(Mockito.any())).thenReturn(completeFuture);
- when(writeContext.getMappingContext()).thenReturn(mapping);
- when(mapping.read(Mockito.any())).thenReturn(com.google.common.base.Optional
+ when(api.lispAddDelRemoteMapping(Mockito.any())).thenReturn(completeFuture);
+ when(mappingContext.read(Mockito.any())).thenReturn(com.google.common.base.Optional
.of(new RemoteMappingBuilder().setKey(key).setId(mappingId).setEid(eid).build()));
}
@@ -134,11 +114,11 @@ public class RemoteMappingCustomizerTest {
@Test
public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
//to simulate no mapping
- when(mapping.read(Mockito.any())).thenReturn(com.google.common.base.Optional.absent());
+ when(mappingContext.read(Mockito.any())).thenReturn(com.google.common.base.Optional.absent());
customizer.writeCurrentAttributes(id, intf, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
+ verify(api, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
LispAddDelRemoteMapping request = mappingCaptor.getValue();
@@ -162,7 +142,7 @@ public class RemoteMappingCustomizerTest {
public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
customizer.deleteCurrentAttributes(id, intf, writeContext);
- verify(fakeJvpp, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
+ verify(api, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
LispAddDelRemoteMapping request = mappingCaptor.getValue();
diff --git a/v3po/v3po2vpp/pom.xml b/v3po/v3po2vpp/pom.xml
index 21b0aeb08..ba5cf0352 100644
--- a/v3po/v3po2vpp/pom.xml
+++ b/v3po/v3po2vpp/pom.xml
@@ -86,6 +86,12 @@
<!-- Testing Dependencies -->
<dependency>
+ <groupId>io.fd.honeycomb.vpp</groupId>
+ <artifactId>vpp-translate-test</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
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/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;
diff --git a/vpp-common/pom.xml b/vpp-common/pom.xml
index a3b38fce3..f46a182cd 100644
--- a/vpp-common/pom.xml
+++ b/vpp-common/pom.xml
@@ -37,6 +37,7 @@
<module>naming-context-impl</module>
<module>minimal-distribution</module>
<module>vpp-impl-parent</module>
+ <module>vpp-translate-test</module>
</modules>
<!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
<build>
diff --git a/vpp-common/vpp-translate-test/pom.xml b/vpp-common/vpp-translate-test/pom.xml
new file mode 100644
index 000000000..a80d90bd1
--- /dev/null
+++ b/vpp-common/vpp-translate-test/pom.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <groupId>io.fd.honeycomb.vpp</groupId>
+ <artifactId>vpp-impl-parent</artifactId>
+ <version>1.16.12-SNAPSHOT</version>
+ <relativePath>../../vpp-common/vpp-impl-parent</relativePath>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>io.fd.honeycomb.vpp</groupId>
+ <artifactId>vpp-translate-test</artifactId>
+ <version>1.16.12-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>io.fd.honeycomb</groupId>
+ <artifactId>translate-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.fd.vpp</groupId>
+ <artifactId>jvpp-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ListReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ListReaderCustomizerTest.java
index 936e82c16..0509ef9e5 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ListReaderCustomizerTest.java
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ListReaderCustomizerTest.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package io.fd.honeycomb.translate.v3po.test;
+package io.fd.honeycomb.vpp.test.read;
import static org.junit.Assert.assertNotNull;
@@ -34,8 +34,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
* @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> {
-
+ ReaderCustomizerTest<D, B> {
protected ListReaderCustomizerTest(Class<D> dataObjectClass) {
super(dataObjectClass);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ReaderCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java
index 8aeebaba4..4648676bf 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/translate/v3po/test/ReaderCustomizerTest.java
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/read/ReaderCustomizerTest.java
@@ -14,19 +14,19 @@
* limitations under the License.
*/
-package io.fd.honeycomb.translate.v3po.test;
+package io.fd.honeycomb.vpp.test.read;
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 io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -42,12 +42,12 @@ public abstract class ReaderCustomizerTest<D extends DataObject, B extends Build
@Mock
protected FutureJVppCore api;
- protected ModificationCache cache;
@Mock
protected ReadContext ctx;
@Mock
protected MappingContext mappingContext;
+ protected ModificationCache cache;
protected final Class<D> dataObjectClass;
private ReaderCustomizer<D, B> customizer;
@@ -57,28 +57,18 @@ public abstract class ReaderCustomizerTest<D extends DataObject, B extends Build
@Before
public void setUpParent() throws Exception {
- initMocks(this);
+ MockitoAnnotations.initMocks(this);
cache = new ModificationCache();
- doReturn(cache).when(ctx).getModificationCache();
- doReturn(mappingContext).when(ctx).getMappingContext();
-
- setUpBefore();
+ Mockito.doReturn(cache).when(ctx).getModificationCache();
+ Mockito.doReturn(mappingContext).when(ctx).getMappingContext();
+ setUp();
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 void setUp() throws Exception {
}
protected abstract ReaderCustomizer<D, B> initCustomizer();
@@ -91,4 +81,6 @@ public abstract class ReaderCustomizerTest<D extends DataObject, B extends Build
public void testGetBuilder() throws Exception {
assertNotNull(customizer.getBuilder(InstanceIdentifier.create(dataObjectClass)));
}
+
+ // TODO HONEYCOMB-116: create generic testMerge()
}
diff --git a/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/write/WriterCustomizerTest.java b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/write/WriterCustomizerTest.java
new file mode 100644
index 000000000..0e1d00a9c
--- /dev/null
+++ b/vpp-common/vpp-translate-test/src/main/java/io/fd/honeycomb/vpp/test/write/WriterCustomizerTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.vpp.test.write;
+
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.write.WriteContext;
+import org.junit.Before;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+/**
+ * Generic test for classes implementing {@link WriterCustomizer} interface.
+ */
+public abstract class WriterCustomizerTest {
+
+ @Mock
+ protected FutureJVppCore api;
+ @Mock
+ protected WriteContext writeContext;
+ @Mock
+ protected MappingContext mappingContext;
+
+ protected ModificationCache cache;
+
+ protected WriterCustomizerTest() {
+ }
+
+ @Before
+ public void setUpParent() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ cache = new ModificationCache();
+ Mockito.doReturn(cache).when(writeContext).getModificationCache();
+ Mockito.doReturn(mappingContext).when(writeContext).getMappingContext();
+ setUp();
+ }
+
+ /**
+ * Optional setup for subclasses. Invoked after parent initialization.
+ */
+ protected void setUp() throws Exception {
+ }
+}