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

Scala Assert类代码示例

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

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



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

示例1: SettingsTest

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

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig
import com.google.appengine.tools.development.testing.LocalServiceTestHelper
import com.google.gson.JsonObject
import org.junit.{Assert, Test, After, Before}

class SettingsTest {
  val helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig())

  @Before def setUp(): Unit = helper.setUp
  @After def tearDown() = helper.tearDown()

  @Test
  def testSetAndGetSetting = {
    Settings.set("bla", "ble")
    Assert.assertTrue(Settings.get("bla").isDefined)
    Assert.assertEquals("ble", Settings.get("bla").get)
  }

  @Test
  def testFromJson = {
    val json = new JsonObject
    json.addProperty("bla", "ble")
    json.addProperty("ble", "bla")

    Settings.fromJson(json)

    Assert.assertTrue(Settings.get("bla").isDefined)
    Assert.assertEquals("ble", Settings.get("bla").get)

    Assert.assertTrue(Settings.get("ble").isDefined)
    Assert.assertEquals("bla", Settings.get("ble").get)
  }

  @Test
  def asJson = {
    Settings.set("bla", "ble")
    Settings.set("ble", "bla")

    val json = Settings.asJson

    Assert.assertEquals("ble", json.get("bla").getAsString)
    Assert.assertEquals("bla", json.get("ble").getAsString)
  }
} 
开发者ID:erickzanardo,项目名称:spammer,代码行数:47,代码来源:SettingsTest.scala


示例2: SampleTest

//设置package包名称以及导入依赖的类
package io.github.nawforce.apexlink

import io.github.nawforce.ApexLink
import org.junit.{Assert, Test}

class SampleTest {

  def sample(path : String) : Unit = {
    Assert.assertEquals(0, ApexLink.run(Array(path)))
  }

  @Test def sample1() : Unit = {
    sample("samples/forcedotcom-enterprise-architecture/src")
  }

  @Test def sample2() : Unit = {
    sample("samples/forcedotcomlabs/chatter-game/src")
  }

  @Test def sample3() : Unit = {
    sample("samples/SalesforceFoundation/Cumulus/src")
  }

  @Test def sample4() : Unit = {
    sample("samples/SalesforceFoundation/HEDAP/src")
  }

  @Test def sample5() : Unit = {
    sample("samples/SalesforceFoundation/CampaignTools/src")
  }

  @Test def sample6() : Unit = {
    sample("samples/SalesforceFoundation/Volunteers-for-Salesforce/src")
  }

  @Test def sample7() : Unit = {
    sample("samples/SalesforceFoundation/Relationships/src")
  }

  @Test def sample8() : Unit = {
    sample("samples/SalesforceFoundation/Households/src")
  }

  @Test def sample9() : Unit = {
    sample("samples/SalesforceFoundation/Recurring_Donations/src")
  }

  @Test def sample10() : Unit = {
    sample("samples/SalesforceFoundation/Contacts_and_Organizations/src")
  }

  @Test def sample11() : Unit = {
    sample("samples/SalesforceFoundation/Affiliations/src")
  }
} 
开发者ID:nawforce,项目名称:ApexLink,代码行数:56,代码来源:SampleTest.scala


示例3: UtilsTest

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

import org.junit.Test
import org.junit.Assert

