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%2FAbstractTest.java;h=c0df6bd0059cf106ec549c83692ef49b20854e05;hb=2634ed7138a343f051ff6452ccc7edd3abfc0c3a;hp=66a41275fcc5803fadfea1866cec2d2bea500122;hpb=4d1709660b7af992d4c382a2a38debb5c7d64fb9;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTest.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTest.java index 66a41275fc..c0df6bd005 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTest.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/AbstractTest.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.cluster.datastore; +import java.util.concurrent.CompletionStage; import java.util.concurrent.atomic.AtomicLong; import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; @@ -14,9 +15,14 @@ import org.opendaylight.controller.cluster.access.concepts.FrontendType; import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier; import org.opendaylight.controller.cluster.access.concepts.MemberName; import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier; +import scala.compat.java8.FutureConverters; +import scala.concurrent.Await; +import scala.concurrent.duration.Duration; public abstract class AbstractTest { protected static final MemberName MEMBER_NAME = MemberName.forName("member-1"); + protected static final MemberName MEMBER_2_NAME = MemberName.forName("member-2"); + private static final FrontendType FRONTEND_TYPE = FrontendType.forName(ShardTransactionTest.class.getSimpleName()); protected static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE); @@ -26,6 +32,11 @@ public abstract class AbstractTest { private static final AtomicLong HISTORY_COUNTER = new AtomicLong(); private static final AtomicLong TX_COUNTER = new AtomicLong(); + protected static void setUpStatic() { + HISTORY_COUNTER.set(1L); + TX_COUNTER.set(1L); + } + protected static TransactionIdentifier nextTransactionId() { return new TransactionIdentifier(HISTORY_ID, TX_COUNTER.getAndIncrement()); } @@ -33,4 +44,9 @@ public abstract class AbstractTest { protected static LocalHistoryIdentifier nextHistoryId() { return new LocalHistoryIdentifier(CLIENT_ID, HISTORY_COUNTER.incrementAndGet()); } + + protected static T waitOnAsyncTask(final CompletionStage completionStage, final Duration timeout) + throws Exception { + return Await.result(FutureConverters.toScala(completionStage), timeout); + } }