introduce AkkaApplication
- remove global Config
- pull everything which depended on it into new AkkaApplication
- leave EventHandler alone for the moment: that evil sucker gets his
very own AkkaApplication("akka-reference.conf") until we have settled
on an acceptable logging API without globals
- make akka-actor and akka-testkit compile
- TestKit uses implicit AkkaApplication passing for maximum convenience
- Actor object nearly completely removed, actor creation possible via
ActorRefFactory interface which is implemented by AkkaApplication and
ActorContext
- serialization of ActorRef is probably broken, and so is the reflective
RemoteSupport (now needs AkkaApplication constructor arg)
- everything else is still broken, including akka-actor-tests, so this
is of course all not runtime-tested
This commit is contained in:
parent
ccb429df13
commit
2381ec54d0
46 changed files with 734 additions and 1066 deletions
|
|
@ -7,9 +7,9 @@ package akka.testkit
|
|||
import akka.actor._
|
||||
import akka.util.ReflectiveAccess
|
||||
import akka.event.EventHandler
|
||||
|
||||
import com.eaio.uuid.UUID
|
||||
import akka.actor.Props._
|
||||
import akka.AkkaApplication
|
||||
|
||||
/**
|
||||
* This special ActorRef is exclusively for use during unit testing in a single-threaded environment. Therefore, it
|
||||
|
|
@ -19,7 +19,8 @@ import akka.actor.Props._
|
|||
* @author Roland Kuhn
|
||||
* @since 1.1
|
||||
*/
|
||||
class TestActorRef[T <: Actor](props: Props, address: String) extends LocalActorRef(props.withDispatcher(CallingThreadDispatcher.global), address, false) {
|
||||
class TestActorRef[T <: Actor](application: AkkaApplication, props: Props, address: String)
|
||||
extends LocalActorRef(application, props.withDispatcher(CallingThreadDispatcher.global), address, false) {
|
||||
/**
|
||||
* Directly inject messages into actor receive behavior. Any exceptions
|
||||
* thrown will be available to you, while still being able to use
|
||||
|
|
@ -41,19 +42,19 @@ class TestActorRef[T <: Actor](props: Props, address: String) extends LocalActor
|
|||
|
||||
object TestActorRef {
|
||||
|
||||
def apply[T <: Actor](factory: ⇒ T): TestActorRef[T] = apply[T](Props(factory), new UUID().toString)
|
||||
def apply[T <: Actor](factory: ⇒ T)(implicit application: AkkaApplication): TestActorRef[T] = apply[T](Props(factory), new UUID().toString)
|
||||
|
||||
def apply[T <: Actor](factory: ⇒ T, address: String): TestActorRef[T] = apply[T](Props(factory), address)
|
||||
def apply[T <: Actor](factory: ⇒ T, address: String)(implicit application: AkkaApplication): TestActorRef[T] = apply[T](Props(factory), address)
|
||||
|
||||
def apply[T <: Actor](props: Props): TestActorRef[T] = apply[T](props, new UUID().toString)
|
||||
def apply[T <: Actor](props: Props)(implicit application: AkkaApplication): TestActorRef[T] = apply[T](props, new UUID().toString)
|
||||
|
||||
def apply[T <: Actor](props: Props, address: String): TestActorRef[T] = new TestActorRef(props, address)
|
||||
def apply[T <: Actor](props: Props, address: String)(implicit application: AkkaApplication): TestActorRef[T] = new TestActorRef(application, props, address)
|
||||
|
||||
def apply[T <: Actor: Manifest]: TestActorRef[T] = apply[T](new UUID().toString)
|
||||
def apply[T <: Actor](implicit m: Manifest[T], application: AkkaApplication): TestActorRef[T] = apply[T](new UUID().toString)
|
||||
|
||||
def apply[T <: Actor: Manifest](address: String): TestActorRef[T] = apply[T](Props({
|
||||
def apply[T <: Actor](address: String)(implicit m: Manifest[T], application: AkkaApplication): TestActorRef[T] = apply[T](Props({
|
||||
import ReflectiveAccess.{ createInstance, noParams, noArgs }
|
||||
createInstance[T](manifest[T].erasure, noParams, noArgs) match {
|
||||
createInstance[T](m.erasure, noParams, noArgs) match {
|
||||
case Right(value) ⇒ value
|
||||
case Left(exception) ⇒ throw new ActorInitializationException(
|
||||
"Could not instantiate Actor" +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue