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

Scala Suite类代码示例

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

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



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

示例1: materializer

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.ironmq

import akka.stream.{ActorMaterializer, Materializer}
import org.scalatest.{BeforeAndAfterEach, Suite}

trait AkkaStreamFixture extends AkkaFixture with BeforeAndAfterEach { _: Suite =>

  private var mutableMaterializer = Option.empty[ActorMaterializer]

  implicit def materializer: Materializer =
    mutableMaterializer.getOrElse(throw new IllegalStateException("Materializer not initialized"))

  override protected def beforeEach(): Unit = {
    super.beforeEach()
    mutableMaterializer = Option(ActorMaterializer())
  }

  override protected def afterEach(): Unit = {
    mutableMaterializer.foreach(_.shutdown())
    super.afterEach()
  }
} 
开发者ID:akka,项目名称:alpakka,代码行数:23,代码来源:AkkaStreamFixture.scala


示例2: app

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.agentrelationships.support

import com.codahale.metrics.MetricRegistry
import com.kenshoo.play.metrics.Metrics
import org.scalatest.{Matchers, Suite}
import play.api.Application

import scala.collection.JavaConversions

trait MetricTestSupport {
  self: Suite with Matchers =>

  def app: Application

  private var metricsRegistry: MetricRegistry = _

  def givenCleanMetricRegistry(): Unit = {
    val registry = app.injector.instanceOf[Metrics].defaultRegistry
    for (metric <- JavaConversions.asScalaIterator[String](registry.getMetrics.keySet().iterator())) {
      registry.remove(metric)
    }
    metricsRegistry = registry
  }

  def timerShouldExistsAndBeenUpdated(metric: String): Unit = {
    metricsRegistry.getTimers.get(s"Timer-$metric").getCount should be >= 1L
  }

} 
开发者ID:hmrc,项目名称:agent-client-relationships,代码行数:30,代码来源:MetricTestSupport.scala


示例3: fillFromEnv

//设置package包名称以及导入依赖的类
package hu.blackbelt.cd.bintray.deploy

import java.io.{File, FileInputStream}
import java.util.Properties

import org.scalatest.{BeforeAndAfter, Suite}

trait Creds extends BeforeAndAfter {
  this: Suite =>

  def fillFromEnv(prop: Properties) = {
    def put(key: String) = sys.env.get(key.replace('.','_')).map(prop.put(key.replace('_','.'), _))
    put(Access.aws_accessKeyId)
    put(Access.aws_secretKey)
    put(Access.bintray_organization)
    put(Access.bintray_user)
    put(Access.bintray_apikey)
  }

  before {
    import scala.collection.JavaConverters._
    val prop = new Properties()
    val propsFile = new File("env.properties")
    if (propsFile.exists()) {
      prop.load(new FileInputStream(propsFile))
    } else {
      fillFromEnv(prop)
    }
    prop.entrySet().asScala.foreach {
      (entry) => {
        sys.props += ((entry.getKey.asInstanceOf[String], entry.getValue.asInstanceOf[String]))
      }
    }
  }


} 
开发者ID:tsechov,项目名称:s3-bintray-deploy,代码行数:38,代码来源:Creds.scala


示例4: WireMockBaseUrl

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.agentmapping.support

import java.net.URL

import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock.{configureFor, reset}
import com.github.tomakehurst.wiremock.core.WireMockConfiguration
import com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, Suite}
import uk.gov.hmrc.play.it.Port.randomAvailable

case class WireMockBaseUrl(value: URL)

object WireMockSupport {
  // We have to make the wireMockPort constant per-JVM instead of constant
  // per-WireMockSupport-instance because config values containing it are
  // cached in the GGConfig object
  private lazy val wireMockPort = randomAvailable
}

trait WireMockSupport extends BeforeAndAfterAll with BeforeAndAfterEach{
  me: Suite =>

  val wireMockPort: Int = WireMockSupport.wireMockPort
  val wireMockHost = "localhost"
  val wireMockBaseUrlAsString = s"http://$wireMockHost:$wireMockPort"
  val wireMockBaseUrl = new URL(wireMockBaseUrlAsString)
  protected implicit val implicitWireMockBaseUrl = WireMockBaseUrl(wireMockBaseUrl)

