2018-03-13 23:45:55 +09:00
|
|
|
/*
|
2019-01-02 18:55:26 +08:00
|
|
|
* Copyright (C) 2018-2019 Lightbend Inc. <https://www.lightbend.com>
|
2018-03-13 23:45:55 +09:00
|
|
|
*/
|
|
|
|
|
|
2012-02-27 22:38:26 +01:00
|
|
|
package akka.actor;
|
|
|
|
|
|
2013-05-02 17:12:36 +02:00
|
|
|
import akka.testkit.AkkaJUnitActorSystemResource;
|
2013-05-22 11:49:30 +02:00
|
|
|
import akka.testkit.TestProbe;
|
|
|
|
|
|
2013-05-02 17:12:36 +02:00
|
|
|
import org.junit.ClassRule;
|
2012-02-27 22:38:26 +01:00
|
|
|
import org.junit.Test;
|
2019-02-17 11:45:39 -08:00
|
|
|
import org.scalatestplus.junit.JUnitSuite;
|
2012-09-19 23:55:53 +02:00
|
|
|
|
2016-04-06 01:23:21 +02:00
|
|
|
public class StashJavaAPI extends JUnitSuite {
|
2012-02-27 22:38:26 +01:00
|
|
|
|
2013-05-02 17:12:36 +02:00
|
|
|
@ClassRule
|
|
|
|
|
public static AkkaJUnitActorSystemResource actorSystemResource =
|
2019-01-12 04:00:53 +08:00
|
|
|
new AkkaJUnitActorSystemResource("StashJavaAPI", ActorWithBoundedStashSpec.testConf());
|
2012-09-19 23:55:53 +02:00
|
|
|
|
2013-05-02 17:12:36 +02:00
|
|
|
private final ActorSystem system = actorSystemResource.getSystem();
|
2012-09-19 23:55:53 +02:00
|
|
|
|
2013-07-01 15:55:59 +02:00
|
|
|
private void testAStashApi(Props props) {
|
2019-01-12 04:00:53 +08:00
|
|
|
ActorRef ref = system.actorOf(props);
|
|
|
|
|
final TestProbe probe = new TestProbe(system);
|
|
|
|
|
probe.send(ref, "Hello");
|
|
|
|
|
probe.send(ref, "Hello2");
|
|
|
|
|
probe.send(ref, "Hello12");
|
|
|
|
|
probe.expectMsg(5);
|
2013-07-01 15:55:59 +02:00
|
|
|
}
|
|
|
|
|
|
2012-09-19 23:55:53 +02:00
|
|
|
@Test
|
|
|
|
|
public void mustBeAbleToUseStash() {
|
2013-07-01 15:55:59 +02:00
|
|
|
testAStashApi(Props.create(StashJavaAPITestActors.WithStash.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void mustBeAbleToUseUnboundedStash() {
|
|
|
|
|
testAStashApi(Props.create(StashJavaAPITestActors.WithUnboundedStash.class));
|
2012-09-19 23:55:53 +02:00
|
|
|
}
|
2012-02-27 22:38:26 +01:00
|
|
|
|
2013-07-01 15:55:59 +02:00
|
|
|
@Test
|
|
|
|
|
public void mustBeAbleToUseUnrestrictedStash() {
|
2019-01-12 04:00:53 +08:00
|
|
|
testAStashApi(
|
|
|
|
|
Props.create(StashJavaAPITestActors.WithUnrestrictedStash.class)
|
2013-07-01 15:55:59 +02:00
|
|
|
.withMailbox("akka.actor.mailbox.unbounded-deque-based"));
|
|
|
|
|
}
|
2012-02-27 22:38:26 +01:00
|
|
|
}
|