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

Scala LocalServiceLocator类代码示例

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

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



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

示例1: LagomhandsondevelopmentServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.example.lagomhandsondevelopment.api._

class LagomhandsondevelopmentServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new LagomhandsondevelopmentApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[LagomhandsondevelopmentService]

  override protected def afterAll() = server.stop()

  "lagom-hands-on-development service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:negokaz,项目名称:lagom-hands-on-development.scala,代码行数:39,代码来源:LagomhandsondevelopmentServiceSpec.scala


示例2: HelloServiceSpec

//设置package包名称以及导入依赖的类
package se.hultner.hello.impl

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import se.hultner.hello.api._

class HelloServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new HelloApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[HelloService]

  override protected def afterAll() = server.stop()

  "Hello service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:Hultner,项目名称:hello_scala_microservices,代码行数:39,代码来源:HelloServiceSpec.scala


示例3: BasketServiceSpec

//设置package包名称以及导入依赖的类
import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import demo.api.basket.{Basket, BasketService, Item}
import demo.impl.basket.{BasketApplication, BasketSerializerRegistry}
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}

import scala.concurrent.Future

class BasketServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {
  lazy val service = ServiceTest.startServer(ServiceTest.defaultSetup.withCassandra(true)) { ctx =>
    new BasketApplication(ctx) with LocalServiceLocator {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }
  }

  override protected def beforeAll() = service
  override protected def afterAll() = service.stop()
  val client = service.serviceClient.implement[BasketService]

  "Basket Service" should {
    "add a single item and get the basket" in {
      client.addItem("basket1").invoke(Item("Apple", 50)).flatMap { response =>
        response should ===(NotUsed)

        client.getBasket("basket1").invoke().map { getItemsResponse =>
          getItemsResponse should ===(Basket(Seq(Item("Apple", 50)), 50))
        }
      }
    }

    "get an empty basket" in {
      client.getBasket("basket2").invoke().map { getItemsResponse =>
        getItemsResponse should ===(Basket(Seq(), 0))
      }
    }

    "add multiple items" in {
      val items = "Apple" -> 50 :: "Apple" -> 50 :: "Orange" -> 30 :: Nil

      Future.sequence(items.map(i => client.addItem("basket3").invoke(Item(i._1, i._2)))).flatMap{ f =>
        client.getBasket("basket3").invoke().flatMap { getItemsResponse =>
          getItemsResponse.items should contain(Item("Apple", 50))
          getItemsResponse.items should contain(Item("Orange", 30))
          getItemsResponse.total should===(130)

          client.getTotal("basket3").invoke().map { getItemsResponse =>
            getItemsResponse should===(130)
          }
        }
      }
    }
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:56,代码来源:BasketServiceSpec.scala


示例4: BasketServiceSpec

//设置package包名称以及导入依赖的类
import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import demo.api.basket.{Basket, BasketService, Item}
import demo.impl.basket.{BasketApplication, BasketSerializerRegistry}
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}

import scala.concurrent.Future

class BasketServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {
  lazy val service = ServiceTest.startServer(ServiceTest.defaultSetup.withCassandra(true)) { ctx =>
    new BasketApplication(ctx) with LocalServiceLocator {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }
  }

  override protected def beforeAll() = service
  override protected def afterAll() = service.stop()
  val client = service.serviceClient.implement[BasketService]

  "Basket Service" should {
    "add a single item" in {
      client.addItem("basket1").invoke(Item("Apple", 50)).flatMap { response =>
        response should ===(NotUsed)

        client.getBasket("basket1").invoke().map { getItemsResponse =>
          getItemsResponse should ===(Basket(Seq(Item("Apple", 50)), 50))
        }
      }
    }

    "get an empty basket" in {
      client.getBasket("basket2").invoke().map { getItemsResponse =>
        getItemsResponse should ===(Basket(Seq(), 0))
      }
    }

    "add multiple items" in {
      val items = ("Apple" -> 50 :: "Apple" -> 50 :: "Orange" -> 30 :: Nil).map { t =>
        Item(t._1, t._2)
      }

      items.foldLeft(Future.successful(List[NotUsed]())) { (f, i) =>
        f.flatMap(l => client.addItem("basket3").invoke(i).map(n => n :: l))
      }.flatMap { f =>
        client.getBasket("basket3").invoke().map { getItemsResponse =>
          getItemsResponse.items should be(items)
          getItemsResponse.total should===(130)
        }
      }
    }
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:55,代码来源:BasketServiceSpec.scala


示例5: BasketServiceSpec

//设置package包名称以及导入依赖的类
import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import demo.api.basket.{Basket, BasketService, Item}
import demo.impl.basket.{BasketApplication, BasketSerializerRegistry}
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}

import scala.concurrent.Future

class BasketServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {
  lazy val service = ServiceTest.startServer(ServiceTest.defaultSetup.withCassandra(true)) { ctx =>
    new BasketApplication(ctx) with LocalServiceLocator {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }
  }

