Adding tests for the actor ref serialization bug, 837
This commit is contained in:
parent
e30f85a1ba
commit
aaa8b163f3
3 changed files with 30 additions and 7 deletions
|
|
@ -4,10 +4,9 @@
|
|||
|
||||
package akka.dispatch
|
||||
|
||||
import akka.actor.{Actor, ActorType, ActorRef, ActorInitializationException}
|
||||
import akka.AkkaException
|
||||
|
||||
import java.util.{Queue, List, Comparator, PriorityQueue}
|
||||
import java.util.{Comparator, PriorityQueue}
|
||||
import java.util.concurrent._
|
||||
import akka.util._
|
||||
|
||||
|
|
|
|||
|
|
@ -269,15 +269,13 @@ object RemoteActorSerialization {
|
|||
.setTimeout(r.timeout)
|
||||
.build
|
||||
case ar: LocalActorRef =>
|
||||
import ar._
|
||||
|
||||
Actor.remote.registerByUuid(ar)
|
||||
|
||||
RemoteActorRefProtocol.newBuilder
|
||||
.setClassOrServiceName("uuid:"+uuid.toString)
|
||||
.setActorClassname(actorClassName)
|
||||
.setClassOrServiceName("uuid:"+ar.uuid.toString)
|
||||
.setActorClassname(ar.actorClassName)
|
||||
.setHomeAddress(ActorSerialization.toAddressProtocol(ar))
|
||||
.setTimeout(timeout)
|
||||
.setTimeout(ar.timeout)
|
||||
.build
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,6 +186,7 @@ class SerializableTypeClassActorSpec extends
|
|||
}
|
||||
*/
|
||||
}
|
||||
|
||||
describe("Custom serializable actors") {
|
||||
it("should serialize and de-serialize") {
|
||||
import BinaryFormatMyActorWithSerializableMessages._
|
||||
|
|
@ -208,6 +209,31 @@ class SerializableTypeClassActorSpec extends
|
|||
(actor3 !! "hello-reply").getOrElse("_") should equal("world")
|
||||
}
|
||||
}
|
||||
|
||||
describe("ActorRef serialization") {
|
||||
it("should serialize and deserialize local actor refs ") {
|
||||
val a = actorOf[MyActorWithDualCounter].start
|
||||
val out = RemoteActorSerialization.toRemoteActorRefProtocol(a).toByteArray
|
||||
val in = RemoteActorSerialization.fromBinaryToRemoteActorRef(out)
|
||||
|
||||
in.id should equal("uuid:"+a.uuid)
|
||||
in.actorClassName should equal(a.actorClassName)
|
||||
in.timeout should equal(a.timeout)
|
||||
in.homeAddress should equal(Some(Actor.remote.address))
|
||||
a.stop
|
||||
}
|
||||
|
||||
it("should serialize and deserialize remote actor refs ") {
|
||||
val a = Actor.remote.actorFor("foo", "localhost", 6666)
|
||||
val out = RemoteActorSerialization.toRemoteActorRefProtocol(a).toByteArray
|
||||
val in = RemoteActorSerialization.fromBinaryToRemoteActorRef(out)
|
||||
|
||||
in.id should equal(a.id)
|
||||
in.actorClassName should equal(a.actorClassName)
|
||||
in.timeout should equal(a.timeout)
|
||||
in.homeAddress should equal(a.homeAddress)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MyActorWithDualCounter extends Actor {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue