Java time duration support for javadsl #24646

java.time.Duration support in all jdocs java file, the persistence module and the distributed-data
This commit is contained in:
Guy Youansi 2018-06-26 15:41:30 +02:00 committed by Johan Andrén
parent ced08fcb57
commit a4951e0ce7
30 changed files with 214 additions and 141 deletions

View file

@ -12,7 +12,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.time.Duration;
import akka.NotUsed;
import jdocs.AbstractJavaTest;
@ -21,14 +20,11 @@ import org.junit.*;
import static org.junit.Assert.assertEquals;
import akka.actor.*;
import akka.testkit.*;
import akka.japi.Pair;
import akka.stream.*;
import akka.stream.javadsl.*;
import akka.stream.testkit.*;
import akka.stream.testkit.javadsl.*;
import akka.testkit.TestProbe;
import scala.concurrent.duration.FiniteDuration;
public class StreamTestKitDocTest extends AbstractJavaTest {
@ -97,14 +93,12 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
.from(Arrays.asList(1, 2, 3, 4))
.grouped(2);
final TestProbe probe = new TestProbe(system);
final TestKit probe = new TestKit(system);
final CompletionStage<List<List<Integer>>> future = sourceUnderTest
.grouped(2)
.runWith(Sink.head(), mat);
akka.pattern.PatternsCS.pipe(future, system.dispatcher()).to(probe.ref());
probe.expectMsg(FiniteDuration.create(3, TimeUnit.SECONDS),
Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4))
);
akka.pattern.PatternsCS.pipe(future, system.dispatcher()).to(probe.getRef());
probe.expectMsg(Duration.ofSeconds(3), Arrays.asList(Arrays.asList(1, 2), Arrays.asList(3, 4)));
//#pipeto-testprobe
}
@ -118,14 +112,13 @@ public class StreamTestKitDocTest extends AbstractJavaTest {
Duration.ofMillis(200),
Tick.TOCK);
final TestProbe probe = new TestProbe(system);
final Cancellable cancellable = sourceUnderTest
.to(Sink.actorRef(probe.ref(), Tick.COMPLETED)).run(mat);
probe.expectMsg(FiniteDuration.create(3, TimeUnit.SECONDS), Tick.TOCK);
probe.expectNoMsg(FiniteDuration.create(100, TimeUnit.MILLISECONDS));
probe.expectMsg(FiniteDuration.create(3, TimeUnit.SECONDS), Tick.TOCK);
final TestKit probe = new TestKit(system);
final Cancellable cancellable = sourceUnderTest.to(Sink.actorRef(probe.getRef(), Tick.COMPLETED)).run(mat);
probe.expectMsg(Duration.ofSeconds(3), Tick.TOCK);
probe.expectNoMessage(Duration.ofMillis(100));
probe.expectMsg(Duration.ofSeconds(3), Tick.TOCK);
cancellable.cancel();
probe.expectMsg(FiniteDuration.create(3, TimeUnit.SECONDS), Tick.COMPLETED);
probe.expectMsg(Duration.ofSeconds(3), Tick.COMPLETED);
//#sink-actorref
}