  protected def basicWireMockConfig(): WireMockConfiguration = wireMockConfig()

  private val wireMockServer = new WireMockServer(basicWireMockConfig().port(wireMockPort))

  override protected def beforeAll(): Unit = {
    super.beforeAll()
    configureFor(wireMockHost, wireMockPort)
    wireMockServer.start()
  }

  override protected def afterAll(): Unit = {
    wireMockServer.stop()
    super.afterAll()
  }

  override protected def beforeEach(): Unit = {
    super.beforeEach()
    reset()
  }
} 
开发者ID:hmrc,项目名称:agent-mapping,代码行数:50,代码来源:WireMockSupport.scala


示例5: WireMockBaseUrl

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.agentmappingfrontend.support

import java.net.URL

import com.github.tomakehurst.wiremock.WireMockServer
import com.github.tomakehurst.wiremock.client.WireMock.{configureFor, reset}
import com.github.tomakehurst.wiremock.core.WireMockConfiguration
import com.github.tomakehurst.wiremock.core.WireMockConfiguration._
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, Suite}
import uk.gov.hmrc.play.it.Port

case class WireMockBaseUrl(value: URL)

object WireMockSupport {
  // We have to make the wireMockPort constant per-JVM instead of constant
  // per-WireMockSupport-instance because config values containing it are
  // cached in the GGConfig object
  private lazy val wireMockPort = Port.randomAvailable
}

trait WireMockSupport extends BeforeAndAfterAll with BeforeAndAfterEach {
  me: Suite =>

  val wireMockPort: Int = WireMockSupport.wireMockPort
  val wireMockHost = "localhost"
  val wireMockBaseUrlAsString = s"http://$wireMockHost:$wireMockPort"
  val wireMockBaseUrl = new URL(wireMockBaseUrlAsString)
  protected implicit val implicitWireMockBaseUrl = WireMockBaseUrl(wireMockBaseUrl)

  protected def basicWireMockConfig(): WireMockConfiguration = wireMockConfig()

  private val wireMockServer = new WireMockServer(basicWireMockConfig().port(wireMockPort))

  override protected def beforeAll(): Unit = {
    super.beforeAll()
    configureFor(wireMockHost, wireMockPort)
    wireMockServer.start()
  }

  override protected def afterAll(): Unit = {
    wireMockServer.stop()
    super.afterAll()
  }

  override protected def beforeEach(): Unit = {
    super.beforeEach()
    reset()
  }
} 
开发者ID:hmrc,项目名称:agent-mapping-frontend,代码行数:50,代码来源:WireMockSupport.scala


示例6: ironMqClient

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.ironmq

import java.util.UUID

import com.typesafe.config.{Config, ConfigFactory}
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{BeforeAndAfterEach, Notifying, Suite}

import scala.concurrent.ExecutionContext
import scala.util.hashing.MurmurHash3

trait IronMqFixture extends AkkaStreamFixture with BeforeAndAfterEach with ScalaFutures { _: Suite with Notifying =>

  private implicit val ec = ExecutionContext.global
  private var mutableIronMqClient = Option.empty[IronMqClient]

  def ironMqClient: IronMqClient =
    mutableIronMqClient.getOrElse(throw new IllegalStateException("The IronMqClient is not initialized"))

  override protected def initConfig(): Config =
    ConfigFactory.parseString(s"""akka.stream.alpakka.ironmq {
        |  credentials {
        |    project-id = "${MurmurHash3.stringHash(System.currentTimeMillis().toString)}"
        |  }
        |}
      """.stripMargin).withFallback(super.initConfig())

  override protected def beforeEach(): Unit = {
    super.beforeEach()
    mutableIronMqClient = Option(IronMqClient(IronMqSettings(config.getConfig("akka.stream.alpakka.ironmq"))))
  }

  override protected def afterEach(): Unit = {
    mutableIronMqClient = Option.empty
    super.afterEach()
  }

