Skip to content

Commit

Permalink
#265 extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 10, 2017
1 parent eb883f5 commit 7eb4d0e
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/test/java/org/cactoos/func/AsyncFuncTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package org.cactoos.func;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.cactoos.FuncApplies;
Expand Down Expand Up @@ -52,7 +53,26 @@ public void runsInBackground() {
new FuncApplies<>(
true,
new FuncAsMatcher<Future<String>>(
input -> !input.isDone()
future -> !future.isDone()
)
)
);
}

@Test
public void runsInBackgroundWithoutFuture() {
final CountDownLatch latch = new CountDownLatch(1);
MatcherAssert.assertThat(
"Can't run in the background without us touching the Future",
new AsyncFunc<>(
input -> {
latch.countDown();
}
),
new FuncApplies<>(
true,
new FuncAsMatcher<Future<String>>(
future -> latch.await(1L, TimeUnit.SECONDS)
)
)
);
Expand Down

0 comments on commit 7eb4d0e

Please sign in to comment.