Skip to content

Commit

Permalink
Issue #192 code review comments to make test more strict
Browse files Browse the repository at this point in the history
  • Loading branch information
njr-11 committed Sep 14, 2020
1 parent 7ded7e3 commit b5b3c6c
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018,2019 Contributors to the Eclipse Foundation
* Copyright (c) 2018,2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
Expand Down Expand Up @@ -1549,23 +1549,20 @@ public void newIncompleteFutureDependentStagesRunWithContext() throws ExecutionE
*/
@Test
public void propagateApplicationContext() throws ExecutionException, InterruptedException, TimeoutException {
ClassLoader appClassLoader = Thread.currentThread().getContextClassLoader();

ManagedExecutor.Builder builder = ManagedExecutor.builder()
.propagated(ThreadContext.APPLICATION)
.cleared(ThreadContext.ALL_REMAINING);

ManagedExecutor executor;
try {
executor = builder.build();
}
catch (IllegalStateException x) {
return; // Skip test if Application context is not supported.
}
ManagedExecutor executor = builder.build();

try {
CompletableFuture<Class<?>> cf = executor.supplyAsync(() -> {
try {
// load a class from the application
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Assert.assertEquals(loader, appClassLoader);
return loader.loadClass("org.eclipse.microprofile.context.tck.contexts.label.Label");
}
catch (ClassNotFoundException x) {
Expand Down

0 comments on commit b5b3c6c

Please sign in to comment.