class UtilsTest {
	@Test
	def testStr2HttpHost1() = {
		val httpHost = HttpTarget("localhost")
		Assert.assertEquals(80, httpHost.port)
		Assert.assertEquals("http", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
	
	@Test
	def testStr2HttpHost2() = {
		val httpHost = HttpTarget("https://localhost")
		Assert.assertEquals(80, httpHost.port)
		Assert.assertEquals("https", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
	
	@Test
	def testStr2HttpHost3() = {
		val httpHost = HttpTarget("https://localhost:8443")
		Assert.assertEquals(8443, httpHost.port)
		Assert.assertEquals("https", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
	
	
	// ignore path
	@Test
	def testStr2HttpHost4() = {
		val httpHost = HttpTarget("https://localhost:8443/")
		Assert.assertEquals(8443, httpHost.port)
		Assert.assertEquals("https", httpHost.scheme)
		Assert.assertEquals("localhost", httpHost.host)
	}
} 
开发者ID:lis0x90,项目名称:httpduplicator,代码行数:41,代码来源:UtilsTest.scala


示例4: HttpRddIOTest

//设置package包名称以及导入依赖的类
import java.util.Date

import org.apache.spark.SparkConf
import org.apache.spark.serializer.KryoSerializer
import org.apache.spark.sql.execution.streaming.BufferedTextCollector
import org.apache.spark.sql.execution.streaming.HttpTextReceiver
import org.apache.spark.sql.execution.streaming.HttpTextSender
import org.apache.spark.sql.execution.streaming.TextConsolePrinter
import org.junit.Test
import org.junit.Assert

class HttpRddIOTest {
	val LINES1 = Array[(String, Int, Boolean, Char, Float, Double, Long, Date)](("hello1", 1, true, 'a', 0.1f, 0.1d, 1L, new Date(10000)),
		("hello2", 2, false, 'b', 0.2f, 0.2d, 2L, new Date(20000)), ("hello3", 3, true, 'c', 0.3f, 0.3d, 3L, new Date(30000)));

	@Test
	def testHttpRddIO() {
		//starts a http server with a receiver servlet
		val receiver = HttpTextReceiver.startReceiver(new SparkConf(), "receiver1", "/xxxx", 8080);
		receiver.addListener(new TextConsolePrinter());
		val buffer = new BufferedTextCollector();
		receiver.addListener(buffer);

		val sender = new HttpTextSender("http://localhost:8080/xxxx");
		val kryoSerializer = new KryoSerializer(new SparkConf());
		sender.sendObjectArray(kryoSerializer, "topic-1", 1, LINES1);
		receiver.stop();

		val data = buffer.dump().map(_._1).toArray;
		Assert.assertArrayEquals(LINES1.asInstanceOf[Array[Object]], data.asInstanceOf[Array[Object]]);
	}
} 
开发者ID:bluejoe2008,项目名称:spark-http-stream,代码行数:33,代码来源:HttpRddIOTest.scala


示例5: RFParameterBuilderTest

//设置package包名称以及导入依赖的类
package reforest.rf.parameter

import org.junit.{Assert, Test}

class RFParameterBuilderTest {

  @Test
  def builderInit = {
    val b1 = RFParameterBuilder.apply
    val b2 = RFParameterBuilder.apply

    val parameter1 = b1.build
    val parameter2 = b2.build

    Assert.assertNotEquals(parameter1.UUID, parameter2.UUID)
  }

  @Test
  def builderInitFromParameter = {
    val b1 = RFParameterBuilder.apply
    val parameter1 = b1.build

    val b2 = RFParameterBuilder.apply(parameter1)
    val parameter2 = b2.build

    Assert.assertEquals(parameter1.UUID, parameter2.UUID)
  }

  @Test
  def builderAddParameter = {
    val b1 = RFParameterBuilder.apply
      .addParameter(RFParameterType.Instrumented, true)
      .addParameter(RFParameterType.SparkCompressionCodec, "snappy")
      .addParameter(RFParameterType.MaxNodesConcurrent, 5)
      .addParameter(RFParameterType.PoissonMean, 5.3)

    val parameter1 = b1.build

    Assert.assertEquals(true, parameter1.Instrumented)
    Assert.assertEquals("snappy", parameter1.sparkCompressionCodec)
    Assert.assertEquals(5, parameter1.maxNodesConcurrent)
    Assert.assertEquals(5.3, parameter1.poissonMean, 0.000001)
  }
} 
开发者ID:alessandrolulli,项目名称:reforest,代码行数:45,代码来源:RFParameterBuilderTest.scala


示例6: RFParameterTest

//设置package包名称以及导入依赖的类
package reforest.rf.parameter

import org.junit.{Assert, Test}

class RFParameterTest {

  @Test
  def builderInit = {
    val b1 = RFParameterBuilder.apply
      .addParameter(RFParameterType.NumTrees, 100)
    val parameter1 = b1.build

    Assert.assertEquals(1, parameter1.numTrees.length)
    Assert.assertEquals(100, parameter1.getMaxNumTrees)

    val parameter2 = parameter1.applyNumTrees(101)

    Assert.assertEquals(1, parameter1.numTrees.length)
    Assert.assertEquals(1, parameter2.numTrees.length)
    Assert.assertEquals(100, parameter1.getMaxNumTrees)
    Assert.assertEquals(101, parameter2.getMaxNumTrees)
  }
} 
开发者ID:alessandrolulli,项目名称:reforest,代码行数:24,代码来源:RFParameterTest.scala


示例7: MessageTest

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

import com.google.appengine.tools.development.testing.{LocalDatastoreServiceTestConfig, LocalServiceTestHelper}
import org.junit.{Assert, After, Before, Test}

class MessageTest {
  val helper = new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig().setDefaultHighRepJobPolicyUnappliedJobPercentage(100))

  @Before def setUp(): Unit = helper.setUp
  @After def tearDown() = helper.tearDown()

  @Test
  def testSaveAndFind = {
    val id = new Message("messageTitle", "messageContent").save
    val message = Message.findById(id)

    Assert.assertEquals(id, message.id)
    Assert.assertEquals("messageTitle", message.title)
    Assert.assertEquals("messageContent", message.content)
  }
} 
开发者ID:erickzanardo,项目名称:spammer,代码行数:22,代码来源:MessageTest.scala


示例8: BytecodeBackendUtilTest

//设置package包名称以及导入依赖的类
package com.github.kaeluka.cflat.test

import com.github.kaeluka.cflat.ast._
import com.github.kaeluka.cflat.backend.BytecodeBackendUtil
import org.hamcrest.MatcherAssert._
import org.hamcrest.Matchers._
import org.junit.{Assert, Test}

class BytecodeBackendUtilTest {
  def foo_or_bar = Alt(("foo", None), ("bar", None))
  def foo_or_bar_or_baz = Alt(("foo", None), ("bar", None), ("baz", None))

  def ten_times_eps = Rep("col", 10, None, "ok", None)

  def assertSize(term : TypeSpec, n : Option[Int]) = {
    Assert.assertEquals(s"type spec $term must have size $n", n, term.getSize)
  }

  @Test
  def testPairingFunction() {
    def testPairingFunction(f: (Long, Long) => Long, frev: Long => (Long, Long)) = {
      for (i <- 0L to 100L; j <- 0L to 100L) {
        assertThat(frev(f(i, j)), equalTo((i, j)))
      }
    }
    testPairingFunction(BytecodeBackendUtil.cantorPairingFunction, BytecodeBackendUtil.cantorPairingFunctionRev)
  }
} 
开发者ID:kaeluka,项目名称:cflat,代码行数:29,代码来源:BytecodeBackendUtilTest.scala


示例9: VideoTranscoderTest

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

import java.io.File
import java.util.concurrent.CountDownLatch

import android.content.Context
import android.net.Uri
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import com.waz.api.AssetFactory.LoadCallback
import com.waz.api.{AssetFactory, AssetForUpload}
import com.waz.bitmap.video.VideoTranscoder
import com.waz.service.ZMessaging
import com.waz.threading.Threading
import org.junit.runner.RunWith
import org.junit.{Assert, Before, Test}

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

@RunWith(classOf[AndroidJUnit4])
class VideoTranscoderTest {

  @Before def setUp(): Unit = {
    Threading.AssertsEnabled = false
    ZMessaging.onCreate(context)
  }

  @Test def audioTranscodingFrom8kHz(): Unit = {
    val transcoder = VideoTranscoder(context)
    val out = File.createTempFile("video", ".mp4", context.getCacheDir)

    val future = transcoder(Uri.parse("content://com.waz.test/8khz.mp4"), out, { _ => })

    Assert.assertEquals(out, Await.result(future, 15.seconds))
  }

  @Test def assetLoadingWithNoAudio(): Unit = {
    val latch = new CountDownLatch(1)
    var asset = Option.empty[AssetForUpload]

    AssetFactory.videoAsset(Uri.parse("content://com.waz.test/no_audio.mp4"), new LoadCallback {
      override def onLoaded(a: AssetForUpload): Unit = {
        asset = Some(a)
        latch.countDown()

      }
      override def onFailed(): Unit = {
        println(s"transcode failed")
        latch.countDown()
      }
    })

    latch.await()
    Assert.assertTrue(asset.isDefined)
  }

  def context: Context = instr.getTargetContext
  def instr = InstrumentationRegistry.getInstrumentation
} 
开发者ID:wireapp,项目名称:wire-android-sync-engine,代码行数:61,代码来源:VideoTranscoderTest.scala


示例10: AssetMetaDataTest

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

import android.content.Context
import android.net.Uri
import android.support.test.InstrumentationRegistry
import android.support.test.runner.AndroidJUnit4
import com.waz.model.AssetMetaData
import com.waz.service.ZMessaging
import com.waz.threading.Threading
import com.waz.utils._
import org.junit.runner.RunWith
import org.junit.{Assert, Before, Test}

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

@RunWith(classOf[AndroidJUnit4])
class AssetMetaDataTest {

  @Before def setUp(): Unit = {
    Threading.AssertsEnabled = false
    ZMessaging.onCreate(context)
  }

  @Test def testAudioDurationLoadingFromUri(): Unit = {
    val meta = Await.result(AssetMetaData.Audio(context, Uri.parse("content://com.waz.test/32kbps.m4a")), 5.seconds)

    Assert.assertEquals(309L, meta.fold2(0L, _.duration.getSeconds))
  }

  def context: Context = instr.getTargetContext
  def instr = InstrumentationRegistry.getInstrumentation
} 
开发者ID:wireapp,项目名称:wire-android-sync-engine,代码行数:34,代码来源:AssetMetaDataTest.scala


示例11: KafkaStatsdReporterConfigTest

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

import org.junit.Assert
import org.junit.Test
import org.kongo.kafka.metrics.config.KafkaStatsdReporterConfig

class KafkaStatsdReporterConfigTest {

  @Test
  def defaultMapConfig(): Unit = {
    val config = TestUtils.emptyMapConfig
    testDefaults(config)
  }

  @Test
  def defaultVerifiableProperties(): Unit = {
    val config = TestUtils.emptyVerfiableConfig
    testDefaults(config)
  }

  private def testDefaults(config: KafkaStatsdReporterConfig): Unit = {
    Assert.assertEquals("localhost", config.host)
    Assert.assertEquals(8125, config.port)
    Assert.assertEquals(10, config.pollingIntervalSecs)
    Assert.assertEquals(None, config.include)
    Assert.assertEquals(None, config.exclude)
    Assert.assertEquals(Dimension.Values, config.dimensions)
    Assert.assertEquals(false, config.enabled)
    Assert.assertEquals("kafka", config.prefix)
  }
} 
开发者ID:kongo2002,项目名称:kafka-statsd-reporter,代码行数:32,代码来源:KafkaStatsdReporterConfigTest.scala


示例12: KafkaMetricsRegistryTest

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

import org.junit.Assert
import org.junit.Test

class KafkaMetricsRegistryTest {

  @Test
  def updateMetrics(): Unit = {
    val registry = KafkaMetricsRegistry()
    Assert.assertEquals(0, registry.metrics.size)

    registry.update(TestUtils.dummyKafkaMetric)
    Assert.assertEquals(1, registry.metrics.size)
  }

  @Test
  def removeMetrics(): Unit = {
    val metric = TestUtils.dummyKafkaMetric
    val registry = KafkaMetricsRegistry()

    registry.update(metric)
    Assert.assertEquals(1, registry.metrics.size)

    registry.remove(metric)
    Assert.assertEquals(0, registry.metrics.size)
  }
} 
开发者ID:kongo2002,项目名称:kafka-statsd-reporter,代码行数:29,代码来源:KafkaMetricsRegistryTest.scala


示例13: RegexMetricPredicateTest

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

import java.util.regex.Pattern

import org.junit.Assert
import org.junit.Test

class RegexMetricPredicateTest {

  private val startsWithFoo = Pattern.compile("foo.*")
  private val containsBar = Pattern.compile(".*bar.*")

  @Test
  def allMatchingPredicate(): Unit = {
    val all = RegexMetricPredicate(None, None)

    Assert.assertTrue(all.matches(""))
    Assert.assertTrue(all.matches("some"))
    Assert.assertTrue(all.matches("foo.bar.test"))
  }

  @Test
  def includePatternPredicate(): Unit = {
    val startsWith = RegexMetricPredicate(Some(startsWithFoo), None)

    Assert.assertTrue(startsWith.matches("foo"))
    Assert.assertTrue(startsWith.matches("foo.bar.test"))

    Assert.assertFalse(startsWith.matches(""))
    Assert.assertFalse(startsWith.matches("bar"))
    Assert.assertFalse(startsWith.matches("bar.foo"))
    Assert.assertFalse(startsWith.matches("bar.foo.test"))
  }

  @Test
  def excludePatternPredicate(): Unit = {
    val doesNotStartsWith = RegexMetricPredicate(None, Some(startsWithFoo))

    Assert.assertFalse(doesNotStartsWith.matches("foo"))
    Assert.assertFalse(doesNotStartsWith.matches("foo.bar.test"))

    Assert.assertTrue(doesNotStartsWith.matches(""))
    Assert.assertTrue(doesNotStartsWith.matches("bar"))
    Assert.assertTrue(doesNotStartsWith.matches("bar.foo"))
    Assert.assertTrue(doesNotStartsWith.matches("bar.foo.test"))
  }

  @Test
  def includeExcludePatternsPredicate(): Unit = {
    val matcher = RegexMetricPredicate(Some(startsWithFoo), Some(containsBar))

    Assert.assertTrue(matcher.matches("foo"))

    Assert.assertFalse(matcher.matches("foo.bar.test"))
    Assert.assertFalse(matcher.matches(""))
    Assert.assertFalse(matcher.matches("bar"))
    Assert.assertFalse(matcher.matches("bar.foo"))
    Assert.assertFalse(matcher.matches("bar.foo.test"))
  }
} 
开发者ID:kongo2002,项目名称:kafka-statsd-reporter,代码行数:61,代码来源:RegexMetricPredicateTest.scala


示例14: SimpleValidationTest

//设置package包名称以及导入依赖的类
package com.github.rehei.scala.forms.test

import com.github.rehei.scala.forms.test.model.Company
import org.junit.Test
import com.github.rehei.scala.forms.test.model.Employee
import com.github.rehei.scala.forms.validation.Validator
import com.github.rehei.scala.macros.Reflection
import com.github.rehei.scala.forms.util.Conversions._
import com.github.rehei.scala.forms.rules.IsTrue
import com.github.rehei.scala.forms.rules.MinLength
import com.github.rehei.scala.forms.rules.MaxLength
import org.junit.Assert
import org.junit.Assert._

class SimpleValidationTest {

  @Test
  def test() {

    val company = new Reflection[Company]
    val employee = new Reflection[Employee]

    val model = new Company()
    model.employees.add(new Employee())
    model.employees.add(new Employee())

    model.name = "123"

    val validator = {
      Validator
        .attach(
          company(_.name)
            .assert(MinLength(5).message("Too short"))
            .assert(MaxLength(10).message("Too long")))
    }

    val results = validator.validate(model)

    val v0 = results(0)
    val v1 = results(1)

    assertEquals(v0.isValid, false)
    assertEquals(v0.ruleName, classOf[MinLength].getCanonicalName)

    assertEquals(v1.isValid, true)
    assertEquals(v1.ruleName, classOf[MaxLength].getCanonicalName)

    println(v0)
    println(v1)
  }

} 
开发者ID:rehei,项目名称:scala-forms,代码行数:53,代码来源:SimpleValidationTest.scala


示例15: DerivedAttributesShouldBeReadOnlyTest

//设置package包名称以及导入依赖的类
package com.github.bmaggi.sysml.evaluation

/**
  * Created by Benoit Maggi on 11/05/2016.
  */

import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import org.junit.{Assert, Test}

import scala.xml.{Node, XML}

@RunWith(classOf[JUnit4])
class DerivedAttributesShouldBeReadOnlyTest {

  @Test def test() {
    val xml = XML.load(getClass.getResource("/SysML.xmi"))
    val ownedAttributeList = (xml \\ XMIUtils.ownedAttribute).filter(x => // filter the sequence of ownedAttribute
      ((x \\ "isDerived").nonEmpty && (x \\ "isReadOnly").isEmpty))
    Assert.assertTrue("Some elements are missing read only:\n" + prettyPrint(ownedAttributeList), ownedAttributeList.isEmpty)
  }

  //TODO : there is probably a better Scala way to do that
  def prettyPrint(ownedAttributeSeq: Seq[Node]): String = {
    var res = new String()
    for (missingReadOnly: Node <- ownedAttributeSeq) {
      res ++= missingReadOnly.attribute(XMIUtils.XMI_XMNLS, "id").get.toString
      res ++= "\n"
    }
    return res
  }

} 
开发者ID:bmaggi,项目名称:sysml-evaluation,代码行数:34,代码来源:DerivedAttributesShouldBeReadOnlyTest.scala


示例16: AttributesShouldHaveAnnotatedCommentsTest

//设置package包名称以及导入依赖的类
package com.github.bmaggi.sysml.evaluation

/**
  * Created by Benoit Maggi on 11/05/2016.
  */


import org.junit.{Assert, Test}

import scala.collection.mutable.ListBuffer
import scala.xml.XML


class AttributesShouldHaveAnnotatedCommentsTest {


  @Test def testMissingAnnotatedComments() {
    val xml = XML.load(getClass.getResource("/SysML.xmi"))
    val ownedAttributeList = (xml \\ XMIUtils.ownedAttribute);
    var ownedAttributeIds = new ListBuffer[String]()
    for (ownedAttribute <- ownedAttributeList) {
      ownedAttributeIds += ownedAttribute.attribute(XMIUtils.XMI_XMNLS, "id").get.toString
    }
    val annotatedElementList = (xml \\ XMIUtils.annotatedElement);
    // remove annotated elements
    for (annotatedElement <- annotatedElementList) {
      val id: String = annotatedElement.attribute(XMIUtils.XMI_XMNLS, "idref").get.toString
      ownedAttributeIds.-=(id)
    }
    // remove base elements (we don't explicitly require a description for the tooling)
    val ownedAttributeIdsNoBase = ownedAttributeIds.filterNot(_.contains("base_"))
    Assert.assertTrue("Some elements are missing annotated comments:\n" + prettyPrint(ownedAttributeIdsNoBase), ownedAttributeIdsNoBase.isEmpty)
  }

  //TODO : there is probably a better Scala way to do that
  def prettyPrint(ownedAttributeIdsNoBase: ListBuffer[String]): String = {
    var res = new String()
    for (notAnnotated: String <- ownedAttributeIdsNoBase) {
      res ++= notAnnotated
      res ++= "\n"
    }
    return res
  }

} 
开发者ID:bmaggi,项目名称:sysml-evaluation,代码行数:46,代码来源:AttributesShouldHaveAnnotatedCommentsTest.scala


示例17: NullSensitiveOrdered

//设置package包名称以及导入依赖的类
package de.hpi.isg.sodap.rdfind.util

import de.hpi.isg.sodap.rdfind.util.NullSensitiveOrdered$Test.TestClass
import org.junit.{Assert, Test}


class NullSensitiveOrdered$Test {

  @Test
  def testOrdering = {
    Assert.assertTrue(TestClass(null) <= TestClass(null))
    Assert.assertTrue(TestClass(null) >= TestClass(null))
    Assert.assertTrue(TestClass("a") > TestClass(null))
    Assert.assertTrue(TestClass(null) < TestClass("a"))
    Assert.assertTrue(TestClass("a") >= TestClass("a"))
    Assert.assertTrue(TestClass("a") <= TestClass("a"))
    Assert.assertTrue(TestClass("a") < TestClass("b"))
    Assert.assertTrue(TestClass("b") > TestClass("a"))
  }

}

object NullSensitiveOrdered$Test {

  case class TestClass(value: String) extends NullSensitiveOrdered[TestClass] {
    override def compare(that: TestClass): Int = compareNullSensitive(this.value, that.value)
  }

} 
开发者ID:stratosphere,项目名称:rdfind,代码行数:30,代码来源:NullSensitiveOrdered$Test.scala


示例18: ConditionCodes

//设置package包名称以及导入依赖的类
package de.hpi.isg.sodap.rdfind.util

import org.junit.Assert._
import org.junit.{Assert, Test}

class ConditionCodes$Test {

  def test: Unit = ???

  @Test
  def testIsBinaryCondition = {
    List(9, 10, 12, 17, 18, 20, 33, 34, 36).foreach { code =>
      Assert.assertFalse(s"Code $code was classified incorrectly!", ConditionCodes.isBinaryCondition(code))
    }
    List(11, 13, 14, 19, 21, 22, 35, 37, 38).foreach { code =>
      Assert.assertTrue(s"Code $code was classified incorrectly!", ConditionCodes.isBinaryCondition(code))
    }
  }
  @Test
  def testIsUnaryCondition = {
    List(9, 10, 12, 17, 18, 20, 33, 34, 36).foreach { code =>
      Assert.assertTrue(s"Code $code was classified incorrectly!", ConditionCodes.isUnaryCondition(code))
    }
    List(11, 13, 14, 19, 21, 22, 35, 37, 38).foreach { code =>
      Assert.assertFalse(s"Code $code was classified incorrectly!", ConditionCodes.isUnaryCondition(code))
    }
  }
  @Test
  def testSanityCheck = {
    val allCodes = List(10, 12, 17, 20, 33, 34) ++ List(14, 21, 35)
    for (i <- 0 to 255) {
      Assert.assertEquals(s"False sanity check on $i.", allCodes.contains(i), ConditionCodes.isValidStandardCapture(i))
    }
  }

} 
开发者ID:stratosphere,项目名称:rdfind,代码行数:37,代码来源:ConditionCodes$Test.scala


示例19: HttpTextIOTest

//设置package包名称以及导入依赖的类
import org.apache.spark.sql.execution.streaming.BufferedTextCollector
import org.apache.spark.sql.execution.streaming.HttpTextReceiver
import org.apache.spark.sql.execution.streaming.HttpTextSender
import org.apache.spark.sql.execution.streaming.TextConsolePrinter
import org.junit.Assert
import org.junit.Test
import org.apache.spark.SparkConf

class HttpTextIOTest {
	val LINES1 = Array[String]("hello", "world", "bye", "world");
	val LINES2 = Array[String]("HELLO", "WORLD", "BYE", "WORLD");

	@Test
	def testHttpTextIO() {
		//starts a http server with a receiver servlet
		val receiver = HttpTextReceiver.startReceiver(new SparkConf(), "receiver1", "/xxxx", 8080);
		receiver.addListener(new TextConsolePrinter());
		val buffer = new BufferedTextCollector();
		receiver.addListener(buffer);

		val sender = new HttpTextSender("http://localhost:8080/xxxx");
		sender.sendTextArray("topic-1", -1, LINES1, false);
		receiver.stop();

		val data = buffer.dump().map(_._1).toArray;
		Assert.assertArrayEquals(LINES1.asInstanceOf[Array[Object]], data.asInstanceOf[Array[Object]]);
	}

	@Test
	def testHttpGzippedTextIO() {
		//starts a http server with a receiver servlet
		val receiver = HttpTextReceiver.startReceiver(new SparkConf(), "receiver1", "/xxxx", 8080);
		receiver.addListener(new TextConsolePrinter());
		val buffer = new BufferedTextCollector();
		receiver.addListener(buffer);

		val sender = new HttpTextSender("http://localhost:8080/xxxx");
		sender.sendTextArray("topic-1", -1, LINES1, true);
		receiver.stop();

		val data = buffer.dump().map(_._1).toArray;
		Assert.assertArrayEquals(LINES1.asInstanceOf[Array[Object]], data.asInstanceOf[Array[Object]]);
	}
} 
开发者ID:bluejoe2008,项目名称:spark-http-stream,代码行数:45,代码来源:HttpTextIOTest.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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