Skip to content

Commit

Permalink
Added ParSeqUnitTestHelper.tearDown(int, TimeUnit) method which waits
Browse files Browse the repository at this point in the history
for specified amount of time for all currently running plans to
complete.
  • Loading branch information
jodzga committed Apr 13, 2017
1 parent 87cc4ec commit afd6088
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src-test/com/linkedin/parseq/ParSeqUnitTestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public ParSeqUnitTestHelper(Consumer<EngineBuilder> engineCustomizer) {
_engineCustomizer = engineCustomizer;
}

/**
* Creates Engine instance to be used for testing.
*/
@SuppressWarnings("deprecation")
public void setUp() throws Exception {
final int numCores = Runtime.getRuntime().availableProcessors();
Expand Down Expand Up @@ -98,9 +101,17 @@ public void setUp() throws Exception {
_engine = engineBuilder.build();
}

/**
* Equivalent to {@code tearDown(200, TimeUnit.MILLISECONDS);}.
* @see #tearDown(int, TimeUnit)
*/
public void tearDown() throws Exception {
tearDown(200, TimeUnit.MILLISECONDS);
}

public void tearDown(final int time, final TimeUnit unit) throws Exception {
_engine.shutdown();
_engine.awaitTermination(200, TimeUnit.MILLISECONDS);
_engine.awaitTermination(time, unit);
_engine = null;
_scheduler.shutdownNow();
_scheduler = null;
Expand Down

0 comments on commit afd6088

Please sign in to comment.