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%2Fdatabroker%2FAbstractDOMBrokerWriteTransactionTest.java;h=e77f6456dedc24a4a46ffb7353b7dc6e2d358b1a;hb=HEAD;hp=69265ddc773046e1835cceaf681b5f28bcb0763f;hpb=7ab6f974861e01daa16ff56658eeb1be163cbfec;p=controller.git 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 deleted file mode 100644 index 69265ddc77..0000000000 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/AbstractDOMBrokerWriteTransactionTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.cluster.databroker; - -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doThrow; - -import com.google.common.util.concurrent.CheckedFuture; -import java.util.Collection; -import java.util.Collections; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException; -import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction; - -public class AbstractDOMBrokerWriteTransactionTest { - - @Mock - private AbstractDOMTransactionFactory abstractDOMTransactionFactory; - - @Mock - private DOMStoreWriteTransaction domStoreWriteTransaction; - - private class AbstractDOMBrokerWriteTransactionTestImpl - extends AbstractDOMBrokerWriteTransaction { - - AbstractDOMBrokerWriteTransactionTestImpl() { - super(new Object(), Collections.emptyMap(), abstractDOMTransactionFactory); - } - - @Override - protected DOMStoreWriteTransaction createTransaction(LogicalDatastoreType key) { - return null; - } - - @Override - protected Collection getSubtransactions() { - return Collections.singletonList(domStoreWriteTransaction); - } - } - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Test - public void readyRuntimeExceptionAndCancel() { - RuntimeException thrown = new RuntimeException(); - doThrow(thrown).when(domStoreWriteTransaction).ready(); - AbstractDOMBrokerWriteTransactionTestImpl abstractDOMBrokerWriteTransactionTestImpl = - new AbstractDOMBrokerWriteTransactionTestImpl(); - - CheckedFuture submitFuture = - abstractDOMBrokerWriteTransactionTestImpl.submit(); - try { - submitFuture.checkedGet(); - Assert.fail("TransactionCommitFailedException expected"); - } catch (TransactionCommitFailedException e) { - assertTrue(e.getCause() == thrown); - abstractDOMBrokerWriteTransactionTestImpl.cancel(); - } - } - - @Test - public void submitRuntimeExceptionAndCancel() { - RuntimeException thrown = new RuntimeException(); - doThrow(thrown).when(abstractDOMTransactionFactory).submit(any(), any()); - AbstractDOMBrokerWriteTransactionTestImpl abstractDOMBrokerWriteTransactionTestImpl - = new AbstractDOMBrokerWriteTransactionTestImpl(); - - CheckedFuture submitFuture = - abstractDOMBrokerWriteTransactionTestImpl.submit(); - try { - submitFuture.checkedGet(); - Assert.fail("TransactionCommitFailedException expected"); - } catch (TransactionCommitFailedException e) { - assertTrue(e.getCause() == thrown); - abstractDOMBrokerWriteTransactionTestImpl.cancel(); - } - } -} \ No newline at end of file