本文整理汇总了Scala中org.scalatest.FunSpecLike类的典型用法代码示例。如果您正苦于以下问题:Scala FunSpecLike类的具体用法?Scala FunSpecLike怎么用?Scala FunSpecLike使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FunSpecLike类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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")
}
}
}
}
示例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()
}
}
示例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
}
}
}
}
示例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"))
}
}
}
}
示例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)
}
}
}
示例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 ....")
}
}
}
}
示例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"))
}
}
}
}
示例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"))
}
}
}
}
示例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)
}
}
}
示例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"))
}
}
}
}
示例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"
}
}
}
}
示例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"))
}
}
}
}
示例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)
)
}
}
示例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]]))
}
}
示例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"))
}
}
}
}