• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala FunSuiteLike类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中org.scalatest.FunSuiteLike的典型用法代码示例。如果您正苦于以下问题:Scala FunSuiteLike类的具体用法?Scala FunSuiteLike怎么用?Scala FunSuiteLike使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FunSuiteLike类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: PortMappingTest

//设置package包名称以及导入依赖的类
package mesosphere.marathon
package state

import com.wix.accord._
import mesosphere.marathon.state.Container.PortMapping
import org.scalatest.{ FunSuiteLike, Matchers }

class PortMappingTest extends FunSuiteLike with Matchers {
  import mesosphere.marathon.state.Container.PortMapping.portMappingValidator

  test("valid portMapping should be valid") {
    validate(Fixture.validPortMapping) should be(Success)
  }

  test("valid portMapping with no name should be valid") {
    validate(Fixture.validPortMapping.copy(name = None)) should be(Success)
  }

  test("portMapping with invalid name should be invalid") {
    validate(Fixture.validPortMapping.copy(name = Some("[email protected]?"))).isFailure should be(true)
  }

  test("portMapping with invalid protocol is invalid") {
    validate(Fixture.validPortMapping.copy(protocol = "icmp")).isFailure should be(true)
  }

  test("portMapping with invalid port is invalid") {
    validate(Fixture.validPortMapping.copy(hostPort = Some(-1))).isFailure should be(true)
    validate(Fixture.validPortMapping.copy(containerPort = -1)).isFailure should be(true)
  }

  test("portMapping without hostport may be valid") {
    validate(Fixture.validPortMapping.copy(hostPort = None)) should be (Success)
  }

  test("portMapping with zero hostport is valid") {
    validate(Fixture.validPortMapping.copy(hostPort = Some(0))) should be (Success)
  }

  object Fixture {
    val validPortMapping = PortMapping(
      hostPort = Some(80),
      containerPort = 80,
      protocol = "tcp",
      name = Some("http-port"),
      labels = Map("foo" -> "bar"))
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:49,代码来源:PortMappingTest.scala


示例2: PortDefinitionTest

//设置package包名称以及导入依赖的类
package mesosphere.marathon.state

import com.wix.accord._
import org.scalatest.{ FunSuiteLike, Matchers }

class PortDefinitionTest extends FunSuiteLike with Matchers {
  test("valid portDefinition should be valid") {
    validate(Fixture.validPortDefinition) should be(Success)
  }

  test("portDefinition with tcp and udp should be valid") {
    validate(Fixture.tcpUdpPortDefinition) should be(Success)
  }

  test("valid portDefinition with no name should be valid") {
    validate(Fixture.validPortDefinition.copy(name = None)) should be(Success)
  }

  test("portDefinition with invalid name should be invalid") {
    validate(Fixture.validPortDefinition.copy(name = Some("[email protected]?"))).isFailure should be(true)
  }

  test("portDefinition with invalid protocol is invalid") {
    validate(Fixture.validPortDefinition.copy(protocol = "icmp")).isFailure should be(true)
  }

  test("portDefinition with invalid port is invalid") {
    validate(Fixture.validPortDefinition.copy(port = -1)).isFailure should be(true)
  }

  object Fixture {
    val validPortDefinition = PortDefinition(
      port = 80,
      protocol = "tcp",
      name = Some("http-port"),
      labels = Map("foo" -> "bar"))

    val tcpUdpPortDefinition = PortDefinition(
      port = 80,
      protocol = "udp,tcp",
      name = Some("http-port"),
      labels = Map("foo" -> "bar"))
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:45,代码来源:PortDefinitionTest.scala


示例3: StopActorTest

//设置package包名称以及导入依赖的类
package mesosphere.marathon.upgrade

import akka.actor.{ ActorRef, Props }
import akka.testkit.TestActor.{ AutoPilot, NoAutoPilot }
import akka.testkit.TestProbe
import mesosphere.marathon.test.MarathonActorSupport
import mesosphere.marathon.upgrade.DeploymentActor.Cancel
import org.scalatest.{ FunSuiteLike, Matchers }

import scala.concurrent.duration._
import scala.concurrent.{ Await, Promise }

class StopActorTest extends MarathonActorSupport with FunSuiteLike with Matchers {

