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%2Factors%2Fdds%2FTestUtils.java;h=092d262ae8fe034ccc83d073a4b585a961a3713f;hb=f83b2d36fdd7e953ba72492ffb684cd112aa04a6;hp=d713ba4d3caef7e505d5402ec50108d2512cda39;hpb=ddb42663a4a53d8440d33f955a5944184f3b602d;p=controller.git diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java index d713ba4d3c..092d262ae8 100644 --- a/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java +++ b/opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/databroker/actors/dds/TestUtils.java @@ -10,16 +10,32 @@ package org.opendaylight.controller.cluster.databroker.actors.dds; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import org.junit.Assert; +import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier; +import org.opendaylight.controller.cluster.access.concepts.FrontendIdentifier; +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; -class TestUtils { - +final class TestUtils { @FunctionalInterface public interface RunnableWithException { void run() throws Exception; } + static final MemberName MEMBER_NAME = MemberName.forName("member-1"); + static final FrontendType FRONTEND_TYPE = FrontendType.forName("type-1"); + static final FrontendIdentifier FRONTEND_ID = FrontendIdentifier.create(MEMBER_NAME, FRONTEND_TYPE); + static final ClientIdentifier CLIENT_ID = ClientIdentifier.create(FRONTEND_ID, 0); + static final LocalHistoryIdentifier HISTORY_ID = new LocalHistoryIdentifier(CLIENT_ID, 0L); + static final TransactionIdentifier TRANSACTION_ID = new TransactionIdentifier(HISTORY_ID, 0L); + private static final long TIMEOUT = 3; + private TestUtils() { + + } + /** * Asserts, that future result when it completes is equal to given object. * Future must complete in {@link TestUtils#TIMEOUT} seconds. @@ -56,9 +72,9 @@ class TestUtils { */ //Throwable is propagated if doesn't match the expected type @SuppressWarnings("checkstyle:IllegalCatch") - static Throwable assertOperationThrowsException(final RunnableWithException operation, - final Class expectedException, - final String message) throws Exception { + static T assertOperationThrowsException(final RunnableWithException operation, + final Class expectedException, + final String message) throws Exception { try { operation.run(); throw new AssertionError(message + expectedException); @@ -66,7 +82,7 @@ class TestUtils { if (!e.getClass().equals(expectedException)) { throw e; } - return e; + return expectedException.cast(e); } } @@ -78,8 +94,8 @@ class TestUtils { * @return expected exception instance. Can be used for additional assertions. * @throws Exception unexpected exception. */ - static Throwable assertOperationThrowsException(final RunnableWithException operation, - final Class expectedException) + static T assertOperationThrowsException(final RunnableWithException operation, + final Class expectedException) throws Exception { return assertOperationThrowsException(operation, expectedException, "Operation should throw exception: "); }