本文整理汇总了Scala中org.scalatest.FunSpecLike类的典型用法代码示例。如果您正苦于以下问题:Scala FunSpecLike类的具体用法?Scala FunSpecLike怎么用?Scala FunSpecLike使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FunSpecLike类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: SClientIntegrationSpec
//设置package包名称以及导入依赖的类
import org.scalatest._
import org.scalatest.{FunSpecLike, Matchers}
import scala.concurrent._
import scala.concurrent.duration._
import com.akkademy.SClient
import com.akkademy.messages.KeyNotFoundException
class SClientIntegrationSpec extends FunSpecLike with Matchers {
var client = new SClient("127.0.0.1:2552")
describe("akkademyDb Scala Client") {
describe("set method") {
it("should set a value") {
client.set("123", new Integer(123))
val futureResult = client.get("123")
val result = Await.result(futureResult, 10 seconds)
result should equal(123)
}
}
describe("setIfNotExists method") {
it("should not set a value if it already exists") {
client.setIfNotExists("key", new Integer(123))
client.setIfNotExists("key", new Integer(555))
val futureResult = client.get("key")
val result = Await.result(futureResult, 10 seconds)
result should equal(123)
}
it("should set a value if not exists") {
//trick untill the server is mocked
client.setIfNotExists("newKey", new Integer(555))
val futureResult = client.get("newKey")
val result = Await.result(futureResult, 10 seconds)
result should equal(555)
}
}
describe("delete method") {
it("should delete a key if it exists") {
client.set("123", new Integer(123))
val futureResult = client.delete("123")
val result = Await.result(futureResult, 10 seconds)
result should equal("123")
}
it("should fail with KeyNotFoundException when deleting a key that does not exist") {
val futureResult = client.delete("unknown")
val thrown = intercept[KeyNotFoundException] {
Await.result(futureResult, 10 seconds)
}
thrown.key should equal("unknown")
}
}
}
}
开发者ID:miguelsaddress,项目名称:akkademy-db-client,代码行数:59,代码来源:SClientIntegrationSpec.scala
示例2: ActorSpec
//设置package包名称以及导入依赖的类
package com.github.j5ik2o.reactive.redis
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.testkit.{ ImplicitSender, TestKit }
import akka.util.Timeout
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{ BeforeAndAfterAll, DiagrammedAssertions, FunSpecLike }
import scala.concurrent.duration._
abstract class ActorSpec(_system: ActorSystem)
extends TestKit(_system)
with ImplicitSender
with FunSpecLike
with DiagrammedAssertions
with BeforeAndAfterAll
with TimeFactorSupport
with ScalaFutures {
implicit override val patienceConfig: PatienceConfig = PatienceConfig(15 * timeFactor seconds)
implicit val materializer = ActorMaterializer()
implicit val timeout = Timeout(15 seconds)
override protected def afterAll(): Unit = {
shutdown()
super.beforeAll()
}
}
开发者ID:j5ik2o,项目名称:reactive-redis,代码行数:33,代码来源:ActorSpec.scala
示例3: AkkademyDbSpec
//设置package包名称以及导入依赖的类
import akka.actor.{ActorSystem, Props}
import akka.testkit.TestActorRef
import akka.util.Timeout
import com.example.{AkkademyDb, ScalaPongActor, SetRequest}
import org.scalatest.{FunSpecLike, _}
import scala.concurrent.duration._
class AkkademyDbSpec extends FunSpecLike with Matchers {
implicit val system = ActorSystem()
implicit val timeout = Timeout(5 seconds)
describe("akkademyDb") {
describe("given SetRequest") {
it("should place key/value into your map") {
val actorRef = TestActorRef(new AkkademyDb)
actorRef ! SetRequest("key", "value")
val akkademyDb = actorRef.underlyingActor
akkademyDb.map.get("key") should equal(Some("value"))
}
}
}
}
class ScalaPongActorSpec extends FunSpecLike with Matchers {
implicit val system = ActorSystem()
implicit val timeout = Timeout(5 seconds)
describe("scalaPongActor") {
describe("given Ping") {
it("should return message Pong") {
val actorRef = system.actorOf(Props[ScalaPongActor], "PongFoo")
actorRef ! "ping"
true
}
}
}
}
开发者ID:hanchenyi,项目名称:FirstAkkaProject,代码行数:43,代码来源:AkkademyDbSpec.scala
示例4: AkkademyDbSpec
//设置package包名称以及导入依赖的类
package akkademy.server
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import akka.util.Timeout
import org.scalatest.{FunSpecLike, Matchers}
import scala.concurrent.duration._
class AkkademyDbSpec extends FunSpecLike with Matchers {
implicit val system = ActorSystem()
implicit val timeout = Timeout(5 seconds)
describe("akkademyDb") {
describe("given SetRequest") {
it("should place key/value into map") {
val actorRef: TestActorRef[AkkademyDb] = TestActorRef(new AkkademyDb)
actorRef ! SetRequest("key", "value")
val akkademyDb = actorRef.underlyingActor
akkademyDb.map.get("key") should equal(Some("value"))
}
}
describe("given two SetRequest") {
it("should place two key/value into map") {
val actorRef: TestActorRef[AkkademyDb] = TestActorRef(new AkkademyDb)
actorRef ! SetRequest("key", "value")
actorRef ! SetRequest("name", "vito")
val akkademyDb = actorRef.underlyingActor
akkademyDb.map.get("key") should equal(Some("value"))
akkademyDb.map.get("name") should equal(Some("vito"))
}
}
}
}
开发者ID:is-land,项目名称:examples-akka,代码行数:38,代码来源:AkkademyDbSpec.scala
示例5: ClientIntegrationSpec
//设置package包名称以及导入依赖的类
import com.dbaktor.Client
import org.scalatest.{FunSpecLike, Matchers}
import scala.concurrent.Await
import scala.concurrent.duration._
class ClientIntegrationSpec extends FunSpecLike with Matchers {
val client = new Client("127.0.0.1:2552")
describe("akkademyDbClient") {
it("should set a value"){
client.set("123", new Integer(123))
val futureResult = client.get("123")
val result = Await.result(futureResult, 10 seconds)
println(result)
result should equal(123)
}
}
}
开发者ID:nokeechia,项目名称:dbaktor-client,代码行数:19,代码来源:ClientIntegrationSpec.scala
示例6: AkkadmeyDBSecondTest
//设置package包名称以及导入依赖的类
package com.harmeetsingh13.chapter1
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import com.harmeetsingh13.chapter1.examples.AkkadmeyDBSecond
import com.harmeetsingh13.chapter1.messages.Message
import org.scalatest.{BeforeAndAfterEach, Matchers, FunSpecLike}
class AkkadmeyDBSecondTest extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem();
describe("akkadmey-db-homework-first-test"){
describe("receive-msg-correctly"){
it("should receive message correctly"){
val actorRef = TestActorRef(new AkkadmeyDBSecond)
actorRef ! Message("First Message .... ")
actorRef ! Message("Second Message .... ")
val akkadmeyDb = actorRef.underlyingActor;
akkadmeyDb.messages.apply(0) should equal("First Message ....")
akkadmeyDb.messages.apply(1) should equal("Second Message ....")
}
}
}
}
开发者ID:harmeetsingh0013,项目名称:Akka-practice-using-scala,代码行数:27,代码来源:AkkadmeyDBSecondTest.scala
示例7: AkkadmeyDBFirstTest
//设置package包名称以及导入依赖的类
package com.harmeetsingh13.chapter1
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import com.harmeetsingh13.chapter1.examples.AkkadmeyDBFirst
import com.harmeetsingh13.chapter1.messages.SetRequest
import org.scalatest.{Matchers, FunSpecLike, BeforeAndAfterEach, FunSpec}
import org.scalatest.matchers.Matcher
class AkkadmeyDBFirstTest extends FunSpecLike with Matchers with BeforeAndAfterEach{
implicit val system = ActorSystem()
describe("akkadmey-db-first-test"){
describe("given SetRequest"){
it("should place key/value into map"){
val actorRef = TestActorRef(new AkkadmeyDBFirst)
actorRef ! SetRequest("key", "value")
val akkadmeyDb = actorRef.underlyingActor
akkadmeyDb.map.get("key") should equal (Some("value"))
}
}
}
}
开发者ID:harmeetsingh0013,项目名称:Akka-practice-using-scala,代码行数:25,代码来源:AkkadmeyDBFirstTest.scala
示例8: AcademyDbSpec
//设置package包名称以及导入依赖的类
package com.sunnymix.academydb
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import org.scalatest.{BeforeAndAfterEach, FunSpecLike, Matchers}
import com.sunnymix.academydb.messages._
class AcademyDbSpec extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem()
describe("AcademyDB") {
describe("given SetRequest") {
it("should place key/value to map") {
val actorRef = TestActorRef(new AcademyDB)
val akkademyDb = actorRef.underlyingActor
actorRef ! SetRequest("key", "value")
akkademyDb.map.get("key") should equal(Some("value"))
actorRef ! SetRequest("key", "new value")
akkademyDb.map.get("key") should equal(Some("new value"))
}
}
}
}
开发者ID:sunnymix,项目名称:academydb,代码行数:28,代码来源:AcademyDbSpec.scala
示例9: ClientIntegrationSpec
//设置package包名称以及导入依赖的类
import com.dbaktor.client.Client
import org.scalatest.{FunSpecLike, Matchers}
import scala.concurrent.Await
import scala.concurrent.duration._
class ClientIntegrationSpec extends FunSpecLike with Matchers {
val client = new Client("127.0.0.1:2553")
describe("akkademyDbClient") {
it("should set a value"){
client.set("123", new Integer(123))
val futureResult = client.get("123")
val result = Await.result(futureResult, 10 seconds)
println(result)
result should equal(123)
}
}
}
开发者ID:nokeechia,项目名称:dbaktor,代码行数:19,代码来源:ClientIntegrationSpec.scala
示例10: DbaktorTest
//设置package包名称以及导入依赖的类
package com.dbaktor.actors
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import com.dbaktor.messages.SetRequest
import org.scalatest.{BeforeAndAfterEach, FunSpecLike, Matchers}
class DbaktorTest extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem()
describe("dbaktor") {
describe("given SetRequest"){
it("should place key/value into map"){
val actorRef = TestActorRef(new Dbaktor)
actorRef ! SetRequest("key", "value")
val akkademyDb = actorRef.underlyingActor
akkademyDb.map.get("key") should equal(Some("value"))
}
}
}
}
开发者ID:nokeechia,项目名称:dbaktor,代码行数:23,代码来源:DbaktorTest.scala
示例11: LastStringTest
//设置package包名称以及导入依赖的类
package com.dbaktor.actors
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import org.scalatest.{BeforeAndAfterEach, FunSpecLike, Matchers}
class LastStringTest extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem()
describe("dbaktor") {
describe("given SetRequest"){
it("should place key/value into map"){
val actorRef = TestActorRef(new LastString)
actorRef ! "This is NOT the last string"
actorRef ! "This is the last string"
val akkademyDb = actorRef.underlyingActor
akkademyDb.lastString shouldBe "This is the last string"
}
}
}
}
开发者ID:nokeechia,项目名称:dbaktor,代码行数:23,代码来源:LastStringTest.scala
示例12: AkkaDbSpec
//设置package包名称以及导入依赖的类
package com.akkademy
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import org.scalatest.{BeforeAndAfterEach, FunSpecLike, Matchers}
class AkkaDbSpec extends FunSpecLike with Matchers with
BeforeAndAfterEach {
implicit val system = ActorSystem()
describe("akkademyDb") {
describe("given SetRequest") {
it("should place key/value into map") {
val actorRef = TestActorRef(new AkkaDb)
actorRef ! SetRequest("key", "value")
val akkademyDb = actorRef.underlyingActor
akkademyDb.map.get("key") should equal(Some("value"))
}
}
}
}
开发者ID:oneraghavan,项目名称:akka-db,代码行数:21,代码来源:AkkaDbSpec.scala
示例13: EventStreamerSpec
//设置package包名称以及导入依赖的类
package io.hydrosphere.mist.master
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Sink
import akka.testkit.TestKit
import io.hydrosphere.mist.Messages.StatusMessages.StartedEvent
import org.scalatest.{FunSpecLike, Matchers}
import scala.concurrent.Await
import scala.concurrent.duration.Duration
class EventStreamerSpec extends TestKit(ActorSystem("streamer"))
with FunSpecLike
with Matchers {
implicit val materializer = ActorMaterializer()
it("should broadcast events") {
val streamer = EventsStreamer(system)
val f = streamer.eventsSource()
.take(2)
.runWith(Sink.seq)
streamer.push(StartedEvent("1", 1))
streamer.push(StartedEvent("2", 1))
streamer.push(StartedEvent("3", 1))
val events = Await.result(f, Duration.Inf)
events should contain allOf (
StartedEvent("1", 1),
StartedEvent("2", 1)
)
}
}
开发者ID:Hydrospheredata,项目名称:mist,代码行数:38,代码来源:EventStreamerSpec.scala
示例14: LogStreamsSpec
//设置package包名称以及导入依赖的类
package io.hydrosphere.mist.master.logging
import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Keep, Sink, Source}
import akka.testkit.TestKit
import io.hydrosphere.mist.api.logging.MistLogging.LogEvent
import org.scalatest.{FunSpecLike, Matchers}
import org.mockito.Mockito._
import org.mockito.Matchers._
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
class LogStreamsSpec extends TestKit(ActorSystem("log-service-test"))
with FunSpecLike
with Matchers {
implicit val materializer = ActorMaterializer()
it("should store events") {
val writer = mock(classOf[LogsWriter])
when(writer.write(any(classOf[String]), any(classOf[Seq[LogEvent]])))
.thenReturn(Future.successful(LogUpdate("jobId", Seq.empty, 1)))
val out = Source.single(LogEvent.mkDebug("id", "message"))
.via(LogStreams.storeFlow(writer))
.take(1)
.toMat(Sink.seq)(Keep.right).run()
val updates = Await.result(out, Duration.Inf)
updates.size shouldBe 1
verify(writer).write(any(classOf[String]), any(classOf[Seq[LogEvent]]))
}
}
开发者ID:Hydrospheredata,项目名称:mist,代码行数:38,代码来源:LogStreamsSpec.scala
示例15: AkkademyDbSpec
//设置package包名称以及导入依赖的类
package akkademy
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import org.scalatest.{BeforeAndAfterEach, FunSpecLike, Matchers}
import akkademy.messages.SetRequest
class AkkademyDbSpec extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem()
describe("akkademyDb") {
describe("given SetRequest") {
it("should place key/value into map") {
val actorRef = TestActorRef(new AkkademyDb)
actorRef ! SetRequest("key", "value")
val akkademyDb = actorRef.underlyingActor
akkademyDb.map.get("key") should equal(Some("value"))
}
}
}
}
开发者ID:bahadley,项目名称:learning-akka,代码行数:23,代码来源:AkkademyDbSpec.scala
示例16: StickyStringSpec
//设置package包名称以及导入依赖的类
package stickyString
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import org.scalatest.{BeforeAndAfterEach, FunSpecLike, Matchers}
class StickyStringSpec extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem()
val msgs = Vector("foo", "bar")
describe("store last string message") {
describe("send one string") {
it("should store the string") {
val actor = TestActorRef(new StickyString)
actor ! msgs.head
actor.underlyingActor.lastString should equal(Some(msgs.head))
}
}
describe("send two strings") {
it("should store the last string") {
val actor = TestActorRef(new StickyString)
msgs.foreach {m => actor ! m}
actor.underlyingActor.lastString should equal(Some(msgs.last))
}
}
}
}
开发者ID:bahadley,项目名称:learning-akka,代码行数:31,代码来源:StickyStringSpec.scala
示例17: Rabbit
//设置package包名称以及导入依赖的类
package com.katapal.actor.test
import akka.actor.{Actor, ActorRef, ActorSystem, Props}
import akka.pattern._
import akka.testkit.{TestActorRef, TestKit}
import akka.util.Timeout
import com.katapal.actor.deferResolvePath
import org.scalatest.{BeforeAndAfterAll, FunSpecLike, Matchers}
import scala.concurrent.Await
import scala.concurrent.duration._
class Rabbit extends Actor {
def receive: Receive = {
case addr: String =>
val child = context.actorOf(Props[Rabbit], addr)
sender() ! child
}
}
class PackageSpec(system: ActorSystem) extends TestKit(system) with FunSpecLike
with BeforeAndAfterAll with Matchers {
private implicit val timeout = Timeout(1.minute)
implicit val ec = system.dispatcher
implicit val s = system
def this() = this(ActorSystem("contract-actor-test-system"))
override def afterAll {
shutdown(system)
}
describe("The Actor package") {
it("should resolve child path") {
val actorRef = TestActorRef[Rabbit]
Await.result(deferResolvePath(actorRef.path, 10, 1.millis), 100.millis) should === (actorRef)
}
it("should resolve child path with delay") {
val actorRef = TestActorRef[Rabbit]
val path = actorRef.path / "bugs"
val fut = deferResolvePath(path, 5, 1000.millis)
Thread.sleep(500)
val childRef = Await.result(actorRef ? "bugs", 100.millis).asInstanceOf[ActorRef]
Await.result(fut, 5.seconds) should === (childRef)
}
}
}
开发者ID:dxiao2003,项目名称:contract-actor,代码行数:54,代码来源:PackageSpec.scala
示例18: DakkabaseDbSpec
//设置package包名称以及导入依赖的类
import com.dazito.scala.dakkabase.messages.SetRequest
import org.scalatest.{BeforeAndAfterEach, Matchers, FunSpecLike}
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import com.dazito.scala.dakkabase.DakkabaseDb
class DakkabaseDbSpec extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem()
describe("Given SetRequest") {
it("Should place key/value into map") {
val actorRef = TestActorRef(new DakkabaseDb)
actorRef ! SetRequest("key", "value")
val dakkabaseDb = actorRef.underlyingActor
dakkabaseDb.map.get("key") should equal(Some("value"))
}
}
}
开发者ID:dazito,项目名称:LearningAkkaScalaServer,代码行数:21,代码来源:DakkabaseDbSpec.scala
示例19: SimpleActorTest
//设置package包名称以及导入依赖的类
package com.zoaks.learnakka
import akka.actor.ActorSystem
import akka.testkit.TestActorRef
import org.scalatest.{BeforeAndAfterEach, FunSpecLike, Matchers}
class SimpleActorTest extends FunSpecLike with Matchers with BeforeAndAfterEach {
implicit val system = ActorSystem()
describe("akkajz") {
describe("given message") {
it("should place the message on the lstString field") {
val msg = "Hello, Actor."
val actorRef = TestActorRef(new SimpleActor)
actorRef ! msg
actorRef.underlyingActor.lstString should equal(msg)
}
}
describe("given two messages") {
it("should place the last message on the lstString field") {
val msg1 = "hello, Actor"
val msg2 = "hello, Actor again"
val actorRef = TestActorRef(new SimpleActor)
actorRef ! msg1
actorRef ! msg2
actorRef.underlyingActor.lstString should equal(msg2)
actorRef ! 1
}
}
}
}
开发者ID:jackzhou,项目名称:AkkaJZ,代码行数:36,代码来源:SimpleActorTest.scala
示例20: SearchHistoryActorTest
//设置package包名称以及导入依赖的类
package googlesearch.actors
import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import googlesearch.actors.SearchHistoryActor._
import org.scalatest.{BeforeAndAfterAll, FunSpecLike}
class SearchHistoryActorTest
extends TestKit(ActorSystem("SearchHistoryActorTest")) with ImplicitSender
with FunSpecLike with BeforeAndAfterAll {
describe("SearchHistoryActor") {
describe("String storing") {
it("should acknowledge string storing") {
val actor = system.actorOf(props)
actor ! RememberString("0", "foo")
expectMsg(AcknowledgeRemembering("0"))
}
}
describe("History requesting") {
it("should restore one remembered string") {
val actor = system.actorOf(props)
actor ! RememberString("0", "foo")
expectMsg(AcknowledgeRemembering("0"))
actor ! Remind("1")
expectMsg(Remembered("1", Seq("foo")))
}
it("should preserve order of memoization") {
val actor = system.actorOf(props)
actor ! RememberString("0", "foo1")
actor ! RememberString("1", "foo2")
expectMsg(AcknowledgeRemembering("0"))
expectMsg(AcknowledgeRemembering("1"))
actor ! Remind("3")
expectMsg(Remembered("3", Seq("foo1", "foo2")))
}
it("should respond with empty list if no strings stored") {
val actor = system.actorOf(props)
actor ! Remind("0")
expectMsg(Remembered("0", Seq.empty))
}
}
}
override protected def afterAll() {
shutdown()
}
}
开发者ID:chikh,项目名称:google-search-history,代码行数:58,代码来源:SearchHistoryActorTest.scala
注:本文中的org.scalatest.FunSpecLike类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论