本文整理汇总了Scala中com.google.inject.Stage类的典型用法代码示例。如果您正苦于以下问题:Scala Stage类的具体用法?Scala Stage怎么用?Scala Stage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stage类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ExampleServerStartupTest
//设置package包名称以及导入依赖的类
package com.example
import com.google.inject.Stage
import com.twitter.finatra.thrift.EmbeddedThriftServer
import com.twitter.inject.server.FeatureTest
import com.swissguard.SwissGuardThriftServer
class ExampleServerStartupTest extends FeatureTest {
val server = new EmbeddedThriftServer(
twitterServer = new SwissGuardThriftServer,
stage = Stage.PRODUCTION)
"server" should {
"startup" in {
server.assertHealthy()
}
}
}
示例2: StartupTest
//设置package包名称以及导入依赖的类
package uk.ac.wellcome.platform.reindexer
import com.google.inject.Stage
import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.inject.server.FeatureTest
import uk.ac.wellcome.test.utils.{
AmazonCloudWatchFlag,
DynamoDBLocal,
StartupLogbackOverride
}
class StartupTest
extends FeatureTest
with StartupLogbackOverride
with DynamoDBLocal
with AmazonCloudWatchFlag {
val server = new EmbeddedHttpServer(
stage = Stage.PRODUCTION,
twitterServer = new Server,
flags = Map(
"aws.dynamo.reindexTracker.tableName" -> "ReindexTracker",
"aws.dynamo.miroData.tableName" -> "MiroData",
"reindex.target.tableName" -> "MiroData"
) ++ dynamoDbLocalEndpointFlags ++ cloudWatchLocalEndpointFlag
)
test("server starts up correctly") {
server.assertHealthy()
}
}
示例3: StartupTest
//设置package包名称以及导入依赖的类
package uk.ac.wellcome.platform.ingestor
import com.google.inject.Stage
import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.inject.server.FeatureTest
import uk.ac.wellcome.test.utils.{
AmazonCloudWatchFlag,
SQSLocal,
StartupLogbackOverride
}
class StartupTest
extends FeatureTest
with StartupLogbackOverride
with SQSLocal
with AmazonCloudWatchFlag {
val server = new EmbeddedHttpServer(
stage = Stage.PRODUCTION,
twitterServer = new Server,
flags = sqsLocalFlags ++ cloudWatchLocalEndpointFlag)
test("server starts up correctly") {
server.assertHealthy()
}
}
示例4: StartupTest
//设置package包名称以及导入依赖的类
package uk.ac.wellcome.platform.transformer
import com.google.inject.Stage
import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.inject.server.FeatureTest
import uk.ac.wellcome.test.utils._
class StartupTest
extends FeatureTest
with StartupLogbackOverride
with AmazonCloudWatchFlag
with SQSLocal
with SNSLocal {
val server = new EmbeddedHttpServer(
stage = Stage.PRODUCTION,
twitterServer = new Server,
flags = Map(
"transformer.source" -> "MiroData"
) ++ cloudWatchLocalEndpointFlag ++ sqsLocalFlags ++ snsLocalEndpointFlags
)
test("server starts up correctly") {
server.assertHealthy()
}
}
示例5: StartupFeatureTest
//设置package包名称以及导入依赖的类
package com.twitter.diffy
import com.google.inject.Stage
import com.twitter.finatra.http.test.EmbeddedHttpServer
import com.twitter.inject.Test
class StartupFeatureTest extends Test {
val server = new EmbeddedHttpServer(
stage = Stage.PRODUCTION,
twitterServer = new MainService {
},
extraArgs = Seq(
"-proxy.port=:0",
"-candidate=localhost:80",
"-master.primary=localhost:80",
"-master.secondary=localhost:80",
"-service.protocol=http"))
"verify startup" in {
server.assertHealthy()
}
}
示例6: ExampleStartupTest
//设置package包名称以及导入依赖的类
package com.example
import com.google.inject.Stage
import com.twitter.finatra.http.EmbeddedHttpServer
import org.scalatest.FunSuite
class ExampleStartupTest extends FunSuite {
lazy val server = new EmbeddedHttpServer(
stage = Stage.PRODUCTION,
twitterServer = new HelloServer)
test("Server#startup") {
try {
server.assertHealthy()
} catch {
case e: Exception => e.printStackTrace()
}
}
}
示例7: UserLoginControllerTest
//设置package包名称以及导入依赖的类
package cronus.auth
import com.google.inject.Stage
import com.twitter.finagle.http.Status
import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.finatra.json.FinatraObjectMapper
import com.twitter.inject.server.FeatureTest
import cronus.FrontServer
class UserLoginControllerTest extends FeatureTest {
override val server = new EmbeddedHttpServer(
twitterServer = new FrontServer,
stage = Stage.PRODUCTION,
verbose = true,
maxStartupTimeSeconds = 60)
val url = "/user/authenticate"
val objectMapper = FinatraObjectMapper.create(injector.underlying)
"UserLoginController" should {
"Get a token when sending the right access credentials" in {
val shuttle = AuthShuttle("test", "test", "")
val sendJson = objectMapper.writePrettyString(shuttle)
val response = server.httpPostJson[AuthShuttle](path = url, postBody = sendJson, andExpect = Status.Ok)
assert(response.uid == response.uid)
assert(response.password == "")
assert(response.token == "TESTTOKEN")
//objectMapper.writePrettyString()
}
"Get Unauthorized when sending wrong user" in {
val shuttle = AuthShuttle("wrong", "test", "")
val sendJson = objectMapper.writePrettyString(shuttle)
server.httpPost(path = url, postBody = sendJson, andExpect = Status.Unauthorized)
}
"Get Unauthorized when sending wrong password" in {
val shuttle = AuthShuttle("test", "wrong", "")
val sendJson = objectMapper.writePrettyString(shuttle)
server.httpPost(path = url, postBody = sendJson, andExpect = Status.Unauthorized)
}
"Get BadRequest when sending non json" in {
server.httpPost(path = url, postBody = "wrong", andExpect = Status.BadRequest)
}
"Get BadRequest when sending empty string" in {
server.httpPost(path = url, postBody = "", andExpect = Status.BadRequest)
}
}
}
示例8: FrontServerStartupTest
//设置package包名称以及导入依赖的类
package cronus
import com.google.inject.Stage
import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.inject.server.FeatureTest
class FrontServerStartupTest extends FeatureTest {
override val server = new EmbeddedHttpServer(
twitterServer = new FrontServer,
stage = Stage.PRODUCTION,
verbose = false)
"Server" should {
"startup" in {
server.assertHealthy()
}
}
}
示例9: AssetControllerFeatureTest
//设置package包名称以及导入依赖的类
package cronus.controllers
import com.google.common.net.MediaType
import com.google.inject.Stage
import com.twitter.finagle.http.Status
import com.twitter.finatra.http.EmbeddedHttpServer
import com.twitter.inject.server.FeatureTest
import cronus.FrontServer
import org.webjars.WebJarAssetLocator
import scala.io.Source
class AssetControllerFeatureTest extends FeatureTest
{
override val server = new EmbeddedHttpServer(
twitterServer = new FrontServer,
stage = Stage.PRODUCTION,
verbose = true,
maxStartupTimeSeconds = 60)
"AssetController" should {
"return -ok- for an existing WebJar resource" in {
val locator: WebJarAssetLocator = new WebJarAssetLocator()
val fullPath = locator.getFullPath("bootstrap", "js/npm.js")
val is = locator.getClass.getClassLoader.getResourceAsStream(fullPath)
val response = server.httpGet(path="/assets/bootstrap/js/npm.js", andExpect = Status.Ok,
withBody = Source.fromInputStream(is).mkString)
response.contentType should equal(Some(MediaType.JAVASCRIPT_UTF_8.toString))
val fullPath2 = locator.getFullPath("backbonejs", "backbone-min.js")
val is2 = locator.getClass.getClassLoader.getResourceAsStream(fullPath2)
val response2 = server.httpGet(path="/assets/backbonejs/backbone-min.js", andExpect = Status.Ok,
withBody = Source.fromInputStream(is2).mkString)
response2.contentType should equal(Some(MediaType.JAVASCRIPT_UTF_8.toString))
}
"return -not found- for an path containing only a webjar name" in {
server.httpGet(path="/assets/bootstrap/", andExpect = Status.NotFound)
server.httpGet(path="/assets/bootstrap", andExpect = Status.NotFound)
}
"return -not found- for an path containing /assets" in {
server.httpGet(path="/assets/", andExpect = Status.NotFound)
server.httpGet(path="/assets", andExpect = Status.NotFound)
}
"return -not found- for an non existing WebJar resource" in {
server.httpGet(path="/assets/bootstrap/css/.fail", andExpect = Status.NotFound)
}
}
}