assertThat(contextId, is("foo"));
}
@Test
public void testContextIsNotModifiedByChildThread_contextShouldBeUnchanged() throws Exception {
ContextHolder context = ContextHolder.get();
context.setCurrentContextId("foo");
Callable<String> task = new Callable<String>() {
@Override
public String call() throws Exception {
ContextHolder.get().setCurrentContextId("bar");
return ContextHolder.get().getCurrentContextId();
}
};
String result = Executors.newSingleThreadExecutor().submit(task).get();
assertThat(result, is("bar"));
assertThat(context.getCurrentContextId(), is("foo"));
}