  test("Stop") {
    val promise = Promise[Boolean]()
    val probe = TestProbe()

    probe.setAutoPilot(new AutoPilot {
      def run(sender: ActorRef, msg: Any): AutoPilot = msg match {
        case Cancel(reason) =>
          system.stop(probe.ref)
          NoAutoPilot
      }
    })
    val ref = system.actorOf(Props(classOf[StopActor], probe.ref, promise, new Exception))

    watch(ref)
    expectTerminated(ref)

    Await.result(promise.future, 5.seconds) should be(true)
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:34,代码来源:StopActorTest.scala


示例4: 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


示例5: MyActor

//设置package包名称以及导入依赖的类
package csw.services.logging.compat

import akka.actor.{Actor, ActorLogging, Props}
import csw.services.logging.commons.LoggingKeys
import csw.services.logging.internal.LoggingLevels
import csw.services.logging.internal.LoggingLevels.Level
import csw.services.logging.utils.LoggingTestSuite
import org.scalatest.{FunSuiteLike, Matchers}

class MyActor extends Actor with ActorLogging {
  val exception = new RuntimeException("Exception occurred")

  def receive = {
    case "info"  ? log.info("info")
    case "debug" ? log.debug("debug")
    case "warn"  ? log.warning("warn")
    case "error" ? log.error(exception, "error")
  }
}

class AkkaLoggerTest extends LoggingTestSuite with FunSuiteLike with Matchers {

  test("logging framework should capture akka log messages and log it") {
    val actorRef  = actorSystem.actorOf(Props(new MyActor()), "my-actor")
    val className = classOf[MyActor].getName

    actorRef ! "info"
    actorRef ! "debug"
    actorRef ! "warn"
    actorRef ! "error"

    Thread.sleep(300)

    logBuffer.foreach { log ?
      log.contains(LoggingKeys.COMPONENT_NAME) shouldBe false

      log.contains(LoggingKeys.SEVERITY) shouldBe true
      val currentLogLevel = log(LoggingKeys.SEVERITY).toString.toLowerCase
      Level(currentLogLevel) >= LoggingLevels.INFO shouldBe true

      log(LoggingKeys.MESSAGE) shouldBe currentLogLevel
      log(LoggingKeys.ACTOR) shouldBe actorRef.path.toString
      log(LoggingKeys.CLASS) shouldBe className
      log(LoggingKeys.KIND) shouldBe "akka"
    }

  }

} 
开发者ID:tmtsoftware,项目名称:csw-prod,代码行数:50,代码来源:AkkaLoggerTest.scala


示例6: CardSpec

//设置package包名称以及导入依赖的类
import org.scalatest.{FunSuiteLike, Matchers}

class CardSpec extends FunSuiteLike with Matchers {
  test("ace of spades") {
    val card = Card(12)
    card.suit should be(0)
    card.rank should be(12)
    card.english should be("Spade Ace")
  }

  test("king of hearts") {
    val card = Card(24)
    card.suit should be(1)
    card.rank should be(11)
    card.english should be("Heart King")
  }

  test("queen of diamonds") {
    val card = Card(36)
    card.suit should be(2)
    card.rank should be(10)
    card.english should be("Diamond Queen")
  }

  test("jack of clubs") {
    val card = Card(48)
    card.suit should be(3)
    card.rank should be(9)
    card.english should be("Club Jack")
  }

  test("sortable") {
    Seq(42,13).map(Card(_)).sorted should be(Seq(Card(13), Card(42)))
  }
} 
开发者ID:sokrahta,项目名称:tacoma-narrows,代码行数:36,代码来源:CardSpec.scala


示例7: DistributedSourceWorkerSpec

//设置package包名称以及导入依赖的类
package aecor.tests

import akka.actor.ActorSystem
import akka.stream.OverflowStrategy
import akka.stream.scaladsl.Source
import akka.testkit.TestKit
import com.typesafe.config.{ Config, ConfigFactory }
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{ BeforeAndAfterAll, FunSuiteLike, Matchers }

import scala.concurrent.duration._

object DistributedSourceWorkerSpec {
  def conf: Config = ConfigFactory.parseString(s"""
        cluster.system-name=test
        akka.persistence.journal.plugin=akka.persistence.journal.inmem
        akka.persistence.snapshot-store.plugin=akka.persistence.no-snapshot-store
        aecor.akka-runtime.idle-timeout = 1s
        cluster.seed-nodes = ["akka://[email protected]:51000"]
     """).withFallback(ConfigFactory.load())
}

class DistributedSourceWorkerSpec
    extends TestKit(ActorSystem("test", ShardedRuntimeSpec.conf))
    with FunSuiteLike
    with Matchers
    with ScalaFutures
    with BeforeAndAfterAll {

  override implicit val patienceConfig = PatienceConfig(15.seconds, 150.millis)

  override def afterAll: Unit =
    TestKit.shutdownActorSystem(system)

  val sink = Source.queue(10, OverflowStrategy.backpressure)

} 
开发者ID:notxcain,项目名称:aecor,代码行数:38,代码来源:DistributedSourceWorkerSpec.scala


示例8: SerialManagerSpec

//设置package包名称以及导入依赖的类
package com.github.akileev.akka.serial.io

import akka.actor.ActorSystem
import akka.io._
import akka.testkit._
import com.github.akileev.akka.serial.io.Serial._
import org.scalatest.{BeforeAndAfterAll, FunSuiteLike}

import scala.concurrent.Await
import scala.concurrent.duration.Duration

class SerialManagerSpec extends TestKit(ActorSystem("SerialManagerSpec"))
  with FunSuiteLike
  with BeforeAndAfterAll
  with ImplicitSender {

  override def afterAll = {
    val whenTerminated = system.terminate()
    Await.result(whenTerminated, Duration.Inf)
  }

  test("list ports") {
    IO(Serial) ! ListPorts
    val Ports(ports) = expectMsgType[Ports]
    println("Found serial ports: " + ports.mkString(", "))
  }
} 
开发者ID:akileev,项目名称:akka-serial-io,代码行数:28,代码来源:SerialManagerSpec.scala


示例9: test

//设置package包名称以及导入依赖的类
package io.iohk.ethereum.vm

import org.scalatest.FunSuiteLike


trait OpCodeTesting extends FunSuiteLike {

  val config: EvmConfig

  lazy val unaryOps = config.opCodes.collect { case op: UnaryOp => op }
  lazy val binaryOps = config.opCodes.collect { case op: BinaryOp => op }
  lazy val ternaryOps = config.opCodes.collect { case op: TernaryOp => op }
  lazy val constOps = config.opCodes.collect { case op: ConstOp => op }
  lazy val pushOps = config.opCodes.collect { case op: PushOp => op }
  lazy val dupOps = config.opCodes.collect { case op: DupOp => op }
  lazy val swapOps = config.opCodes.collect { case op: SwapOp => op }
  lazy val logOps = config.opCodes.collect { case op: LogOp => op }
  lazy val constGasOps = config.opCodes.collect { case op: ConstGas if op != INVALID => op }

  def test[T <: OpCode](ops: T*)(f: T => Any): Unit =
    ops.foreach(op => test(op.toString)(f(op)))

  def ignore[T <: OpCode](ops: T*)(f: T => Any): Unit =
    ops.foreach(op => ignore(op.toString)(f(op)))

  
  def verifyAllOpCodesRegistered(except: OpCode*): Unit = {
    test("all opcodes have been registered") {
      val untested = config.opCodes.filterNot(op => testNames(op.toString)).diff(except)
      if (untested.isEmpty)
        succeed
      else
        fail("Unregistered opcodes: " + untested.mkString(", "))
    }
  }
} 
开发者ID:input-output-hk,项目名称:etc-client,代码行数:37,代码来源:OpCodeTesting.scala


示例10: genDateTimeFromSameOffsetPeriod

//设置package包名称以及导入依赖的类
package dtc.tests

import java.time.temporal.ChronoField
import java.time.temporal.ChronoUnit._
import java.time.{Duration, LocalDate, LocalTime}

import dtc.TimeZoneId
import org.scalacheck.{Arbitrary, Gen}
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.{FunSuiteLike, Matchers}
import org.typelevel.discipline.scalatest.Discipline

trait DTCSuite extends FunSuiteLike
  with Matchers
  with GeneratorDrivenPropertyChecks
  with Discipline {


  override implicit val generatorDrivenConfig: PropertyCheckConfiguration = PropertyCheckConfiguration(
    minSuccessful = 100
  )
  private val nanoOfDayRange = ChronoField.NANO_OF_DAY.range()

  val genLocalTime: Gen[LocalTime] =
    Gen.choose(nanoOfDayRange.getMinimum, nanoOfDayRange.getMaximum).map(LocalTime.ofNanoOfDay)
  implicit val arbLocalTime: Arbitrary[LocalTime] = Arbitrary(genLocalTime)

  val genDuration: Gen[Duration] =
    Gen.choose(Long.MinValue / 1000, Long.MaxValue / 1000)
      .map(l => Duration.of(l, MILLIS))

  implicit val arbDuration = Arbitrary(genDuration)

  def genDateTimeFromSameOffsetPeriod(period: SameZoneOffsetPeriod): Gen[(LocalDate, LocalTime, TimeZoneId)] = for {
    date <- Gen.choose(period.startDate.toEpochDay + 1L, period.endDate.toEpochDay - 1L).map(LocalDate.ofEpochDay)
    timeBounds <- Gen.const(
      if (date == period.startDate && date == period.endDate) (period.startTime, period.endTime)
      else if (date == period.startDate) (period.startTime, LocalTime.MAX)
      else if (date == period.endDate) (LocalTime.MAX, period.endTime)
      else (LocalTime.MIN, LocalTime.MAX)
    )
    time <- Gen.choose(timeBounds._1.toNanoOfDay, timeBounds._2.toNanoOfDay).map(LocalTime.ofNanoOfDay)
  } yield (date, time, period.zone)
} 
开发者ID:vpavkin,项目名称:dtc,代码行数:45,代码来源:DTCSuite.scala


示例11: PaymentHandlerSpec

//设置package包名称以及导入依赖的类
package fr.acinq.eclair.payment

import akka.actor.ActorSystem
import akka.actor.Status.Failure
import akka.testkit.{TestKit, TestProbe}
import fr.acinq.bitcoin.MilliSatoshi
import fr.acinq.eclair.TestConstants.Alice
import fr.acinq.eclair.channel.CMD_FULFILL_HTLC
import fr.acinq.eclair.wire.UpdateAddHtlc
import org.junit.runner.RunWith
import org.scalatest.FunSuiteLike
import org.scalatest.junit.JUnitRunner


@RunWith(classOf[JUnitRunner])
class PaymentHandlerSpec extends TestKit(ActorSystem("test")) with FunSuiteLike {

  test("LocalPaymentHandler should send an event when receiving a payment") {
    val handler = system.actorOf(LocalPaymentHandler.props(Alice.nodeParams))
    val sender = TestProbe()
    val eventListener = TestProbe()
    system.eventStream.subscribe(eventListener.ref, classOf[PaymentReceived])

    val amountMsat = MilliSatoshi(42000)
    sender.send(handler, ReceivePayment(amountMsat))
    val pr = sender.expectMsgType[PaymentRequest]

    val add = UpdateAddHtlc("11" * 32, 0, amountMsat.amount, 0, pr.paymentHash, "")
    sender.send(handler, add)
    sender.expectMsgType[CMD_FULFILL_HTLC]
    eventListener.expectMsg(PaymentReceived(amountMsat, add.paymentHash))
  }

  test("Payment request generation should fail when the amount asked in not valid") {
    val handler = system.actorOf(LocalPaymentHandler.props(Alice.nodeParams))
    val sender = TestProbe()
    val eventListener = TestProbe()
    system.eventStream.subscribe(eventListener.ref, classOf[PaymentReceived])

    // negative amount should fail
    sender.send(handler, ReceivePayment(MilliSatoshi(-50)))
    val negativeError = sender.expectMsgType[Failure]
    assert(negativeError.cause.getMessage.contains("amount is not valid"))

    // amount = 0 should fail
    sender.send(handler, ReceivePayment(MilliSatoshi(0)))
    val zeroError = sender.expectMsgType[Failure]
    assert(zeroError.cause.getMessage.contains("amount is not valid"))

    // large amount should fail (> 42.95 mBTC)
    sender.send(handler, ReceivePayment(MilliSatoshi(PaymentRequest.maxAmountMsat + 10)))
    val largeAmountError = sender.expectMsgType[Failure]
    assert(largeAmountError.cause.getMessage.contains("amount is not valid"))

    // success with 1 mBTC
    sender.send(handler, ReceivePayment(MilliSatoshi(100000000L)))
    val pr = sender.expectMsgType[PaymentRequest]
    assert(pr.amount.amount == 100000000L
      && pr.nodeId.toString == Alice.nodeParams.privateKey.publicKey.toString)
  }
} 
开发者ID:viacoin,项目名称:eclair,代码行数:62,代码来源:PaymentHandlerSpec.scala


示例12: RepositoryDataStoreFactoryTest

//设置package包名称以及导入依赖的类
package services

import com.google.api.client.auth.oauth2.StoredCredential
import common._
import org.scalatest.FunSuiteLike
import org.specs2.mock.Mockito

import scala.concurrent.ExecutionContext

class RepositoryDataStoreFactoryTest extends FunSuiteLike with Mockito {
  test("store credentials while refreshing access token") {
    val repository = mock[Repository]
    val credentialDataStore = new RepositoryDataStoreFactory(repository, ExecutionContext.global).createStoredCredentialDataStore("id")
    val accountId = "[email protected]"

    val credential = new StoredCredential
    credential.setAccessToken(null)
    credential.setRefreshToken("fakeRefreshToken")
    credential.setExpirationTimeMilliseconds(null)

    repository.updateAccessToken(any, any, any) returns fs(())
    credentialDataStore.set(accountId, credential)
    there was one(repository).updateAccessToken(accountId, null, null)
  }
} 
开发者ID:phdezann,项目名称:connectus,代码行数:26,代码来源:RepositoryDataStoreFactoryTest.scala


示例13: UserActionActorIntegrationTest

//设置package包名称以及导入依赖的类
package com.mz.training.actions

import akka.actor.{ActorSystem, PoisonPill, Props}
import akka.pattern._
import akka.testkit.{ImplicitSender, TestKit}
import com.mz.training.common.supervisors.DataSourceSupervisorActor
import com.mz.training.domains.address.Address
import com.mz.training.domains.user.User
import com.mz.training.domains.user.UserServiceActor.RegistrateUser
import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, Matchers}

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.language.postfixOps


class UserActionActorIntegrationTest extends TestKit(ActorSystem("test-jdbc-demo-UserActionActorTest"))
with FunSuiteLike
with BeforeAndAfterAll
with Matchers
with ImplicitSender {

  implicit val timeOut: akka.util.Timeout = 10000.millisecond

  val dataSourceSupervisor = system.actorOf(DataSourceSupervisorActor.props, DataSourceSupervisorActor.actorName)

  test("Registrate user") {
    val futures =
      for (i <- 1 to 20) yield {
        Thread sleep 0
        val userAction = system.actorOf(Props[UserActionActor])
        userAction ? RegistrateUser(User(0, "FirstNameTest_" + i, "LastNameTest_" + i, None, None),
          Address(0, "test_" + i, "82109", "9A" + i, "testCity_" + i))
      }

    for {future <- futures} yield Await.result(future, 1 minutes)

  }

  test("Parent acotr stop") {
    val userAction = system.actorOf(Props[UserActionActor])
    userAction ! PoisonPill
    expectNoMsg(200 microseconds)
    userAction ! RegistrateUser(User(0, "FirstNameTest", "LastNameTest", None, None)
      ,Address(0, "test", "82109", "9A", "testCity"))
    expectNoMsg(5 seconds)
  }

  override protected def afterAll(): Unit = {
    system.shutdown()
  }
} 
开发者ID:michalzeman,项目名称:angular2-training,代码行数:53,代码来源:UserActionActorIntegrationTest.scala


示例14: DataSourceActorTest

//设置package包名称以及导入依赖的类
package com.mz.training.jdbc

import akka.actor.ActorSystem
import akka.testkit.{ImplicitSender, TestKit}
import com.mz.training.common.factories.jdbc.DataSourceActorFactory
import com.mz.training.common.jdbc.DataSourceActor.{ConnectionResult, GetConnection}
import com.mz.training.common.supervisors.DataSourceSupervisorActor
import org.scalatest.{BeforeAndAfterAll, FunSuiteLike, Matchers}

import scala.concurrent.duration._


class DataSourceActorTest extends TestKit(ActorSystem("test-jdbc-demo-DataSourceActorTest"))
with FunSuiteLike
with BeforeAndAfterAll
with Matchers
with ImplicitSender
with DataSourceActorFactory {

  implicit val timeOut: akka.util.Timeout = 2000.millisecond

  override protected def afterAll(): Unit = {
    system.shutdown()
  }

  test("init dataSource") {
    val dataSourceSupervisor = system.actorOf(DataSourceSupervisorActor.props, DataSourceSupervisorActor.actorName)
    selectDataSourceActor(system) ! GetConnection
    expectMsgType[ConnectionResult](5 seconds)
  }
} 
开发者ID:michalzeman,项目名称:angular2-training,代码行数:32,代码来源:DataSourceActorTest.scala


示例15: ProxyServletTest

//设置package包名称以及导入依赖的类
package web



import org.scalatest.FunSuiteLike
import org.scalatra.test.scalatest.ScalatraSuite


class ProxyServletTest extends ScalatraSuite with FunSuiteLike {
  val model = new ProxyModel(EndpointInfo.makeFromStrings(List("http://foo.bar", "http://bar.foo")))
  addServlet(new FixtureServlet, "/fixtures/*")
  addServlet(new ProxyServlet(model), "/proxy/*")

