use of io.helidon.common.context.Context in project helidon by oracle.
the class WebClientService method testFollowRedirect.
public void testFollowRedirect(Context ctx) {
client.get().path("/wc/redirect").followRedirects(true).context(ctx).request(Animal.class).thenAccept(animal -> assertTrue(animal, a -> "Frank".equals(a.getName()))).await(15, TimeUnit.SECONDS);
WebClientResponse response = client.get().path("/wc/redirect").followRedirects(false).context(ctx).request().await(15, TimeUnit.SECONDS);
assertEquals(response.status(), Http.Status.MOVED_PERMANENTLY_301);
}
use of io.helidon.common.context.Context in project helidon by oracle.
the class Slf4jMdcTest method testThreadPropagation.
@Test
public void testThreadPropagation() {
HelidonMdc.set(TEST_KEY, TEST_VALUE);
Context context = Context.create();
ExecutorService executor = Contexts.wrap(Executors.newFixedThreadPool(1));
Contexts.runInContext(context, () -> {
try {
String value = executor.submit(new TestCallable()).get();
assertThat(value, is(TEST_VALUE));
} catch (Exception e) {
throw new ExecutorException("failed to execute", e);
}
});
}
Aggregations