Hi,I test my module with a fake application, but how I can simulate the call to ApplicationLifeCycle hook setted on the module ? (this hook is used to close some TCP connections).
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/9a97b053-7dc3-49ba-aad2-df11b09db5c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hey Thibault,You can create your own implementation of ApplicationLifecycle and use it at your tests, instead the default one. To use it at your tests, you can override the bind using GuiceApplicationBuilder.overrides.Best.
On Tue, Feb 14, 2017 at 1:06 AM, Thibault Meyer <thibaul...@payintech.com> wrote:
Hi,I test my module with a fake application, but how I can simulate the call to ApplicationLifeCycle hook setted on the module ? (this hook is used to close some TCP connections).
--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/9a97b053-7dc3-49ba-aad2-df11b09db5c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/9da23356-b79e-4298-9681-d579c2b88256%40googlegroups.com.
void addStopHook(Callable<? extends CompletionStage<?>> hook)
def addStopHook(hook: () => Future[_])
def stop()
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class RedisTest {
private RedisModule redisModule;
private ApplicationLifecycle applicationLifecycle;
@Before
public void initializeRedisModule() {
if (this.redisModule == null) {
final Application application = Helpers.
fakeApplication(new HashMap<String, Object>() {{
put("redis.default.db.default", 0);
put("redis.default.host", "127.0.0.1");
put("redis.default.port", 6379);
}});
this.applicationLifecycle = mock(ApplicationLifecycle.class);
this.redisModule = new RedisModuleImpl(
this.applicationLifecycle
application.configuration()
);
Assert.assertNotEquals(null, this.redisModule);
}
}
@After
public void closeRedisModule() {
if (this.applicationLifecycle != null) {
this.applicationLifecycle.stop(); // NOT AVAILABLE ON JAVA IMPLEMENTATION
}
}
}
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/9da23356-b79e-4298-9681-d579c2b88256%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/d62c8650-36ea-43bb-983e-b7c88048a879%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/79fdd3cd-65fd-43e5-8e8f-3bf0ab7c86a9%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/3e5879e6-9531-40d6-99c6-93a832542f8d%40googlegroups.com.
/.../
if (this.redisModule == null) {
final Application application = Helpers.
fakeApplication(new HashMap<String, Object>() {{
put("redis.default.db.default", 0);
put("redis.default.host", "127.0.0.1");
put("redis.default.port", 6379);
}});
this.applicationLifecycle = mock(ApplicationLifecycle.class); // MOCK
this.redisModule = new RedisModuleImpl(
this.applicationLifecycle
application.configuration()
);
Assert.assertNotEquals(null, this.redisModule);
}
/.../