当前位置: 首页>>代码示例>>Scala>>正文


Scala AssertionsForJUnit类代码示例

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


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

示例1: DtabStatsFilterTest

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

import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}
import com.twitter.finagle.stats.InMemoryStatsReceiver
import com.twitter.finagle.{Dtab, Service}
import com.twitter.util.{Await, Future}

@RunWith(classOf[JUnitRunner])
class DtabStatsFilterTest extends FunSuite with AssertionsForJUnit {

  test("empty Dtab.local") {
    val statsReceiver = new InMemoryStatsReceiver
    val service =
      new DtabStatsFilter[Unit, Unit](statsReceiver.scope("prefix")) andThen
      Service.mk[Unit, Unit](_ => Future.Unit)

    Dtab.unwind {
      Dtab.local = Dtab.empty
      Await.result(service((): Unit))
    }

    val stat = statsReceiver.stat("prefix", "dtab", "size")
    assert(stat() == Nil)
  }

  test("non-empty Dtab.local") {
    val statsReceiver = new InMemoryStatsReceiver
    val service =
      new DtabStatsFilter[Unit, Unit](statsReceiver.scope("prefix")) andThen
      Service.mk[Unit, Unit](_ => Future.Unit)

    Dtab.unwind {
      Dtab.local = Dtab.read("/s=>/foo;/s=>/bar;/s=>/bah")
      Await.result(service((): Unit))
    }

    val stat = statsReceiver.stat("prefix", "dtab", "size")
    assert(stat() == List(3.0))
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:43,代码来源:DtabStatsFilterTest.scala

示例2: DeadlineTest

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

import com.twitter.util.{Time, Duration, Return}
import org.junit.runner.RunWith
import org.scalacheck.Gen
import org.scalatest.FunSuite
import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}
import org.scalatest.prop.GeneratorDrivenPropertyChecks

@RunWith(classOf[JUnitRunner])
class DeadlineTest 
  extends FunSuite 
  with AssertionsForJUnit
  with GeneratorDrivenPropertyChecks {

  val time = for (t <- Gen.choose(0L, Long.MaxValue)) yield Time.fromNanoseconds(t)
  val dur = for (d <- Gen.choose(0L, Long.MaxValue)) yield Duration.fromNanoseconds(d)
  val deadline = for (t <- time; d <- dur) yield Deadline(t, t + d)
  val deadlineWithoutTop  = deadline.filter(_.deadline != Time.Top)

  test("Deadline marshalling") {
    // won't pass Time.Top as deadline for marshalling
    forAll(deadlineWithoutTop) { d =>
      assert(Deadline.tryUnmarshal(Deadline.marshal(d)) == Return(d))
    }
  }

  test("Deadline.combined") {
    forAll(deadline, deadline) { (d1, d2) =>
      assert(Deadline.combined(d1, d2).timestamp == (d1.timestamp max d2.timestamp))
      assert(Deadline.combined(d1, d2).deadline == (d1.deadline min d2.deadline))
      assert(Deadline.combined(d1, d2) == Deadline.combined(d2, d1))
    }
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:36,代码来源:DeadlineTest.scala

示例3: StatsScopingTest

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

import com.twitter.finagle.{Addr, Service, Stack, StackBuilder, ServiceFactory}
import com.twitter.finagle.client.AddrMetadataExtraction.AddrMetadata
import com.twitter.finagle.param.Stats
import com.twitter.finagle.stack.nilStack
import com.twitter.finagle.stats.{InMemoryStatsReceiver, StatsReceiver}
import com.twitter.util.{Await, Future}
import org.junit.runner.RunWith
import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}
import org.scalatest.FunSuite

@RunWith(classOf[JUnitRunner])
class StatsScopingTest extends FunSuite with AssertionsForJUnit {
  class Ctx {
    val stats = new InMemoryStatsReceiver

    def mkCounterService(stats: StatsReceiver) =
      Service.mk[String, Unit] { key =>
        stats.counter(key).incr()
        Future.Done
      }

    val counterServiceModule = new Stack.Module[ServiceFactory[String, Unit]] {
      val role = Stack.Role("counterServiceModule")
      val description = "Produce a test service that increments stats counters"
      val parameters = Seq(implicitly[Stack.Param[StatsScoping.Scoper]])
      def make(params: Stack.Params, next: Stack[ServiceFactory[String, Unit]]) = {
        val Stats(stats0) = params[Stats]
        Stack.Leaf(this, ServiceFactory.const(mkCounterService(stats0)))
      }
    }

    def mkService(metadata: Addr.Metadata)(scoper: StatsScoping.ScoperFunction) = {
      val factory = new StackBuilder[ServiceFactory[String, Unit]](nilStack[String, Unit])
        .push(counterServiceModule)
        .push(StatsScoping.module)
        .make(Stack.Params.empty
          + Stats(stats)
          + StatsScoping.Scoper(scoper)
          + AddrMetadata(metadata))

      Await.result(factory())
    }
  }

  test("scope based on metadata")(new Ctx {
    val service = mkService(Addr.Metadata("zone" -> "foo")) { (stats0, metadata) =>
      stats0.scope(metadata("zone").toString)
    }
    assert(Map.empty == stats.counters)

    Await.result(service("bar"))
    Await.result(service("baz"))

    assert(Map(Seq("foo", "bar") -> 1, Seq("foo", "baz") -> 1) == stats.counters)
  })
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:59,代码来源:StatsScopingTest.scala

示例4: ResolutionRaceTest

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

import com.twitter.util._
import java.net.{InetAddress, InetSocketAddress}
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}

@RunWith(classOf[JUnitRunner])
class ResolutionRaceTest extends FunSuite with AssertionsForJUnit {

  private[this] val Echoer = Service.mk[String, String](Future.value)

  
   // Fails in CI, see CSL-1307 and CSL-1358
   if (!sys.props.contains("SKIP_FLAKY")) test("resolution raciness") {
    val socketAddr = new InetSocketAddress(InetAddress.getLoopbackAddress, 0)
    val server = Echo.serve(socketAddr, Echoer)
    val addr = server.boundAddress.asInstanceOf[InetSocketAddress]
    val dest = "asyncinet!localhost:%d".format(addr.getPort)
    try {
      1 to 1000 foreach { i =>
        val phrase = "%03d [%s]".format(i, dest)
        val echo = Echo.newService(dest)
        try {
          val echoed = Await.result(echo(phrase))
          assert(echoed == phrase)
        } finally Await.ready(echo.close())
      }
    } catch {
      case _: NoBrokersAvailableException =>
        fail("resolution is racy")
    } finally {
      Await.result(server.close())
    }
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:38,代码来源:ResolutionRaceTest.scala

示例5: ExitGuardTest

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

import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.concurrent.{Eventually, IntegrationPatience}
import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}
import org.scalatest.mock.MockitoSugar

@RunWith(classOf[JUnitRunner])
class ExitGuardTest
  extends FunSuite
  with MockitoSugar
  with AssertionsForJUnit
  with Eventually
  with IntegrationPatience {

  test("guard creates thread, unguard removes") {
    val name = s"ExitGuardTest-${System.nanoTime}"
    val guard = ExitGuard.guard(name)
    val (thread, guards) = ExitGuard.guards.get

    assert(!thread.isDaemon)
    assert(thread.isAlive)
    assert(guards.map(_.reason).contains(name))

    guard.unguard()

    // depending on what has been registered and unregistered,
    // either there should be no guards or our name should not be in the list.
    ExitGuard.guards match {
      case None =>
        eventually { assert(!thread.isAlive, ExitGuard.explainGuards()) }
      case Some((_, gs)) =>
        assert(!gs.map(_.reason).contains(name))
    }
  }

  test("explain shows reason") {
    val guard = ExitGuard.guard("<%= reason %>")
    assert(ExitGuard.explainGuards().contains("<%= reason %>"))
    guard.unguard()
    assert(!ExitGuard.explainGuards().contains("<%= reason %>"))
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:45,代码来源:ExitGuardTest.scala

示例6: ThriftIfaceTest

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

import com.twitter.finagle.ThriftMux
import com.twitter.util.Future
import org.junit.runner.RunWith
import org.scalatest.FunSuite
import org.scalatest.junit.{AssertionsForJUnit, JUnitRunner}

@RunWith(classOf[JUnitRunner])
class ThriftIfaceTest extends FunSuite with AssertionsForJUnit {
  test("invalid thrift ifaces") {
    trait FakeThriftIface {
      def query(x: String): Future[String]
    }

    intercept[IllegalArgumentException] {
      ThriftMux.server.serveIface(
        "localhost:*",
        new FakeThriftIface { def query(x: String) = Future.value(x) })
    }
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:23,代码来源:ThriftIfaceTest.scala

示例7: ReferenceFileReadTest

//设置package包名称以及导入依赖的类
package se.lth.immun.anubis

import org.scalatest.junit.AssertionsForJUnit
import scala.collection.mutable.ListBuffer
import org.junit.Assert._
import org.junit.Test
import org.junit.Before

import se.lth.immun.xml.XmlReader
import java.io.StringReader
import java.io.File
import java.io.FileReader
import java.io.BufferedReader

class ReferenceFileReadTest extends AssertionsForJUnit {
	
	val valid = """<?xml version="1.0"?>
<reference>
  <reference_files count="1">
    <reference_file file_id="0" absolute_path="/path/to/my/dir/hej.raw" />
  </reference_files>
  <precursors count="1">
	<precursor mz="507.303124" file_id="0" protein_name="Hello" peptide_sequence="ABC">
      <retention_time start="33.333" peak="33.444" end="34.555" />
      <measured_transitions count="2">
      	<transition mz="541.298038" ion="b5" data_name="SIC1" transition_id="0" />
        <transition mz="654.382102" ion="b6" data_name="SIC2" transition_id="1" />
      </measured_transitions>
      <ignored_transitions count="0" />
      <transition_ratios count="1">
        <transition_ratio id1="0" id2="1" mean="1.39669380015338" std_dev="1.18884798746988" />
      </transition_ratios>
    </precursor>
  </precursors>
</reference>
	"""
	
	var x:XmlReader = null
	var s:StringReader = null

	@Before
	def setupReader() = {
		s = new StringReader(valid)
		x = new XmlReader(s)
	}
	

} 
开发者ID:fickludd,项目名称:anubis,代码行数:49,代码来源:ReferenceFileReadTest.scala

示例8: PrettyWorklogPrinterTest

//设置package包名称以及导入依赖的类
package ch.loewenfels.jira.plugin.vertec

import org.scalatest.junit.AssertionsForJUnit
import org.specs2.mock.Mockito
import org.junit.Test
import com.atlassian.jira.issue.worklog.Worklog
import com.atlassian.jira.issue.Issue

class PrettyWorklogPrinterTest extends AssertionsForJUnit with Mockito  {

  @Test def print_worklog_stringWithIssueKeyDateAndTimeSpent {
    //arrange
    val worklog = mock[Worklog]

    val issue=mock[Issue]
    issue.getKey returns "DEV-XY"
    worklog.getStartDate returns new java.util.Date(1000000)
    worklog.getIssue returns issue
    worklog.getTimeSpent returns 60*60*2
    worklog.getId returns 5L
    //act
    val actual=PrettyWorklogPrinter.print(worklog)
    //assert
    assert(actual === "DEV-XY at 01.01.1970 spent 120 minutes (id=5)")
  }

} 
开发者ID:loewenfels,项目名称:jira-vertec-plugin,代码行数:28,代码来源:PrettyWorklogPrinterTest.scala

示例9: PluginTest

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

import java.nio.charset.Charset

import org.apache.http.client.fluent.Response
import org.junit.{After, Before, Test}
import org.scalatest.junit.AssertionsForJUnit

class PluginTest extends AssertionsForJUnit {

  @Before
  def init(): Unit = {
  }

  @After
  def exit() {
  }

  @Test
  def testRegex(): Unit = {
    val regex = "http://user.mahua.com/ajax/joke/checkJokesDynamic[\\w\\W]*"
    val url = "http://user.mahua.com/ajax/joke/checkJokesDynamic?callback=jQuery17209865076656443552_1498566208473&joke_ids=1679937%2C1679936%2C1679935%2C1679934%2C1679933%2C1679932%2C1679928%2C1679927%2C1679929%2C1679931%2C1679930%2C1679926%2C1679923%2C1679921%2C1679919%2C1679918%2C1679925%2C1679924%2C1679922%2C1679920&_=1498566208688"

    println(url.matches(regex))
  }

  @Test
  def testGetVoteUpDown(): Unit = {
    val url = "http://user.mahua.com/ajax/joke/checkJokesDynamic?callback=jQuery&joke_ids=1679937&_=1498571259447"

    val resp: Response = org.apache.http.client.fluent.Request.Get(url)
      .addHeader("Accept", "text/html,application/xhtml+xml,application/json;q=0.9,image/webp,*/*;q=0.8")
      .addHeader("Accept-Encoding", "gzip, deflate, sdch")
      .addHeader("Accept-Language", "zh-CN,zh;q=0.8,en;q=0.6")
      .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36")
      .addHeader("Upgrade-Insecure-Requests", "1")
      .addHeader("Proxy-Connection", "keep-alive")
      .addHeader("DNT", "1")
      .execute
    val result = resp.returnContent.asString(Charset.forName("UTF-8"))
    println(result)
  }
} 
开发者ID:sutine,项目名称:webant-workbench,代码行数:44,代码来源:PluginTest.scala

示例10: KuaidailiCrawlerTest

//设置package包名称以及导入依赖的类
package org.webant.plugin.test.kuaidaili

import java.io.IOException
import java.nio.charset.Charset

import org.jsoup.Jsoup
import org.junit.{After, Before, Test}
import org.scalatest.junit.AssertionsForJUnit

import scala.collection.JavaConverters._

class KuaidailiCrawlerTest extends AssertionsForJUnit {

  @Before
  def init(): Unit = {
  }

  @After
  def exit() {
  }

  @Test
  @throws[IOException]
  def crawl() {
    val regex = "http://www.kuaidaili.com/free/?\\w*/?\\d*/?"
    val url = "http://www.kuaidaili.com/free/intr/1714/"
    if (!url.matches(regex))
      return

    val resp = org.apache.http.client.fluent.Request.Get(url)
      .addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
      .addHeader("Accept-Encoding", "gzip, deflate")
      .addHeader("Accept-Language", "zh-CN,zh;q=0.8")
      .addHeader("Cache-Control", "max-age=0")
      .addHeader("Connection", "keep-alive")
      .addHeader("Cookie", "channelid=0; sid=1499250960617393; _ga=GA1.2.1752332708.1497859110; _gid=GA1.2.235526105.1499251241; Hm_lvt_7ed65b1cc4b810e9fd37959c9bb51b31=1497859110; Hm_lpvt_7ed65b1cc4b810e9fd37959c9bb51b31=1499252564")
      .addHeader("Upgrade-Insecure-Requests", "1")
      .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36")
      .execute
    val result = resp.returnContent.asString(Charset.forName("UTF-8"))
    val doc = Jsoup.parse(result, url)

    val tds = doc.select("#list tbody tr").asScala.map(tr => {
      tr.select("td").asScala.map(td => {
        td.text()
      })
    })
    println(tds)
  }
} 
开发者ID:sutine,项目名称:webant-workbench,代码行数:51,代码来源:KuaidailiCrawlerTest.scala

示例11: GuShiWenCrawlerTest

//设置package包名称以及导入依赖的类
package org.webant.plugin.test.gushiwen

import java.io.IOException
import java.nio.charset.Charset

import org.junit.{After, Before, Test}
import org.scalatest.junit.AssertionsForJUnit
import org.webant.plugin.zhihu.processor.{AnswersProcessor, ZhihuSeedProcessor}

class GuShiWenCrawlerTest extends AssertionsForJUnit {

  @Before
  def init(): Unit = {
  }

  @After
  def exit() {
  }

  @Test
  def testLoadIds(): Unit = {
    val seed = new ZhihuSeedProcessor
    val answer = new AnswersProcessor
    val ids = seed.links()
    val remainIds = ids.filter(answer.accept)
    println(remainIds.size)
  }

  @Test
  def testRegex(): Unit = {
    val regex = "https://www.zhihu.com/api/v4/members/[0-9a-zA-Z-]*/answers?[\\w\\W]*"
    val url = "https://www.zhihu.com/api/v4/members/ma-en-32/answers?include=data%5B*%5D.is_normal%2Cis_collapsed%2Ccollapse_reason%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Cmark_infos%2Ccreated_time%2Cupdated_time%2Creview_info%2Crelationship.is_authorized%2Cvoting%2Cis_author%2Cis_thanked%2Cis_nothelp%2Cupvoted_followees%3Bdata%5B*%5D.author.badge%5B%3F(type%3Dbest_answerer)%5D.topics&offset=20&limit=20&sort_by=created"

    println(url.matches(regex))
  }

  @Test
  @throws[IOException]
  def crawl() {
    val url = "http://www.gushiwen.org/default_3.aspx"
    val body = ""
    val resp = org.apache.http.client.fluent.Request.Get(url)
//      .bodyString(body, ContentType.APPLICATION_FORM_URLENCODED)
      .addHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8")
      .addHeader("Accept-Encoding", "gzip, deflate")
      .addHeader("Accept-Language", "zh-CN,zh;q=0.8")
      .addHeader("Cache-Control", "max-age=0")
      .addHeader("Connection", "keep-alive")
      .addHeader("Cookie", "ASP.NET_SessionId=53xs3mimhjnhuoprpehzws0i; Hm_lvt_04660099568f561a75456483228a9516=1498717319; Hm_lpvt_04660099568f561a75456483228a9516=1498720515")
//      .addHeader("If-Modified-Since", "Wed, 28 Jun 2017 08:59:13 GMT")
      .addHeader("Referer", "http://www.gushiwen.org/")
      .addHeader("Upgrade-Insecure-Requests", "1")
      .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36")
      .execute
    val result = resp.returnContent.asString(Charset.forName("UTF-8"))
    println(result)
  }
} 
开发者ID:sutine,项目名称:webant-workbench,代码行数:59,代码来源:GuShiWenCrawlerTest.scala

示例12: ZhihuCrawler

//设置package包名称以及导入依赖的类
package org.webant.plugin.test.zhihu

import java.io.IOException
import java.nio.charset.Charset

import org.apache.http.client.fluent.Response
import org.junit.{After, Before, Test}
import org.scalatest.junit.AssertionsForJUnit
import org.webant.plugin.zhihu.processor.{AnswersProcessor, ZhihuSeedProcessor}

class ZhihuCrawler extends AssertionsForJUnit {

  @Before
  def init(): Unit = {
  }

  @After
  def exit() {
  }

  @Test
  def testLoadIds(): Unit = {
    val seed = new ZhihuSeedProcessor
    val answer = new AnswersProcessor
    val ids = seed.links()
    val remainIds = ids.filter(answer.accept)
    println(remainIds.size)
  }

  @Test
  def testRegex(): Unit = {
    val regex = "https://www.zhihu.com/api/v4/members/[0-9a-zA-Z-]*/answers?[\\w\\W]*"
    val url = "https://www.zhihu.com/api/v4/members/ma-en-32/answers?include=data%5B*%5D.is_normal%2Cis_collapsed%2Ccollapse_reason%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Cmark_infos%2Ccreated_time%2Cupdated_time%2Creview_info%2Crelationship.is_authorized%2Cvoting%2Cis_author%2Cis_thanked%2Cis_nothelp%2Cupvoted_followees%3Bdata%5B*%5D.author.badge%5B%3F(type%3Dbest_answerer)%5D.topics&offset=20&limit=20&sort_by=created"

    println(url.matches(regex))
  }

  @Test
  @throws[IOException]
  def crawl() {
    val url: String = "https://www.zhihu.com/api/v4/members/huang-jie-rui-23/answers?offset=0&limit=20&sort_by=created&include=data[*].is_normal,is_collapsed,collapse_reason,suggest_edit,comment_count,can_comment,content,voteup_count,reshipment_settings,comment_permission,mark_infos,created_time,updated_time,review_info,relationship.is_authorized,voting,is_author,is_thanked,is_nothelp,upvoted_followees;data[*].author.badge[?(type=best_answerer)].topics"
    val body: String = "offset=20&limit=20&sort_by=created&include=data[*].is_normal,is_collapsed,collapse_reason,suggest_edit,comment_count,can_comment,content,voteup_count,reshipment_settings,comment_permission,mark_infos,created_time,updated_time,review_info,relationship.is_authorized,voting,is_author,is_thanked,is_nothelp,upvoted_followees;data[*].author.badge[?(type=best_answerer)].topics"
    val referer: String = "https://www.zhihu.com/people/sgai/answers"
    val resp: Response = org.apache.http.client.fluent.Request.Get(url)
//      .bodyString(body, ContentType.APPLICATION_FORM_URLENCODED)
      .addHeader("Accept", "application/json, text/plain, */*")
      .addHeader("Accept-Encoding", "gzip, deflate, br")
      .addHeader("Accept-Language", "zh-CN,zh;q=0.8")
      .addHeader("authorization", "oauth c3cef7c66a1843f8b3a9e6a1e3160e20")
      .addHeader("Connection", "keep-alive")
      .addHeader("Cookie", "q_c1=4e2c8fb281aa49f7a1a4c8f88297eb25|1497321957000|1497321957000; q_c1=ce4133c29ce34b8cb8a3d2f217706cee|1497321957000|1497321957000; aliyungf_tc=AQAAAOHxiwPxPQUAUb0Qt6/uDktO7KJF; capsion_ticket=\"2|1:0|10:1497930998|14:capsion_ticket|44:ZjRkNDVkNDEwYmY1NDZiNjk0ZjhlNjA1NGM3Mjk1ODk=|1f544f44ef3522b9bd1dede68727c906774eef7d8e1efc05e62b642bea3278ac\"; r_cap_id=\"MGQxNmI4MTViNDNkNDdkZDhiNDJjYmMxYjFlZTk2MTk=|1498653197|7a5cc12917ace5c66d6558b8d9639d3bdd9734f9\"; cap_id=\"Y2RjYzU4YjQ5MzRlNDEzOGE5NDlhMTgyYTU0Y2ZmNWM=|1498653197|5eb2b7e7932423a4f49322a0d7b0d4087b5536a0\"; d_c0=\"AIBCCu2_-wuPTv6gpIWSY62GJJWv1Q6X7vM=|1498653198\"; _zap=5da260eb-bc7d-4ee6-8563-ca7267dc83a7; __utma=51854390.1081252107.1498653231.1498653231.1498653231.1; __utmc=51854390; __utmz=51854390.1498653231.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=51854390.000--|3=entry_date=20170613=1; l_n_c=1; l_cap_id=\"NzFiNzIxZjM0YTZkNGRmYWJkMGU3NzliZjljYWRmZGQ=|1498653211|9028a58183ea376bf5dcc3be0014a071a6fb0a16\"; n_c=1; _xsrf=77f2b8a9-9707-4117-b1e6-2876f8f8405a")
      .addHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36")
      .addHeader("x-udid", "AIBCCu2_-wuPTv6gpIWSY62GJJWv1Q6X7vM=")
      .execute
    val result = resp.returnContent.asString(Charset.forName("GBK"))
    println(result)
  }
} 
开发者ID:sutine,项目名称:webant-workbench,代码行数:59,代码来源:ZhihuCrawler.scala

示例13: IpadicMecabTestSuite

//设置package包名称以及导入依赖的类
package us.feliscat.text.analyzer.mor.mecab

import org.junit.Test
import org.scalatest.junit.AssertionsForJUnit
import us.feliscat.text.StringOption


class IpadicMecabTestSuite extends AssertionsForJUnit {
  @Test
  def testAnalysisResult(): Unit = {
    val result: String = UnidicMecab.analysisResult(
      StringOption(
        "????????????????????????????????"
      )
    ).get
    assert(result ==
      """??	??,????,??,*,*,*,???,??,??,???,??,???,?,*,*,*,*,???,???,???,???,*,*,1,C1,*
        |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,?,?,,,*,*,*,*,*
        |??	??,????,????,*,*,*,????,??,??,????,??,????,?,*,*,*,*,????,????,????,????,*,*,0,C2,*
        |??	??,????,??,*,*,*,????,??,??,????,??,????,?,*,*,*,*,????,????,????,????,*,*,1,C1,*
        |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,??%F1,*
        |??	??,????,????,*,*,*,????,??,??,????,??,????,?,*,*,*,*,????,????,????,????,*,*,0,C2,*
        |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,"??%[email protected],??%F1",*
        |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,,,,,*,*,*,*,*
        |???	??,????,??,*,*,*,???????,???????,basyo,basyo,??,??,?,*,*,*,*
        |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,?,?,,,*,*,*,*,*
        |????	??,????,??,*,*,*,???????,???????,basyo,basyo,??,??,?,*,*,*,*
        |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,??%F1,*
        |???	??,????,??,*,*,*,???????,???????,syakaigainen,syakaigainen,[email protected][email protected]??,[email protected][email protected]??,?,*,*,*,*
        |?	???,???,????,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,C4,*
        |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,"??%[email protected],??%F1,???%[email protected]",*
        |????	??,??,*,*,??-??,???-??,????,??,????,????,????,????,?,*,*,*,*,????,????,????,????,*,*,"0,3",C2,*
        |?	???,*,*,*,???-?,???-??,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,"??%[email protected],???%[email protected]",*
        |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,,,,,*,*,*,*,*
        |EOS
        |""".stripMargin)
  }
} 
开发者ID:ktr-skmt,项目名称:FelisCatusZero-multilingual,代码行数:39,代码来源:IpadicMecabTestSuite.scala

示例14: UnidicMecabTestSuite

//设置package包名称以及导入依赖的类
package us.feliscat.text.analyzer.mor.mecab

import org.junit.Test
import org.scalatest.junit.AssertionsForJUnit
import us.feliscat.text.StringOption


class UnidicMecabTestSuite extends AssertionsForJUnit {
  @Test
  def testAnalysisResult(): Unit = {
    val result: String = UnidicMecab.analysisResult(
      StringOption(
        "????????????????????????????????"
      )
    ).get
    assert(
      result ==
        """??	??,????,??,*,*,*,???,??,??,???,??,???,?,*,*,*,*,???,???,???,???,*,*,1,C1,*
          |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,?,?,,,*,*,*,*,*
          |??	??,????,????,*,*,*,????,??,??,????,??,????,?,*,*,*,*,????,????,????,????,*,*,0,C2,*
          |??	??,????,??,*,*,*,????,??,??,????,??,????,?,*,*,*,*,????,????,????,????,*,*,1,C1,*
          |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,??%F1,*
          |??	??,????,????,*,*,*,????,??,??,????,??,????,?,*,*,*,*,????,????,????,????,*,*,0,C2,*
          |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,"??%[email protected],??%F1",*
          |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,,,,,*,*,*,*,*
          |???	??,????,??,*,*,*,???????,???????,basyo,basyo,??,??,?,*,*,*,*
          |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,?,?,,,*,*,*,*,*
          |????	??,????,??,*,*,*,???????,???????,basyo,basyo,??,??,?,*,*,*,*
          |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,??%F1,*
          |???	??,????,??,*,*,*,???????,???????,syakaigainen,syakaigainen,[email protected][email protected]??,[email protected][email protected]??,?,*,*,*,*
          |?	???,???,????,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,C4,*
          |?	??,???,*,*,*,*,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,"??%[email protected],??%F1,???%[email protected]",*
          |????	??,??,*,*,??-??,???-??,????,??,????,????,????,????,?,*,*,*,*,????,????,????,????,*,*,"0,3",C2,*
          |?	???,*,*,*,???-?,???-??,?,?,?,?,?,?,?,*,*,*,*,?,?,?,?,*,*,*,"??%[email protected],???%[email protected]",*
          |?	????,??,*,*,*,*,,?,?,,?,,??,*,*,*,*,,,,,*,*,*,*,*
          |EOS
          |""".stripMargin)
  }
} 
开发者ID:ktr-skmt,项目名称:FelisCatusZero-multilingual,代码行数:40,代码来源:UnidicMecabTestSuite.scala

示例15: Exercise01

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

import forimpatient.chapter06.Exercise02.{GallonsToLiters, InchesToCentimeters, MilesToKilometers}
import org.scalatest.junit.AssertionsForJUnit
import org.junit.Assert.{assertEquals, assertNotNull}
import org.junit.Test


class Exercise01 extends AssertionsForJUnit {
  val delta = 0.00001

  @Test def testNotNull() = {
    val actual = "10"
    assertNotNull(actual)
  }

  @Test def testInchesToCentimeters() = {
    val actual = InchesToCentimeters.convert(10)
    val expected = 25.4
    assertEquals(expected, actual, delta)
  }

  @Test def testGallonsToLiters() = {
    val actual = GallonsToLiters.convert(10)
    val expected = 37.8541178
    assertEquals(expected, actual, delta)
  }

  @Test def testMilesToKilometers() = {
    val actual = MilesToKilometers.convert(10)
    val expected = 16.09344
    assertEquals(expected, actual, delta)
  }
} 
开发者ID:Kiryna,项目名称:Scala-for-the-Impatient,代码行数:35,代码来源:Exercise01.scala


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