use of com.spotify.apollo.Environment in project apollo by spotify.
the class ApolloEnvironmentModuleTest method shouldSetUpConfig.
@Test
public void shouldSetUpConfig() throws Exception {
final AtomicReference<Environment> envReference = new AtomicReference<>();
final Map<String, String> env = ImmutableMap.of("APOLLO_APOLLO_DOMAIN", "my-domain");
try (Service.Instance i = service.build().start(ZERO_ARGS, env)) {
final ApolloEnvironment environment = ApolloEnvironmentModule.environment(i);
final RequestHandler handler = environment.initialize(new EnvApp(envReference::set));
assertNotNull(handler);
final Environment e = envReference.get();
assertNotNull(e);
assertNotNull(e.config());
// from ping.conf
assertEquals("baz", e.config().getString("bar"));
assertEquals("my-domain", e.domain());
} catch (IOException e) {
fail(e.getMessage());
}
}
use of com.spotify.apollo.Environment in project apollo by spotify.
the class ApolloEnvironmentModuleTest method shouldUseEndpointRunnableFactoryDecorator.
@Test
public void shouldUseEndpointRunnableFactoryDecorator() throws Exception {
AtomicReference<String> lastResponseRef = new AtomicReference<>();
final Service service = this.service.withModule(new LastResponseModule(lastResponseRef)).build();
try (Service.Instance i = service.start()) {
final ApolloEnvironment environment = ApolloEnvironmentModule.environment(i);
final RequestHandler handler = environment.initialize(env -> {
env.routingEngine().registerAutoRoute(Route.sync("GET", "/", ctx -> "hello"));
});
assertNotNull(handler);
final FakeOngoingRequest ongoingRequest = ongoingRequest("http://foo");
handler.handle(ongoingRequest);
assertThat(ongoingRequest.getReply(), hasStatus(Status.GONE));
assertEquals("hello", lastResponseRef.get());
} catch (IOException e) {
fail(e.getMessage());
}
}
use of com.spotify.apollo.Environment in project apollo by spotify.
the class ApolloEnvironmentModuleTest method shouldGetFunctioningEnvironmentInAppInit.
@Test
public void shouldGetFunctioningEnvironmentInAppInit() throws Exception {
final AtomicReference<Environment> envReference = new AtomicReference<>();
try (Service.Instance i = service.build().start()) {
final ApolloEnvironment environment = ApolloEnvironmentModule.environment(i);
final RequestHandler handler = environment.initialize(envReference::set);
assertNotNull(handler);
final Environment e = envReference.get();
validateEnv(e);
} catch (IOException e) {
fail(e.getMessage());
}
}
use of com.spotify.apollo.Environment in project apollo by spotify.
the class EnvironmentFactoryTest method customConfigResolverShouldWork.
@Test
public void customConfigResolverShouldWork() throws Exception {
when(configResolver.getConfig(SERVICE_NAME)).thenReturn(configNode);
final Environment environment = sut.withConfigResolver(configResolver).build().create(SERVICE_NAME, routingContext);
assertEquals(configNode, environment.config());
}
use of com.spotify.apollo.Environment in project apollo by spotify.
the class EnvironmentFactoryTest method staticConfigShouldWork.
@Test
public void staticConfigShouldWork() throws Exception {
final Environment environment = sut.withStaticConfig(configNode).build().create(SERVICE_NAME, routingContext);
assertEquals(configNode, environment.config());
}
Aggregations