本文整理汇总了Scala中akka.actor.ActorNotFound类的典型用法代码示例。如果您正苦于以下问题:Scala ActorNotFound类的具体用法?Scala ActorNotFound怎么用?Scala ActorNotFound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ActorNotFound类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ServerLauncherTest
//设置package包名称以及导入依赖的类
package me.invkrh.raft.deploy.actor
import java.io.File
import scala.concurrent.Await
import scala.concurrent.duration._
import akka.actor.{ActorNotFound, ActorRef, Props}
import akka.testkit.TestProbe
import com.typesafe.config.ConfigFactory
import me.invkrh.raft.core.ServerConf
import me.invkrh.raft.deploy.remote.RemoteProvider
import me.invkrh.raft.exception.UnexpectedSenderException
import me.invkrh.raft.kit.{ExceptionDetector, RaftTestHarness}
import me.invkrh.raft.message.{ServerId, ServerIdRequest}
class ServerLauncherTest extends RaftTestHarness("ServerLauncherTest") {
"ServerLauncher" should {
val raftConfigFilePath = getClass.getResource(s"/raft.conf").getPath
val config = ConfigFactory.parseFile(new File(raftConfigFilePath))
val serverConf = ServerConf(config.getConfig("server"))
"shutdown the system when ServerIdRequest is rejected" in {
new RemoteProvider {
override var host: String = "localhost"
override var port: Int = 0
val spawnerRef: ActorRef = system.actorOf(ServerLauncher.props(self, serverConf))
val path = spawnerRef.path
expectMsg(ServerIdRequest)
spawnerRef ! ServerId(-1)
Thread.sleep(1000)
intercept[ActorNotFound] {
Await.result(system.actorSelection(path).resolveOne(5.seconds), 5.seconds)
}
}
}
"throw UnexpectedSenderException if ServerId is not sent from initializer" in {
val probe = TestProbe()
val supervisor: ActorRef = system.actorOf(Props(new ExceptionDetector(s"ExDet", probe.ref)))
supervisor ! ServerLauncher.props(probe.ref, serverConf)
val launcherRef = expectMsgType[ActorRef]
probe.expectMsg(ServerIdRequest)
launcherRef ! ServerId(0)
probe.expectMsgType[UnexpectedSenderException]
}
}
}
示例2: TestkitBaseClass
//设置package包名称以及导入依赖的类
package fr.acinq.eclair
import akka.actor.{ActorNotFound, ActorSystem, PoisonPill}
import akka.testkit.TestKit
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, fixture}
import scala.concurrent.Await
abstract class TestkitBaseClass extends TestKit(ActorSystem("test")) with fixture.FunSuiteLike with BeforeAndAfterEach with BeforeAndAfterAll {
override def beforeAll {
Globals.blockCount.set(400000)
Globals.feeratePerKw.set(TestConstants.feeratePerKw)
}
override def afterEach() {
system.actorSelection(system / "*") ! PoisonPill
intercept[ActorNotFound] {
import scala.concurrent.duration._
Await.result(system.actorSelection(system / "*").resolveOne(42 days), 42 days)
}
}
override def afterAll {
TestKit.shutdownActorSystem(system)
Globals.feeratePerKw.set(0)
}
}