  def givenQueue(name: Queue.Name): Queue = {
    val created = ironMqClient.createQueue(name).futureValue
    note(s"Queue created: ${created.name.value}", Some(created))
    created
  }

  def givenQueue(): Queue =
    givenQueue(Queue.Name(s"test-${UUID.randomUUID()}"))
} 
开发者ID:akka,项目名称:alpakka,代码行数:47,代码来源:IronMqFixture.scala


示例7: actorSystemTerminateTimeout

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.ironmq

import akka.actor.ActorSystem
import org.scalatest.{BeforeAndAfterEach, Suite}

import scala.concurrent.Await
import scala.concurrent.duration._

trait AkkaFixture extends ConfigFixture with BeforeAndAfterEach { _: Suite =>
  import AkkaFixture._

  
  def actorSystemTerminateTimeout: Duration = DefaultActorSystemTerminateTimeout

  private var mutableActorSystem = Option.empty[ActorSystem]
  implicit def actorSystem: ActorSystem =
    mutableActorSystem.getOrElse(throw new IllegalArgumentException("The ActorSystem is not initialized"))

  override protected def beforeEach(): Unit = {
    super.beforeEach()
    mutableActorSystem = Option(ActorSystem(s"test-${System.currentTimeMillis()}", config))
  }

  override protected def afterEach(): Unit = {
    Await.result(actorSystem.terminate(), actorSystemTerminateTimeout)
    super.afterEach()
  }
}

object AkkaFixture {
  val DefaultActorSystemTerminateTimeout: Duration = 10.seconds
} 
开发者ID:akka,项目名称:alpakka,代码行数:33,代码来源:AkkaFixture.scala


示例8: Integration

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.sqs.scaladsl

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.amazonaws.auth.{AWSCredentialsProvider, AWSStaticCredentialsProvider, BasicAWSCredentials}
import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration
import com.amazonaws.services.sqs.{AmazonSQSAsync, AmazonSQSAsyncClientBuilder}
import org.elasticmq.rest.sqs.{SQSRestServer, SQSRestServerBuilder}
import org.scalatest.{BeforeAndAfterAll, Suite, Tag}

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.util.Random

trait DefaultTestContext extends BeforeAndAfterAll { this: Suite =>

  lazy val sqsServer: SQSRestServer = SQSRestServerBuilder.withDynamicPort().start()
  lazy val sqsAddress = sqsServer.waitUntilStarted().localAddress
  lazy val sqsPort = sqsAddress.getPort
  lazy val sqsEndpoint: String = {
    s"http://${sqsAddress.getHostName}:$sqsPort"
  }

  object Integration extends Tag("akka.stream.alpakka.sqs.scaladsl.Integration")

  //#init-mat
  implicit val system = ActorSystem()
  implicit val mat = ActorMaterializer()
  //#init-mat

  val credentialsProvider = new AWSStaticCredentialsProvider(new BasicAWSCredentials("x", "x"))

  implicit val sqsClient = createAsyncClient(sqsEndpoint, credentialsProvider)

  def randomQueueUrl(): String = sqsClient.createQueue(s"queue-${Random.nextInt}").getQueueUrl

  override protected def afterAll(): Unit = {
    super.afterAll()
    sqsServer.stopAndWait()
    Await.ready(system.terminate(), 5.seconds)
  }

  def createAsyncClient(sqsEndpoint: String, credentialsProvider: AWSCredentialsProvider): AmazonSQSAsync = {
    //#init-client
    val client: AmazonSQSAsync = AmazonSQSAsyncClientBuilder
      .standard()
      .withCredentials(credentialsProvider)
      .withEndpointConfiguration(new EndpointConfiguration(sqsEndpoint, "eu-central-1"))
      .build()
    //#init-client
    client
  }

} 
开发者ID:akka,项目名称:alpakka,代码行数:55,代码来源:DefaultTestContext.scala


示例9: getNode

//设置package包名称以及导入依赖的类
package au.csiro.data61.magda.test.util

