X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatastore%2FTransactionChainProxyTest.java;h=e4ad8fd054c8d808afaabe68836592fbf38abbd7;hb=3115b8171461584e85f58d87a9f179013cfbb262;hp=d0af812608072fdda4c66057eb632b2581ae4dce;hpb=c796596b5c46b5203c30b143e6282662e66c5642;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java index d0af812608..e4ad8fd054 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/TransactionChainProxyTest.java @@ -8,11 +8,11 @@ package org.opendaylight.controller.cluster.datastore; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Matchers.isA; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.timeout; @@ -20,6 +20,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.opendaylight.controller.cluster.datastore.TransactionType.READ_WRITE; import static org.opendaylight.controller.cluster.datastore.TransactionType.WRITE_ONLY; + import akka.actor.ActorRef; import akka.util.Timeout; import java.util.concurrent.CountDownLatch; @@ -33,10 +34,10 @@ import org.opendaylight.controller.cluster.datastore.messages.BatchedModificatio import org.opendaylight.controller.cluster.datastore.modification.WriteModification; import org.opendaylight.controller.cluster.datastore.shardstrategy.DefaultShardStrategy; import org.opendaylight.controller.md.cluster.datastore.model.TestModel; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransaction; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransaction; +import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import scala.concurrent.Promise; @@ -75,11 +76,12 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest { } + @SuppressWarnings("unchecked") @Test public void testClose() { new TransactionChainProxy(mockComponentFactory, historyId).close(); - verify(mockActorContext, times(1)).broadcast(any(Function.class)); + verify(mockActorContext, times(1)).broadcast(any(Function.class), any(Class.class)); } @Test @@ -117,6 +119,7 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest { * initiated until the first one completes its read future. */ @Test + @SuppressWarnings("checkstyle:IllegalCatch") public void testChainedWriteOnlyTransactions() throws Exception { dataStoreContextBuilder.writeOnlyTransactionOptimizationsEnabled(true); @@ -149,20 +152,17 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest { final AtomicReference caughtEx = new AtomicReference<>(); final CountDownLatch write2Complete = new CountDownLatch(1); - new Thread() { - @Override - public void run() { - try { - writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2); - } catch (Exception e) { - caughtEx.set(e); - } finally { - write2Complete.countDown(); - } + new Thread(() -> { + try { + writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2); + } catch (Exception e) { + caughtEx.set(e); + } finally { + write2Complete.countDown(); } - }.start(); + }).start(); - assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS)); + assertTrue("Tx 2 write should've completed", write2Complete.await(5, TimeUnit.SECONDS)); if (caughtEx.get() != null) { throw caughtEx.get(); @@ -187,6 +187,7 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest { * initiated until the first one completes its read future. */ @Test + @SuppressWarnings("checkstyle:IllegalCatch") public void testChainedReadWriteTransactions() throws Exception { try (TransactionChainProxy txChainProxy = new TransactionChainProxy(mockComponentFactory, historyId)) { @@ -220,20 +221,17 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest { final AtomicReference caughtEx = new AtomicReference<>(); final CountDownLatch write2Complete = new CountDownLatch(1); - new Thread() { - @Override - public void run() { - try { - writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2); - } catch (Exception e) { - caughtEx.set(e); - } finally { - write2Complete.countDown(); - } + new Thread(() -> { + try { + writeTx2.write(TestModel.OUTER_LIST_PATH, writeNode2); + } catch (Exception e) { + caughtEx.set(e); + } finally { + write2Complete.countDown(); } - }.start(); + }).start(); - assertEquals("Tx 2 write should've completed", true, write2Complete.await(5, TimeUnit.SECONDS)); + assertTrue("Tx 2 write should've completed", write2Complete.await(5, TimeUnit.SECONDS)); if (caughtEx.get() != null) { throw caughtEx.get(); @@ -268,8 +266,6 @@ public class TransactionChainProxyTest extends AbstractTransactionProxyTest { NormalizedNode writeNode1 = ImmutableNodes.containerNode(TestModel.TEST_QNAME); writeTx1.write(TestModel.TEST_PATH, writeNode1); - NormalizedNode writeNode2 = ImmutableNodes.containerNode(TestModel.OUTER_LIST_QNAME); - txChainProxy.newWriteOnlyTransaction(); } }