Wait on shutdown of extra actor systems in tests. See #3217

This commit is contained in:
Björn Antonsson 2013-05-02 17:12:36 +02:00
parent 3bc661bed6
commit e00ab533bb
84 changed files with 762 additions and 845 deletions

View file

@ -4,8 +4,8 @@
package docs.io;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import akka.testkit.AkkaJUnitActorSystemResource;
import org.junit.ClassRule;
import org.junit.Test;
import akka.actor.ActorSystem;
@ -27,6 +27,7 @@ public class UdpConnectedDocTest {
static public class Demo extends UntypedActor {
ActorRef connectionActor = null;
ActorRef handler = getSelf();
ActorSystem system = context().system();
@Override
public void onReceive(Object msg) {
@ -78,18 +79,6 @@ public class UdpConnectedDocTest {
}
}
static ActorSystem system;
@BeforeClass
static public void setup() {
system = ActorSystem.create("UdpConnectedDocTest");
}
@AfterClass
static public void teardown() {
system.shutdown();
}
@Test
public void demonstrateConnect() {
}

View file

@ -19,83 +19,73 @@ import java.util.ArrayList;
import java.util.List;
//#imports
import org.junit.AfterClass;
import org.junit.BeforeClass;
import akka.testkit.AkkaJUnitActorSystemResource;
import org.junit.ClassRule;
import org.junit.Test;
public class UdpDocTest {
static public class Demo extends UntypedActor {
public void onReceive(Object message) {
//#manager
final ActorRef udp = Udp.get(system).manager();
//#manager
static public class Demo extends UntypedActor {
ActorSystem system = context().system();
//#simplesend
udp.tell(UdpMessage.simpleSender(), getSelf());
public void onReceive(Object message) {
//#manager
final ActorRef udp = Udp.get(system).manager();
//#manager
// ... or with socket options:
final List<Inet.SocketOption> options = new ArrayList<Inet.SocketOption>();
options.add(UdpSO.broadcast(true));
udp.tell(UdpMessage.simpleSender(), getSelf());
//#simplesend
//#simplesend
udp.tell(UdpMessage.simpleSender(), getSelf());
ActorRef simpleSender = null;
// ... or with socket options:
final List<Inet.SocketOption> options = new ArrayList<Inet.SocketOption>();
options.add(UdpSO.broadcast(true));
udp.tell(UdpMessage.simpleSender(), getSelf());
//#simplesend
//#simplesend-finish
if (message instanceof Udp.SimpleSendReady) {
simpleSender = getSender();
}
//#simplesend-finish
ActorRef simpleSender = null;
final ByteString data = ByteString.empty();
//#simplesend-finish
if (message instanceof Udp.SimpleSendReady) {
simpleSender = getSender();
}
//#simplesend-finish
//#simplesend-send
simpleSender.tell(UdpMessage.send(data, new InetSocketAddress("127.0.0.1", 7654)), getSelf());
//#simplesend-send
final ByteString data = ByteString.empty();
final ActorRef handler = getSelf();
//#simplesend-send
simpleSender.tell(UdpMessage.send(data, new InetSocketAddress("127.0.0.1", 7654)), getSelf());
//#simplesend-send
//#bind
udp.tell(UdpMessage.bind(handler, new InetSocketAddress("127.0.0.1", 9876)), getSelf());
//#bind
final ActorRef handler = getSelf();
ActorRef udpWorker = null;
//#bind
udp.tell(UdpMessage.bind(handler, new InetSocketAddress("127.0.0.1", 9876)), getSelf());
//#bind
//#bind-finish
if (message instanceof Udp.Bound) {
udpWorker = getSender();
}
//#bind-finish
ActorRef udpWorker = null;
//#bind-receive
if (message instanceof Udp.Received) {
final Udp.Received rcvd = (Udp.Received) message;
final ByteString payload = rcvd.data();
final InetSocketAddress sender = rcvd.sender();
}
//#bind-receive
//#bind-finish
if (message instanceof Udp.Bound) {
udpWorker = getSender();
}
//#bind-finish
//#bind-send
udpWorker.tell(UdpMessage.send(data, new InetSocketAddress("127.0.0.1", 7654)), getSelf());
//#bind-send
}
//#bind-receive
if (message instanceof Udp.Received) {
final Udp.Received rcvd = (Udp.Received) message;
final ByteString payload = rcvd.data();
final InetSocketAddress sender = rcvd.sender();
}
//#bind-receive
//#bind-send
udpWorker.tell(UdpMessage.send(data, new InetSocketAddress("127.0.0.1", 7654)), getSelf());
//#bind-send
}
}
static ActorSystem system;
@BeforeClass
static public void setup() {
system = ActorSystem.create("IODocTest");
}
@AfterClass
static public void teardown() {
system.shutdown();
}
@Test
public void demonstrateConnect() {
}
@Test
public void demonstrateConnect() {
}
}

View file

@ -5,8 +5,8 @@
package docs.io.japi;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import akka.testkit.AkkaJUnitActorSystemResource;
import org.junit.ClassRule;
import org.junit.Test;
//#imports
@ -138,19 +138,13 @@ public class IODocTest {
}
//#client
private static ActorSystem system;
@BeforeClass
public static void setup() {
system = ActorSystem.create("IODocTest", AkkaSpec.testConf());
}
@AfterClass
public static void teardown() {
system.shutdown();
}
@ClassRule
public static AkkaJUnitActorSystemResource actorSystemResource =
new AkkaJUnitActorSystemResource("IODocTest", AkkaSpec.testConf());
private final ActorSystem system = actorSystemResource.getSystem();
@Test
public void testConnection() {
new JavaTestKit(system) {

View file

@ -7,8 +7,8 @@ package docs.io.japi;
import java.nio.ByteOrder;
import java.util.concurrent.TimeUnit;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import akka.testkit.AkkaJUnitActorSystemResource;
import org.junit.ClassRule;
import org.junit.Test;
import scala.concurrent.duration.Duration;
@ -48,18 +48,12 @@ public class PipelineTest {
}
final Context ctx = new Context();
//#byteorder
static ActorSystem system = null;
@BeforeClass
public static void setup() {
system = ActorSystem.create("PipelineTest");
}
@AfterClass
public static void teardown() {
system.shutdown();
}
@ClassRule
public static AkkaJUnitActorSystemResource actorSystemResource =
new AkkaJUnitActorSystemResource("PipelineTest");
private final ActorSystem system = actorSystemResource.getSystem();
@Test
public void demonstratePipeline() throws Exception {

View file

@ -9,8 +9,8 @@ import java.net.InetSocketAddress;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import akka.testkit.AkkaJUnitActorSystemResource;
import org.junit.ClassRule;
import org.junit.Test;
import akka.actor.ActorContext;
@ -184,17 +184,11 @@ public class SslDocTest {
}
//#server
private static ActorSystem system;
@BeforeClass
public static void setup() {
system = ActorSystem.create("IODocTest", AkkaSpec.testConf());
}
@AfterClass
public static void teardown() {
system.shutdown();
}
@ClassRule
public static AkkaJUnitActorSystemResource actorSystemResource =
new AkkaJUnitActorSystemResource("SslDocTest", AkkaSpec.testConf());
private final ActorSystem system = actorSystemResource.getSystem();
@Test
public void demonstrateSslClient() {