From 068a6d7e1281be8d47f177d1ec302f1fbf8e4da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bon=C3=A9r?= Date: Thu, 10 Jun 2010 16:00:42 +0200 Subject: [PATCH] Added SerializableActorSpec for testing deep actor serialization --- .../test/scala/SerializableActorSpec.scala | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 akka-core/src/test/scala/SerializableActorSpec.scala diff --git a/akka-core/src/test/scala/SerializableActorSpec.scala b/akka-core/src/test/scala/SerializableActorSpec.scala new file mode 100644 index 0000000000..13f018c6a0 --- /dev/null +++ b/akka-core/src/test/scala/SerializableActorSpec.scala @@ -0,0 +1,37 @@ +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 + +// val actor2 = serializer.fromBinary(bytes, Some(classOf[JavaSerializableTestActor])).asInstanceOf[Actor] +// (actor2 !! "hello").getOrElse("_") should equal("world") + true should equal(true) + } + } +} + +@serializable class JavaSerializableTestActor extends JavaSerializableActor[JavaSerializableTestActor] { + def receive = { + case "hello" => reply("world") + } +} \ No newline at end of file