本文整理汇总了Scala中akka.event.NoLogging类的典型用法代码示例。如果您正苦于以下问题:Scala NoLogging类的具体用法?Scala NoLogging怎么用?Scala NoLogging使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NoLogging类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: log
//设置package包名称以及导入依赖的类
package me.snov.akka.sqs.shape
import akka.event.{LoggingAdapter, NoLogging}
import akka.stream.ActorMaterializer
import akka.stream.stage.GraphStageLogic
private[sqs] trait StageLogging { self: GraphStageLogic =>
private var loggingAdapter: LoggingAdapter = _
def log: LoggingAdapter = {
if (loggingAdapter eq null) {
materializer match {
case actorMaterializer: ActorMaterializer =>
loggingAdapter = akka.event.Logging(actorMaterializer.system, self.getClass)
case _ =>
loggingAdapter = NoLogging
}
}
loggingAdapter
}
}
示例2: BaseHttpApiSpec
//设置package包名称以及导入依赖的类
package hmda.api.http
import akka.event.{ NoLogging, LoggingAdapter }
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.model.headers.{ HttpEncodings, `Accept-Encoding` }
import akka.http.scaladsl.model.headers.HttpEncodings._
import akka.http.scaladsl.testkit.ScalatestRouteTest
import hmda.api.model.Status
import org.scalatest.{ MustMatchers, WordSpec }
import scala.concurrent.ExecutionContext
class BaseHttpApiSpec extends WordSpec with MustMatchers with ScalatestRouteTest with BaseHttpApi {
override val log: LoggingAdapter = NoLogging
val ec: ExecutionContext = system.dispatcher
"Http API service" must {
"return OK for GET requests to the root path" in {
Get() ~> routes("hmda-filing-api") ~> check {
responseAs[Status].status mustBe "OK"
responseAs[Status].service mustBe "hmda-filing-api"
}
}
"use requested encoding for root path" in {
Get().addHeader(`Accept-Encoding`(gzip)) ~> routes("hmda-filing-api") ~> check {
response.encoding mustBe HttpEncodings.gzip
}
}
}
}
示例3:
//设置package包名称以及导入依赖的类
package me.archdev
import me.archdev.restapi.http.HttpService
import me.archdev.restapi.models.{ TokenEntity, UserEntity }
import me.archdev.restapi.utils.Migration
import org.scalatest._
import akka.event.{ NoLogging, LoggingAdapter }
import akka.http.scaladsl.testkit.ScalatestRouteTest
import scala.concurrent.Await
import scala.concurrent.duration._
trait BaseServiceTest extends WordSpec with Matchers with ScalatestRouteTest with HttpService with Migration {
protected val log: LoggingAdapter = NoLogging
import driver.api._
val testUsers = Seq(
UserEntity(Some(1), "Arhelmus", "test"),
UserEntity(Some(2), "Arch", "test"),
UserEntity(Some(3), "Hierarh", "test")
)
val testTokens = Seq(
TokenEntity(userId = Some(1)),
TokenEntity(userId = Some(2)),
TokenEntity(userId = Some(3))
)
reloadSchema()
Await.result(db.run(users ++= testUsers), 10.seconds)
Await.result(db.run(tokens ++= testTokens), 10.seconds)
}
示例4: ServiceSpec
//设置package包名称以及导入依赖的类
package org.stanoq.tests.crawler
import akka.event.NoLogging
import akka.http.scaladsl.model.ContentTypes._
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest._
import org.stanoq.crawler.CrawlerService
import org.stanoq.crawler.model.{ConfigProperties, CrawlerProtocols, CrawlerResponse}
import spray.json._
import scala.io.Source
class ServiceSpec extends FlatSpec with Matchers with ScalatestRouteTest with CrawlerProtocols {
override def testConfigSource = "akka.loglevel = DEBUG"
def config = testConfig
val logger = NoLogging
val crawlerService = new CrawlerService
val configJson = Source.fromFile("config.json").mkString
"CrawlerService" should "respond with >2 processed pages on crawling websocket.org with depth 1 (json)" in {
Post(s"/crawler", configJson.parseJson.convertTo[ConfigProperties]) ~> crawlerService.route ~> check {
status shouldBe OK
contentType shouldBe `application/json`
responseAs[CrawlerResponse].pages.size should be >2
}
}
"CrawlerService" should "respond with >20 processed pages on crawling websocket.org with depth 4" in {
Post(s"/crawler", ConfigProperties("https://www.websocket.org/index.html",4)) ~> crawlerService.route ~> check {
status shouldBe OK
contentType shouldBe `application/json`
val res = responseAs[CrawlerResponse]
res.pages.size should be >20
res.pages.filter(_.statusCode!=200).size shouldBe 2
}
}
}
示例5:
//设置package包名称以及导入依赖的类
package synahive
import synahive.restapi.http.HttpService
import synahive.restapi.models.{ TokenEntity, UserEntity }
import synahive.restapi.utils.Migration
import org.scalatest._
import akka.event.{ NoLogging, LoggingAdapter }
import akka.http.scaladsl.testkit.ScalatestRouteTest
import scala.concurrent.Await
import scala.concurrent.duration._
trait BaseServiceTest extends WordSpec with Matchers with ScalatestRouteTest with HttpService with Migration {
protected val log: LoggingAdapter = NoLogging
import driver.api._
val testUsers = Seq(
UserEntity(Some(1), "Synahive", "test"),
UserEntity(Some(2), "Marius", "test"),
UserEntity(Some(3), "Gerald", "test")
)
val testTokens = Seq(
TokenEntity(userId = Some(1)),
TokenEntity(userId = Some(2)),
TokenEntity(userId = Some(3))
)
reloadSchema()
Await.result(db.run(users ++= testUsers), 10.seconds)
Await.result(db.run(tokens ++= testTokens), 10.seconds)
}
示例6: ServiceSpec
//设置package包名称以及导入依赖的类
import actors.EventManager
import akka.event.NoLogging
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.model.ContentTypes._
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.testkit.ScalatestRouteTest
import messages.{ClientEvent, RequestText}
import org.aj.ner.EmbeddedToken
import org.scalatest._
import akka.testkit.TestActorRef
class ServiceSpec extends FlatSpec with Matchers with ScalatestRouteTest with Service {
override def testConfigSource = "akka.loglevel = WARNING"
override def config = testConfig
override val logger = NoLogging
override val eventManager = TestActorRef(EventManager.props, "eventManager")
subscribe((eventManager, classOf[ClientEvent]))
val requestText = RequestText(
"Marcora doesn't even have to talk in his mother tongue to spark a reaction: In his adopted hometown of Chatham in Kent, southeast of London, just speaking English with an Italian accent can be enough to provoke a reaction. This is post-Brexit referendum Britain. And it's a place Marcora, who has lived and worked in the UK for 18 years, barely recognizes.",
Some(Array("MISC"))
)
val tokens = Set(
EmbeddedToken("MISC", "English"),
EmbeddedToken("MISC", "Italian"),
EmbeddedToken("MISC", "post-Brexit")
)
"Service" should "respond to query with MISC tokens only" in {
Get("/ner/aj", requestText) ~> routes ~> check {
status shouldBe OK
contentType shouldBe `application/json`
responseAs[Set[EmbeddedToken]] shouldBe tokens
}
}
}
示例7: ServiceSpec
//设置package包名称以及导入依赖的类
import akka.event.NoLogging
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.model.ContentTypes._
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.testkit.ScalatestRouteTest
import org.scalatest._
class ServiceSpec extends FlatSpec with Matchers with ScalatestRouteTest with Service with Protocols {
override def testConfigSource = "akka.loglevel = WARNING"
override def config = testConfig
override val logger = NoLogging
import domain.Services._
import orderMgmr._
import scenarios.Order
"OrderMgr" should "allow adding a product given any customer auth info" in {
import scenarios.ProductAddTest._
Post(s"/${orderMgmr.name}/${api.productAdd}", orderMgmtService.request) ~> routes(orderMgmtService) ~> check {
status shouldBe OK
contentType shouldBe `application/json`
val response = responseAs[(domain.ResultCode, scenarios.OrderSummary)]
println(response)
response._1 shouldBe true
response._2.customerId shouldBe customer._3
response._2.order.details.size shouldBe 1
response._2.order.details.head.productId shouldBe xspaceIceCream
}
}
"OrderMgr" should "allow viewing order history given any customer id" in {
import scenarios.OrdersViewTest._
Get(s"/${orderMgmr.name}/${api.ordersView}/${orderMgmtService.request}") ~> routes(orderMgmtService) ~> check {
status shouldBe OK
contentType shouldBe `application/json`
val response = responseAs[List[Order]]
println(response)
response.size shouldBe 2
response.dropWhile(_.customerId == customer._3) shouldBe List.empty
}
}
}