diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-11-21 15:06:16 +0100 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-11-24 06:54:46 +0000 |
commit | f698c1ccc38646129ee4a15adacdf47942a24a52 (patch) | |
tree | 779e64002860a328f121dc3f2b958b8225c5c0c7 /v3po/v3po2vpp/src/test/java | |
parent | 294d0ea77bd20d580405cc1470dc9a1078be7a5c (diff) |
HONEYCOMB-275 - compilation error with HC runner and setUp
Refactored setUp() method in WriteCustomizerTest
to not trigger http://errorprone.info/bugpattern/JUnit4SetUpNotRun
while used in combination with @RunWith(HoneycombTestRunner.class)
Change-Id: Iba56b39399ddd7678dda97e094e935a3f02dd22c
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src/test/java')
30 files changed, 361 insertions, 372 deletions
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AclCustomizerTest.java index 7f55ae60a..e8160b7b9 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/AclCustomizerTest.java @@ -22,11 +22,11 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfaces.acl.ingress.AclCustomizer; import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.InputAclSetInterface; import io.fd.vpp.jvpp.core.dto.InputAclSetInterfaceReply; @@ -36,29 +36,37 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.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.rev161214.VppInterfaceAugmentation; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.acl.base.attributes.L2Acl; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.acl.base.attributes.L2AclBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Acl; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.acl.Ingress; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.acl.IngressBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.acl.base.attributes.L2Acl; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.acl.base.attributes.L2AclBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class AclCustomizerTest extends WriterCustomizerTest { - @Mock - private VppClassifierContextManager classifyTableContext; - - private AclCustomizer customizer; - private static final String IFC_TEST_INSTANCE = "ifc-test-instance"; private static final String IF_NAME = "local0"; private static final int IF_INDEX = 1; - private static final int ACL_TABLE_INDEX = 0; private static final String ACL_TABLE_NAME = "table0"; + @Mock + private VppClassifierContextManager classifyTableContext; + private AclCustomizer customizer; + + private static InputAclSetInterface generateInputAclSetInterface(final byte isAdd, final int ifIndex, + final int l2TableIndex) { + final InputAclSetInterface request = new InputAclSetInterface(); + request.isAdd = isAdd; + request.l2TableIndex = l2TableIndex; + request.ip4TableIndex = ~0; + request.ip6TableIndex = ~0; + request.swIfIndex = ifIndex; + return request; + } @Override - public void setUp() { + public void setUpTest() { defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); customizer = new AclCustomizer(api, new NamingContext("generatedInterfaceName", IFC_TEST_INSTANCE), classifyTableContext); @@ -85,17 +93,6 @@ public class AclCustomizerTest extends WriterCustomizerTest { doReturn(failedFuture()).when(api).inputAclSetInterface(any(InputAclSetInterface.class)); } - private static InputAclSetInterface generateInputAclSetInterface(final byte isAdd, final int ifIndex, - final int l2TableIndex) { - final InputAclSetInterface request = new InputAclSetInterface(); - request.isAdd = isAdd; - request.l2TableIndex = l2TableIndex; - request.ip4TableIndex = ~0; - request.ip6TableIndex = ~0; - request.swIfIndex = ifIndex; - return request; - } - @Test public void testCreate() throws Exception { final Ingress acl = generateAcl(ACL_TABLE_NAME); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java index da75fa92d..1381541a6 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/GreCustomizerTest.java @@ -27,9 +27,13 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import com.google.common.net.InetAddresses; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.GreAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.GreAddDelTunnelReply; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress; @@ -41,25 +45,28 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Gre; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.GreBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.GreAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.GreAddDelTunnelReply; public class GreCustomizerTest extends WriterCustomizerTest { private static final String IFC_TEST_INSTANCE = "ifc-test-instance"; + private static final byte ADD_GRE = 1; + private static final byte DEL_GRE = 0; private final String IFACE_NAME = "eth0"; private final int IFACE_ID = 1; private InstanceIdentifier<Gre> id = InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME)) .augmentation(VppInterfaceAugmentation.class).child(Gre.class); - private static final byte ADD_GRE = 1; - private static final byte DEL_GRE = 0; - private GreCustomizer customizer; + private static Gre generateGre() { + final GreBuilder builder = new GreBuilder(); + builder.setSrc(new IpAddress(new Ipv4Address("192.168.20.10"))); + builder.setDst(new IpAddress(new Ipv4Address("192.168.20.11"))); + builder.setOuterFibId(Long.valueOf(123)); + return builder.build(); + } + @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { InterfaceTypeTestUtils.setupWriteContext(writeContext, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.GreTunnel.class); customizer = new GreCustomizer(api, new NamingContext("generateInterfaceNAme", IFC_TEST_INSTANCE)); @@ -98,14 +105,6 @@ public class GreCustomizerTest extends WriterCustomizerTest { assertEquals(DEL_GRE, actual.isAdd); } - private static Gre generateGre() { - final GreBuilder builder = new GreBuilder(); - builder.setSrc(new IpAddress(new Ipv4Address("192.168.20.10"))); - builder.setDst(new IpAddress(new Ipv4Address("192.168.20.11"))); - builder.setOuterFibId(Long.valueOf(123)); - return builder.build(); - } - @Test public void testWriteCurrentAttributes() throws Exception { final Gre gre = generateGre(); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java index c72d43a02..311889d1a 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/InterfaceCustomizerTest.java @@ -24,19 +24,19 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; 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.InterfaceBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; public class InterfaceCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator { private static final String IFACE_CTX_NAME = "interface-ctx"; @@ -48,7 +48,7 @@ public class InterfaceCustomizerTest extends WriterCustomizerTest implements Byt InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IF_NAME)); @Override - protected void setUp() throws Exception { + protected void setUpTest() throws Exception { customizer = new InterfaceCustomizer(api, new NamingContext("ifacePrefix", IFACE_CTX_NAME)); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFACE_CTX_NAME); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/L2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/L2CustomizerTest.java index d54bd3392..cf184937b 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/L2CustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/L2CustomizerTest.java @@ -22,10 +22,15 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Xconnect; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2XconnectReply; 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; @@ -39,11 +44,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.interconnection.XconnectBased; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.l2.base.attributes.interconnection.XconnectBasedBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Xconnect; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2XconnectReply; public class L2CustomizerTest extends WriterCustomizerTest implements ByteDataTranslator { private static final String IFACE_CTX_NAME = "interface-ctx"; @@ -61,7 +61,7 @@ public class L2CustomizerTest extends WriterCustomizerTest implements ByteDataTr private L2Customizer customizer; @Override - protected void setUp() throws Exception { + protected void setUpTest() throws Exception { customizer = new L2Customizer(api, new NamingContext("ifacePrefix", IFACE_CTX_NAME), new NamingContext("bdPrefix", BD_CTX_NAME)); defineMapping(mappingContext, IF1_NAME, IF1_INDEX, IFACE_CTX_NAME); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/LoopbackCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/LoopbackCustomizerTest.java index 67c90343e..70ba2f1d4 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/LoopbackCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/LoopbackCustomizerTest.java @@ -23,8 +23,8 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.vpp.jvpp.core.dto.CreateLoopback; import io.fd.vpp.jvpp.core.dto.CreateLoopbackReply; import io.fd.vpp.jvpp.core.dto.DeleteLoopback; @@ -47,7 +47,7 @@ public class LoopbackCustomizerTest extends WriterCustomizerTest { private LoopbackCustomizer loopCustomizer; @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { InterfaceTypeTestUtils.setupWriteContext(writeContext, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.Loopback.class); loopCustomizer = new LoopbackCustomizer(api, new NamingContext("ifcintest", IFC_TEST_INSTANCE)); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizerTest.java index 232d62e9e..87e8e6422 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ProxyArpCustomizerTest.java @@ -20,9 +20,11 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel; +import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply; import org.junit.Test; 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; @@ -32,8 +34,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.ProxyArp; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.ProxyArpBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.ProxyArpAddDel; -import io.fd.vpp.jvpp.core.dto.ProxyArpAddDelReply; public class ProxyArpCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator { private static final String IF_NAME = "eth1"; @@ -41,7 +41,7 @@ public class ProxyArpCustomizerTest extends WriterCustomizerTest implements Byte private ProxyArpCustomizer customizer; @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { customizer = new ProxyArpCustomizer(api); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RewriteCustomizerTest.java index fa9914233..151ba3fe1 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RewriteCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RewriteCustomizerTest.java @@ -22,10 +22,10 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.verify; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.common.translate.util.TagRewriteOperation; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.VppInvocationException; import io.fd.vpp.jvpp.core.dto.L2InterfaceVlanTagRewrite; @@ -47,24 +47,15 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class RewriteCustomizerTest extends WriterCustomizerTest { - private NamingContext namingContext; - private RewriteCustomizer customizer; - private static final String IFC_TEST_INSTANCE = "ifc-test-instance"; private static final String IF_NAME = "local0"; private static final String VLAN_IF_NAME = "local0.1"; private static final int VLAN_IF_ID = 1; private static final int VLAN_IF_INDEX = 11; + private NamingContext namingContext; + private RewriteCustomizer customizer; private InstanceIdentifier<Rewrite> VLAN_IID; - @Override - public void setUp() throws Exception { - namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE); - customizer = new RewriteCustomizer(api, namingContext); - VLAN_IID = getVlanTagRewriteId(IF_NAME, VLAN_IF_ID); - defineMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_TEST_INSTANCE); - } - private static InstanceIdentifier<Rewrite> getVlanTagRewriteId(final String name, final long index) { final Class<ChildOf<? super SubInterface>> child = (Class) Rewrite.class; final InstanceIdentifier id = @@ -75,6 +66,14 @@ public class RewriteCustomizerTest extends WriterCustomizerTest { return id; } + @Override + public void setUpTest() throws Exception { + namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE); + customizer = new RewriteCustomizer(api, namingContext); + VLAN_IID = getVlanTagRewriteId(IF_NAME, VLAN_IF_ID); + defineMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_TEST_INSTANCE); + } + private Rewrite generateRewrite(final TagRewriteOperation op) { final RewriteBuilder builder = new RewriteBuilder(); builder.setPopTags((short) op.getPopTags()); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RoutingCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RoutingCustomizerTest.java index a61cd149b..e05ed08a1 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RoutingCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/RoutingCustomizerTest.java @@ -20,9 +20,9 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTable; import io.fd.vpp.jvpp.core.dto.SwInterfaceSetTableReply; import org.junit.Test; @@ -45,7 +45,7 @@ public class RoutingCustomizerTest extends WriterCustomizerTest { private RoutingCustomizer customizer; @Override - protected void setUp() throws Exception { + protected void setUpTest() throws Exception { customizer = new RoutingCustomizer(api, new NamingContext("ifacePrefix", IFACE_CTX_NAME)); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFACE_CTX_NAME); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java index fd71a8015..4a80e98b6 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceCustomizerTest.java @@ -25,9 +25,14 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.CreateSubif; +import io.fd.vpp.jvpp.core.dto.CreateSubifReply; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; import java.util.Arrays; import java.util.List; import org.junit.Test; @@ -55,30 +60,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.tags.TagBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.tags.TagKey; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.CreateSubif; -import io.fd.vpp.jvpp.core.dto.CreateSubifReply; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlags; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetFlagsReply; public class SubInterfaceCustomizerTest extends WriterCustomizerTest { - private NamingContext namingContext; - private SubInterfaceCustomizer customizer; - private static final String IFC_TEST_INSTANCE = "ifc-test-instance"; private static final String SUPER_IF_NAME = "local0"; private static final int SUPER_IF_ID = 1; private static final String SUB_IFACE_NAME = "local0.11"; private static final int SUBIF_INDEX = 11; - private static final short STAG_ID = 100; private static final short CTAG_ID = 200; private static final short CTAG_ANY_ID = 0; // only the *IdAny flag is set - private final Tag STAG_100; private final Tag CTAG_200; private final Tag CTAG_ANY; + private NamingContext namingContext; + private SubInterfaceCustomizer customizer; public SubInterfaceCustomizerTest() { STAG_100 = generateTag((short) 0, SVlan.class, new Dot1qTag.VlanId(new Dot1qVlanId((int) STAG_ID))); @@ -86,29 +83,6 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest { CTAG_ANY = generateTag((short) 1, CVlan.class, new Dot1qTag.VlanId(Dot1qTag.VlanId.Enumeration.Any)); } - @Override - public void setUp() throws Exception { - namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE); - customizer = new SubInterfaceCustomizer(api, namingContext); - defineMapping(mappingContext, SUB_IFACE_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE); - defineMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_ID, IFC_TEST_INSTANCE); - } - - private SubInterface generateSubInterface(final boolean enabled, final List<Tag> tagList) { - SubInterfaceBuilder builder = new SubInterfaceBuilder(); - builder.setVlanType(_802dot1ad.class); - builder.setIdentifier(11L); - final TagsBuilder tags = new TagsBuilder(); - - tags.setTag(tagList); - - builder.setTags(tags.build()); - - builder.setMatch(generateMatch()); - builder.setEnabled(enabled); - return builder.build(); - } - private static Tag generateTag(final short index, final Class<? extends Dot1qTagVlanType> tagType, final Dot1qTag.VlanId vlanId) { TagBuilder tag = new TagBuilder(); @@ -131,6 +105,29 @@ public class SubInterfaceCustomizerTest extends WriterCustomizerTest { return match.build(); } + @Override + public void setUpTest() throws Exception { + namingContext = new NamingContext("generatedSubInterfaceName", IFC_TEST_INSTANCE); + customizer = new SubInterfaceCustomizer(api, namingContext); + defineMapping(mappingContext, SUB_IFACE_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE); + defineMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_ID, IFC_TEST_INSTANCE); + } + + private SubInterface generateSubInterface(final boolean enabled, final List<Tag> tagList) { + SubInterfaceBuilder builder = new SubInterfaceBuilder(); + builder.setVlanType(_802dot1ad.class); + builder.setIdentifier(11L); + final TagsBuilder tags = new TagsBuilder(); + + tags.setTag(tagList); + + builder.setTags(tags.build()); + + builder.setMatch(generateMatch()); + builder.setEnabled(enabled); + return builder.build(); + } + private CreateSubif generateSubInterfaceRequest(final int superIfId, final short innerVlanId, final boolean isInnerAny) { CreateSubif request = new CreateSubif(); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceL2CustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceL2CustomizerTest.java index 29b1b0d99..7c45919ec 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceL2CustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/SubInterfaceL2CustomizerTest.java @@ -20,10 +20,12 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge; +import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply; 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; @@ -36,8 +38,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.L2; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.L2Builder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2Bridge; -import io.fd.vpp.jvpp.core.dto.SwInterfaceSetL2BridgeReply; public class SubInterfaceL2CustomizerTest extends WriterCustomizerTest implements ByteDataTranslator { private static final String IFACE_CTX_NAME = "interface-ctx"; @@ -60,7 +60,7 @@ public class SubInterfaceL2CustomizerTest extends WriterCustomizerTest implement private SubInterfaceL2Customizer customizer; @Override - protected void setUp() throws Exception { + protected void setUpTest() throws Exception { customizer = new SubInterfaceL2Customizer(api, new NamingContext("ifacePrefix", IFACE_CTX_NAME), new NamingContext("bdPrefix", BD_CTX_NAME)); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFACE_CTX_NAME); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizerTest.java index f55859ace..9f66f7fee 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizerTest.java @@ -23,8 +23,14 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.vpp.jvpp.core.dto.TapConnect; +import io.fd.vpp.jvpp.core.dto.TapConnectReply; +import io.fd.vpp.jvpp.core.dto.TapDelete; +import io.fd.vpp.jvpp.core.dto.TapDeleteReply; +import io.fd.vpp.jvpp.core.dto.TapModify; +import io.fd.vpp.jvpp.core.dto.TapModifyReply; import org.junit.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -36,12 +42,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Tap; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.TapBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.core.dto.TapConnect; -import io.fd.vpp.jvpp.core.dto.TapConnectReply; -import io.fd.vpp.jvpp.core.dto.TapDelete; -import io.fd.vpp.jvpp.core.dto.TapDeleteReply; -import io.fd.vpp.jvpp.core.dto.TapModify; -import io.fd.vpp.jvpp.core.dto.TapModifyReply; public class TapCustomizerTest extends WriterCustomizerTest { @@ -49,7 +49,7 @@ public class TapCustomizerTest extends WriterCustomizerTest { private TapCustomizer tapCustomizer; @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { InterfaceTypeTestUtils.setupWriteContext(writeContext, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.Tap.class); tapCustomizer = new TapCustomizer(api, new NamingContext("ifcintest", IFC_TEST_INSTANCE)); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java index 4f8b7a6d4..f1188c892 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizerTest.java @@ -29,10 +29,18 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.Ipv4Translator; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.CreateVhostUserIf; +import io.fd.vpp.jvpp.core.dto.CreateVhostUserIfReply; +import io.fd.vpp.jvpp.core.dto.DeleteVhostUserIf; +import io.fd.vpp.jvpp.core.dto.DeleteVhostUserIfReply; +import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIf; +import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIfReply; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces; @@ -43,26 +51,25 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VhostUser; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VhostUserBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.CreateVhostUserIf; -import io.fd.vpp.jvpp.core.dto.CreateVhostUserIfReply; -import io.fd.vpp.jvpp.core.dto.DeleteVhostUserIf; -import io.fd.vpp.jvpp.core.dto.DeleteVhostUserIfReply; -import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIf; -import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIfReply; public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv4Translator { - 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); + private VhostUserCustomizer customizer; + + private static VhostUser generateVhostUser(final VhostUserRole role, final String socketName) { + VhostUserBuilder builder = new VhostUserBuilder(); + builder.setRole(role); + builder.setSocket(socketName); + return builder.build(); + } @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { InterfaceTypeTestUtils.setupWriteContext(writeContext, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VhostUser.class); customizer = new VhostUserCustomizer(api, new NamingContext("generatedInterfaceName", "test-instance")); @@ -105,13 +112,6 @@ public class VhostUserCustomizerTest extends WriterCustomizerTest implements Ipv return actual; } - private static VhostUser generateVhostUser(final VhostUserRole role, final String socketName) { - VhostUserBuilder builder = new VhostUserBuilder(); - builder.setRole(role); - builder.setSocket(socketName); - return builder.build(); - } - @Test public void testWriteCurrentAttributes() throws Exception { final VhostUser vhostUser = generateVhostUser(VhostUserRole.Server, "socketName"); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java index f5b6873de..e39c523d3 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanCustomizerTest.java @@ -28,10 +28,14 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.net.InetAddresses; -import io.fd.hc2vpp.v3po.DisabledInterfacesManager; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.DisabledInterfacesManager; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.VppInvocationException; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; @@ -45,10 +49,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Vxlan; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VxlanBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.VppInvocationException; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.VxlanAddDelTunnelReply; public class VxlanCustomizerTest extends WriterCustomizerTest { @@ -62,8 +62,21 @@ public class VxlanCustomizerTest extends WriterCustomizerTest { private String ifaceName; private InstanceIdentifier<Vxlan> id; + private static Vxlan generateVxlan(long vni) { + final VxlanBuilder builder = new VxlanBuilder(); + builder.setSrc(new IpAddress(new Ipv4Address("192.168.20.10"))); + builder.setDst(new IpAddress(new Ipv4Address("192.168.20.11"))); + builder.setEncapVrfId(Long.valueOf(123)); + builder.setVni(new VxlanVni(Long.valueOf(vni))); + return builder.build(); + } + + private static Vxlan generateVxlan() { + return generateVxlan(Long.valueOf(11)); + } + @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { InterfaceTypeTestUtils.setupWriteContext(writeContext, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanTunnel.class); @@ -108,19 +121,6 @@ public class VxlanCustomizerTest extends WriterCustomizerTest { assertEquals(DEL_VXLAN, actual.isAdd); } - private static Vxlan generateVxlan(long vni) { - final VxlanBuilder builder = new VxlanBuilder(); - builder.setSrc(new IpAddress(new Ipv4Address("192.168.20.10"))); - builder.setDst(new IpAddress(new Ipv4Address("192.168.20.11"))); - builder.setEncapVrfId(Long.valueOf(123)); - builder.setVni(new VxlanVni(Long.valueOf(vni))); - return builder.build(); - } - - private static Vxlan generateVxlan() { - return generateVxlan(Long.valueOf(11)); - } - @Test public void testWriteCurrentAttributes() throws Exception { final Vxlan vxlan = generateVxlan(); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizerTest.java index 7337c16e3..62da6be03 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/VxlanGpeCustomizerTest.java @@ -28,10 +28,13 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.net.InetAddresses; -import io.fd.hc2vpp.v3po.DisabledInterfacesManager; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.DisabledInterfacesManager; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnel; +import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Mock; @@ -46,9 +49,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VxlanGpe; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VxlanGpeBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnel; -import io.fd.vpp.jvpp.core.dto.VxlanGpeAddDelTunnelReply; public class VxlanGpeCustomizerTest extends WriterCustomizerTest { @@ -62,8 +62,23 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest { private String ifaceName; private InstanceIdentifier<VxlanGpe> id; + private static VxlanGpe generateVxlanGpe(long vni) { + final VxlanGpeBuilder builder = new VxlanGpeBuilder(); + builder.setLocal(new IpAddress(new Ipv4Address("192.168.20.10"))); + builder.setRemote(new IpAddress(new Ipv4Address("192.168.20.11"))); + builder.setVni(new VxlanGpeVni(Long.valueOf(vni))); + builder.setNextProtocol(VxlanGpeNextProtocol.forValue(1)); + builder.setEncapVrfId(Long.valueOf(123)); + builder.setDecapVrfId(Long.valueOf(456)); + return builder.build(); + } + + private static VxlanGpe generateVxlanGpe() { + return generateVxlanGpe(Long.valueOf(11)); + } + @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { InterfaceTypeTestUtils.setupWriteContext(writeContext, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VxlanGpeTunnel.class); NamingContext namingContext = new NamingContext("generateInterfaceName", "test-instance"); @@ -110,21 +125,6 @@ public class VxlanGpeCustomizerTest extends WriterCustomizerTest { assertEquals(DEL_VXLAN_GPE, actual.isAdd); } - private static VxlanGpe generateVxlanGpe(long vni) { - final VxlanGpeBuilder builder = new VxlanGpeBuilder(); - builder.setLocal(new IpAddress(new Ipv4Address("192.168.20.10"))); - builder.setRemote(new IpAddress(new Ipv4Address("192.168.20.11"))); - builder.setVni(new VxlanGpeVni(Long.valueOf(vni))); - builder.setNextProtocol(VxlanGpeNextProtocol.forValue(1)); - builder.setEncapVrfId(Long.valueOf(123)); - builder.setDecapVrfId(Long.valueOf(456)); - return builder.build(); - } - - private static VxlanGpe generateVxlanGpe() { - return generateVxlanGpe(Long.valueOf(11)); - } - @Test public void testWriteCurrentAttributes() throws Exception { final VxlanGpe vxlanGpe = generateVxlanGpe(); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/AclWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/AclWriterTest.java index 7641bd912..a9451f53c 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/AclWriterTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/AclWriterTest.java @@ -20,8 +20,8 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.when; import com.google.common.base.Optional; -import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.honeycomb.translate.write.WriteFailedException; import java.util.Collections; import java.util.List; import org.junit.Test; @@ -37,10 +37,10 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces. import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentation; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.VppInterfaceAugmentationBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.ietf.acl.base.attributes.AccessListsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.ietf.acl.base.attributes.access.lists.AclBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.IetfAclBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.ietf.acl.IngressBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.ietf.acl.base.attributes.AccessListsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.ietf.acl.base.attributes.access.lists.AclBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class AclWriterTest extends WriterCustomizerTest { @@ -55,7 +55,7 @@ public class AclWriterTest extends WriterCustomizerTest { private IetfAclWriter customizer; @Override - public void setUp() { + public void setUpTest() { customizer = new IetfAclWriter(); when(acl.getAclName()).thenReturn(ACL_NAME); doReturn(ACL_TYPE).when(acl).getAclType(); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/EgressIetfAclWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/EgressIetfAclWriterTest.java index 0b75b5bce..26b14e5a8 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/EgressIetfAclWriterTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/EgressIetfAclWriterTest.java @@ -21,8 +21,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.base.Optional; -import io.fd.hc2vpp.v3po.interfaces.acl.common.AclTableContextManager; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.v3po.interfaces.acl.common.AclTableContextManager; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSessionReply; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTableReply; @@ -61,17 +61,17 @@ public class EgressIetfAclWriterTest extends WriterCustomizerTest { @Mock private InstanceIdentifier<?> id; - @Override - protected void setUp() throws Exception { - writer = new EgressIetfAclWriter(api, aclCtx); - } - private static ClassifyAddDelTable classifyAddDelTable(final int tableIndex) { final ClassifyAddDelTable reply = new ClassifyAddDelTable(); reply.tableIndex = tableIndex; return reply; } + @Override + protected void setUpTest() throws Exception { + writer = new EgressIetfAclWriter(api, aclCtx); + } + private ClassifySetInterfaceL2Tables classifySetInterfaceL2TablesRequest() { final ClassifySetInterfaceL2Tables request = new ClassifySetInterfaceL2Tables(); request.isInput = 0; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/IetfAclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/IetfAclCustomizerTest.java index 07e6518e5..4c11c86f4 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/IetfAclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/IetfAclCustomizerTest.java @@ -19,10 +19,10 @@ package io.fd.hc2vpp.v3po.interfaces.acl.egress; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; -import io.fd.hc2vpp.v3po.interfaces.acl.common.IetfAclWriter; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.interfaces.acl.common.IetfAclWriter; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import java.util.Collections; import org.junit.Test; import org.mockito.Mock; @@ -55,12 +55,6 @@ public class IetfAclCustomizerTest extends WriterCustomizerTest { private IetfAclWriter aclWriter; private IetfAclCustomizer customizer; - @Override - protected void setUp() { - customizer = new IetfAclCustomizer(aclWriter, new NamingContext("prefix", IFC_TEST_INSTANCE)); - defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); - } - private static Egress acl(final InterfaceMode mode) { return new EgressBuilder().setAccessLists( new AccessListsBuilder().setAcl( @@ -73,6 +67,12 @@ public class IetfAclCustomizerTest extends WriterCustomizerTest { ).build(); } + @Override + protected void setUpTest() { + customizer = new IetfAclCustomizer(aclWriter, new NamingContext("prefix", IFC_TEST_INSTANCE)); + defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); + } + private void verifyWrite(final AccessLists accessLists) throws WriteFailedException { verify(aclWriter) .write(IID, IF_INDEX, accessLists.getAcl(), accessLists.getDefaultAction(), accessLists.getMode(), diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/SubInterfaceIetfAclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/SubInterfaceIetfAclCustomizerTest.java index 24c57a1d5..df450cfa1 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/SubInterfaceIetfAclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/egress/SubInterfaceIetfAclCustomizerTest.java @@ -21,10 +21,10 @@ import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; import com.google.common.base.Optional; -import io.fd.hc2vpp.v3po.interfaces.acl.common.IetfAclWriter; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.interfaces.acl.common.IetfAclWriter; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import java.util.Collections; import org.junit.Test; import org.mockito.Mock; @@ -65,18 +65,6 @@ public class SubInterfaceIetfAclCustomizerTest extends WriterCustomizerTest { private IetfAclWriter aclWriter; private SubInterfaceIetfAclCustomizer customizer; - @Override - protected void setUp() { - customizer = new SubInterfaceIetfAclCustomizer(aclWriter, new NamingContext("prefix", IFC_TEST_INSTANCE)); - defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); - defineMapping(mappingContext, SUBIF_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE); - - - when(writeContext.readAfter(IID.firstIdentifierOf(SubInterface.class))).thenReturn(Optional.of( - new SubInterfaceBuilder().build() - )); - } - private static Egress acl(final InterfaceMode mode) { return new EgressBuilder().setAccessLists( new AccessListsBuilder().setAcl( @@ -89,6 +77,18 @@ public class SubInterfaceIetfAclCustomizerTest extends WriterCustomizerTest { ).build(); } + @Override + protected void setUpTest() { + customizer = new SubInterfaceIetfAclCustomizer(aclWriter, new NamingContext("prefix", IFC_TEST_INSTANCE)); + defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); + defineMapping(mappingContext, SUBIF_NAME, SUBIF_INDEX, IFC_TEST_INSTANCE); + + + when(writeContext.readAfter(IID.firstIdentifierOf(SubInterface.class))).thenReturn(Optional.of( + new SubInterfaceBuilder().build() + )); + } + private void verifyWrite(final AccessLists accessLists) throws WriteFailedException { verify(aclWriter) .write(IID, SUBIF_INDEX, accessLists.getAcl(), accessLists.getDefaultAction(), accessLists.getMode(), diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java index 9b7267d52..bb205fc6e 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/IetfAclCustomizerTest.java @@ -22,10 +22,10 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.base.Optional; -import io.fd.hc2vpp.v3po.interfaces.acl.common.AclTableContextManager; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.interfaces.acl.common.AclTableContextManager; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSessionReply; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable; @@ -85,8 +85,45 @@ public class IetfAclCustomizerTest extends WriterCustomizerTest { private int DENY = 0; private int PERMIT = -1; + private static Ace ace(final PacketHandling action) { + return new AceBuilder() + .setMatches(new MatchesBuilder().setAceType( + new AceIpBuilder() + .setAceIpVersion(new AceIpv6Builder().build()) + .setProtocol((short) 1) + .build() + ).build()) + .setActions(new ActionsBuilder().setPacketHandling(action).build()) + .build(); + } + + private static InputAclSetInterface inputAclSetInterfaceDeleteRequest() { + final InputAclSetInterface request = new InputAclSetInterface(); + request.swIfIndex = IF_INDEX; + request.l2TableIndex = 1; + request.ip4TableIndex = 2; + request.ip6TableIndex = 3; + return request; + } + + private static ClassifyAddDelTable classifyAddDelTable(final int tableIndex) { + final ClassifyAddDelTable reply = new ClassifyAddDelTable(); + reply.tableIndex = tableIndex; + return reply; + } + + private static InputAclSetInterface inputAclSetInterfaceWriteRequest() { + final InputAclSetInterface request = new InputAclSetInterface(); + request.swIfIndex = IF_INDEX; + request.isAdd = 1; + request.l2TableIndex = -1; + request.ip4TableIndex = -1; + request.ip6TableIndex = 0; + return request; + } + @Override - protected void setUp() { + protected void setUpTest() { customizer = new IetfAclCustomizer(new IngressIetfAclWriter(api, aclCtx), new NamingContext("prefix", IFC_TEST_INSTANCE)); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); acl = new IngressBuilder().setAccessLists( @@ -131,7 +168,6 @@ public class IetfAclCustomizerTest extends WriterCustomizerTest { return table -> table.missNextIndex == action; } - private ArgumentMatcher<ClassifyAddDelSession> actionOnHitEquals(final int action) { return session -> session.hitNextIndex == action; } @@ -144,18 +180,6 @@ public class IetfAclCustomizerTest extends WriterCustomizerTest { return new PermitBuilder().build(); } - private static Ace ace(final PacketHandling action) { - return new AceBuilder() - .setMatches(new MatchesBuilder().setAceType( - new AceIpBuilder() - .setAceIpVersion(new AceIpv6Builder().build()) - .setProtocol((short) 1) - .build() - ).build()) - .setActions(new ActionsBuilder().setPacketHandling(action).build()) - .build(); - } - @Test public void testDelete() throws WriteFailedException { when(api.inputAclSetInterface(any())).thenReturn(future(new InputAclSetInterfaceReply())); @@ -177,29 +201,4 @@ public class IetfAclCustomizerTest extends WriterCustomizerTest { verify(api).classifyAddDelTable(classifyAddDelTable(2)); verify(api).classifyAddDelTable(classifyAddDelTable(3)); } - - private static InputAclSetInterface inputAclSetInterfaceDeleteRequest() { - final InputAclSetInterface request = new InputAclSetInterface(); - request.swIfIndex = IF_INDEX; - request.l2TableIndex = 1; - request.ip4TableIndex = 2; - request.ip6TableIndex = 3; - return request; - } - - private static ClassifyAddDelTable classifyAddDelTable(final int tableIndex) { - final ClassifyAddDelTable reply = new ClassifyAddDelTable(); - reply.tableIndex = tableIndex; - return reply; - } - - private static InputAclSetInterface inputAclSetInterfaceWriteRequest() { - final InputAclSetInterface request = new InputAclSetInterface(); - request.swIfIndex = IF_INDEX; - request.isAdd = 1; - request.l2TableIndex = -1; - request.ip4TableIndex = -1; - request.ip6TableIndex = 0; - return request; - } }
\ No newline at end of file diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java index 8b088883f..b5140df12 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceAclCustomizerTest.java @@ -20,10 +20,10 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; +import io.fd.hc2vpp.v3po.vppclassifier.VppClassifierContextManager; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.core.dto.InputAclSetInterface; import io.fd.vpp.jvpp.core.dto.InputAclSetInterfaceReply; import org.junit.Test; @@ -65,7 +65,7 @@ public class SubInterfaceAclCustomizerTest extends WriterCustomizerTest { private SubInterfaceAclCustomizer customizer; @Override - protected void setUp() throws Exception { + protected void setUpTest() throws Exception { customizer = new SubInterfaceAclCustomizer(api, new NamingContext("prefix", IFC_TEST_INSTANCE), classifyTableContext); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizerTest.java index e3c1d86f9..d64af5715 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/ingress/SubInterfaceIetfAclCustomizerTest.java @@ -21,11 +21,11 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.base.Optional; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfaces.acl.IetfAclWriter; import io.fd.hc2vpp.v3po.interfaces.acl.common.AclTableContextManager; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.core.dto.ClassifyTableByInterface; import io.fd.vpp.jvpp.core.dto.InputAclSetInterface; import io.fd.vpp.jvpp.core.dto.InputAclSetInterfaceReply; @@ -73,8 +73,27 @@ public class SubInterfaceIetfAclCustomizerTest extends WriterCustomizerTest { @Mock private AclTableContextManager aclCtx; + private static InputAclSetInterface inputAclSetInterfaceWriteRequest() { + final InputAclSetInterface request = new InputAclSetInterface(); + request.swIfIndex = SUBIF_INDEX; + request.isAdd = 1; + request.l2TableIndex = -1; + request.ip4TableIndex = -1; + request.ip6TableIndex = -1; + return request; + } + + private static InputAclSetInterface inputAclSetInterfaceDeleteRequest() { + final InputAclSetInterface request = new InputAclSetInterface(); + request.swIfIndex = SUBIF_INDEX; + request.l2TableIndex = -1; + request.ip4TableIndex = -1; + request.ip6TableIndex = -1; + return request; + } + @Override - protected void setUp() { + protected void setUpTest() { customizer = new SubInterfaceIetfAclCustomizer(new IngressIetfAclWriter(api, aclCtx), new NamingContext("prefix", IFC_TEST_INSTANCE)); defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); @@ -89,16 +108,6 @@ public class SubInterfaceIetfAclCustomizerTest extends WriterCustomizerTest { ).build(); } - private static InputAclSetInterface inputAclSetInterfaceWriteRequest() { - final InputAclSetInterface request = new InputAclSetInterface(); - request.swIfIndex = SUBIF_INDEX; - request.isAdd = 1; - request.l2TableIndex = -1; - request.ip4TableIndex = -1; - request.ip6TableIndex = -1; - return request; - } - @Test public void testDelete() throws WriteFailedException { defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); @@ -119,15 +128,6 @@ public class SubInterfaceIetfAclCustomizerTest extends WriterCustomizerTest { verify(api).inputAclSetInterface(inputAclSetInterfaceDeleteRequest()); } - private static InputAclSetInterface inputAclSetInterfaceDeleteRequest() { - final InputAclSetInterface request = new InputAclSetInterface(); - request.swIfIndex = SUBIF_INDEX; - request.l2TableIndex = -1; - request.ip4TableIndex = -1; - request.ip6TableIndex = -1; - return request; - } - @Test public void testWrite() throws WriteFailedException { defineMapping(mappingContext, IF_NAME, IF_INDEX, IFC_TEST_INSTANCE); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java index 6659e79b6..3b46d7fb0 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4AddressCustomizerTest.java @@ -22,18 +22,21 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.argThat; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.doThrow; 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 com.google.common.base.Optional; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.hc2vpp.v3po.interfaces.ip.subnet.validation.SubnetValidationException; import io.fd.hc2vpp.v3po.interfaces.ip.subnet.validation.SubnetValidator; -import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -58,10 +61,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.address.subnet.PrefixLengthBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DottedQuad; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.IpAddressDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; public class Ipv4AddressCustomizerTest extends WriterCustomizerTest { @@ -75,8 +74,22 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest { private NamingContext interfaceContext; private Ipv4AddressCustomizer customizer; + private static InstanceIdentifier<Address> getAddressId(final String ifaceName) { + return InstanceIdentifier.builder(Interfaces.class) + .child(Interface.class, new InterfaceKey(ifaceName)) + .augmentation(Interface1.class) + .child(Ipv4.class) + .child(Address.class) + .build(); + } + + private static ArgumentMatcher<InstanceIdentifier<?>> matchInstanceIdentifier( + Class<?> desiredClass) { + return o -> o instanceof InstanceIdentifier && (o.getTargetType().equals(desiredClass)); + } + @Before - public void setUp() throws Exception { + public void setUpTest() throws Exception { interfaceContext = new NamingContext("generatedIfaceName", IFC_CTX_NAME); customizer = new Ipv4AddressCustomizer(api, interfaceContext, subnetValidator); @@ -86,15 +99,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest { .thenReturn(Optional.of(new Ipv4Builder().setAddress(Collections.emptyList()).build())); } - private static InstanceIdentifier<Address> getAddressId(final String ifaceName) { - return InstanceIdentifier.builder(Interfaces.class) - .child(Interface.class, new InterfaceKey(ifaceName)) - .augmentation(Interface1.class) - .child(Ipv4.class) - .child(Address.class) - .build(); - } - private void whenSwInterfaceAddDelAddressThenSuccess() { doReturn(future(new SwInterfaceAddDelAddressReply())).when(api).swInterfaceAddDelAddress(any(SwInterfaceAddDelAddress.class)); } @@ -180,11 +184,6 @@ public class Ipv4AddressCustomizerTest extends WriterCustomizerTest { } - private static ArgumentMatcher<InstanceIdentifier<?>> matchInstanceIdentifier( - Class<?> desiredClass) { - return o -> o instanceof InstanceIdentifier && (o.getTargetType().equals(desiredClass)); - } - @Test(expected = WriteFailedException.UpdateFailedException.class) public void testUpdate() throws Exception { final Address data = mock(Address.class); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java index 390561d80..9ddefdc87 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/Ipv4NeighbourCustomizerTest.java @@ -21,10 +21,14 @@ import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; + +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.Ipv4Translator; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel; +import io.fd.vpp.jvpp.core.dto.IpNeighborAddDelReply; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; @@ -37,9 +41,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev14061 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.ip.rev140616.interfaces._interface.ipv4.NeighborBuilder; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.IpNeighborAddDel; -import io.fd.vpp.jvpp.core.dto.IpNeighborAddDelReply; public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements Ipv4Translator { @@ -53,7 +54,7 @@ public class Ipv4NeighbourCustomizerTest extends WriterCustomizerTest implements private Ipv4NeighbourCustomizer customizer; @Override - public void setUp() { + public void setUpTest() { defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME); customizer = new Ipv4NeighbourCustomizer(api, new NamingContext("prefix", IFC_CTX_NAME)); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizerTest.java index be0869fa9..e4479a0e0 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/ip/SubInterfaceIpv4AddressCustomizerTest.java @@ -22,10 +22,13 @@ import static org.mockito.Matchers.any; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.vpp.jvpp.VppBaseCallException; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; +import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; import org.junit.Test; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone; @@ -46,9 +49,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.ipv4.address.subnet.PrefixLength; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.ip4.attributes.ipv4.address.subnet.PrefixLengthBuilder; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import io.fd.vpp.jvpp.VppBaseCallException; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddress; -import io.fd.vpp.jvpp.core.dto.SwInterfaceAddDelAddressReply; public class SubInterfaceIpv4AddressCustomizerTest extends WriterCustomizerTest implements ByteDataTranslator { @@ -66,7 +66,7 @@ public class SubInterfaceIpv4AddressCustomizerTest extends WriterCustomizerTest private SubInterfaceIpv4AddressCustomizer customizer; @Override - protected void setUp() { + protected void setUpTest() { customizer = new SubInterfaceIpv4AddressCustomizer(api, new NamingContext("prefix", IFC_CTX_NAME)); defineMapping(mappingContext, IFACE_NAME, IFACE_INDEX, IFC_CTX_NAME); defineMapping(mappingContext, SUBIF_NAME, SUBIF_INDEX, IFC_CTX_NAME); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java index fa68e61b6..214f760d1 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/pbb/PbbRewriteCustomizerTest.java @@ -26,9 +26,9 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.VppCallbackException; import io.fd.vpp.jvpp.core.dto.L2InterfacePbbTagRewrite; import io.fd.vpp.jvpp.core.dto.L2InterfacePbbTagRewriteReply; @@ -56,7 +56,7 @@ public class PbbRewriteCustomizerTest extends WriterCustomizerTest { private InstanceIdentifier<PbbRewrite> invalidId; @Override - protected void setUp() throws Exception { + protected void setUpTest() throws Exception { interfaceContext = new NamingContext("interface", "interface-context"); customizer = new PbbRewriteCustomizer(api, interfaceContext); diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java index 3377809b7..4d5675630 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/ArpTerminationTableEntryCustomizerTest.java @@ -25,9 +25,9 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.VppInvocationException; import io.fd.vpp.jvpp.core.dto.BdIpMacAddDel; @@ -62,8 +62,15 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest private ArpTerminationTableEntry entry; private InstanceIdentifier<ArpTerminationTableEntry> id; + private static InstanceIdentifier<ArpTerminationTableEntry> getArpEntryId(final IpAddress ipAddress, + final PhysAddress physAddress) { + return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(BD_NAME)) + .child(ArpTerminationTable.class) + .child(ArpTerminationTableEntry.class, new ArpTerminationTableEntryKey(ipAddress, physAddress)); + } + @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { customizer = new ArpTerminationTableEntryCustomizer(api, new NamingContext("generatedBdName", BD_CTX_NAME)); ipAddressRaw = new byte[]{1, 2, 3, 4}; @@ -78,13 +85,6 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME); } - private static InstanceIdentifier<ArpTerminationTableEntry> getArpEntryId(final IpAddress ipAddress, - final PhysAddress physAddress) { - return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(BD_NAME)) - .child(ArpTerminationTable.class) - .child(ArpTerminationTableEntry.class, new ArpTerminationTableEntryKey(ipAddress, physAddress)); - } - private void whenBdIpMacAddDelThenSuccess() { doReturn(future(new BdIpMacAddDelReply())).when(api).bdIpMacAddDel(any(BdIpMacAddDel.class)); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/BridgeDomainCustomizerTest.java index cab5d5c3b..73106d87b 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/BridgeDomainCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/BridgeDomainCustomizerTest.java @@ -23,10 +23,10 @@ import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.ByteDataTranslator; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.VppInvocationException; import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDel; import io.fd.vpp.jvpp.core.dto.BridgeDomainAddDelReply; @@ -45,11 +45,6 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements private static final byte ADD_OR_UPDATE_BD = (byte) 1; private BridgeDomainCustomizer customizer; - @Override - public void setUp() throws Exception { - customizer = new BridgeDomainCustomizer(api, new NamingContext("generatedBDName", BD_CTX_NAME)); - } - @Nullable private static Boolean intToBoolean(final int value) { if (value == 0) { @@ -66,6 +61,11 @@ public class BridgeDomainCustomizerTest extends WriterCustomizerTest implements return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(bdName)); } + @Override + public void setUpTest() throws Exception { + customizer = new BridgeDomainCustomizer(api, new NamingContext("generatedBDName", BD_CTX_NAME)); + } + private BridgeDomain generateBridgeDomain(final String bdName) { final byte arpTerm = 0; final byte flood = 1; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/L2FibEntryCustomizerTest.java index 6bb5bc6cf..689d53636 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/L2FibEntryCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vpp/L2FibEntryCustomizerTest.java @@ -24,9 +24,9 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; +import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.hc2vpp.common.translate.util.NamingContext; import io.fd.honeycomb.translate.write.WriteFailedException; -import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.VppInvocationException; import io.fd.vpp.jvpp.core.dto.L2FibAddDel; @@ -55,8 +55,13 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest { private L2FibEntryCustomizer customizer; + private static InstanceIdentifier<L2FibEntry> getL2FibEntryId(final PhysAddress address) { + return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(BD_NAME)) + .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address)); + } + @Override - public void setUp() throws Exception { + public void setUpTest() throws Exception { defineMapping(mappingContext, BD_NAME, BD_ID, BD_CTX_NAME); defineMapping(mappingContext, IFACE_NAME, IFACE_ID, IFC_CTX_NAME); @@ -66,11 +71,6 @@ public class L2FibEntryCustomizerTest extends WriterCustomizerTest { new NamingContext("generatedIfaceName", IFC_CTX_NAME)); } - private static InstanceIdentifier<L2FibEntry> getL2FibEntryId(final PhysAddress address) { - return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(BD_NAME)) - .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address)); - } - private void whenL2FibAddDelThenSuccess() { doReturn(future(new L2FibAddDelReply())).when(api).l2FibAddDel(any(L2FibAddDel.class)); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifySessionWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifySessionWriterTest.java index 654900c81..3cc4511bb 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifySessionWriterTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifySessionWriterTest.java @@ -25,8 +25,8 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import com.google.common.base.Optional; -import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSession; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelSessionReply; @@ -49,25 +49,10 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { private static final int TABLE_INDEX = 123; private static final String TABLE_NAME = "table123"; - + private static final int SESSION_INDEX = 456; @Mock private VppClassifierContextManager classfierContext; - private ClassifySessionWriter customizer; - private static final int SESSION_INDEX = 456; - - @Override - public void setUp() throws Exception { - customizer = new ClassifySessionWriter(api, classfierContext); - - 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")); - when(writeContext.readAfter(any())).thenReturn(Optional.of(table)); - when(writeContext.readBefore(any())).thenReturn(Optional.of(table)); - } private static ClassifySession generateClassifySession(final long opaqueIndex, final String match) { final ClassifySessionBuilder builder = new ClassifySessionBuilder(); @@ -85,15 +70,6 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { .child(ClassifySession.class, new ClassifySessionKey(new HexString(match))); } - private void whenClassifyAddDelSessionThenSuccess() { - doReturn(future(new ClassifyAddDelSessionReply())).when(api) - .classifyAddDelSession(any(ClassifyAddDelSession.class)); - } - - private void whenClassifyAddDelSessionThenFailure() { - doReturn(failedFuture()).when(api).classifyAddDelSession(any(ClassifyAddDelSession.class)); - } - private static ClassifyAddDelSession generateClassifyAddDelSession(final byte isAdd, final int tableIndex, final int sessionIndex) { final ClassifyAddDelSession request = new ClassifyAddDelSession(); @@ -108,6 +84,28 @@ public class ClassifySessionWriterTest extends WriterCustomizerTest { return request; } + @Override + public void setUpTest() throws Exception { + customizer = new ClassifySessionWriter(api, classfierContext); + + 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")); + when(writeContext.readAfter(any())).thenReturn(Optional.of(table)); + when(writeContext.readBefore(any())).thenReturn(Optional.of(table)); + } + + private void whenClassifyAddDelSessionThenSuccess() { + doReturn(future(new ClassifyAddDelSessionReply())).when(api) + .classifyAddDelSession(any(ClassifyAddDelSession.class)); + } + + private void whenClassifyAddDelSessionThenFailure() { + doReturn(failedFuture()).when(api).classifyAddDelSession(any(ClassifyAddDelSession.class)); + } + @Test public void testCreate() throws Exception { final String match = "00:00:00:00:00:00:01:02:03:04:05:06:00:00:00:00"; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifyTableWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifyTableWriterTest.java index a4da54631..f09cea7d9 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifyTableWriterTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/vppclassifier/ClassifyTableWriterTest.java @@ -24,8 +24,8 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.hc2vpp.common.test.write.WriterCustomizerTest; +import io.fd.honeycomb.translate.write.WriteFailedException; import io.fd.vpp.jvpp.VppBaseCallException; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTable; import io.fd.vpp.jvpp.core.dto.ClassifyAddDelTableReply; @@ -51,11 +51,6 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { private ClassifyTableWriter customizer; - @Override - public void setUp() throws Exception { - customizer = new ClassifyTableWriter(api, classifierContext); - } - private static ClassifyTable generateClassifyTable(final String name) { final ClassifyTableBuilder builder = new ClassifyTableBuilder(); builder.setName(name); @@ -74,16 +69,6 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { .child(ClassifyTable.class, new ClassifyTableKey(name)); } - private void whenClassifyAddDelTableThenSuccess() { - final ClassifyAddDelTableReply reply = new ClassifyAddDelTableReply(); - reply.newTableIndex = TABLE_INDEX; - doReturn(future(reply)).when(api).classifyAddDelTable(any(ClassifyAddDelTable.class)); - } - - private void whenClassifyAddDelTableThenFailure() { - doReturn(failedFuture()).when(api).classifyAddDelTable(any(ClassifyAddDelTable.class)); - } - private static ClassifyAddDelTable generateClassifyAddDelTable(final byte isAdd) { return generateClassifyAddDelTable(isAdd, -1); } @@ -104,6 +89,21 @@ public class ClassifyTableWriterTest extends WriterCustomizerTest { return request; } + @Override + public void setUpTest() throws Exception { + customizer = new ClassifyTableWriter(api, classifierContext); + } + + private void whenClassifyAddDelTableThenSuccess() { + final ClassifyAddDelTableReply reply = new ClassifyAddDelTableReply(); + reply.newTableIndex = TABLE_INDEX; + doReturn(future(reply)).when(api).classifyAddDelTable(any(ClassifyAddDelTable.class)); + } + + private void whenClassifyAddDelTableThenFailure() { + doReturn(failedFuture()).when(api).classifyAddDelTable(any(ClassifyAddDelTable.class)); + } + @Test public void testCreate() throws Exception { final ClassifyTable classifyTable = generateClassifyTable(TABLE_NAME); |