本文整理汇总了Scala中akka.testkit.ImplicitSender类的典型用法代码示例。如果您正苦于以下问题:Scala ImplicitSender类的具体用法?Scala ImplicitSender怎么用?Scala ImplicitSender使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ImplicitSender类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: AbstractActorSpec
//设置package包名称以及导入依赖的类
package name.mikulskibartosz.demo.akka.actors
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, DefaultTimeout, TestKit}
import name.mikulskibartosz.demo.akka.service.Service
import org.mockito.Mockito._
import org.scalatest.mock.MockitoSugar
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import scala.util.Try
abstract class AbstractActorSpec extends TestKit(ActorSystem()) with DefaultTimeout with ImplicitSender
with WordSpecLike with Matchers with BeforeAndAfterAll with MockitoSugar {
override def afterAll() = {
super.afterAll()
shutdown()
}
def createServiceReturning(value: Try[Int]) = {
val service = mock[Service]
when(service.generate()).thenReturn(value)
service
}
}
开发者ID:mikulskibartosz,项目名称:demoAkkaAccessingUnreliableService,代码行数:26,代码来源:AbstractActorSpec.scala
示例2: SnapshotDirectoryFailureSpec
//设置package包名称以及导入依赖的类
package akka.persistence
import akka.testkit.{ ImplicitSender, EventFilter, TestEvent, AkkaSpec }
import java.io.{ IOException, File }
import akka.actor.{ ActorInitializationException, Props, ActorRef }
object SnapshotDirectoryFailureSpec {
val inUseSnapshotPath = "target/inUseSnapshotPath"
class TestProcessor(name: String, probe: ActorRef) extends Processor {
override def persistenceId: String = name
override def preStart(): Unit = ()
def receive = {
case s: String ? saveSnapshot(s)
case SaveSnapshotSuccess(md) ? probe ! md.sequenceNr
case other ? probe ! other
}
}
}
class SnapshotDirectoryFailureSpec extends AkkaSpec(PersistenceSpec.config("leveldb", "SnapshotDirectoryFailureSpec", extraConfig = Some(
s"""
|akka.persistence.snapshot-store.local.dir = "${SnapshotDirectoryFailureSpec.inUseSnapshotPath}"
""".stripMargin))) with ImplicitSender {
import SnapshotDirectoryFailureSpec._
val file = new File(inUseSnapshotPath)
override protected def atStartup() {
if (!file.createNewFile()) throw new IOException(s"Failed to create test file [${file.getCanonicalFile}]")
}
override protected def afterTermination() {
if (!file.delete()) throw new IOException(s"Failed to delete test file [${file.getCanonicalFile}]")
}
"A local snapshot store configured with an failing directory name " must {
"throw an exception at startup" in {
EventFilter[ActorInitializationException](occurrences = 1).intercept {
val processor = system.actorOf(Props(classOf[TestProcessor], "SnapshotDirectoryFailureSpec-1", testActor))
processor ! "blahonga"
}
}
}
}
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:50,代码来源:SnapshotDirectoryFailureSpec.scala
示例3: MySpec
//设置package包名称以及导入依赖的类
package docs.testkit
//#plain-spec
import akka.actor.ActorSystem
import akka.actor.Actor
import akka.actor.Props
import akka.testkit.{ TestActors, TestKit, ImplicitSender }
import org.scalatest.WordSpecLike
import org.scalatest.Matchers
import org.scalatest.BeforeAndAfterAll
//#implicit-sender
class MySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
with WordSpecLike with Matchers with BeforeAndAfterAll {
//#implicit-sender
def this() = this(ActorSystem("MySpec"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
"An Echo actor" must {
"send back messages unchanged" in {
val echo = system.actorOf(TestActors.echoActorProps)
echo ! "hello world"
expectMsg("hello world")
}
}
}
//#plain-spec
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:34,代码来源:PlainWordSpec.scala
示例4: ControllerSpec
//设置package包名称以及导入依赖的类
package akka.remote.testconductor
import akka.testkit.AkkaSpec
import akka.actor.{ PoisonPill, Props, AddressFromURIString }
import akka.testkit.ImplicitSender
import akka.remote.testconductor.Controller.NodeInfo
import java.net.InetSocketAddress
import java.net.InetAddress
object ControllerSpec {
val config = """
akka.testconductor.barrier-timeout = 5s
akka.actor.provider = akka.remote.RemoteActorRefProvider
akka.actor.debug.fsm = on
akka.actor.debug.lifecycle = on
"""
}
class ControllerSpec extends AkkaSpec(ControllerSpec.config) with ImplicitSender {
val A = RoleName("a")
val B = RoleName("b")
"A Controller" must {
"publish its nodes" in {
val c = system.actorOf(Props(classOf[Controller], 1, new InetSocketAddress(InetAddress.getLocalHost, 0)))
c ! NodeInfo(A, AddressFromURIString("akka://sys"), testActor)
expectMsg(ToClient(Done))
c ! NodeInfo(B, AddressFromURIString("akka://sys"), testActor)
expectMsg(ToClient(Done))
c ! Controller.GetNodes
expectMsgType[Iterable[RoleName]].toSet should be(Set(A, B))
c ! PoisonPill // clean up so network connections don't accumulate during test run
}
}
}
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:40,代码来源:ControllerSpec.scala
示例5: ARouterTestSuite
//设置package包名称以及导入依赖的类
package service.a.core.actors
import akka.testkit.TestKit
import org.scalatest.SpecLike
import akka.testkit.ImplicitSender
import akka.actor.Props
import akka.actor.ActorSystem
class ARouterTestSuite extends TestKit(ActorSystem()) with SpecLike with ImplicitSender {
import ARouter._
object `An ARouter` {
object `when being send a random message` {
def `replies with a "Not yet implemented" message` {
val aRouter = system.actorOf(Props[ARouter])
aRouter ! "Find the answer to everything"
expectMsg("Not yet implemented")
}
}
}
}
开发者ID:kevinkl,项目名称:scalakka,代码行数:23,代码来源:ARouterTestSuite.scala
示例6: WireTransferSpec
//设置package包名称以及导入依赖的类
package akka
import BankAccount.{BankAccount, WireTransfer}
import akka.actor.{ActorSystem, Props}
import akka.testkit.{ImplicitSender, TestKit, TestProbe}
import org.scalatest._
class WireTransferSpec(_system: ActorSystem) extends TestKit(_system)
with FlatSpecLike
with ImplicitSender
with Matchers
with BeforeAndAfterAll {
def this() = this(ActorSystem("WireTransferSpec"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
it should "transfer money from A to B in case of sufficient funds on A" in {
val accountA = TestProbe()
val accountB = TestProbe()
val transfer = system.actorOf(Props[WireTransfer])
transfer ! WireTransfer.Transfer(accountA.ref, accountB.ref, 20)
accountA.expectMsg(BankAccount.Withdraw(20))
accountA.reply(BankAccount.Done)
accountB.expectMsg(BankAccount.Deposit(20))
accountB.reply(BankAccount.Done)
expectMsg(WireTransfer.Done)
}
it should "not transfer money from A to B in case of insufficient funds on A" in {
val accountA = TestProbe()
val accountB = TestProbe()
val transfer = system.actorOf(Props[WireTransfer])
transfer ! WireTransfer.Transfer(accountA.ref, accountB.ref, 20)
accountA.expectMsg(BankAccount.Withdraw(20))
accountA.reply(BankAccount.Failed)
expectMsg(WireTransfer.Failed)
}
}
开发者ID:zsomboracs,项目名称:akka-bankaccount,代码行数:44,代码来源:WireTransferSpec.scala
示例7: BankAccountSpec
//设置package包名称以及导入依赖的类
package akka
import BankAccount.BankAccount
import akka.actor.{ActorRef, ActorSystem, Props}
import akka.testkit.{ImplicitSender, TestKit}
import org.scalatest._
class BankAccountSpec(_system: ActorSystem) extends TestKit(_system)
with FlatSpecLike
with ImplicitSender
with Matchers
with BeforeAndAfterAll {
def this() = this(ActorSystem("BankAccountSpec"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
it should "has 0 balance by default" in {
val bankAccount = system.actorOf(Props[BankAccount])
bankAccount ! BankAccount.GetBalance
expectMsg(BankAccount.Balance(0))
}
it should "has deposit amount as balance" in {
val bankAccount = system.actorOf(Props[BankAccount])
deposit(bankAccount, 10)
bankAccount ! BankAccount.GetBalance
expectMsg(BankAccount.Balance(10))
}
it should "has reduced balance after withdraw in case of sufficient funds" in {
val bankAccount = system.actorOf(Props[BankAccount])
deposit(bankAccount, 10)
bankAccount ! BankAccount.Withdraw(5)
expectMsg(BankAccount.Done)
bankAccount ! BankAccount.GetBalance
expectMsg(BankAccount.Balance(5))
}
it should "should fail withdraw in case of insufficient funds" in {
val bankAccount = system.actorOf(Props[BankAccount])
bankAccount ! BankAccount.Withdraw(5)
expectMsg(BankAccount.Failed)
}
def deposit(bankAccount: ActorRef, amount: Int) = {
bankAccount ! BankAccount.Deposit(amount)
expectMsg(BankAccount.Done)
}
}
开发者ID:zsomboracs,项目名称:akka-bankaccount,代码行数:56,代码来源:BankAccountSpec.scala
示例8: aultPatience
//设置package包名称以及导入依赖的类
import akka.actor.ActorSystem
import akka.stream.{ActorMaterializer, ActorMaterializerSettings, Supervision}
import akka.testkit.{ImplicitSender, TestKit, TestKitBase}
import com.amazonaws.services.sqs.AmazonSQSAsync
import com.taxis99.amazon.sqs.SqsClientFactory
import com.typesafe.config.ConfigFactory
import org.scalatest._
import org.scalatest.concurrent.PatienceConfiguration
import org.scalatest.time._
import scala.concurrent.{ExecutionContext, Future}
package object test {
trait BaseSpec extends FlatSpec with Matchers with OptionValues with PatienceConfiguration with RecoverMethods {
implicit val defaultPatience =
PatienceConfig(timeout = Span(3, Seconds), interval = Span(5, Millis))
}
trait StreamSpec extends AsyncFlatSpec with Matchers with OptionValues with PatienceConfiguration
with TestKitBase with ImplicitSender with BeforeAndAfterAll {
implicit lazy val system: ActorSystem = ActorSystem("test", ConfigFactory.parseString("""
akka.actor.deployment.default.dispatcher = "akka.test.calling-thread-dispatcher"
"""))
override implicit def executionContext: ExecutionContext = system.dispatcher
override implicit def patienceConfig = PatienceConfig(timeout = Span(1, Minute), interval = Span(5, Millis))
val decider: Supervision.Decider = {
case _ => Supervision.Stop
}
val settings = ActorMaterializerSettings(system).withSupervisionStrategy(decider)
implicit lazy val materializer = ActorMaterializer(settings)
def withInMemoryQueue(testCode: (AmazonSQSAsync) => Future[Assertion]): Future[Assertion] = {
val (server, aws) = SqsClientFactory.inMemory(Some(system))
// "loan" the fixture to the test
testCode(aws) andThen {
case _ => server.stopAndWait()
}
}
override def afterAll {
TestKit.shutdownActorSystem(system)
}
}
}
开发者ID:99Taxis,项目名称:common-sqs,代码行数:50,代码来源:package.scala
示例9: ReaperUTest
//设置package包名称以及导入依赖的类
package com.example.util
import akka.actor.{ActorSystem, Props}
import akka.testkit.{ImplicitSender, TestKit, TestProbe}
import com.example.StopSystemAfterAll
import org.scalatest.{FlatSpecLike, ShouldMatchers}
class ReaperUTest
extends TestKit(ActorSystem("testsystem"))
with FlatSpecLike
with ShouldMatchers
with StopSystemAfterAll
with ImplicitSender {
import Reaper._
override def afterAll(): Unit = {
system.shutdown()
super.afterAll()
}
trait ReaperFixture {
val reaper = system.actorOf(Props(new TestReaper(testActor)))
val actor1 = TestProbe()
val actor2 = TestProbe()
val actor3 = TestProbe()
val actor4 = TestProbe()
}
"The Reaper" should "call the allSoulsReaped method after all watched actors are dead" in new ReaperFixture {
reaper ! WatchMe(actor3.ref)
reaper ! WatchMe(actor1.ref)
system.stop(actor1.ref)
system.stop(actor3.ref)
expectMsg("Dead")
}
it should "fail to call the allSoulsReaped method if not all watched actors are dead" in new ReaperFixture {
reaper ! WatchMe(actor3.ref)
reaper ! WatchMe(actor1.ref)
system.stop(actor1.ref)
expectNoMsg()
}
}
开发者ID:shafiquejamal,项目名称:akka-scala-reaper-seed,代码行数:49,代码来源:ReaperUTest.scala
示例10: UnhandledMessageWatcherSpec
//设置package包名称以及导入依赖的类
package com.tpalanga.newsletter.utils
import akka.actor.{Actor, ActorSystem, Props}
import akka.event.Logging.LogEvent
import akka.testkit.{ImplicitSender, TestKit, TestProbe}
import com.tpalanga.newsletter.util.UnhandledMessageWatcher
import org.scalatest.{FlatSpecLike, Matchers}
object UnhandledMessageWatcherSpec {
abstract class Test(implicit system: ActorSystem) {
val watcher = system.actorOf(UnhandledMessageWatcher.props())
val logProbe = TestProbe()
system.eventStream.subscribe(logProbe.ref, classOf[LogEvent])
val destination = system.actorOf(Props(new Actor {
override def receive: Receive = {
case 'Handled =>
}
}))
}
}
class UnhandledMessageWatcherSpec extends TestKit(ActorSystem("UnhandledMessageWatcherSpec")) with FlatSpecLike with Matchers with ImplicitSender {
import UnhandledMessageWatcherSpec._
"UnhandledMessageWatcher" should "log unhandled messages" in new Test {
destination ! 'Unhandled
val event = logProbe.fishForMessage() {
case akka.event.Logging.Error(_, _, _, msg) if msg.toString startsWith "UnhandledMessage:" =>
true
case _ =>
false
}
}
it should "log DeadLetters" in new Test {
system.stop(destination)
Thread.sleep(100)
destination ! 'Handled
val event = logProbe.fishForMessage() {
case akka.event.Logging.Warning(_, _, msg) if msg.toString startsWith "DeadLetter:" =>
true
case _ =>
false
}
}
}
开发者ID:tpalanga,项目名称:akka-http-microservice,代码行数:52,代码来源:UnhandledMessageWatcherSpec.scala
示例11: AmazonFineFoodManagerSpec
//设置package包名称以及导入依赖的类
package com.taintech.aff.actor
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import com.taintech.aff.actor.AmazonFineFoodManager.{Review, ReviewParser}
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, MustMatchers}
class AmazonFineFoodManagerSpec extends TestKit(ActorSystem("test-system"))
with FlatSpecLike
with ImplicitSender
with BeforeAndAfterAll
with MustMatchers {
import AmazonFineFoodManagerSpec._
"ReviewParser" should "parse test line with values test" in {
val rp = new ReviewParser()
rp.parse(testLine) must equal(Review("test3", "test2", "test10"))
}
}
object AmazonFineFoodManagerSpec {
val testLine = "test1,test2,test3,test4,test5,test6,test7,test8,test9,test10"
val mockReview: String => Review = _ => Review("test user", "test product", "test text")
}
开发者ID:taintech,项目名称:AmazonFineFoods,代码行数:29,代码来源:AmazonFineFoodManagerSpec.scala
示例12: GGG
//设置package包名称以及导入依赖的类
package dgl
import akka.actor.ActorSystem
import akka.actor.Props
import akka.testkit.{ TestKit, ImplicitSender }
import dcp.business.actors.HbaseRouter
import org.specs2.mutable.SpecificationLike
case class GGG(msg: String)
case class TestMsg(msggg: GGG)
class TestDcpActor extends TestKit(ActorSystem()) with ImplicitSender with SpecificationLike {
"An Echo actor" should {
"send back messages unchanged" in {
val echo = system.actorOf(Props[HbaseRouter],"echo-actor")
val ggg = GGG("lllllll")
val msg = TestMsg(ggg)
echo ! msg
println("waiting for echo reply from echo actor")
expectMsg(msg)
success
}
}
}
开发者ID:TopSpoofer,项目名称:dcp2.0,代码行数:27,代码来源:TestDcpActor.scala
示例13: UserRepositorySpec
//设置package包名称以及导入依赖的类
package org.cristal.repository
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import akka.util.Timeout
import com.github.t3hnar.bcrypt._
import org.cristal.model.{NewUser, User}
import org.cristal.repository.UserRepository.UserCreated
import org.cristal.repository.dao.UserDAO
import org.mockito.ArgumentMatchers._
import org.mockito.Mockito.when
import org.scalatest.concurrent.Eventually
import org.scalatest.mockito.MockitoSugar
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import scala.concurrent.Future
import scala.concurrent.duration._
class UserRepositorySpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
with WordSpecLike with Matchers with BeforeAndAfterAll with Eventually with MockitoSugar {
implicit val duration: Timeout = 10 seconds
def this() = this(ActorSystem("UserRepositorySpecSystem"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
"An UserRepository Actor" should {
"Create a new user" in {
val userDAO = mock[UserDAO]
val passowod = "my_password"
val encryptedPassword = passowod.bcrypt
when(userDAO.insert(any())).thenReturn(Future.successful(()))
val userRepository = system.actorOf(UserRepository.props(userDAO))
val newUser = NewUser("name", passowod, "[email protected]", "John", "Doe")
userRepository ! UserRepository.CreateUser(newUser, self)
expectMsgPF() {
case UserCreated(User("name", encryptedPassword, "[email protected]", "John", "Doe")) => ()
}
}
}
}
开发者ID:frecano,项目名称:cristal,代码行数:43,代码来源:UserRepositorySpec.scala
示例14: ReviewerActorSpec
//设置package包名称以及导入依赖的类
package io.github.jlprat.akka.http.workshop.bookstore.actor
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import io.github.jlprat.akka.http.workshop.bookstore.model.{Author, Book, Review}
import Review._
import io.github.jlprat.akka.http.workshop.bookstore.actor.ReviewerActor._
import org.scalatest.{BeforeAndAfterAll, FlatSpecLike, Matchers}
class ReviewerActorSpec extends TestKit(ActorSystem("ReviewerActorSpec"))
with ImplicitSender with FlatSpecLike with Matchers with BeforeAndAfterAll {
override def afterAll {
TestKit.shutdownActorSystem(system)
}
"ReviewerActor" should "accept new reviews" in {
val reviewerActor = system.actorOf(ReviewerActor.props)
val book = Book("1234567", "The art of Doe", 321, Author("Jane Doe"))
val review = Review(author = Author("John Doe"), comment = "I liked it", stars = `*****`)
reviewerActor ! AddReview(review, book)
expectMsg(Success)
}
it should "return the reviews for a given book" in {
val reviewerActor = system.actorOf(ReviewerActor.props)
val book = Book("1234567", "The art of Doe", 321, Author("Jane Doe"))
val review = Review(author = Author("John Doe"), comment = "I liked it", stars = `*****`)
reviewerActor ! AddReview(review, book)
expectMsg(Success)
reviewerActor ! ListReviews(book)
expectMsg(Reviews(Seq(review)))
}
it should "return empty reviews if the book has none" in {
val reviewerActor = system.actorOf(ReviewerActor.props)
val book = Book("1234567", "The art of Doe", 321, Author("Jane Doe"))
reviewerActor ! ListReviews(book)
expectMsg(Reviews(Seq.empty))
}
it should "accept and return more than one review per book" in {
val reviewerActor = system.actorOf(ReviewerActor.props)
val book = Book("1234567", "The art of Doe", 321, Author("Jane Doe"))
val review1 = Review(author = Author("John Doe"), comment = "I liked it", stars = `*****`)
val review2 = Review(author = Author("Alice"), comment = "I liked it not", stars = `*`)
reviewerActor ! AddReview(review1, book)
expectMsg(Success)
reviewerActor ! AddReview(review2, book)
expectMsg(Success)
reviewerActor ! ListReviews(book)
expectMsg(Reviews(Seq(review2, review1)))
}
}
开发者ID:jlprat,项目名称:akka-http-workshop,代码行数:55,代码来源:ReviewerActorSpec.scala
示例15: SellerTest
//设置package包名称以及导入依赖的类
package auction_system
import akka.actor.{Props, ActorSystem}
import akka.testkit.{TestProbe, TestFSMRef, ImplicitSender, TestKit}
import auction_system.auction.Auction
import auction_system.auction.Auction.{AuctionEnded, Setup}
import auction_system.auction_search.{MyAuctions, AuctionSearch}
import auction_system.notifier.Notifier
import auction_system.seller.Seller.Initialize
import auction_system.seller.{Active, Uninitialized, Seller}
import org.scalatest.{BeforeAndAfterAll, MustMatchers, WordSpecLike}
class SellerTest (_system: ActorSystem) extends TestKit(_system) with ImplicitSender
with WordSpecLike
with MustMatchers
with BeforeAndAfterAll {
def this() = this(ActorSystem("AuctionSearchTest"))
override def afterAll: Unit = {
system.terminate()
}
"A Seller actor" must {
val seller = TestFSMRef(new Seller)
"start in Uninitialized state" in {
assert(seller.stateName == Uninitialized)
}
val auctionSearcher = TestFSMRef(new AuctionSearch, "auction_search")
val notifier = TestFSMRef(new Notifier, "notifier")
"create and register an auction and switch to Active state" in {
seller ! Initialize(List("a1"), notifier)
assert(seller.stateName == Active)
assert(auctionSearcher.stateData.asInstanceOf[MyAuctions].auctions.head.path.name == "a1")
}
}
"An Auction actor" must {
val seller = TestProbe()
val notifier = TestFSMRef(new Notifier, "notifier")
val auction = seller.childActorOf(Props[Auction])
seller.send(auction, Setup(seller.ref, notifier))
"report the end of an auction afret tieout" in {
seller.expectMsg(AuctionEnded(auction))
}
}
}
开发者ID:pkociepka,项目名称:reactive_scala,代码行数:51,代码来源:SellerTest.scala
示例16:
//设置package包名称以及导入依赖的类
package util
import akka.testkit.{DefaultTimeout, ImplicitSender, TestKitBase}
import core.{Core, CoreActors}
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
trait ActorSpecBase
extends ImplicitSender
with Core
with WordSpecLike
with Matchers
with BeforeAndAfterAll
with AwaitHelper
with DefaultTimeout {
self: TestKitBase =>
}
开发者ID:Lastik,项目名称:money-transfer-sample,代码行数:17,代码来源:ActorSpecBase.scala
示例17: SyncMasterActorSpec
//设置package包名称以及导入依赖的类
package com.example
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit, TestProbe}
import com.example.Orders.{Address, Order, OrderPage}
import com.example.SyncTriggerActor.SyncTrigger
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
class SyncMasterActorSpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
with WordSpecLike with Matchers with BeforeAndAfterAll {
def this() = this(ActorSystem("MySpec"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
"A SyncMasterActor" must {
"sends a page after receiving it" in {
val endProbe = TestProbe()
val mockOrderClient = new MockOrderClient()
val syncMaster = system.actorOf(SyncMasterActor.props(endProbe.ref, mockOrderClient))
syncMaster ! new SyncTrigger()
endProbe.expectMsg(OrderPage(1, List(Order("5704208B-1DED-0DB1-312D-0A0C05E643DB",Address("Pilatuspool 2",Some("Hamburg"), "DE")))))
}
}
}
开发者ID:mduesterhoeft,项目名称:hack16-order-geo-statistics-akka-scala,代码行数:29,代码来源:SyncMasterActorSpec.scala
示例18: LSNodeSpec
//设置package包名称以及导入依赖的类
package csw.services.location.helpers
import akka.remote.testkit.{MultiNodeSpec, MultiNodeSpecCallbacks}
import akka.testkit.ImplicitSender
import csw.services.location.commons.CswCluster
import csw.services.location.scaladsl.{LocationService, LocationServiceFactory}
import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, Matchers}
abstract class LSNodeSpec[T <: NMembersAndSeed](val config: T)
extends MultiNodeSpec(config, config.makeSystem)
with ImplicitSender
with MultiNodeSpecCallbacks
with FunSuiteLike
with Matchers
with BeforeAndAfterAll {
protected val cswCluster: CswCluster = CswCluster.withSystem(system)
protected val locationService: LocationService = LocationServiceFactory.withCluster(cswCluster)
override def initialParticipants: Int = roles.size
override def beforeAll(): Unit = multiNodeSpecBeforeAll()
override def afterAll(): Unit = multiNodeSpecAfterAll()
test("ensure that location service is up for all the nodes") {
locationService.list.await
enterBarrier("cluster-formed")
}
}
开发者ID:tmtsoftware,项目名称:csw-prod,代码行数:32,代码来源:LSNodeSpec.scala
示例19: PingPongActorSpec
//设置package包名称以及导入依赖的类
package com.example
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
class PingPongActorSpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
with WordSpecLike with Matchers with BeforeAndAfterAll {
assert(1 == 1)
def this() = this(ActorSystem("MySpec"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
"A Ping actor" must {
"send back a ping on a pong" in {
val pingActor = system.actorOf(PingActor.props)
pingActor ! PongActor.PongMessage("pong")
expectMsg(PingActor.PingMessage("ping"))
}
}
"A Pong actor" must {
"send back a pong on a ping" in {
val pongActor = system.actorOf(PongActor.props)
pongActor ! PingActor.PingMessage("ping")
expectMsg(PongActor.PongMessage("pong"))
}
}
}
开发者ID:astray1988,项目名称:AkkaExplore,代码行数:35,代码来源:PingPongActorSpec.scala
示例20: JsonFormatSpec
//设置package包名称以及导入依赖的类
package formats
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import formats.JsonFormat._
import models.data.Build
import models.equipments.{Armor, Weapon}
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}
import spray.json._
import DefaultJsonProtocol._
class JsonFormatSpec(_system: ActorSystem) extends TestKit(_system) with ImplicitSender
with WordSpecLike with Matchers with BeforeAndAfterAll {
def this() = this(ActorSystem("JsonFormatSpec"))
override def afterAll {
TestKit.shutdownActorSystem(system)
}
val jsonBuild = """{"_id":"58ac3d110501000501e94126","circleName":"Cleric","stuff":{"rings":[]},"mainStat":{"dex":5,"con":2,"str":1,"spr":4,"int":3},"level":1}""".parseJson
val jsonWeapon = """{"name":"weaponTest","_id":"58ac40493301003301cbe268","basicStat":{"spRecovery":0,"hpRecovery":0,"maximumStamina":20,"hp":0,"sp":0,"maximumCarryWeight":0},"twoHanded":false,"secondary":false,"typeName":"Weapon","defensiveStat":{"magicDefense":0,"evasion":0,"criticalResistance":0,"physicalDefense":0,"block":0,"blockRate":0},"category":"Slash","offensiveStat":{"aoeAttackRatio":0,"physicalAttack":0,"secondaryPhysicalAttack":0,"magicAttack":0,"criticalRate":0,"accuracy":0,"blockPenetration":0,"magicAmplification":0,"criticalAttack":0},"mainStat":{"dex":0,"con":0,"str":0,"spr":0,"int":0},"type":"Sword","primary":true}""".parseJson
val jsonArmor = """{"name":"armorTest","_id":"58ac40df4e01004e01b837af","basicStat":{"spRecovery":0,"hpRecovery":0,"maximumStamina":20,"hp":0,"sp":0,"maximumCarryWeight":0},"typeName":"Armor","defensiveStat":{"magicDefense":0,"evasion":0,"criticalResistance":0,"physicalDefense":0,"block":0,"blockRate":0},"offensiveStat":{"aoeAttackRatio":0,"physicalAttack":0,"secondaryPhysicalAttack":0,"magicAttack":0,"criticalRate":0,"accuracy":0,"blockPenetration":0,"magicAmplification":0,"criticalAttack":0},"mainStat":{"dex":0,"con":0,"str":0,"spr":0,"int":0},"type":"Leather"}""".parseJson
"An object" must {
"be instantiated with json value (Weapon object)" in {
val weapon = WeaponFormat.read(jsonWeapon)
weapon.isInstanceOf[Weapon] should be(true)
}
"be instantiated with json value (Build object)" in {
val build = buildFormat.read(jsonBuild)
build.isInstanceOf[Build] should be (true)
}
"be instantiated with json value (Armor object)" in {
val armor = armorFormat.read(jsonArmor)
armor.isInstanceOf[Armor] should be (true)
}
}
}
开发者ID:tictactoki,项目名称:TosPvp,代码行数:46,代码来源:JsonFormatSpec.scala
注:本文中的akka.testkit.ImplicitSender类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论