Package com.atlassian.crowd.test.rules
Class ExecutorServiceFactoryRule
java.lang.Object
com.atlassian.crowd.test.rules.ExecutorServiceFactoryRule
- All Implemented Interfaces:
org.junit.rules.TestRule
Helper test rule for running multithreading tests. Automatically shutdowns created
ExecutorService
.-
Constructor Summary
ConstructorDescriptionExecutorServiceFactoryRule
(Duration shutdownTimeout, boolean shutdownAllInterruptRunningTasks) -
Method Summary
Modifier and TypeMethodDescriptionorg.junit.runners.model.Statement
apply
(org.junit.runners.model.Statement base, org.junit.runner.Description description) createExecutorService
(int threads) int
<T> List<T>
runConcurrently
(int threadCount, Callable<T> task) void
shutdownAndWait
(ExecutorService executorService) shutdownAndWait
(ExecutorService executorService, Duration shutdownTimeout)
-
Constructor Details
-
ExecutorServiceFactoryRule
public ExecutorServiceFactoryRule(Duration shutdownTimeout, boolean shutdownAllInterruptRunningTasks)
-
-
Method Details
-
createExecutorService
-
shutdownAll
- Throws:
InterruptedException
-
shutdownAndWait
- Throws:
InterruptedException
-
shutdownAndWait
public Duration shutdownAndWait(ExecutorService executorService, Duration shutdownTimeout) throws InterruptedException - Throws:
InterruptedException
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base, org.junit.runner.Description description) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
getExecutorServiceCount
public int getExecutorServiceCount() -
runConcurrently
public <T> List<T> runConcurrently(int threadCount, Callable<T> task) throws ExecutionException, InterruptedException
-