import java.nio.file.Paths
import java.nio.file.Path
import java.util.UUID
import com.sksamuel.elastic4s.embedded.LocalNode
import com.sksamuel.elastic4s.testkit.LocalNodeProvider
import com.sksamuel.elastic4s.testkit.SharedElasticSugar
import org.scalatest.Suite

trait MagdaElasticSugar extends SharedElasticSugar {
  this: Suite with LocalNodeProvider =>

  override def getNode: LocalNode = ClassloaderLocalNodeProvider.node

}
object ClassloaderLocalNodeProvider {
  lazy val node = {

    val tempDirectoryPath: Path = Paths get System.getProperty("java.io.tmpdir")
    val pathHome: Path = tempDirectoryPath resolve UUID.randomUUID().toString
    val requiredSettings = LocalNode.requiredSettings("classloader-node", pathHome.toAbsolutePath.toString)

    val settings = requiredSettings ++ Map(
      "bootstrap.memory_lock" -> "true",
      "cluster.routing.allocation.disk.threshold_enabled" -> "false"
    )

    LocalNode(settings)
  }
} 
开发者ID:TerriaJS,项目名称:magda,代码行数:32,代码来源:MagdaElasticSugar.scala


示例10: gen

//设置package包名称以及导入依赖的类
package org.dsa.iot.scala

import scala.collection.JavaConverters._

import org.dsa.iot.dslink.node.value.Value
import org.dsa.iot.dslink.util.json.{ JsonArray, JsonObject }
import org.scalacheck.{ Gen, Arbitrary }
import org.scalatest.{ BeforeAndAfterAll, Matchers, Suite, WordSpecLike }
import org.scalatest.prop.GeneratorDrivenPropertyChecks


trait AbstractSpec extends Suite
    with WordSpecLike
    with Matchers
    with BeforeAndAfterAll
    with GeneratorDrivenPropertyChecks {

  import Arbitrary._

  object gen {
    val ids = Gen.identifier.map(_.take(10))
    val scalars = Gen.oneOf(arbitrary[Number], arbitrary[Boolean], arbitrary[String], arbitrary[Array[Byte]])
    val scalarLists = Gen.resize(10, Gen.listOf(scalars))
    val scalarJavaLists = scalarLists.map(_.asJava)
    val scalarMaps = Gen.resize(10, Gen.mapOf(Gen.zip(ids, scalars)))
    val scalarJavaMaps = scalarMaps.map(_.asJava)
    val anyLists = Gen.resize(10, Gen.listOf(Gen.oneOf(scalars, scalarLists, scalarMaps)))
    val anyMaps = Gen.resize(10, Gen.mapOf(Gen.zip(ids, Gen.oneOf(scalars, scalarLists, scalarMaps))))
    val any = Gen.oneOf(scalars, anyLists, anyMaps)
  }

  object valueGen {
    val bools = arbitrary[Boolean] map (new Value(_))

    val ints = arbitrary[Int] map (new Value(_))
    val longs = arbitrary[Long] map (new Value(_))
    val shorts = arbitrary[Short] map (new Value(_))
    val bytes = arbitrary[Byte] map (new Value(_))
    val doubles = arbitrary[Double] map (new Value(_))
    val floats = arbitrary[Float] map (new Value(_))
    val numbers = Gen.oneOf(ints, longs, shorts, bytes, doubles, floats)

    val strings = arbitrary[String] map (new Value(_))

    val binary = arbitrary[Array[Byte]] map (new Value(_))

    val scalarArrays = gen.scalarLists map (x => new JsonArray(x.asJava))

    val scalarMaps = gen.scalarMaps map (x => new JsonObject(x.asInstanceOf[Map[String, Object]].asJava))

    val arrays = scalarArrays map (new Value(_))

    val maps = scalarMaps map (new Value(_))
  }
} 
开发者ID:IOT-DSA,项目名称:sdk-dslink-scala,代码行数:56,代码来源:AbstractSpec.scala


示例11: setup

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

trait MongoTestFrameworkInterface {
  def setup()
  def cleanUp()
}

object MongoTestFrameworkInterface {

  import org.scalatest.{BeforeAndAfterAll, Suite}

