2012-06-15 13:04:10 +02:00
|
|
|
/**
|
2013-01-09 01:47:48 +01:00
|
|
|
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
|
2012-06-15 13:04:10 +02:00
|
|
|
*/
|
|
|
|
|
|
2011-01-04 13:24:28 +01:00
|
|
|
package akka.actor;
|
|
|
|
|
|
2011-11-10 20:08:00 +01:00
|
|
|
import akka.actor.ActorSystem;
|
2012-04-10 12:07:14 +02:00
|
|
|
import akka.event.Logging;
|
|
|
|
|
import akka.event.Logging.LoggerInitialized;
|
2011-01-04 13:24:28 +01:00
|
|
|
import akka.japi.Creator;
|
2012-04-10 12:07:14 +02:00
|
|
|
import akka.routing.CurrentRoutees;
|
|
|
|
|
import akka.routing.FromConfig;
|
|
|
|
|
import akka.routing.NoRouter;
|
2011-11-30 15:16:20 +01:00
|
|
|
import akka.testkit.AkkaSpec;
|
|
|
|
|
|
|
|
|
|
import org.junit.AfterClass;
|
|
|
|
|
import org.junit.BeforeClass;
|
2011-01-04 13:24:28 +01:00
|
|
|
import org.junit.Test;
|
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
|
|
public class JavaAPI {
|
|
|
|
|
|
2011-11-30 15:16:20 +01:00
|
|
|
private static ActorSystem system;
|
|
|
|
|
|
|
|
|
|
@BeforeClass
|
|
|
|
|
public static void beforeAll() {
|
|
|
|
|
system = ActorSystem.create("JavaAPI", AkkaSpec.testConf());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@AfterClass
|
|
|
|
|
public static void afterAll() {
|
2011-12-14 01:06:20 +01:00
|
|
|
system.shutdown();
|
2011-11-30 15:16:20 +01:00
|
|
|
system = null;
|
|
|
|
|
}
|
2012-04-10 12:07:14 +02:00
|
|
|
|
|
|
|
|
// compilation tests
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
|
public void mustCompile() {
|
2012-04-10 16:49:29 +02:00
|
|
|
final Kill kill = Kill.getInstance();
|
|
|
|
|
final PoisonPill pill = PoisonPill.getInstance();
|
|
|
|
|
final ReceiveTimeout t = ReceiveTimeout.getInstance();
|
2012-04-10 12:07:14 +02:00
|
|
|
|
2012-04-10 16:49:29 +02:00
|
|
|
final LocalScope ls = LocalScope.getInstance();
|
|
|
|
|
final NoScopeGiven noscope = NoScopeGiven.getInstance();
|
2012-04-10 12:07:14 +02:00
|
|
|
|
|
|
|
|
final LoggerInitialized x = Logging.loggerInitialized();
|
|
|
|
|
|
2012-04-10 16:49:29 +02:00
|
|
|
final CurrentRoutees r = CurrentRoutees.getInstance();
|
|
|
|
|
final NoRouter nr = NoRouter.getInstance();
|
|
|
|
|
final FromConfig fc = FromConfig.getInstance();
|
2012-04-10 12:07:14 +02:00
|
|
|
}
|
2011-10-13 13:41:44 +02:00
|
|
|
|
2011-11-15 11:34:39 +01:00
|
|
|
@Test
|
2011-11-30 15:16:20 +01:00
|
|
|
public void mustBeAbleToCreateActorRefFromClass() {
|
2011-12-13 14:09:40 +01:00
|
|
|
ActorRef ref = system.actorOf(new Props(JavaAPITestActor.class));
|
2011-11-15 11:34:39 +01:00
|
|
|
assertNotNull(ref);
|
2011-01-04 13:24:28 +01:00
|
|
|
}
|
|
|
|
|
|
2011-11-15 11:34:39 +01:00
|
|
|
@Test
|
2011-11-30 15:16:20 +01:00
|
|
|
public void mustBeAbleToCreateActorRefFromFactory() {
|
2011-11-15 11:34:39 +01:00
|
|
|
ActorRef ref = system.actorOf(new Props().withCreator(new Creator<Actor>() {
|
|
|
|
|
public Actor create() {
|
|
|
|
|
return new JavaAPITestActor();
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
assertNotNull(ref);
|
2011-01-04 13:24:28 +01:00
|
|
|
}
|
2011-08-03 23:08:38 +02:00
|
|
|
|
2011-11-15 11:34:39 +01:00
|
|
|
@Test
|
2011-11-30 15:16:20 +01:00
|
|
|
public void mustAcceptSingleArgTell() {
|
2011-12-13 14:09:40 +01:00
|
|
|
ActorRef ref = system.actorOf(new Props(JavaAPITestActor.class));
|
2011-10-22 16:06:20 +02:00
|
|
|
ref.tell("hallo");
|
|
|
|
|
ref.tell("hallo", ref);
|
2011-08-03 23:08:38 +02:00
|
|
|
}
|
2011-01-04 13:24:28 +01:00
|
|
|
}
|