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

@ -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() {
}
}