Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package org.apache.pekko.actor;

import org.apache.pekko.actor.javadsl.ActorSystem;
import org.apache.pekko.testkit.PekkoJUnitActorSystemResource;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -39,7 +40,7 @@ public void beforeEach() {

@Test
public void testGetWhenTerminated() throws Exception {
system.terminate();
system.terminateAsync();
final CompletionStage<Terminated> cs = system.getWhenTerminated();
cs.toCompletableFuture().get(2, SECONDS);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""
val ecProbe = TestProbe()
val ec = new SnitchingExecutionContext(ecProbe.ref, ExecutionContexts.global())

val system2 = ActorSystem(name = "ActorSystemDispatchersSpec-passed-in-ec", defaultExecutionContext = Some(ec))
val system2 = pekko.actor.scaladsl.ActorSystem(name = "ActorSystemDispatchersSpec-passed-in-ec",
defaultExecutionContext = Some(ec))

try {
val ref = system2.actorOf(Props(new Actor {
Expand All @@ -79,7 +80,7 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""
val ec = new SnitchingExecutionContext(ecProbe.ref, ExecutionContexts.global())

val config = ConfigFactory.parseString("pekko.actor.default-dispatcher.executor = \"fork-join-executor\"")
val system2 = ActorSystem(
val system2 = pekko.actor.scaladsl.ActorSystem(
name = "ActorSystemDispatchersSpec-ec-configured",
config = Some(config),
defaultExecutionContext = Some(ec))
Expand All @@ -103,7 +104,7 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""
}

"provide a single place to override the internal dispatcher" in {
val sys = ActorSystem(
val sys = pekko.actor.scaladsl.ActorSystem(
"ActorSystemDispatchersSpec-override-internal-disp",
ConfigFactory.parseString("""
pekko.actor.internal-dispatcher = pekko.actor.default-dispatcher
Expand All @@ -124,7 +125,7 @@ class ActorSystemDispatchersSpec extends PekkoSpec(ConfigFactory.parseString("""

// using the default for internal dispatcher and passing a pre-existing execution context
val system2 =
ActorSystem(
pekko.actor.scaladsl.ActorSystem(
name = "ActorSystemDispatchersSpec-passed-in-ec-for-internal",
config = Some(ConfigFactory.parseString("""
pekko.actor.internal-dispatcher = pekko.actor.default-dispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class CoordinatedShutdownSpec
}

"terminate ActorSystem" in {
val sys = ActorSystem(system.name, system.settings.config)
val sys = pekko.actor.scaladsl.ActorSystem(system.name, system.settings.config)
try {
Await.result(CoordinatedShutdown(sys).run(CustomReason), 10.seconds) should ===(Done)
sys.whenTerminated.isCompleted should ===(true)
Expand All @@ -544,9 +544,9 @@ class CoordinatedShutdownSpec
}

"be run by ActorSystem.terminate" in {
val sys = ActorSystem(system.name, system.settings.config)
val sys = pekko.actor.scaladsl.ActorSystem(system.name, system.settings.config)
try {
Await.result(sys.terminate(), 10.seconds)
Await.result(sys.terminateAsync(), 10.seconds)
sys.whenTerminated.isCompleted should ===(true)
CoordinatedShutdown(sys).shutdownReason() should ===(Some(CoordinatedShutdown.ActorSystemTerminateReason))
} finally {
Expand All @@ -555,13 +555,13 @@ class CoordinatedShutdownSpec
}

"not be run by ActorSystem.terminate when run-by-actor-system-terminate=off" in {
val sys = ActorSystem(
val sys = pekko.actor.scaladsl.ActorSystem(
system.name,
ConfigFactory
.parseString("pekko.coordinated-shutdown.run-by-actor-system-terminate = off")
.withFallback(system.settings.config))
try {
Await.result(sys.terminate(), 10.seconds)
Await.result(sys.terminateAsync(), 10.seconds)
sys.whenTerminated.isCompleted should ===(true)
CoordinatedShutdown(sys).shutdownReason() should ===(None)
} finally {
Expand All @@ -571,7 +571,7 @@ class CoordinatedShutdownSpec

"not allow terminate-actor-system=off && run-by-actor-system-terminate=on" in {
intercept[ConfigurationException] {
val sys = ActorSystem(
val sys = pekko.actor.scaladsl.ActorSystem(
system.name,
ConfigFactory
.parseString("pekko.coordinated-shutdown.terminate-actor-system = off")
Expand Down Expand Up @@ -659,7 +659,7 @@ class CoordinatedShutdownSpec
}

def withCoordinatedShutdown(block: (ActorSystem, CoordinatedShutdown) => Unit): Unit = {
val system = ActorSystem(
val system = pekko.actor.scaladsl.ActorSystem(
s"CoordinatedShutdownSpec-terminated-${System.currentTimeMillis()}",
ConfigFactory.parseString("""
pekko.coordinated-shutdown.phases {
Expand Down Expand Up @@ -761,7 +761,8 @@ class CoordinatedShutdownSpec
def withSystemRunning(system: ActorSystem, cs: CoordinatedShutdown): Unit

private val newSystem =
ActorSystem(systemName, systemConfig.withFallback(system.settings.config)).asInstanceOf[ExtendedActorSystem]
pekko.actor.scaladsl.ActorSystem(systemName, systemConfig.withFallback(system.settings.config)).asInstanceOf[
ExtendedActorSystem]
private var shutdownHooks = Set.empty[Thread]
private val mockRuntime = new JVMShutdownHooks {
override def addHook(t: Thread): Unit = synchronized {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class DeployerSpec extends PekkoSpec(DeployerSpec.deployerConf) {
ConfigParseOptions.defaults)
.withFallback(PekkoSpec.testConf)

shutdown(ActorSystem("invalid-number-of-instances", invalidDeployerConf))
shutdown(pekko.actor.scaladsl.ActorSystem("invalid-number-of-instances", invalidDeployerConf))
}
}

Expand All @@ -175,7 +175,7 @@ class DeployerSpec extends PekkoSpec(DeployerSpec.deployerConf) {
ConfigParseOptions.defaults)
.withFallback(PekkoSpec.testConf)

shutdown(ActorSystem("invalid-path", invalidDeployerConf))
shutdown(pekko.actor.scaladsl.ActorSystem("invalid-path", invalidDeployerConf))
}
e.getMessage should include("[ubåt]")
e.getMessage should include("[/gul/ubåt]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
package org.apache.pekko.actor

import scala.collection.immutable
import scala.concurrent.Await
import scala.concurrent.duration._
import scala.util.{ Failure, Success, Try }

import org.scalatest.BeforeAndAfterAll
Expand All @@ -32,7 +30,7 @@ class TestClassWithDefaultConstructor extends TestSuperclass {
}

class DynamicAccessSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll {
val system = ActorSystem()
val system = org.apache.pekko.actor.scaladsl.ActorSystem()

"The DynamicAccess of a system" should {
val dynamicAccess = system.asInstanceOf[ExtendedActorSystem].dynamicAccess
Expand Down Expand Up @@ -88,7 +86,7 @@ class DynamicAccessSpec extends AnyWordSpec with Matchers with BeforeAndAfterAll
}

override def afterAll() = {
Await.result(system.terminate(), 10.seconds)
system.close()
super.afterAll()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {

"support extensions" in {
val config = ConfigFactory.parseString("""pekko.extensions = ["org.apache.pekko.actor.TestExtension"]""")
val system = ActorSystem("extensions", config)
val system = pekko.actor.scaladsl.ActorSystem("extensions", config)

// TestExtension is configured and should be loaded at startup
system.hasExtension(TestExtension) should ===(true)
Expand All @@ -80,7 +80,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
}

"handle extensions that fail to initialize" in {
val system = ActorSystem("extensions")
val system = pekko.actor.scaladsl.ActorSystem("extensions")

// First attempt, an actor is created and after that
// an exception is thrown:
Expand All @@ -98,7 +98,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {

"fail the actor system if an extension listed in pekko.extensions fails to start" in {
intercept[RuntimeException] {
val system = ActorSystem(
val system = pekko.actor.scaladsl.ActorSystem(
"failing",
ConfigFactory.parseString("""
pekko.extensions = ["org.apache.pekko.actor.FailingTestExtension"]
Expand All @@ -109,7 +109,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
}

"log an error if an extension listed in pekko.extensions cannot be loaded" in {
val system = ActorSystem(
val system = pekko.actor.scaladsl.ActorSystem(
"failing",
ConfigFactory.parseString("""
pekko.extensions = ["org.apache.pekko.actor.MissingExtension"]
Expand All @@ -123,7 +123,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
import pekko.util.ccompat.JavaConverters._
// could be initialized by other tests, but assuming tests are not running in parallel
val countBefore = InstanceCountingExtension.createCount.get()
val system = ActorSystem("extensions")
val system = pekko.actor.scaladsl.ActorSystem("extensions")
val listedExtensions = system.settings.config.getStringList("pekko.library-extensions").asScala
listedExtensions.count(_.contains("InstanceCountingExtension")) should ===(1)

Expand All @@ -136,7 +136,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {
import pekko.util.ccompat.JavaConverters._
// could be initialized by other tests, but assuming tests are not running in parallel
val countBefore = InstanceCountingExtension.createCount.get()
val system = ActorSystem(
val system = pekko.actor.scaladsl.ActorSystem(
"extensions",
ConfigFactory.parseString(
"""
Expand All @@ -152,7 +152,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {

"fail the actor system if a library-extension fails to start" in {
intercept[FailingTestExtension.TestException] {
ActorSystem(
pekko.actor.scaladsl.ActorSystem(
"failing",
ConfigFactory.parseString("""
pekko.library-extensions += "org.apache.pekko.actor.FailingTestExtension"
Expand All @@ -163,7 +163,7 @@ class ExtensionSpec extends AnyWordSpec with Matchers {

"fail the actor system if a library-extension cannot be loaded" in {
intercept[RuntimeException] {
ActorSystem(
pekko.actor.scaladsl.ActorSystem(
"failing",
ConfigFactory.parseString("""
pekko.library-extensions += "org.apache.pekko.actor.MissingExtension"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with
val config = ConfigFactory
.parseMap(Map("pekko.loglevel" -> "DEBUG", "pekko.actor.debug.fsm" -> true).asJava)
.withFallback(system.settings.config)
val fsmEventSystem = ActorSystem("fsmEvent", config)
val fsmEventSystem = pekko.actor.scaladsl.ActorSystem("fsmEvent", config)
try {
new TestKit(fsmEventSystem) {
EventFilter.debug(occurrences = 5).intercept {
Expand Down Expand Up @@ -351,7 +351,7 @@ class FSMActorSpec extends PekkoSpec(Map("pekko.actor.debug.fsm" -> true)) with
}

"allow cancelling stateTimeout by issuing forMax(Duration.Inf)" taggedAs TimingTest in {
val sys = ActorSystem("fsmEvent")
val sys = pekko.actor.scaladsl.ActorSystem("fsmEvent")
val p = TestProbe()(sys)

val OverrideTimeoutToInf = "override-timeout-to-inf"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class ActorSystemSetupSpec extends AnyWordSpec with Matchers {
var system: ActorSystem = null
try {
val setup = DummySetup("Tad Moore")
system = ActorSystem("name", ActorSystemSetup(setup))
system = pekko.actor.scaladsl.ActorSystem("name", ActorSystemSetup(setup))

(system.settings.setup.get[DummySetup]: Option[Setup]) should ===(Some(setup))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec

import org.apache.pekko
import pekko.actor.ActorSystem
import pekko.testkit.TestKit

class DispatcherShutdownSpec extends AnyWordSpec with Matchers {
Expand All @@ -42,10 +41,10 @@ class DispatcherShutdownSpec extends AnyWordSpec with Matchers {
"DispatcherShutdownSpec-pekko.actor.internal")) // nothing is run on default without any user actors started
.size

val system = ActorSystem("DispatcherShutdownSpec")
val system = pekko.actor.scaladsl.ActorSystem("DispatcherShutdownSpec")
threadCount should be > 0

Await.ready(system.terminate(), 1.second)
Await.ready(system.terminateAsync(), 1.second)
Await.ready(Future(pekko.Done)(system.dispatcher), 1.second)

TestKit.awaitCond(threadCount == 0, 3.second)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import scala.concurrent.duration._
import org.apache.pekko
import pekko.actor.Actor
import pekko.actor.ActorRef
import pekko.actor.ActorSystem
import pekko.actor.Props
import pekko.testkit._

Expand All @@ -42,7 +41,7 @@ class AddressTerminatedTopicBenchSpec extends PekkoSpec("pekko.loglevel=INFO") {
"Subscribe and unsubscribe of AddressTerminated" must {

"be quick" in {
val sys = ActorSystem(system.name + "2", system.settings.config)
val sys = pekko.actor.scaladsl.ActorSystem(system.name + "2", system.settings.config)
try {
val num = 20000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
}

"be able to log unhandled messages" in {
val sys = ActorSystem("EventStreamSpecUnhandled", configUnhandled)
val sys = pekko.actor.scaladsl.ActorSystem("EventStreamSpecUnhandled", configUnhandled)
try {
sys.eventStream.subscribe(testActor, classOf[AnyRef])
val m = UnhandledMessage(42, sys.deadLetters, sys.deadLetters)
Expand Down Expand Up @@ -296,7 +296,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
}

"unsubscribe an actor on its termination" in {
val sys = ActorSystem("EventStreamSpecUnsubscribeOnTerminated", configUnhandledWithDebug)
val sys = pekko.actor.scaladsl.ActorSystem("EventStreamSpecUnsubscribeOnTerminated", configUnhandledWithDebug)

try {
val es = sys.eventStream
Expand Down Expand Up @@ -325,7 +325,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
}

"unsubscribe the actor, when it subscribes already in terminated state" in {
val sys = ActorSystem("EventStreamSpecUnsubscribeTerminated", configUnhandledWithDebug)
val sys = pekko.actor.scaladsl.ActorSystem("EventStreamSpecUnsubscribeTerminated", configUnhandledWithDebug)

try {
val es = sys.eventStream
Expand Down Expand Up @@ -356,7 +356,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
}

"not allow initializing a TerminatedUnsubscriber twice" in {
val sys = ActorSystem("MustNotAllowDoubleInitOfTerminatedUnsubscriber")
val sys = pekko.actor.scaladsl.ActorSystem("MustNotAllowDoubleInitOfTerminatedUnsubscriber")
// initializes an TerminatedUnsubscriber during start

try {
Expand All @@ -373,7 +373,7 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
}

"unwatch an actor from unsubscriber when that actor unsubscribes from the stream" in {
val sys = ActorSystem("MustUnregisterDuringUnsubscribe", configUnhandledWithDebug)
val sys = pekko.actor.scaladsl.ActorSystem("MustUnregisterDuringUnsubscribe", configUnhandledWithDebug)

try {
val es = sys.eventStream
Expand All @@ -393,7 +393,8 @@ class EventStreamSpec extends PekkoSpec(EventStreamSpec.config) {
}

"unwatch an actor from unsubscriber when that actor unsubscribes from channels it subscribed" in {
val sys = ActorSystem("MustUnregisterWhenNoMoreChannelSubscriptions", configUnhandledWithDebug)
val sys =
pekko.actor.scaladsl.ActorSystem("MustUnregisterWhenNoMoreChannelSubscriptions", configUnhandledWithDebug)

try {
val es = sys.eventStream
Expand Down
Loading
Loading