当前位置: 首页>>代码示例>>Scala>>正文


Scala ActorNotFound类代码示例

本文整理汇总了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]
    }
  }
} 
开发者ID:invkrh,项目名称:akka-raft,代码行数:51,代码来源:ServerLauncherTest.scala

示例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)
  }

} 
开发者ID:viacoin,项目名称:eclair,代码行数:31,代码来源:TestkitBaseClass.scala


注:本文中的akka.actor.ActorNotFound类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。