From: Claudio D. Gasparini Date: Tue, 7 Mar 2017 07:02:55 +0000 (+0100) Subject: Remove deprecated class AbstractDataBrokerTest under BGP X-Git-Tag: release/carbon~36 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=6c116ec63e2997f343d2fd352b8ddc2ea6af58a7;hp=d9a7ab7217f7d14c96356db48e7d6dcdd00601ba;p=bgpcep.git Remove deprecated class AbstractDataBrokerTest under BGP Remove deprecated class AbstractDataBrokerTest on tests. Perform some code clean up under tests. Change-Id: I64b120bdbbf59db4df0e4d4e2d769eac22738c33 Signed-off-by: Claudio D. Gasparini --- diff --git a/bgp/benchmark-app/pom.xml b/bgp/benchmark-app/pom.xml index a1537afd2a..ff2b95aa23 100644 --- a/bgp/benchmark-app/pom.xml +++ b/bgp/benchmark-app/pom.xml @@ -83,6 +83,11 @@ sal-binding-config + + ${project.groupId} + testtool-util + test + junit junit diff --git a/bgp/benchmark-app/src/main/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmark.java b/bgp/benchmark-app/src/main/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmark.java index 81efd3d241..fd6cede9a5 100644 --- a/bgp/benchmark-app/src/main/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmark.java +++ b/bgp/benchmark-app/src/main/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmark.java @@ -10,6 +10,8 @@ package org.opendaylight.protocol.bgp.benchmark.app; import com.google.common.base.Stopwatch; import com.google.common.net.InetAddresses; +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; import java.util.Collections; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; @@ -130,7 +132,17 @@ public class AppPeerBenchmark implements OdlBgpAppPeerBenchmarkService, Transact new ApplicationRibKey(new ApplicationRibId(appRibId))).build(); final WriteTransaction wTx = this.txChain.newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.CONFIGURATION, ribIID, appRib); - wTx.submit(); + Futures.addCallback(wTx.submit(), new FutureCallback() { + @Override + public void onSuccess(final Void result) { + LOG.trace("Empty Structure created for Application Peer Benchmark {}", appRibId); + } + + @Override + public void onFailure(final Throwable throwable) { + LOG.error("Failed to create Empty Structure for Application Peer Benchmark {}", appRibId, throwable); + } + }); return ribIID; } diff --git a/bgp/benchmark-app/src/test/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmarkTest.java b/bgp/benchmark-app/src/test/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmarkTest.java index b7cbfc5570..129323c85a 100644 --- a/bgp/benchmark-app/src/test/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmarkTest.java +++ b/bgp/benchmark-app/src/test/java/org/opendaylight/protocol/bgp/benchmark/app/AppPeerBenchmarkTest.java @@ -18,9 +18,10 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; +import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address; @@ -43,7 +44,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; -public class AppPeerBenchmarkTest extends AbstractDataBrokerTest { +public class AppPeerBenchmarkTest extends AbstractConcurrentDataBrokerTest { private static final String PREFIX = "1.1.1.1/32"; private static final String NH = "127.0.0.1"; @@ -63,7 +64,7 @@ public class AppPeerBenchmarkTest extends AbstractDataBrokerTest { private AppPeerBenchmark appPeerBenchmark; @Before - public void setUp() throws MalformedObjectNameException { + public void setUp() throws MalformedObjectNameException, TransactionCommitFailedException { MockitoAnnotations.initMocks(this); Mockito.doReturn(this.registration).when(this.rpcRegistry).addRpcImplementation(Mockito.any(), Mockito.any(OdlBgpAppPeerBenchmarkService.class)); @@ -74,9 +75,7 @@ public class AppPeerBenchmarkTest extends AbstractDataBrokerTest { @Test public void testRpcs() throws InterruptedException, ExecutionException, ReadFailedException { final RpcResult addRpcResult = this.appPeerBenchmark.addPrefix(new AddPrefixInputBuilder() - .setBatchsize(1L) - .setCount(1L) - .setNexthop(new Ipv4Address(NH)) + .setBatchsize(1L).setCount(1L).setNexthop(new Ipv4Address(NH)) .setPrefix(new Ipv4Prefix(PREFIX)).build()).get(); final Result addResult = addRpcResult.getResult().getResult(); Assert.assertEquals(1, addResult.getCount().intValue()); diff --git a/bgp/bmp-impl/src/test/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitorImplTest.java b/bgp/bmp-impl/src/test/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitorImplTest.java index 0027479cd5..176ff8a341 100644 --- a/bgp/bmp-impl/src/test/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitorImplTest.java +++ b/bgp/bmp-impl/src/test/java/org/opendaylight/protocol/bmp/impl/app/BmpMonitorImplTest.java @@ -40,7 +40,7 @@ import org.junit.Before; import org.junit.Test; import org.mockito.MockitoAnnotations; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; @@ -102,7 +102,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -public class BmpMonitorImplTest extends AbstractDataBrokerTest { +public class BmpMonitorImplTest extends AbstractConcurrentDataBrokerTest { // the local port and address where the monitor (ODL) will listen for incoming BMP request private static final int MONITOR_LOCAL_PORT = 12345; private static final String MONITOR_LOCAL_ADDRESS = "127.0.0.10"; diff --git a/bgp/openconfig-state/src/test/java/org/opendaylight/protocol/bgp/state/StateProviderImplTest.java b/bgp/openconfig-state/src/test/java/org/opendaylight/protocol/bgp/state/StateProviderImplTest.java index 8bf9f71bc6..e092970c26 100644 --- a/bgp/openconfig-state/src/test/java/org/opendaylight/protocol/bgp/state/StateProviderImplTest.java +++ b/bgp/openconfig-state/src/test/java/org/opendaylight/protocol/bgp/state/StateProviderImplTest.java @@ -28,7 +28,7 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider; import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration; @@ -51,7 +51,14 @@ import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.r import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.BgpNeighborState; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.graceful.restart.GracefulRestart; -import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.*; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafis; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandling; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.ErrorHandlingBuilder; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TimersBuilder; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TransportBuilder; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroup; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder; @@ -59,7 +66,14 @@ import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.t import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.GlobalBuilder; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors; -import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.*; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.ADDPATHS; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.ASN32; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.BgpCapability; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.CommunityType; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.GRACEFULRESTART; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.MPBGP; +import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.ROUTEREFRESH; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance; import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey; @@ -106,7 +120,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.type import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier; -public class StateProviderImplTest extends AbstractDataBrokerTest { +public class StateProviderImplTest extends AbstractConcurrentDataBrokerTest { private final LongAdder totalPathsCounter = new LongAdder(); private final LongAdder totalPrefixesCounter = new LongAdder(); private final PortNumber localPort = new PortNumber(1790); diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java index 0dfdfed9e3..2d5aa53f67 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java @@ -32,7 +32,7 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy; import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.mdsal.binding.generator.util.JavassistUtils; @@ -110,7 +110,7 @@ import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -class AbstractAddPathTest extends AbstractDataBrokerTest { +class AbstractAddPathTest extends AbstractConcurrentDataBrokerTest { private static final int RETRY_TIMER = 10; static final String RIB_ID = "127.0.0.1"; static final BgpId BGP_ID = new BgpId(RIB_ID); diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathAllPathsTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathAllPathsTest.java index f452028276..ea8495600f 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathAllPathsTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathAllPathsTest.java @@ -196,7 +196,6 @@ public class AddPathAllPathsTest extends AbstractAddPathTest { checkReceivedMessages(listener6, 1); assertEquals(UPD_NA_100, listener6.getListMsg().get(0)); causeBGPError(session6); - //session6.close();aca send wrong message checkEquals(()-> assertEquals(1L, peer6.getPeerState().getBGPPeerMessagesState().getNotificationMessagesSentCount())); checkPeersPresentOnDataStore(5); diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java index 43aa34a110..fffecaeeda 100755 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/ParserToSalTest.java @@ -34,8 +34,7 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; import org.opendaylight.controller.sal.core.api.model.SchemaService; @@ -73,7 +72,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.opendaylight.yangtools.yang.binding.util.BindingReflections; -public class ParserToSalTest extends AbstractDataBrokerTest { +public class ParserToSalTest extends AbstractConcurrentDataBrokerTest { private static final String TEST_RIB_ID = "testRib"; private static final TablesKey TABLE_KEY = new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class); @@ -94,28 +93,6 @@ public class ParserToSalTest extends AbstractDataBrokerTest { @Before public void setUp() throws Exception { super.setup(); - doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider). - registerClusterSingletonService(any(ClusterSingletonService.class)); - } - - @Override - protected Iterable getModuleInfos() throws Exception { - return ImmutableList.of( - BindingReflections.getModuleInfo(Ipv4Route.class), - BindingReflections.getModuleInfo(Ipv6Route.class), - BindingReflections.getModuleInfo(LinkstateRoute.class)); - } - - @Override - protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() { - final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer(); - this.codecFactory = customizer.getBindingToNormalized(); - this.schemaService = customizer.getSchemaService(); - return customizer; - } - - @Override - protected void setupWithDataBroker(final DataBroker dataBroker) { MockitoAnnotations.initMocks(this); final List bgpMessages; try { @@ -138,6 +115,24 @@ public class ParserToSalTest extends AbstractDataBrokerTest { this.baseact.startRIBExtensionProvider(this.ext1); this.lsact.startRIBExtensionProvider(this.ext2); + doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider). + registerClusterSingletonService(any(ClusterSingletonService.class)); + } + + @Override + protected Iterable getModuleInfos() throws Exception { + return ImmutableList.of( + BindingReflections.getModuleInfo(Ipv4Route.class), + BindingReflections.getModuleInfo(Ipv6Route.class), + BindingReflections.getModuleInfo(LinkstateRoute.class)); + } + + @Override + protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() { + final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer(); + this.codecFactory = customizer.getBindingToNormalized(); + this.schemaService = customizer.getSchemaService(); + return customizer; } @After diff --git a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractTopologyBuilderTest.java b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractTopologyBuilderTest.java index 3132da9297..ddf7e3db67 100644 --- a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractTopologyBuilderTest.java +++ b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/AbstractTopologyBuilderTest.java @@ -8,16 +8,11 @@ package org.opendaylight.bgpcep.bgp.topology.provider; -import static org.junit.Assert.fail; - -import com.google.common.base.Optional; import com.google.common.base.Preconditions; import java.util.Collections; -import java.util.concurrent.ExecutionException; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.ReadTransaction; +import org.junit.Before; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; +import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.protocol.bgp.rib.DefaultRibReference; import org.opendaylight.protocol.bgp.rib.RibReference; @@ -28,34 +23,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib. import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder; import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public abstract class AbstractTopologyBuilderTest extends AbstractDataBrokerTest { - - protected static final TopologyId TEST_TOPOLOGY_ID = new TopologyId("test-topo"); - protected static final RibReference LOC_RIB_REF = new DefaultRibReference(InstanceIdentifier.create(BgpRib.class).child(Rib.class, new RibKey(Preconditions.checkNotNull(new RibId("test-rib"))))); +public abstract class AbstractTopologyBuilderTest extends AbstractConcurrentDataBrokerTest { + static final TopologyId TEST_TOPOLOGY_ID = new TopologyId("test-topo"); + static final RibReference LOC_RIB_REF = new DefaultRibReference(InstanceIdentifier.create(BgpRib.class) + .child(Rib.class, new RibKey(Preconditions.checkNotNull(new RibId("test-rib"))))); - @Override - protected void setupWithDataBroker(final DataBroker dataBroker) { - super.setupWithDataBroker(dataBroker); + @Before + public void setUp() { createEmptyTopology(); } - protected void createEmptyTopology() { + private void createEmptyTopology() { final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction(); - wTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(NetworkTopology.class).build(), new NetworkTopologyBuilder().setTopology(Collections.emptyList()).build()); + wTx.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(NetworkTopology.class).build(), + new NetworkTopologyBuilder().setTopology(Collections.emptyList()).build()); wTx.submit(); } - - protected Optional getTopology(final InstanceIdentifier topoIID) { - final ReadTransaction rTx = getDataBroker().newReadOnlyTransaction(); - try { - return rTx.read(LogicalDatastoreType.OPERATIONAL, topoIID).get(); - } catch (InterruptedException | ExecutionException e) { - fail(); - } - return Optional.absent(); - } - } diff --git a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv4ReachabilityTopologyBuilderTest.java b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv4ReachabilityTopologyBuilderTest.java index 80e23c7e67..6cb43e9e2f 100755 --- a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv4ReachabilityTopologyBuilderTest.java +++ b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv4ReachabilityTopologyBuilderTest.java @@ -9,12 +9,12 @@ package org.opendaylight.bgpcep.bgp.topology.provider; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; +import static org.opendaylight.protocol.util.CheckUtil.checkNull; import static org.opendaylight.protocol.util.CheckUtil.readData; +import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; @@ -48,10 +48,11 @@ public class Ipv4ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder private Ipv4ReachabilityTopologyBuilder ipv4TopoBuilder; private InstanceIdentifier ipv4RouteIID; + @Before @Override - protected void setupWithDataBroker(final DataBroker dataBroker) { - super.setupWithDataBroker(dataBroker); - this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID); + public void setUp() { + super.setUp(); + this.ipv4TopoBuilder = new Ipv4ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID); this.ipv4TopoBuilder.start(); final InstanceIdentifier path = this.ipv4TopoBuilder.tableInstanceIdentifier(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class); @@ -98,7 +99,7 @@ public class Ipv4ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder }); this.ipv4TopoBuilder.close(); - assertFalse(getTopology(this.ipv4TopoBuilder.getInstanceIdentifier()).isPresent()); + checkNull(getDataBroker(), this.ipv4TopoBuilder.getInstanceIdentifier()); } private void updateIpv4Route(final Ipv4Route data) { diff --git a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv6ReachabilityTopologyBuilderTest.java b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv6ReachabilityTopologyBuilderTest.java index eedb74cc28..037834d3c9 100755 --- a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv6ReachabilityTopologyBuilderTest.java +++ b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/Ipv6ReachabilityTopologyBuilderTest.java @@ -9,13 +9,13 @@ package org.opendaylight.bgpcep.bgp.topology.provider; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.opendaylight.bgpcep.bgp.topology.provider.Ipv4ReachabilityTopologyBuilderTest.PATH_ID; +import static org.opendaylight.protocol.util.CheckUtil.checkNull; import static org.opendaylight.protocol.util.CheckUtil.readData; +import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException; @@ -48,10 +48,11 @@ public class Ipv6ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder private Ipv6ReachabilityTopologyBuilder ipv6TopoBuilder; private InstanceIdentifier ipv6RouteIID; + @Before @Override - protected void setupWithDataBroker(final DataBroker dataBroker) { - super.setupWithDataBroker(dataBroker); - this.ipv6TopoBuilder = new Ipv6ReachabilityTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID); + public void setUp() { + super.setUp(); + this.ipv6TopoBuilder = new Ipv6ReachabilityTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID); this.ipv6TopoBuilder.start(); final InstanceIdentifier path = this.ipv6TopoBuilder .tableInstanceIdentifier(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class); @@ -99,7 +100,7 @@ public class Ipv6ReachabilityTopologyBuilderTest extends AbstractTopologyBuilder }); this.ipv6TopoBuilder.close(); - assertFalse(getTopology(this.ipv6TopoBuilder.getInstanceIdentifier()).isPresent()); + checkNull(getDataBroker(), this.ipv6TopoBuilder.getInstanceIdentifier()); } private void updateIpv6Route(final Ipv6Route data) { diff --git a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateTopologyBuilderTest.java b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateTopologyBuilderTest.java index 966e24bb20..9ac1e3b5ed 100755 --- a/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateTopologyBuilderTest.java +++ b/bgp/topology-provider/src/test/java/org/opendaylight/bgpcep/bgp/topology/provider/LinkstateTopologyBuilderTest.java @@ -9,7 +9,6 @@ package org.opendaylight.bgpcep.bgp.topology.provider; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -24,6 +23,7 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +import static org.opendaylight.protocol.util.CheckUtil.checkNull; import static org.opendaylight.protocol.util.CheckUtil.readData; import com.google.common.collect.Lists; @@ -34,8 +34,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import org.junit.After; +import org.junit.Before; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; import org.opendaylight.controller.md.sal.binding.api.DataTreeModification; import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; @@ -113,19 +113,21 @@ public class LinkstateTopologyBuilderTest extends AbstractTopologyBuilderTest { private LinkstateTopologyBuilder linkstateTopoBuilder; private InstanceIdentifier linkstateRouteIID; + @Before @Override - protected void setupWithDataBroker(final DataBroker dataBroker) { - super.setupWithDataBroker(dataBroker); - this.linkstateTopoBuilder = new LinkstateTopologyBuilder(dataBroker, LOC_RIB_REF, TEST_TOPOLOGY_ID, LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER); + public void setUp() { + super.setUp(); + this.linkstateTopoBuilder = new LinkstateTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID, LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER); this.linkstateTopoBuilder.start(); final InstanceIdentifier path = this.linkstateTopoBuilder.tableInstanceIdentifier(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class); this.linkstateRouteIID = path.builder().child((Class) LinkstateRoutes.class).child(LinkstateRoute.class, new LinkstateRouteKey(LINKSTATE_ROUTE_KEY)).build(); + } @After public void tearDown() throws Exception { this.linkstateTopoBuilder.close(); - assertFalse(getTopology(this.linkstateTopoBuilder.getInstanceIdentifier()).isPresent()); + checkNull(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier()); } @Test