예제 #1
0
파일: SourceTest.java 프로젝트: hochgi/akka
 @Test
 public void mustBeAbleToUseQueue() throws Exception {
   final Pair<SourceQueueWithComplete<String>, CompletionStage<List<String>>> x =
       Flow.of(String.class)
           .runWith(Source.queue(2, OverflowStrategy.fail()), Sink.seq(), materializer);
   final SourceQueueWithComplete<String> source = x.first();
   final CompletionStage<List<String>> result = x.second();
   source.offer("hello");
   source.offer("world");
   source.complete();
   assertEquals(
       result.toCompletableFuture().get(3, TimeUnit.SECONDS), Arrays.asList("hello", "world"));
 }
예제 #2
0
파일: SourceTest.java 프로젝트: hochgi/akka
 @Test
 public void mustBeAbleToUseActorRefSource() throws Exception {
   final JavaTestKit probe = new JavaTestKit(system);
   final Source<Integer, ActorRef> actorRefSource = Source.actorRef(10, OverflowStrategy.fail());
   final ActorRef ref =
       actorRefSource
           .to(
               Sink.foreach(
                   new Procedure<Integer>() {
                     public void apply(Integer elem) {
                       probe.getRef().tell(elem, ActorRef.noSender());
                     }
                   }))
           .run(materializer);
   ref.tell(1, ActorRef.noSender());
   probe.expectMsgEquals(1);
   ref.tell(2, ActorRef.noSender());
   probe.expectMsgEquals(2);
 }