use of com.spotify.apollo.http.server.HttpRequestMetadata in project apollo by spotify.
the class HttpServiceTest method shouldPopulateRequestMetadata.
@Test
public void shouldPopulateRequestMetadata() throws Exception {
AtomicReference<RequestMetadata> metadataReference = new AtomicReference<>();
final InstanceWaiter waiter = new InstanceWaiter();
Future<?> future = executorService.submit(() -> {
try {
HttpService.boot(environment -> environment.routingEngine().registerRoute(Route.async("GET", "/meta", trackMeta(metadataReference))), "metadatatest", waiter);
} catch (LoadingException e) {
throw new RuntimeException(e);
}
});
final Service.Instance instance = waiter.waitForInstance();
Request httpRequest = new Request.Builder().url("http://localhost:29432/meta").build();
new OkHttpClient().newCall(httpRequest).execute();
assertThat(((HttpRequestMetadata) metadataReference.get()).httpVersion(), is("HTTP/1.1"));
instance.getSignaller().signalShutdown();
instance.waitForShutdown();
future.get();
}
Aggregations