예제 #1
0
파일: SourceTest.java 프로젝트: hochgi/akka
 @Test
 public void mustBeAbleToUseIdleTimeout() throws Throwable {
   try {
     try {
       Source.maybe()
           .idleTimeout(Duration.create(1, "second"))
           .runWith(Sink.head(), materializer)
           .toCompletableFuture()
           .get(3, TimeUnit.SECONDS);
       fail("A TimeoutException was expected");
     } catch (ExecutionException e) {
       throw e.getCause();
     }
   } catch (TimeoutException e) {
     // expected
   }
 }
예제 #2
0
파일: SourceTest.java 프로젝트: hochgi/akka
  @Test
  public void mustBeAbleToUseIdleInject() throws Exception {
    Integer result =
        Source.maybe()
            .keepAlive(
                Duration.create(1, "second"),
                new Creator<Integer>() {
                  public Integer create() {
                    return 0;
                  }
                })
            .takeWithin(Duration.create(1500, "milliseconds"))
            .runWith(Sink.<Integer>head(), materializer)
            .toCompletableFuture()
            .get(3, TimeUnit.SECONDS);

    assertEquals((Object) 0, result);
  }