use of com.spotify.apollo.core.Service in project apollo by spotify.
the class ApolloEnvironmentModuleTest method shouldUseRequestRunnableFactoryDecorator.
@Test
public void shouldUseRequestRunnableFactoryDecorator() throws Exception {
final AtomicInteger counter = new AtomicInteger();
final Service service = this.service.withModule(new RequestInspectingModule("http://foo", counter)).build();
try (Service.Instance i = service.start()) {
final ApolloEnvironment environment = ApolloEnvironmentModule.environment(i);
final RequestHandler handler = environment.initialize(env -> {
});
assertNotNull(handler);
final OngoingRequest ongoingRequest = ongoingRequest("http://foo");
handler.handle(ongoingRequest);
assertEquals(1, counter.get());
handler.handle(ongoingRequest);
assertEquals(2, counter.get());
} catch (IOException e) {
fail(e.getMessage());
}
}
use of com.spotify.apollo.core.Service in project apollo by spotify.
the class HttpService method boot.
public static void boot(AppInit appInit, String serviceName, InstanceListener instanceListener, String... args) throws LoadingException {
final Service service = usingAppInit(appInit, serviceName).build();
boot(service, instanceListener, args);
}
use of com.spotify.apollo.core.Service in project apollo by spotify.
the class HttpServiceModuleTest method shouldInitAndDestroyApplication.
@Test
public void shouldInitAndDestroyApplication() throws Exception {
final AtomicBoolean init = new AtomicBoolean();
final AtomicBoolean destroy = new AtomicBoolean();
final App app = new App(init, destroy);
try (Service.Instance i = service(app).start()) {
final RequestHandler handler = HttpServiceModule.requestHandler(i);
assertNotNull(handler);
} catch (IOException e) {
fail(e.getMessage());
}
assertTrue(init.get());
assertTrue(destroy.get());
}
use of com.spotify.apollo.core.Service in project apollo by spotify.
the class HttpServiceTest method testBrokenService.
@Test
public void testBrokenService() throws Exception {
final Service service = HttpService.usingAppInit(new BrokenService(), "test").build();
exception.expect(LoadingException.class);
HttpService.boot(service, "run", "foo");
}
Aggregations