  override protected def beforeAll() = service
  override protected def afterAll() = service.stop()
  val client = service.serviceClient.implement[BasketService]

  "Basket Service" should {
    "add a single item" in {
      client.addItem("basket1").invoke(Item("Apple", 50)).flatMap { response =>
        response should ===(NotUsed)

        client.getBasket("basket1").invoke().map { getItemsResponse =>
          getItemsResponse should ===(Basket(Seq(Item("Apple", 50)), 50))
        }
      }
    }

    "get an empty basket" in {
      client.getBasket("basket2").invoke().map { getItemsResponse =>
        getItemsResponse should ===(Basket(Seq(), 0))
      }
    }

    "add multiple items" in {
      val items = "Apple" -> 50 :: "Apple" -> 50 :: "Orange" -> 30 :: Nil

      Future.sequence(items.map(i => client.addItem("basket3").invoke(Item(i._1, i._2)))).flatMap{ f =>
        client.getBasket("basket3").invoke().map { getItemsResponse =>
          getItemsResponse.items should contain(Item("Apple", 50))
          getItemsResponse.items should contain(Item("Orange", 30))
          getItemsResponse.total should===(130)
        }
      }
    }
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:52,代码来源:BasketServiceSpec.scala


示例6: UserServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.grossbit.user.api._

class UserServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new UserApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[UserService]

  override protected def afterAll() = server.stop()

  "User service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:sarathraj-coder,项目名称:lagommicroapp,代码行数:39,代码来源:UserServiceSpec.scala


示例7: LagomdemoServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.dannyrobert.lagomdemo.api._

class LagomdemoServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new LagomdemoApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[LagomdemoService]

  override protected def afterAll() = server.stop()

  "lagom-demo service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:drobert,项目名称:lagom-prototype,代码行数:39,代码来源:LagomdemoServiceSpec.scala


示例8: HelloServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.example.hello.api._

class HelloServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new HelloApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[HelloService]

  override protected def afterAll() = server.stop()

  "Hello service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:team3,项目名称:slotbook-api-lagom,代码行数:39,代码来源:HelloServiceSpec.scala


示例9: HelloServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.example.order.api._

class HelloServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new HelloApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[OrderService]

  override protected def afterAll() = server.stop()

  "Hello service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:xebia,项目名称:lagom-saga,代码行数:39,代码来源:HelloServiceSpec.scala


示例10: CounterServiceSpec

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

import com.example.counter.api.CounterService
import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}

class CounterServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {
  val server = ServiceTest.startServer(
    ServiceTest.defaultSetup.withCassandra(true)
  ) { ctx =>
    new CounterApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[CounterService]

  def AfterAll() = server.stop()

  "Counter service" should {
    "return value" in {
      client.counter("1").invoke().map { value =>
        value shouldBe 0
      }
    }

    "add value" in {
      for {
        _ <- client.add("1").invoke(1)
        _ <- client.add("1").invoke(2)
        value <- client.counter("1").invoke()
      } yield {
        value shouldBe 3
      }
    }
  }
} 
开发者ID:namelos,项目名称:lagom-spike,代码行数:37,代码来源:CounterServiceSpec.scala


示例11: HellolagomServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.example.hello.api._

class HellolagomServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new HellolagomApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[HellolagomService]

  override protected def afterAll() = server.stop()

  "hello-lagom service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:clca,项目名称:lagom-scala,代码行数:39,代码来源:HellolagomServiceSpec.scala


示例12: GithubServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import com.onedrop.github.api.{GithubService, GreetingMessage}
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}

class GithubServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new GithubApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[GithubService]

  override protected def afterAll() = server.stop()

  "github service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:jewelsjacobs,项目名称:one-drop-test,代码行数:39,代码来源:GithubServiceSpec.scala


示例13: LagomhelloServiceSpec

//设置package包名称以及导入依赖的类
package de.breitbandig.lagomhello.impl

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import de.breitbandig.lagomhello.api._

class LagomhelloServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new LagomhelloApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[LagomhelloService]

  override protected def afterAll() = server.stop()

  "lagom-hello service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:aanno,项目名称:lagom-hello,代码行数:39,代码来源:LagomhelloServiceSpec.scala


示例14: AlphaApplication

//设置package包名称以及导入依赖的类
package com.lightbend.lagom.scaladsl.testkit

import akka.persistence.query.Offset
import akka.stream.scaladsl.Source
import akka.stream.testkit.scaladsl.TestSink
import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.broker.TopicProducer
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.EmptyJsonSerializerRegistry
import com.lightbend.lagom.scaladsl.server.{ LagomApplication, LagomApplicationContext, LagomServer, LocalServiceLocator }
import com.lightbend.lagom.scaladsl.testkit.services.{ AlphaEvent, AlphaService }
import org.scalatest.{ AsyncWordSpec, Matchers }
import play.api.libs.ws.ahc.AhcWSComponents

abstract class AlphaApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
  with CassandraPersistenceComponents
  with TestTopicComponents
  with AhcWSComponents {

  override lazy val lagomServer = serverFor[AlphaService](new AlphaServiceImpl())

  override lazy val jsonSerializerRegistry = EmptyJsonSerializerRegistry
}

class AlphaServiceImpl extends AlphaService {
  override def messages: Topic[AlphaEvent] =
    TopicProducer.singleStreamWithOffset { offset =>
      val events = (1 to 10).filter(_ % 2 == 0).map(AlphaEvent.apply)
      Source(events).map(event => (event, Offset.sequence(event.message / 2)))
    }
}

class TopicPublishingSpec extends AsyncWordSpec with Matchers {

  "The AlphaService" should {
    "publish events on alpha topic" in ServiceTest.withServer(ServiceTest.defaultSetup) { ctx =>
      new AlphaApplication(ctx) with LocalServiceLocator
    } { server =>

      implicit val system = server.actorSystem
      implicit val mat = server.materializer

      val client: AlphaService = server.serviceClient.implement[AlphaService]
      val source = client.messages.subscribe.atMostOnceSource

      source.runWith(TestSink.probe[AlphaEvent])
        .request(1)
        .expectNext should ===(AlphaEvent(2))

    }
  }

} 
开发者ID:lagom,项目名称:lagom,代码行数:55,代码来源:TopicPublishingSpec.scala


示例15: ProducerStubSpec

//设置package包名称以及导入依赖的类
package com.lightbend.lagom.scaladsl.testkit

import com.lightbend.lagom.scaladsl.api.broker.Topic
import com.lightbend.lagom.scaladsl.server.{ LagomApplicationContext, LocalServiceLocator }
import com.lightbend.lagom.scaladsl.testkit.services._
import org.scalatest.concurrent.Eventually
import org.scalatest.time.{ Seconds, Span }
import org.scalatest.{ BeforeAndAfterAll, Matchers, WordSpec }

class ProducerStubSpec extends WordSpec with Matchers with BeforeAndAfterAll with Eventually {

  var producerStub: ProducerStub[AlphaEvent] = _

  private val stubbedApplication: LagomApplicationContext => DownstreamApplication = {
    ctx =>
      new DownstreamApplication(ctx) with LocalServiceLocator {
        val stubFactory = new ProducerStubFactory(actorSystem, materializer)
        producerStub = stubFactory.producer[AlphaEvent](AlphaService.TOPIC_ID)
        override lazy val alphaService = new AlphaServiceStub(producerStub)
      }
  }

  "The ProducerStub" should {
    "send message to consuming services" in ServiceTest.withServer(ServiceTest.defaultSetup)(stubbedApplication) { server =>
      implicit val exCtx = server.application.actorSystem.dispatcher
      producerStub.send(AlphaEvent(22))
      eventually(timeout(Span(5, Seconds))) {
        server.serviceClient.implement[CharlieService].messages.invoke().map { response =>
          response should ===(Seq(ReceivedMessage("A", 22)))
        }.recover {
          case t: Throwable => fail(t)
        }
      }
    }
  }

}

class AlphaServiceStub(stub: ProducerStub[AlphaEvent]) extends AlphaService {
  override def messages: Topic[AlphaEvent] = stub.topic

} 
开发者ID:lagom,项目名称:lagom,代码行数:43,代码来源:ProducerStubSpec.scala


示例16: JournalServiceSpec

//设置package包名称以及导入依赖的类
package io.namelos.journal.impl

import io.namelos.journal.api.JournalService
import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}

class JournalServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {
  val server = ServiceTest.startServer(
    ServiceTest.defaultSetup.withCassandra(true)
  ) { ctx =>
    new JournalApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[JournalService]

  def AfterAll() = server.stop()

  "Counter service" should {
    "return value" in {
      client.counter("1").invoke().map { value =>
        value shouldBe 0
      }
    }

    "add value" in {
      for {
        _ <- client.add("1").invoke(1)
        _ <- client.add("1").invoke(2)
        value <- client.counter("1").invoke()
      } yield {
        value shouldBe 3
      }
    }
  }
} 
开发者ID:namelos,项目名称:namelos-journal,代码行数:37,代码来源:JournalServiceSpec.scala


示例17: GreetingServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.github.dnvriend.lagomloggingtest.api._
import com.github.dnvriend.logging.api.{GreetingMessage, GreetingService}
import com.github.dnvriend.logging.application.LoggingApplication

class GreetingServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new LoggingApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[GreetingService]

  override protected def afterAll() = server.stop()

  "lagom-logging-test service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:dnvriend,项目名称:lagom-logging-test,代码行数:41,代码来源:GreetingServiceSpec.scala


示例18: ChallengeroneServiceSpec

//设置package包名称以及导入依赖的类
package org.thrx.challengerone.impl

import java.io.File

import akka.cluster.Cluster
import akka.persistence.cassandra.testkit.CassandraLauncher
import com.lightbend.lagom.scaladsl.persistence.cassandra.testkit.TestUtil
import com.lightbend.lagom.scaladsl.server.{LagomApplicationContext, LocalServiceLocator}
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import play.api.Configuration
import play.core.server.NettyServer
import org.thrx.challengerone.api._

import scala.concurrent.Promise

class ChallengeroneServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  CassandraLauncher.start(new File("target/ChallengeroneServiceSpec"), CassandraLauncher.DefaultTestConfigResource,
    clean = true, port = 0)

  private val port = Promise[Int]()
  private val app = new ChallengeroneApplication(LagomApplicationContext.Test) with LocalServiceLocator {
    override def lagomServicePort = port.future
    override def additionalConfiguration: Configuration = Configuration(TestUtil.persistenceConfig(
      "ChallengeroneServiceSpec",
      CassandraLauncher.randomPort
    ))
  }
  val server = NettyServer.fromApplication(app.application)
  port.success(server.httpPort.get)
  val client = app.serviceClient.implement[ChallengeroneService]

  // Start the cluster
  val cluster = Cluster(app.actorSystem)
  cluster.join(cluster.selfAddress)

  override protected def afterAll(): Unit = {
    server.stop()
    CassandraLauncher.stop()
  }

  "ChallengerOne service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:thrxorg,项目名称:thrx-callengerone-lagom-experimental,代码行数:60,代码来源:ChallengeroneServiceSpec.scala


示例19: HelloscalaServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.example.helloscala.api._

class HelloscalaServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new HelloscalaApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[HelloscalaService]

  override protected def afterAll() = server.stop()

  "helloscala service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:ignasi35,项目名称:lagom-helloscala,代码行数:39,代码来源:HelloscalaServiceSpec.scala


示例20: ReferentialwebcrawlerServiceSpec

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

import com.lightbend.lagom.scaladsl.server.LocalServiceLocator
import com.lightbend.lagom.scaladsl.testkit.ServiceTest
import org.scalatest.{AsyncWordSpec, BeforeAndAfterAll, Matchers}
import com.andycot.referentialwebcrawler.api._

class ReferentialwebcrawlerServiceSpec extends AsyncWordSpec with Matchers with BeforeAndAfterAll {

  private val server = ServiceTest.startServer(
    ServiceTest.defaultSetup
      .withCassandra(true)
  ) { ctx =>
    new ReferentialwebcrawlerApplication(ctx) with LocalServiceLocator
  }

  val client = server.serviceClient.implement[ReferentialwebcrawlerService]

  override protected def afterAll() = server.stop()

  "referential-webcrawler service" should {

    "say hello" in {
      client.hello("Alice").invoke().map { answer =>
        answer should ===("Hello, Alice!")
      }
    }

    "allow responding with a custom message" in {
      for {
        _ <- client.useGreeting("Bob").invoke(GreetingMessage("Bob", "Hi"))
        answer <- client.hello("Bob").invoke()
      } yield {
        answer should ===("Hi, Bob!")
      }
    }
  }
} 
开发者ID:frferrari,项目名称:referential-webcrawler,代码行数:39,代码来源:ReferentialwebcrawlerServiceSpec.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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