[英]Lagom - How can I use event processor in a service integration test?
I am building an authentication service in Lagom (scala) which consists of a device entity and an event processor. 我正在Lagom(scala)中构建身份验证服务,该服务由设备实体和事件处理器组成。 The service uses the JDBC plugin instead of the default Cassandra. 该服务使用JDBC插件而不是默认的Cassandra。 While writing the integration tests I found out that the event processor is not being called on events only for initialization. 在编写集成测试时,我发现事件处理器不是仅在初始化时才被调用。 I am not sure how to approach... 我不确定该如何处理...
abstract class AuthApplication(context: LagomApplicationContext) extends LagomApplication(context)
with JdbcPersistenceComponents
with AhcWSComponents
with HikariCPComponents {
override lazy val lagomServer = serverFor[AuthService](wire[AuthServiceImpl])
lazy val jsonSerializerRegistry = AuthSerializerRegistry
lazy val jwtAuthenticator: PkiAuthenticator = new JwtAuthenticator(config.getConfig("jwt"))
lazy val tokenRepository = wire[TokenRepository]
persistentEntityRegistry.register(wire[DeviceEntity])
readSide.register(wire[DeviceEventProcessor])
wire[TokenScheduler]
}
The integration test initialization: 集成测试初始化:
override def beforeAll: Unit = {
server = ServiceTest.startServer(ServiceTest.defaultSetup.withCassandra(true)) { ctx =>
new ServiceTestApplication(ctx)
}
authService = server.serviceClient.implement[AuthService]
}
为了解决这个问题,我不得不使用WordSpec
而不是AsyncWordSpec
,默认执行上下文与Lagom莫名其妙地打乱,另外我不得不添加的eventually
块来检查,如果状态更新,因为事件处理不立即采取像30秒。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.