Re-implement javadsl testkit (#22240)

* re-implement javadsl testkit

* fix mima problem

* rebase master

* move ImplicitSender/DefaultTimeout to scaladsl

* undo the change of moving scala api

* fix return type and add doc

* resolve conflicts and add more comments
This commit is contained in:
Hawstein 2017-03-17 03:02:47 +08:00 committed by Patrik Nordwall
parent 3643f18ded
commit 6434cbe868
93 changed files with 1147 additions and 619 deletions

View file

@ -8,8 +8,8 @@ import akka.NotUsed;
import akka.actor.*;
import akka.stream.*;
import akka.stream.javadsl.*;
import akka.testkit.JavaTestKit;
import akka.testkit.TestProbe;
import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
import com.typesafe.config.Config;
@ -23,6 +23,7 @@ import org.junit.Test;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
@ -62,7 +63,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@AfterClass
public static void tearDown() {
JavaTestKit.shutdownActorSystem(system);
TestKit.shutdownActorSystem(system);
system = null;
mat = null;
ref = null;
@ -328,7 +329,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
public void callingExternalServiceWithMapAsync() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final TestProbe probe = new TestProbe(system);
final AddressSystem addressSystem = new AddressSystem();
final EmailServer emailServer = new EmailServer(probe.ref());
@ -372,7 +373,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
@SuppressWarnings("unused")
public void callingExternalServiceWithMapAsyncAndSupervision() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final AddressSystem2 addressSystem = new AddressSystem2();
{
@ -396,7 +397,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
public void callingExternalServiceWithMapAsyncUnordered() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final TestProbe probe = new TestProbe(system);
final AddressSystem addressSystem = new AddressSystem();
final EmailServer emailServer = new EmailServer(probe.ref());
@ -428,7 +429,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
public void carefulManagedBlockingWithMapAsync() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final AddressSystem addressSystem = new AddressSystem();
final EmailServer emailServer = new EmailServer(getRef());
final SmsServer smsServer = new SmsServer(getRef());
@ -455,8 +456,8 @@ public class IntegrationDocTest extends AbstractJavaTest {
sendTextMessages.run(mat);
//#blocking-mapAsync
final Object[] got = receiveN(7);
final Set<Object> set = new HashSet<>(Arrays.asList(got));
final List<Object> got = receiveN(7);
final Set<Object> set = new HashSet<>(got);
assertTrue(set.contains(String.valueOf("rolandkuhn".hashCode())));
assertTrue(set.contains(String.valueOf("patriknw".hashCode())));
@ -471,7 +472,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
public void carefulManagedBlockingWithMap() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final TestProbe probe = new TestProbe(system);
final AddressSystem addressSystem = new AddressSystem();
final EmailServer emailServer = new EmailServer(probe.ref());
@ -511,7 +512,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
public void callingActorServiceWithMapAsync() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final TestProbe probe = new TestProbe(system);
final EmailServer emailServer = new EmailServer(probe.ref());
@ -542,7 +543,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
public void illustrateOrderingAndParallelismOfMapAsync() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final TestProbe probe = new TestProbe(system);
final EmailServer emailServer = new EmailServer(probe.ref());
@ -588,7 +589,7 @@ public class IntegrationDocTest extends AbstractJavaTest {
@Test
public void illustrateOrderingAndParallelismOfMapAsyncUnordered() throws Exception {
new JavaTestKit(system) {
new TestKit(system) {
final EmailServer emailServer = new EmailServer(getRef());
class MockSystem {
@ -617,8 +618,8 @@ public class IntegrationDocTest extends AbstractJavaTest {
.runForeach(elem -> System.out.println("after: " + elem), mat);
//#sometimes-slow-mapAsyncUnordered
final Object[] got = receiveN(10);
final Set<Object> set = new HashSet<>(Arrays.asList(got));
final List<Object> got = receiveN(10);
final Set<Object> set = new HashSet<>(got);
assertTrue(set.contains("after: A"));
assertTrue(set.contains("after: B"));