  trait ScalaTest extends MongoTestFrameworkInterface with BeforeAndAfterAll {
    this: Suite =>

    abstract override protected def beforeAll(): Unit = {
      setup()
      super.beforeAll()
    }

    abstract override protected def afterAll(): Unit = {
      cleanUp()
      super.afterAll()
    }
  }

} 
开发者ID:mielientiev,项目名称:MongoUnit,代码行数:27,代码来源:MongoTestFrameworkInterface.scala


示例12: dropCollection

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

import org.mongodb.scala.bson.collection.immutable.Document
import org.mongodb.scala.{Completed, MongoCollection}
import org.mongounit.dsl.MongoRequestBuilding
import org.mongounit.embedded.EmbeddedMongo
import org.scalatest.Suite

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


trait MongoTest extends MongoRequestBuilding with EmbeddedMongo {
  this: MongoTestFrameworkInterface =>

  private def dropCollection(collection: MongoCollection[Document]): Unit = {
    Await.ready(collection.drop().toFuture(), 10.seconds)
  }

  private def importJson(collection: MongoCollection[Document], lines: Seq[String]): Future[Seq[Completed]] = {
    Await.ready(collection.insertMany(lines.map(json => Document(json))).toFuture(), 10.seconds)
  }

  implicit class WithSeqMongoRequestLoading(seqRequest: SeqMongoRequest) {
    def ~>(newReq: SeqMongoRequest): SeqMongoRequest = {
      SeqMongoRequest(newReq, seqRequest)
    }

    def ~>[A](block: => A): Unit = {
      seqRequest.requests.foreach { request =>
        val collection = mongoDB.getDatabase(request.database).getCollection(request.collection)
        importJson(collection, request.jsonList)
      }
      block
      seqRequest.requests.foreach { request =>
        val collection = mongoDB.getDatabase(request.database).getCollection(request.collection)
        dropCollection(collection)
      }
    }
  }

}


trait MongoScalaTest extends MongoTest with MongoTestFrameworkInterface.ScalaTest {
  this: Suite =>

  override def setup() = {
    mongod
  }

  override def cleanUp() = {
    mongoDB.close()
    mongod.stop()
    mongodExe.stop()
  }

} 
开发者ID:mielientiev,项目名称:MongoUnit,代码行数:59,代码来源:MongoTest.scala


示例13: assertThrowsAndTestMessage

//设置package包名称以及导入依赖的类
package org.scalawebtest.integration

import org.scalactic.source.Position
import org.scalatest.{Assertion, Succeeded, Suite}

import scala.reflect.ClassTag

trait AdditionalAssertions {self: Suite =>
    def assertThrowsAndTestMessage[T <: AnyRef](f: => Any)(messageTest: String => Assertion)(implicit classTag: ClassTag[T], pos: Position): Assertion = {
    val clazz = classTag.runtimeClass
    val threwExpectedException =
      try {
        f
        false
      }
      catch {
          case u: Throwable =>
            messageTest(u.getMessage)
            if (!clazz.isAssignableFrom(u.getClass)) {
              fail(s"didn't throw expected exception ${clazz.getCanonicalName}")
            }
            else true
      }
    if (threwExpectedException) {
      Succeeded
    }
    else {
      fail(s"didn't throw expected exception ${clazz.getCanonicalName}")
    }
  }

} 
开发者ID:unic,项目名称:ScalaWebTest,代码行数:33,代码来源:AdditionalAssertions.scala


示例14: beforeAll

//设置package包名称以及导入依赖的类
package org.apache.spark.mllib.util

import org.scalatest.Suite
import org.scalatest.BeforeAndAfterAll

import org.apache.spark.SparkContext

trait LocalSparkContext extends BeforeAndAfterAll { self: Suite =>
  @transient var sc: SparkContext = _

  override def beforeAll() {
    sc = new SparkContext("local", "test")
    super.beforeAll()
  }

  override def afterAll() {
    if (sc != null) {
      sc.stop()
    }
    System.clearProperty("spark.driver.port")
    super.afterAll()
  }
} 
开发者ID:rocflysi,项目名称:cloudera-spark,代码行数:24,代码来源:LocalSparkContext.scala


