serializer for akka.actor.typed.ActorRef

* most convenient for users to include it akka-serialization-jackson
  and load it when akka-actor-typed is in classpath
* provided dependency to akka-actor-typed
This commit is contained in:
Patrik Nordwall 2019-05-29 20:15:46 +02:00
parent 6122966fca
commit 93017d05c7
8 changed files with 149 additions and 18 deletions

View file

@ -23,6 +23,7 @@ import akka.actor.BootstrapSetup
import akka.actor.ExtendedActorSystem
import akka.actor.Status
import akka.actor.setup.ActorSystemSetup
import akka.actor.typed.scaladsl.Behaviors
import akka.serialization.Serialization
import akka.serialization.SerializationExtension
import akka.testkit.TestActors
@ -53,6 +54,8 @@ object ScalaTestMessages {
final case class TimeCommand(timestamp: LocalDateTime, duration: FiniteDuration) extends TestMessage
final case class CollectionsCommand(strings: List[String], objects: Vector[SimpleCommand]) extends TestMessage
final case class CommandWithActorRef(name: String, replyTo: ActorRef) extends TestMessage
final case class CommandWithTypedActorRef(name: String, replyTo: akka.actor.typed.ActorRef[String])
extends TestMessage
final case class CommandWithAddress(name: String, address: Address) extends TestMessage
final case class Event1(field1: String) extends TestMessage
@ -365,6 +368,12 @@ abstract class JacksonSerializerSpec(serializerName: String)
checkSerialization(new CommandWithActorRef("echo", echo))
}
"serialize with typed.ActorRef" in {
import akka.actor.typed.scaladsl.adapter._
val ref = system.spawnAnonymous(Behaviors.empty[String])
checkSerialization(new CommandWithTypedActorRef("echo", ref))
}
"serialize with Address" in {
val address = Address("akka", "sys", "localhost", 2552)
checkSerialization(new CommandWithAddress("echo", address))
@ -450,6 +459,12 @@ abstract class JacksonSerializerSpec(serializerName: String)
checkSerialization(CommandWithActorRef("echo", echo))
}
"serialize with typed.ActorRef" in {
import akka.actor.typed.scaladsl.adapter._
val ref = system.spawnAnonymous(Behaviors.empty[String])
checkSerialization(CommandWithTypedActorRef("echo", ref))
}
"serialize with Address" in {
val address = Address("akka", "sys", "localhost", 2552)
checkSerialization(CommandWithAddress("echo", address))