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%2FDataTreeCohortIntegrationTest.java;h=20ecb0c578e8dd55c7a1dd0af06dae08f1fd79c3;hb=c1336f9b497bc6867536a24f629c3f0b002ccb2f;hp=720cd01ad607254f3a54c9cd2fa663642a944c54;hpb=6f3c16acf17d0cb4d5f44b666751f8db84a652be;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java index 720cd01ad6..20ecb0c578 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/DataTreeCohortIntegrationTest.java @@ -14,18 +14,17 @@ import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; + import akka.actor.ActorSystem; import akka.actor.Address; import akka.actor.AddressFromURIString; import akka.cluster.Cluster; import akka.testkit.JavaTestKit; -import akka.util.Timeout; import com.google.common.base.Throwables; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.typesafe.config.ConfigFactory; import java.io.IOException; -import java.util.concurrent.TimeUnit; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; @@ -46,7 +45,6 @@ import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import scala.concurrent.duration.Duration; public class DataTreeCohortIntegrationTest { @@ -58,8 +56,6 @@ public class DataTreeCohortIntegrationTest { private static final DOMDataTreeIdentifier TEST_ID = new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION, TestModel.TEST_PATH); - private static final Timeout TIMEOUT = new Timeout(Duration.create(5, TimeUnit.SECONDS)); - private static ActorSystem system; private final DatastoreContext.Builder datastoreContextBuilder = @@ -68,7 +64,7 @@ public class DataTreeCohortIntegrationTest { @BeforeClass public static void setUpClass() throws IOException { system = ActorSystem.create("cluster-test", ConfigFactory.load().getConfig("Member1")); - final Address member1Address = AddressFromURIString.parse("akka.tcp://cluster-test@127.0.0.1:2558"); + final Address member1Address = AddressFromURIString.parse("akka://cluster-test@127.0.0.1:2558"); Cluster.get(system).join(member1Address); } @@ -90,20 +86,23 @@ public class DataTreeCohortIntegrationTest { ArgumentCaptor candidateCapt = ArgumentCaptor.forClass(DOMDataTreeCandidate.class); new IntegrationTestKit(getSystem(), datastoreContextBuilder) { { - try (final DistributedDataStore dataStore = setupDistributedDataStore("transactionIntegrationTest", "test-1")) { - final ObjectRegistration cohortReg = dataStore.registerCommitCohort(TEST_ID, cohort); + try (AbstractDataStore dataStore = setupDistributedDataStore("transactionIntegrationTest", + "test-1")) { + final ObjectRegistration cohortReg = + dataStore.registerCommitCohort(TEST_ID, cohort); Thread.sleep(1000); // Registration is asynchronous assertNotNull(cohortReg); testWriteTransaction(dataStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); - Mockito.verify(cohort).canCommit(any(Object.class), candidateCapt.capture(), any(SchemaContext.class)); + Mockito.verify(cohort).canCommit(any(Object.class), candidateCapt.capture(), + any(SchemaContext.class)); DOMDataTreeCandidate candidate = candidateCapt.getValue(); assertNotNull(candidate); assertEquals(TEST_ID, candidate.getRootPath()); testWriteTransaction(dataStore, TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build()); - Mockito.verify(cohort, Mockito.times(2)).canCommit(any(Object.class), any(DOMDataTreeCandidate.class), - any(SchemaContext.class)); + Mockito.verify(cohort, Mockito.times(2)).canCommit(any(Object.class), + any(DOMDataTreeCandidate.class), any(SchemaContext.class)); cohortReg.close(); testWriteTransaction(dataStore, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME)); @@ -114,6 +113,7 @@ public class DataTreeCohortIntegrationTest { } @Test + @SuppressWarnings("checkstyle:IllegalCatch") public void failCanCommitTest() throws Exception { final DOMDataTreeCommitCohort failedCohort = mock(DOMDataTreeCommitCohort.class); @@ -122,7 +122,7 @@ public class DataTreeCohortIntegrationTest { new IntegrationTestKit(getSystem(), datastoreContextBuilder) { { - try (final DistributedDataStore dataStore = + try (AbstractDataStore dataStore = setupDistributedDataStore("transactionIntegrationTest", "test-1")) { dataStore.registerCommitCohort(TEST_ID, failedCohort); Thread.sleep(1000); // Registration is asynchronous @@ -144,10 +144,8 @@ public class DataTreeCohortIntegrationTest { } /** - * * FIXME: Weird thing is that invoking canCommit on front-end invokes also preCommit on backend * so we can not test abort after can commit. - * */ @Test @Ignore @@ -159,7 +157,7 @@ public class DataTreeCohortIntegrationTest { Mockito.doReturn(ThreePhaseCommitStep.NOOP_ABORT_FUTURE).when(stepToAbort).abort(); new IntegrationTestKit(getSystem(), datastoreContextBuilder) { { - try (final DistributedDataStore dataStore = + try (AbstractDataStore dataStore = setupDistributedDataStore("transactionIntegrationTest", "test-1")) { dataStore.registerCommitCohort(TEST_ID, cohortToAbort); Thread.sleep(1000); // Registration is asynchronous