示例15: beforeAll

//设置package包名称以及导入依赖的类
package com.github.jparkie.spark.cassandra

import java.net.{ InetAddress, InetSocketAddress }

import com.datastax.driver.core.Session
import com.datastax.spark.connector.cql.CassandraConnector
import org.cassandraunit.utils.EmbeddedCassandraServerHelper
import org.scalatest.{ BeforeAndAfterAll, Suite }

trait CassandraServerSpecLike extends BeforeAndAfterAll { this: Suite =>
  // Remove protected modifier because of SharedSparkContext.
  override def beforeAll(): Unit = {
    super.beforeAll()

    EmbeddedCassandraServerHelper.startEmbeddedCassandra()
  }

  // Remove protected modifier because of SharedSparkContext.
  override def afterAll(): Unit = {
    EmbeddedCassandraServerHelper.cleanEmbeddedCassandra()

    super.afterAll()
  }

  def getClusterName: String = {
    EmbeddedCassandraServerHelper.getClusterName
  }

  def getHosts: Set[InetAddress] = {
    val temporaryAddress =
      new InetSocketAddress(EmbeddedCassandraServerHelper.getHost, EmbeddedCassandraServerHelper.getNativeTransportPort)
        .getAddress

    Set(temporaryAddress)
  }

  def getNativeTransportPort: Int = {
    EmbeddedCassandraServerHelper.getNativeTransportPort
  }

  def getRpcPort: Int = {
    EmbeddedCassandraServerHelper.getRpcPort
  }

  def getCassandraConnector: CassandraConnector = {
    CassandraConnector(hosts = getHosts, port = getNativeTransportPort)
  }

  def createKeyspace(session: Session, keyspace: String): Unit = {
    session.execute(
      s"""CREATE KEYSPACE "$keyspace"
          |WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
       """.stripMargin
    )
  }
} 
开发者ID:jparkie,项目名称:Spark2Cassandra,代码行数:57,代码来源:CassandraServerSpecLike.scala


示例16: beforeAll

//设置package包名称以及导入依赖的类
package org.apache.spark.groupon.metrics.util

import org.apache.spark.{SparkConf, SparkContext}
import org.scalatest.{BeforeAndAfterAll, Suite}

trait SparkContextSetup extends BeforeAndAfterAll { this: Suite =>

  private val master = "local[2]"
  private val appName = "test"
  private val sparkConf = new SparkConf().setAppName(appName).setMaster(master)

  var sc: SparkContext = _

  override def beforeAll(): Unit = {
    sc = new SparkContext(sparkConf)
    sc.setLogLevel("WARN")
    super.beforeAll()
  }

  override def afterAll(): Unit = {
    try {
      super.afterAll()
    }
    finally {
      sc.stop()
    }
  }
} 
开发者ID:groupon,项目名称:spark-metrics,代码行数:29,代码来源:SparkContextSetup.scala


示例17: KafkaUtilsSpec

//设置package包名称以及导入依赖的类
package org.dsa.iot.kafka

import org.scalatest.{ Finders, Matchers, Suite, WordSpecLike }

import kafka.cluster.Broker

class KafkaUtilsSpec extends Suite with WordSpecLike with Matchers {
  import Settings._

  "KafkaUtils.parseBrokerList" should {
    "return an empty list for blank string" in {
      KafkaUtils.parseBrokerList(" ") shouldBe Nil
      KafkaUtils.parseBrokerList(" , ") shouldBe Nil
    }
    "parse hosts with ports" in {
      KafkaUtils.parseBrokerList("host1:111, host2:222,host3:333") shouldBe
        Broker(0, "host1", 111) :: Broker(1, "host2", 222) :: Broker(2, "host3", 333) :: Nil
    }
    "parse hosts without ports" in {
      KafkaUtils.parseBrokerList("host1,host2, host3") shouldBe
        Broker(0, "host1", DEFAULT_PORT) :: Broker(1, "host2", DEFAULT_PORT) :: Broker(2, "host3", DEFAULT_PORT) :: Nil
    }
    "parse mixed hosts with/without ports" in {
      KafkaUtils.parseBrokerList("host1:111,host2, host3:333") shouldBe
        Broker(0, "host1", 111) :: Broker(1, "host2", DEFAULT_PORT) :: Broker(2, "host3", 333) :: Nil
    }
    "fail on bad port format" in {
      a[NumberFormatException] should be thrownBy KafkaUtils.parseBrokerList("host:port")
    }
  }

} 
开发者ID:IOT-DSA,项目名称:dslink-scala-kafka,代码行数:33,代码来源:KafkaUtilsSpec.scala


示例18: MessageBrokerMessageDispatcherUTest

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

import akka.actor.ActorSystem
import akka.testkit.TestKit
import org.scalamock.scalatest.MockFactory
import org.scalatest.{FlatSpecLike, ShouldMatchers, Suite, BeforeAndAfterAll}

class MessageBrokerMessageDispatcherUTest
 extends TestKit(ActorSystem("TestSystem"))
  with FlatSpecLike
  with ShouldMatchers
  with StopSystemAfterAll
  with MockFactory {
  
}

trait StopSystemAfterAll extends BeforeAndAfterAll {

  this: TestKit with Suite =>

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

} 
开发者ID:shafiquejamal,项目名称:microservice-template-play,代码行数:27,代码来源:MessageBrokerMessageDispatcherUTest.scala


示例19: beforeAll

//设置package包名称以及导入依赖的类
package org.apache.spark.mllib.util

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.SQLContext
import org.scalatest.{Suite, BeforeAndAfterAll}


trait MLlibTestSparkContext extends BeforeAndAfterAll { self: Suite =>
  @transient var sc: SparkContext = _
  @transient var sqlContext: SQLContext = _

  override def beforeAll(): Unit = {
    super.beforeAll()
    val conf = new SparkConf().setMaster("local[2]").setAppName("MLlibUnitTest")
    sc = new SparkContext(conf)
    sc.setLogLevel("WARN")
    sqlContext = new SQLContext(sc)
  }

  override def afterAll(): Unit = {
    sqlContext = null
    if (sc != null) {
      sc.stop()
    }
    sc = null
    super.afterAll()
  }
} 
开发者ID:YaozhengWang,项目名称:spark-cofirank,代码行数:29,代码来源:MLlibTestSparkContext.scala


示例20: apply

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

import javax.inject.Singleton

import com.google.inject.ImplementedBy
import monix.execution.Scheduler
import org.scalatest.Suite

@ImplementedBy(classOf[ScalaRuntimeRunner])
trait RuntimeSuiteExecutor {
  def apply(suiteClass: Class[Suite], solutionTrait: Class[AnyRef], solution: String)
           (channel: String => Unit)
           (implicit s: Scheduler): Unit
}

@Singleton
class ScalaRuntimeRunner extends RuntimeSuiteExecutor with SuiteExecution with SuiteToolbox {
  
  def apply(suiteClass: Class[Suite], solutionTrait: Class[AnyRef], solution: String)
           (channel: String => Unit)
           (implicit s: Scheduler): Unit = {
    val solutionInstance = createSolutionInstance(solution, solutionTrait)
    executionTestSuite(suiteClass.getConstructor(solutionTrait).newInstance(solutionInstance), channel)
  }

  def createSolutionInstance(solution: String, solutionTrait: Class[AnyRef]): AnyRef = {
    val patchedSolution = classDefPattern.replaceFirstIn(solution, s"class $userClass extends ${solutionTrait.getSimpleName} ")
    val dynamicCode = s"import ${solutionTrait.getName}; $patchedSolution; new $userClass"

    tb.eval(tb.parse(dynamicCode)).asInstanceOf[AnyRef]
  }
} 
开发者ID:DmytroOrlov,项目名称:devgym,代码行数:33,代码来源:ScalaRuntimeRunner.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala Span类代码示例发布时间:2022-05-23
下一篇:
Scala PrintStream类代码示例发布时间: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