Skip to content

Commit

Permalink
replacing ExecutorShutdownCondition with lambda, seems like it's quic…
Browse files Browse the repository at this point in the history
…ker(?) so had to bump the test timeouts.
  • Loading branch information
toby-weston-db committed Jan 21, 2014
1 parent e6107cc commit 418413e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package com.google.code.tempusfugit.condition;

import com.google.code.tempusfugit.concurrency.Callable;
import com.google.code.tempusfugit.temporal.Condition;
import com.google.code.tempusfugit.temporal.SelfDescribingCondition;
import com.google.code.tempusfugit.temporal.*;
import org.hamcrest.Matcher;
import org.junit.Assert;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeoutException;

public final class Conditions {

Expand All @@ -31,7 +31,7 @@ public static Condition not(Condition condition) {
}

public static Condition shutdown(ExecutorService service) {
return new ExecutorShutdownCondition(service);
return service::isShutdown;
}

public static Condition isAlive(Thread thread) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import static com.google.code.tempusfugit.concurrency.ExecutorServiceShutdown.shutdown;
import static com.google.code.tempusfugit.temporal.Duration.millis;
import static com.google.code.tempusfugit.temporal.Duration.seconds;
import static com.google.code.tempusfugit.temporal.Timeout.timeout;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -94,7 +95,7 @@ public void waitingForShutdown() throws TimeoutException, InterruptedException {
oneOf(executor).shutdownNow();
oneOf(executor).isShutdown(); will(returnValue(true));
}});
assertThat(shutdown(executor).waitingForShutdown(timeout(millis(5))), is(true));
assertThat(shutdown(executor).waitingForShutdown(timeout(millis(500))), is(true));
}

@Test(expected = TimeoutException.class)
Expand All @@ -103,7 +104,7 @@ public void waitingForShutdownTimesOut() throws TimeoutException, InterruptedExc
oneOf(executor).shutdownNow();
atLeast(1).of(executor).isShutdown(); will(returnValue(false));
}});
shutdown(executor).waitingForShutdown(timeout(millis(5)));
shutdown(executor).waitingForShutdown(timeout(millis(500)));
}

private void awaitingTermination(final boolean result) throws InterruptedException {
Expand Down

0 comments on commit 418413e

Please sign in to comment.