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
|
|
@ -16,7 +16,8 @@ import akka.actor.ActorRef;
|
|||
import akka.actor.ActorSystem;
|
||||
import akka.actor.Props;
|
||||
import akka.actor.AbstractActor;
|
||||
import scala.concurrent.duration.Duration;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class TestKitSampleTest extends AbstractJavaTest {
|
||||
|
||||
|
|
@ -67,10 +68,10 @@ public class TestKitSampleTest extends AbstractJavaTest {
|
|||
// like a real resource would be passed in production
|
||||
subject.tell(probe.getRef(), getRef());
|
||||
// await the correct response
|
||||
expectMsg(java.time.Duration.ofSeconds(1), "done");
|
||||
expectMsg(Duration.ofSeconds(1), "done");
|
||||
|
||||
// the run() method needs to finish within 3 seconds
|
||||
within(java.time.Duration.ofSeconds(3), () -> {
|
||||
within(Duration.ofSeconds(3), () -> {
|
||||
subject.tell("hello", getRef());
|
||||
|
||||
// This is a demo: would normally use expectMsgEquals().
|
||||
|
|
@ -78,13 +79,13 @@ public class TestKitSampleTest extends AbstractJavaTest {
|
|||
awaitCond(probe::msgAvailable);
|
||||
|
||||
// response must have been enqueued to us before probe
|
||||
expectMsg(java.time.Duration.ZERO, "world");
|
||||
expectMsg(Duration.ZERO, "world");
|
||||
// check that the probe we injected earlier got the msg
|
||||
probe.expectMsg(java.time.Duration.ZERO, "hello");
|
||||
probe.expectMsg(Duration.ZERO, "hello");
|
||||
Assert.assertEquals(getRef(), probe.getLastSender());
|
||||
|
||||
// Will wait for the rest of the 3 seconds
|
||||
expectNoMsg();
|
||||
expectNoMessage();
|
||||
return null;
|
||||
});
|
||||
}};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue