java.time.Duration APIs in javadsl.TestKit #24646
This commit is contained in:
parent
e078e5a747
commit
7c3a8a8ed5
9 changed files with 96 additions and 65 deletions
|
|
@ -22,8 +22,6 @@ import akka.testkit.javadsl.TestKit;
|
|||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.reactivestreams.Publisher;
|
||||
import scala.concurrent.duration.Duration;
|
||||
import scala.concurrent.duration.FiniteDuration;
|
||||
import akka.testkit.AkkaJUnitActorSystemResource;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -34,6 +32,7 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.stream.Stream;
|
||||
import java.time.Duration;
|
||||
|
||||
import static akka.stream.testkit.StreamTestKit.PublisherProbeSubscription;
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -190,9 +189,9 @@ public class FlowTest extends StreamTest {
|
|||
probe.expectMsgEquals(0);
|
||||
probe.expectMsgEquals(1);
|
||||
|
||||
FiniteDuration duration = Duration.apply(200, TimeUnit.MILLISECONDS);
|
||||
Duration duration = Duration.ofMillis(200);
|
||||
|
||||
probe.expectNoMsg(duration);
|
||||
probe.expectNoMessage(duration);
|
||||
future.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
|
@ -1013,7 +1012,7 @@ public class FlowTest extends StreamTest {
|
|||
public void mustBeAbleToUseInitialTimeout() throws Throwable {
|
||||
try {
|
||||
try {
|
||||
Source.<Integer> maybe().via(Flow.of(Integer.class).initialTimeout(Duration.create(1, "second")))
|
||||
Source.<Integer> maybe().via(Flow.of(Integer.class).initialTimeout(Duration.ofSeconds(1)))
|
||||
.runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
} catch (ExecutionException e) {
|
||||
|
|
@ -1029,7 +1028,7 @@ public class FlowTest extends StreamTest {
|
|||
public void mustBeAbleToUseCompletionTimeout() throws Throwable {
|
||||
try {
|
||||
try {
|
||||
Source.<Integer> maybe().via(Flow.of(Integer.class).completionTimeout(Duration.create(1, "second")))
|
||||
Source.<Integer> maybe().via(Flow.of(Integer.class).completionTimeout(Duration.ofSeconds(1)))
|
||||
.runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
} catch (ExecutionException e) {
|
||||
|
|
@ -1044,7 +1043,7 @@ public class FlowTest extends StreamTest {
|
|||
public void mustBeAbleToUseIdleTimeout() throws Throwable {
|
||||
try {
|
||||
try {
|
||||
Source.<Integer> maybe().via(Flow.of(Integer.class).idleTimeout(Duration.create(1, "second")))
|
||||
Source.<Integer> maybe().via(Flow.of(Integer.class).idleTimeout(Duration.ofSeconds(1)))
|
||||
.runWith(Sink.<Integer> head(), materializer).toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
org.junit.Assert.fail("A TimeoutException was expected");
|
||||
} catch (ExecutionException e) {
|
||||
|
|
@ -1060,9 +1059,9 @@ public class FlowTest extends StreamTest {
|
|||
Integer result =
|
||||
Source.<Integer>maybe()
|
||||
.via(Flow.of(Integer.class)
|
||||
.keepAlive(Duration.create(1, "second"), (Creator<Integer>) () -> 0)
|
||||
.keepAlive(Duration.ofSeconds(1), (Creator<Integer>) () -> 0)
|
||||
)
|
||||
.takeWithin(Duration.create(1500, "milliseconds"))
|
||||
.takeWithin(Duration.ofMillis(1500))
|
||||
.runWith(Sink.<Integer>head(), materializer)
|
||||
.toCompletableFuture().get(3, TimeUnit.SECONDS);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue