本文整理汇总了Scala中org.scalatest.Tag类的典型用法代码示例。如果您正苦于以下问题:Scala Tag类的具体用法?Scala Tag怎么用?Scala Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tag类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: 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
}
}
示例2: TnViewCreatorTest
//设置package包名称以及导入依赖的类
package com.bfm.topnotch.tnview
import com.bfm.topnotch.SparkApplicationTester
import com.bfm.topnotch.TnTestHelper
import org.scalatest.{Matchers, Tag}
/**
* The tests for [[com.bfm.topnotch.tnview.TnViewCreator TnViewCreator]].
*/
class TnViewCreatorTest extends SparkApplicationTester with Matchers {
import TnTestHelper._
lazy val tnViewCreator = new TnViewCreator(spark)
lazy val df = spark.read.parquet(getClass.getResource("currentLoans.parquet").getFile).cache
/**
* The tags
*/
object viewCreatorTag extends Tag("TnViewCreator")
/**
* The tests for TnViewCreator
*/
"TnViewCreator" should "do nothing when given Select *" taggedAs viewCreatorTag in {
dfEquals(tnViewCreator.createView(Seq(df), TnViewParams(Seq("testTable"), "select * from testTable")), df)
}
it should "filter out all but the rows with poolNum == 1 when given the SQL where poolNum = 1" taggedAs viewCreatorTag in {
dfEquals(tnViewCreator.createView(Seq(df), TnViewParams(Seq("testTable"), "select * from testTable where poolNum = 1")),
df.where("poolNum = 1"))
}
}
示例3: TnReaderTest
//设置package包名称以及导入依赖的类
package com.bfm.topnotch.tnengine
import org.json4s._
import org.json4s.native.Serialization
import com.bfm.topnotch.SparkApplicationTester
import org.scalatest.{Matchers, Tag}
/**
* The tests for [[com.bfm.topnotch.tnengine.TnReader TnReader]].
* Note that most testing is done by the tests for [[com.bfm.topnotch.tnengine.TnEngine TnEngine]]
*/
class TnReaderTest extends SparkApplicationTester with Matchers {
object getReaderTag extends Tag("getReader")
object readerVariableTag extends Tag("readerVariables")
object jarReaderTag extends Tag("jarReader")
implicit val formats = Serialization.formats(NoTypeHints)
"getReader" should "throw an IllegalArgumentException when the plan doesn't exist" taggedAs(getReaderTag) in {
intercept[IllegalArgumentException] {
val fileReader = new TnFileReader
fileReader.readConfiguration("src/test/resources/com/bfm/DOESNTEXIST")
}
}
it should "replace variables in a configuration" taggedAs(readerVariableTag) in {
val fileReader = new TnFileReader(Map("var1" -> "true", "var2" -> "false"))
val replacedAST = fileReader.readConfiguration("src/test/resources/com/bfm/topnotch/tnengine/cliReplacementTest.json")
replacedAST \ "trueToBeReplaced" should not equal(JNothing)
(replacedAST \ "replaceThisValue").extract[String] should equal("false")
}
}
示例4: TnWriterTest
//设置package包名称以及导入依赖的类
package com.bfm.topnotch.tnengine
import java.net.URL
import com.bfm.topnotch.SparkApplicationTester
import org.scalatest.{Tag, Matchers}
/**
* The tests for [[com.bfm.topnotch.tnengine.TnWriter TnWriter]].
*/
class TnWriterTest extends SparkApplicationTester with Matchers {
/**
* The tags
*/
object getWriterTag extends Tag("getWriter")
lazy val fileReader = new TnFileReader
lazy val engine = new TnEngine(spark)
"getWriter" should "return an HDFS writer when given a config missing the io namespace" taggedAs (getWriterTag) in {
engine.getWriter(fileReader.readConfiguration("src/test/resources/com/bfm/topnotch/tnengine/emptyPlan.json")) shouldBe a [TnHDFSWriter]
}
it should "return an HDFS writer when given HDFS as the config string with no path" taggedAs (getWriterTag) in {
engine.getWriter(fileReader.readConfiguration("src/test/resources/com/bfm/topnotch/tnengine/writer/hdfsNoFile.json")) shouldBe a [TnHDFSWriter]
}
it should "return an HDFS writer with a non-default destination when given hdfs as the writer with a destination string" taggedAs (getWriterTag) in {
val writer = engine.getWriter(fileReader.readConfiguration("src/test/resources/com/bfm/topnotch/tnengine/writer/hdfsWithFile.json"))
writer shouldBe a [TnHDFSWriter]
writer.asInstanceOf[TnHDFSWriter].dest.get shouldBe "/user/testUser/"
}
it should "return an Hbase writer when given HBase as the config string" taggedAs (getWriterTag) in {
engine.getWriter(fileReader.readConfiguration("src/test/resources/com/bfm/topnotch/tnengine/writer/hbase.json")) shouldBe a [TnHBaseWriter]
}
it should "return a REST writer with a non-default URL when given rest as the writer with a destination string" taggedAs (getWriterTag) in {
val writer = engine.getWriter(fileReader.readConfiguration("src/test/resources/com/bfm/topnotch/tnengine/writer/rest.json"))
writer shouldBe a [TnRESTWriter]
writer.asInstanceOf[TnRESTWriter].dest shouldBe "http://www.testurl.com"
}
}
示例5: SparkSpec
//设置package包名称以及导入依赖的类
package edu.fuberlin.hotspots
import org.apache.spark.{SparkConf, SparkContext}
import org.scalatest.{Outcome, Tag, fixture}
class SparkSpec extends fixture.FlatSpec {
case class FixtureParam(context:SparkContext)
override def withFixture(test:OneArgTest): Outcome ={
val conf = new SparkConf().setAppName("Test").setMaster("local[*]")
val sc = new SparkContext(conf)
try{withFixture(test.toNoArgTest(FixtureParam(sc)))}
finally{
if(sc != null && !sc.isStopped){
sc.stop()
}
}
}
}
object SparkSpec extends Tag("Spark")
示例6: Kudu
//设置package包名称以及导入依赖的类
package io.eels.component.kudu
import io.eels.Row
import io.eels.datastream.DataStream
import io.eels.schema._
import org.scalatest.{FlatSpec, Matchers, Tag}
object Kudu extends Tag("kudu")
class KuduComponentTest extends FlatSpec with Matchers {
"kudu" should "support end to end sink to source" taggedAs Kudu in {
val schema = StructType(
Field("planet", StringType, nullable = false, key = true),
Field("position", StringType, nullable = true)
)
val ds = DataStream.fromValues(
schema,
Seq(
Vector("earth", 3),
Vector("saturn", 6)
)
)
val master = "localhost:7051"
ds.to(KuduSink(master, "mytable"))
val rows = KuduSource(master, "mytable").toDataStream().collect
rows shouldBe Seq(
Row(schema, Vector("earth", "3")),
Row(schema, Vector("saturn", "6"))
)
}
it should "support all basic types" taggedAs Kudu in {
val schema = StructType(
Field("planet", StringType, nullable = false, key = true),
Field("position", ByteType.Signed, nullable = false),
Field("volume", DoubleType, nullable = false),
Field("bytes", BinaryType, nullable = false),
Field("gas", BooleanType, nullable = false),
Field("distance", LongType.Signed, nullable = false)
)
val data = Array("earth", 3: Byte, 4515135988.632, Array[Byte](1, 2, 3), false, 83000000)
val ds = DataStream.fromValues(schema, Seq(data))
val master = "localhost:7051"
ds.to(KuduSink(master, "mytable2"))
val rows = KuduSource(master, "mytable2").toDataStream().collect
val values = rows.head.values.toArray
data(3) = data(3).asInstanceOf[Array[Byte]].toList
values shouldBe data
}
}
示例7: V100
//设置package包名称以及导入依赖的类
package scredis.tags
import org.scalatest.Tag
object V100 extends Tag("V100")
object V101 extends Tag("V101")
object V120 extends Tag("V120")
object V200 extends Tag("V200")
object V220 extends Tag("V220")
object V2212 extends Tag("V2212")
object V223 extends Tag("V223")
object V240 extends Tag("V240")
object V260 extends Tag("V260")
object V269 extends Tag("V269")
object V2612 extends Tag("V2612")
object V280 extends Tag("V280")
object V287 extends Tag("V287")
object V289 extends Tag("V289")
object V2812 extends Tag("V2812")
object V2813 extends Tag("V2813")
object V2950 extends Tag("V2950")
object V300 extends Tag("V300")