2010-06-10 16:00:42 +02:00
|
|
|
package se.scalablesolutions.akka.actor
|
|
|
|
|
|
|
|
|
|
import Actor._
|
|
|
|
|
|
|
|
|
|
import org.scalatest.Spec
|
|
|
|
|
import org.scalatest.Assertions
|
|
|
|
|
import org.scalatest.matchers.ShouldMatchers
|
|
|
|
|
import org.scalatest.BeforeAndAfterAll
|
|
|
|
|
import org.scalatest.junit.JUnitRunner
|
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
|
|
|
|
|
|
@RunWith(classOf[JUnitRunner])
|
|
|
|
|
class SerializableActorSpec extends
|
|
|
|
|
Spec with
|
|
|
|
|
ShouldMatchers with
|
|
|
|
|
BeforeAndAfterAll {
|
|
|
|
|
|
|
|
|
|
describe("SerializableActor") {
|
|
|
|
|
it("should be able to serialize and deserialize a JavaSerializableActor") {
|
|
|
|
|
val actor1 = actorOf[JavaSerializableTestActor].start
|
|
|
|
|
val serializer = actor1.serializer.getOrElse(fail("Serializer not defined"))
|
|
|
|
|
(actor1 !! "hello").getOrElse("_") should equal("world")
|
|
|
|
|
|
|
|
|
|
val bytes = actor1.toBinary
|
2010-06-16 16:15:34 +02:00
|
|
|
val actor2 = ActorRef.fromBinaryToLocalActorRef(bytes)
|
|
|
|
|
|
|
|
|
|
actor2.start
|
|
|
|
|
(actor2 !! "hello").getOrElse("_") should equal("world")
|
2010-06-10 16:00:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@serializable class JavaSerializableTestActor extends JavaSerializableActor[JavaSerializableTestActor] {
|
|
|
|
|
def receive = {
|
|
|
|
|
case "hello" => reply("world")
|
|
|
|
|
}
|
|
|
|
|
}
|