Skip to content
Permalink
Browse files
Align test
  • Loading branch information
AlanBateman committed Mar 2, 2021
1 parent 17d5e3e commit 26d8d03c4eee4733319aed67553e5f01eb421080
Showing 1 changed file with 28 additions and 1 deletion.
@@ -1143,6 +1143,33 @@ public void testContextClassLoader4() throws Exception {
}
}

// no support for thread locals
public void testContextClassLoader5() throws Exception {
ClassLoader loader = new ClassLoader() { };
TestHelper.runInVirtualThread(TestHelper.NO_THREAD_LOCALS, () -> {
Thread t = Thread.currentThread();
assertTrue(t.getContextClassLoader() == null);
assertThrows(UnsupportedOperationException.class,
() -> t.setContextClassLoader(loader));
assertTrue(t.getContextClassLoader() == null);
});
}

// do no inherit the initial value of threads locals
public void testContextClassLoader6() throws Exception {
TestHelper.runInVirtualThread(() -> {
ClassLoader loader = new ClassLoader() { };
Thread.currentThread().setContextClassLoader(loader);
int characteristics = TestHelper.NO_INHERIT_INHERITABLE_THREAD_LOCALS;
TestHelper.runInVirtualThread(characteristics, () -> {
Thread t = Thread.currentThread();
assertTrue(t.getContextClassLoader() == null);
t.setContextClassLoader(loader);
assertTrue(t.getContextClassLoader() == loader);
});
});
}


// -- Thread.UncaughtExceptionHandler --

@@ -1525,7 +1552,7 @@ public void testThreadGroup2() throws Exception {
ThreadGroup vgroup = Thread.currentThread().getThreadGroup();
Thread child = new Thread(() -> { });
ThreadGroup group = child.getThreadGroup();
assertTrue(group != vgroup);
assertTrue(group == vgroup);
});
}

0 comments on commit 26d8d03

Please sign in to comment.