  test("get fixtures status") {
    get("/fixtures/status") {
      status should equal(200)
      JsonDecode.decodeStatus(body).status should include("OK!")
    }

  }

  test("get proxy status") {
    get("/proxy/status") {
      status should equal(200)
      JsonDecode.decodeStatus(body).status should include("OK!")
    }
  }

  test("get foo") {
    get("/proxy/status") {
      status should equal(200)
    }
  }


  test("build model from fixtures content") {
    get("/fixtures/foo") {
      ProxyModel(JsonDecode.decodeEndpointInfoList(body))
    }
  }
} 
开发者ID:salimfadhley,项目名称:funproxy,代码行数:42,代码来源:ProxyServletTest.scala


示例16: ProxyServletTestWithActualData

//设置package包名称以及导入依赖的类
package web

import org.scalatest.FunSuiteLike
import org.scalatra.test.scalatest.ScalatraSuite

class ProxyServletTestWithActualData extends ScalatraSuite with FunSuiteLike {
  val model = ProxyModel.defaultProxyModel

  val proxyServlet = new ProxyServlet(model)
  addServlet(proxyServlet, "/proxy/*")

  val fixturesServlet = new FixtureServlet
  addServlet(fixturesServlet, "/fixtures/*")

  test("verify that the fixture servlet is wired up") {
    get(s"/fixtures/status") {
      status should equal(200)
    }
  }

  test("verify that the proxy servlet is wired up") {
    get(s"/proxy/status") {
      status should equal(200)
    }
  }

  test("update model from fixtures") {

    val port: Int = localPort match {
      case Some(x) => x
      case _ => throw new RuntimeException("No port")
    }
    model.updateFromWeb(s"http://localhost:$port/fixtures/foo")
    assert(model.roundRobinUrl==s"http://localhost:$port/fixtures/foo/a")
    assert(model.roundRobinUrl==s"http://localhost:$port/fixtures/foo/b")

  }

  test("model can fetch data") {

    val port: Int = localPort match {
      case Some(x) => x
      case _ => throw new RuntimeException("No port")
    }
    assert(model.getUrl(s"http://localhost:$port/fixtures/foo/a")=="a")
  }


} 
开发者ID:salimfadhley,项目名称:funproxy,代码行数:50,代码来源:ProxyServletTestWithActualData.scala


示例17: HelloWorldControllerTest

//设置package包名称以及导入依赖的类
import bdir.controllers.HelloWorldController
import org.scalatest.FunSuiteLike
import org.scalatra.test.scalatest.ScalatraSuite

class HelloWorldControllerTest extends ScalatraSuite with FunSuiteLike {
  addServlet(classOf[HelloWorldController], "/*")

  test("get name") {
    get("/hello") {
      status should equal(200)

      body should include("Hello hello")
    }
  }

  test("home page") {
    get("/") {
      status should equal(200)

      body should include("Hello world")
    }
  }

  test("post send") {
    post("/send", Map("name" -> "hello")) {
      status should equal(200)
    }
  }

  test("post unkown param should return code 200") {
    post("/send", Map("n" -> "unkown")) {
      status should equal(200)
    }
  }
} 
开发者ID:ervitis,项目名称:bdir-back,代码行数:36,代码来源:HelloWorldControllerTest.scala


示例18: MonkeySpec

//设置package包名称以及导入依赖的类
package com.clluc.monkeyproblem

import akka.actor.ActorSystem
import akka.testkit.{TestKit, TestProbe}
import com.clluc.monkeyproblem.Monkey._
import com.clluc.monkeyproblem.Rope._
import org.scalatest.{BeforeAndAfterAll, FunSuiteLike}

import scala.concurrent.duration._

class MonkeySpec extends TestKit(ActorSystem("MonkeySpec"))
  with FunSuiteLike
  with BeforeAndAfterAll {

  override def afterAll(): Unit = {
    system.terminate()
  }

  test("monkey shouldn't cross until told to") {
    val rope = TestProbe()
    val monkey = system.actorOf(Monkey.props(0, West, rope.ref))
    rope.expectMsgPF() {
      case Join(_) => ()
    }
    rope.expectNoMsg(300.milliseconds)

    rope.send(monkey, Go)
    rope.expectMsg(Joining)
  }

  //TODO find better way to test this
  test("monkey shold take 1 second to get on the rope, and 4 crossing") {

    val rope = TestProbe()
    val monkey = system.actorOf(Monkey.props(0, West, rope.ref))
    rope.expectMsgPF() {
      case Join(_) => ()
    }
    rope.send(monkey, Go)
    rope.expectMsg(Joining)
    rope.expectNoMsg(1.second)
    rope.expectMsg(Joined)
    rope.expectNoMsg(4.second)
    rope.expectMsg(Left)
  }
} 
开发者ID:vemoo,项目名称:monkey-problem-akka,代码行数:47,代码来源:MonkeySpec.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala BSONDocumentWriter类代码示例发布时间:2022-05-23
下一篇:
Scala TableScan类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap