X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-distributed-datastore%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcluster%2Fdatabroker%2FAbstractDOMBrokerWriteTransactionTest.java;h=1680a79444df2c13a8fae2174fccef11ef3134a8;hp=5263ab67fa52f4783b093f52f0886f590c85a2b0;hb=2fd1fa721510a30f58b3bc277deb05fce58badd6;hpb=f41c5e6e6f6e10b36b1e4b1992877e38e718c8fb diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransactionTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransactionTest.java index 5263ab67fa..1680a79444 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransactionTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransactionTest.java @@ -7,17 +7,19 @@ package org.opendaylight.controller.cluster.databroker; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.doThrow; -import com.google.common.util.concurrent.CheckedFuture; +import com.google.common.util.concurrent.FluentFuture; import java.util.Collection; import java.util.Collections; +import java.util.concurrent.ExecutionException; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; +import org.opendaylight.mdsal.common.api.CommitInfo; import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.mdsal.common.api.TransactionCommitFailedException; import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction; @@ -54,37 +56,37 @@ public class AbstractDOMBrokerWriteTransactionTest { } @Test - public void readyRuntimeExceptionAndCancel() { + public void readyRuntimeExceptionAndCancel() throws InterruptedException { RuntimeException thrown = new RuntimeException(); doThrow(thrown).when(domStoreWriteTransaction).ready(); AbstractDOMBrokerWriteTransactionTestImpl abstractDOMBrokerWriteTransactionTestImpl = new AbstractDOMBrokerWriteTransactionTestImpl(); - CheckedFuture submitFuture = - abstractDOMBrokerWriteTransactionTestImpl.submit(); + FluentFuture submitFuture = abstractDOMBrokerWriteTransactionTestImpl.commit(); try { - submitFuture.checkedGet(); + submitFuture.get(); Assert.fail("TransactionCommitFailedException expected"); - } catch (TransactionCommitFailedException e) { - assertTrue(e.getCause() == thrown); + } catch (ExecutionException e) { + assertTrue(e.getCause() instanceof TransactionCommitFailedException); + assertTrue(e.getCause().getCause() == thrown); abstractDOMBrokerWriteTransactionTestImpl.cancel(); } } @Test - public void submitRuntimeExceptionAndCancel() { + public void submitRuntimeExceptionAndCancel() throws InterruptedException { RuntimeException thrown = new RuntimeException(); - doThrow(thrown).when(abstractDOMTransactionFactory).submit(any(), any()); + doThrow(thrown).when(abstractDOMTransactionFactory).commit(any(), any()); AbstractDOMBrokerWriteTransactionTestImpl abstractDOMBrokerWriteTransactionTestImpl = new AbstractDOMBrokerWriteTransactionTestImpl(); - CheckedFuture submitFuture = - abstractDOMBrokerWriteTransactionTestImpl.submit(); + FluentFuture submitFuture = abstractDOMBrokerWriteTransactionTestImpl.commit(); try { - submitFuture.checkedGet(); + submitFuture.get(); Assert.fail("TransactionCommitFailedException expected"); - } catch (TransactionCommitFailedException e) { - assertTrue(e.getCause() == thrown); + } catch (ExecutionException e) { + assertTrue(e.getCause() instanceof TransactionCommitFailedException); + assertTrue(e.getCause().getCause() == thrown); abstractDOMBrokerWriteTransactionTestImpl.cancel(); } }