Add java.time.Duration support in the JavaDSL in akka-actor module #24646 (#24883)

* Add java.time.Duration support in the JavaDSL in akka-actor module #24646
* add deprecation and change retry
This commit is contained in:
Patrik Nordwall 2018-04-11 16:47:36 +02:00 committed by GitHub
parent e18382bb0f
commit 6a9fa1946d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 419 additions and 80 deletions

View file

@ -4,15 +4,12 @@
package jdocs.actor;
import java.util.concurrent.TimeUnit;
import akka.testkit.AkkaJUnitActorSystemResource;
import jdocs.AbstractJavaTest;
import akka.testkit.javadsl.TestKit;
import org.junit.ClassRule;
import org.junit.Test;
import scala.concurrent.duration.Duration;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Inbox;
@ -20,6 +17,8 @@ import akka.actor.PoisonPill;
import akka.actor.Terminated;
import akka.testkit.AkkaSpec;
import java.time.Duration;
public class InboxDocTest extends AbstractJavaTest {
@ClassRule
@ -40,7 +39,7 @@ public class InboxDocTest extends AbstractJavaTest {
probe.send(probe.getLastSender(), "world");
//#inbox
try {
assert inbox.receive(Duration.create(1, TimeUnit.SECONDS)).equals("world");
assert inbox.receive(Duration.ofSeconds(1)).equals("world");
} catch (java.util.concurrent.TimeoutException e) {
// timeout
}
@ -56,7 +55,7 @@ public class InboxDocTest extends AbstractJavaTest {
inbox.watch(target);
target.tell(PoisonPill.getInstance(), ActorRef.noSender());
try {
assert inbox.receive(Duration.create(1, TimeUnit.SECONDS)) instanceof Terminated;
assert inbox.receive(Duration.ofSeconds(1)) instanceof Terminated;
} catch (java.util.concurrent.TimeoutException e) {
// timeout
}