Andreas Gies
Posts: 15
Nickname: 84653
Registered: Nov, 2012
|
|
Re: Bad symbolic reference to class Duration in package util
|
Posted: Nov 28, 2012 4:15 AM
|
|
Hello,
I have done a bit of search and got around the compile error by using the following version of akka-testkit:
<groupId>com.typesafe.akka</groupId> <artifactId>akka-testkit_2.10.0-RC2</artifactId> <version>2.2-SNAPSHOT</version> <scope>test</scope>
This lives in the typesafe maven repo at http://repo.akka.io/snapshots.
Though the compile works, the sample code runs into an exception:
Caused by: cb1bf64f-7bb1-4049-b7f2-54411b4e45f0akka.actor.ActorInitializationException: You cannot create an instance of [zzz.akka.avionics.TestEventSource] explicitly using the constructor (new). You have to use one of the factory methods to create a new actor. Either use: 'val actor = context.actorOf(Props[MyActor])' (to create a supervised child actor from within an actor), or 'val actor = system.actorOf(Props(new MyActor(..)))' (to create a top level actor from the ActorSystem)
For completeness, this is my current Spec class:
package zzz.akka.avionics
import akka.actor.{ActorSystem, Actor} import akka.testkit.{TestActorRef, TestKit, ImplicitSender} import org.scalatest.{BeforeAndAfterAll, WordSpec} import org.scalatest.matchers.MustMatchers
class TestEventSource extends Actor with ProductionEventSource { def receive = eventSourceReceive }
class EventSourceSpec extends TestKit(ActorSystem("EventSourceSpec")) with WordSpec with MustMatchers with BeforeAndAfterAll {
import EventSource._
override protected def afterAll() { system.shutdown() }
"EventSource" should {
"allow us to register a listener" in { val real = TestActorRef[TestEventSource].underlyingActor real.receive(RegisterListener(testActor)) real.listeners must contain (testActor) }
}
}
I am not sure, where I made the mistake, but it's probably me trying to pick up Scala & Akka at the same time not spotting the obvious.
Best regards Andreas
|
|