Co-authored-by: andrii.ryzhenko <andrii.ryzhenko@betlab.com>
This commit is contained in:
parent
a51a85c8ad
commit
beda844b8d
2 changed files with 19 additions and 2 deletions
|
|
@ -44,7 +44,7 @@ class ActorTestKitSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike wi
|
|||
} finally testkit2.shutdownTestKit()
|
||||
}
|
||||
|
||||
"use name from given class name" in {
|
||||
"use name from given class name with replaced package name" in {
|
||||
val testkit2 = ActorTestKit(classOf[Vector[_]].getName)
|
||||
try {
|
||||
// removing package name and such
|
||||
|
|
@ -52,6 +52,23 @@ class ActorTestKitSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike wi
|
|||
} finally testkit2.shutdownTestKit()
|
||||
}
|
||||
|
||||
"use sanitized name if passed invalid characters" in {
|
||||
val testkit2 = ActorTestKit("actor~!sys-tem&Name#1%(with*invalid^ch@racter$)`")
|
||||
try {
|
||||
// replacing invalid characters with underscore
|
||||
testkit2.system.name should ===("actor__sys-tem_Name_1__with_invalid_ch_racter___")
|
||||
} finally testkit2.shutdownTestKit()
|
||||
}
|
||||
|
||||
"use the same name if passed valid ActorSystem name" in {
|
||||
val validActorSystemNameChars = "abcdefghijklmnopqrstuvwxyz-ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789_"
|
||||
val testkit2 = ActorTestKit(validActorSystemNameChars)
|
||||
try {
|
||||
// all characters should be the same
|
||||
testkit2.system.name should ===(validActorSystemNameChars)
|
||||
} finally testkit2.shutdownTestKit()
|
||||
}
|
||||
|
||||
"spawn an actor" in {
|
||||
val sawMessage = Promise[Boolean]()
|
||||
spawn(Behaviors.setup[AnyRef] { _ =>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ private[akka] object TestKitUtils {
|
|||
name
|
||||
.replaceFirst("""^.*\.""", "") // drop package name
|
||||
.replaceAll("""\$\$?\w+""", "") // drop scala anonymous functions/classes
|
||||
.replaceAll("[^a-zA-Z_0-9]", "_")
|
||||
.replaceAll("[^a-zA-Z_0-9-]", "_")
|
||||
.replaceAll("""MultiJvmNode\d+""", "") // drop MultiJvm suffix
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue