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

Scala GuiceOneServerPerSuite类代码示例

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

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



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

示例1: IntegrationSpec

//设置package包名称以及导入依赖的类
import org.scalatestplus.play._
import org.scalatestplus.play.guice.GuiceOneServerPerSuite
import play.api.{Configuration, Mode}
import play.api.cache.{CacheApi, EhCacheModule}
import play.api.inject._
import play.api.inject.guice.GuiceApplicationBuilder
import play.api.test._
import play.api.test.Helpers._
import util.FakeCache


class IntegrationSpec extends PlaySpec with GuiceOneServerPerSuite with OneBrowserPerTest with HtmlUnitFactory {

  implicit override lazy val app = new GuiceApplicationBuilder()
    .overrides(bind[CacheApi].to[FakeCache])
    .loadConfig(env => Configuration.load(env))
    .in(Mode.Test)
    .build

  "Application" should {

    "work from within a browser" in {

      go to ("http://localhost:" + port)

      pageSource must include ("Aktuelles der Fakultät Informatik")
    }
  }
} 
开发者ID:P1tt187,项目名称:spirit-play,代码行数:30,代码来源:IntegrationSpec.scala


示例2: IntegrationSpec

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

import akka.actor.{ActorRef, ActorSystem, PoisonPill}
import akka.stream.Materializer
import akka.testkit.TestProbe
import akka.util.Timeout
import org.scalatest._
import org.scalatest.concurrent.{Eventually, ScalaFutures}
import org.scalatestplus.play.guice.GuiceOneServerPerSuite
import play.api.test.WsTestClient

import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
import scala.reflect.ClassTag

class IntegrationSpec extends FlatSpec
  with Matchers
  with GivenWhenThen
  with OptionValues
  with TryValues
  with ScalaFutures
  with WsTestClient
  with BeforeAndAfterAll
  with BeforeAndAfterEach
  with Eventually
  with GuiceOneServerPerSuite {

  def getComponent[A: ClassTag]: A = app.injector.instanceOf[A]

  // set the port number of the HTTP server
  override lazy val port: Int = 9001
  implicit val pc: PatienceConfig = PatienceConfig(timeout = 30.seconds, interval = 300.millis)
  implicit val system: ActorSystem = getComponent[ActorSystem]
  implicit val ec: ExecutionContext = getComponent[ExecutionContext]
  implicit val mat: Materializer = getComponent[Materializer]
  implicit val timeout: Timeout = 10.seconds

  def killActors(actors: ActorRef*): Unit = {
    val tp = TestProbe()
    actors.foreach { (actor: ActorRef) =>
      tp watch actor
      actor ! PoisonPill
      tp.expectTerminated(actor)
    }
  }
} 
开发者ID:dnvriend,项目名称:spring-kafka-test,代码行数:47,代码来源:IntegrationSpec.scala


示例3: ApplicationSpec

//设置package包名称以及导入依赖的类
import org.scalatestplus.play.PlaySpec
import org.scalatestplus.play.guice.GuiceOneServerPerSuite
import play.api.test.Helpers._
import play.api.test._

class ApplicationSpec extends PlaySpec with GuiceOneServerPerSuite {

  "Application" must {

    "get greeting" in {
      val Some(greeting) = route(app, FakeRequest(GET, controllers.routes.Application.greeting().url))
      status(greeting) mustBe OK
      contentAsString(greeting) mustBe "Hello"
    }

    "get greetings must include arguments" in {
      val Some(greetings) = route(app, FakeRequest(GET, controllers.routes.Application.greetings("World").url))
      status(greetings) mustBe OK
      contentAsString(greetings) mustBe "Hello World"
    }

    "get greetings must include request parameter" in {
      val Some(greeting) = route(app, FakeRequest(GET, "/greetings?param=World"))
      status(greeting) mustBe OK
      contentAsString(greeting) mustBe "Hello World"
    }

    "render the index page" in {
      val home = route(app, FakeRequest(GET, controllers.routes.Application.index().url)).get
      status(home) mustBe OK
      contentType(home) mustBe Some("text/html")
      contentAsString(home) must include("Your new application is ready.")
    }

    "render the visit page with no parameter set" in {
      val visit = route(app, FakeRequest(GET, "/visit")).get
      status(visit) mustBe OK
      contentType(visit) mustBe  Some("text/html")
      contentAsString(visit) must include("random user")
    }

    "render the visit page with option visitor parameter" in {
      val visit = route(app, FakeRequest(GET, "/visit?visitor=Bob")).get
      status(visit) mustBe OK
      contentType(visit) mustBe Some("text/html")
      contentAsString(visit) must include("Bob")
    }
  }
} 
开发者ID:griffio,项目名称:scalaplay01,代码行数:50,代码来源:ApplicationSpec.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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