Skip to content

Commit

Permalink
Issue #60 code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
njr-11 committed Feb 3, 2019
1 parent f41ff84 commit 0da23c0
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -400,6 +400,9 @@ public void testAppDefinedProducerOfThreadContext() {
* Application-defined producer methods can have injection points of ThreadContext that are provided by the container.
*/
public void testAppDefinedProducerUsingInjectedThreadContext() {
Assert.assertNotNull(priority3Executor,
"Application should be able to create its own CDI producer that injects a ThreadContext that is provided by the container.");

int originalPriority = Thread.currentThread().getPriority();
int newPriority = originalPriority == 2 ? 1 : 2;
try {
Expand Down Expand Up @@ -432,6 +435,9 @@ public void testAppDefinedProducerUsingInjectedThreadContext() {
* types are propagated, except for Transaction context, which is cleared.
*/
public void testInjectThreadContextNoConfig() {
Assert.assertNotNull(defaultContext,
"Container must produce ThreadContext instance for unqualified injection point that lacks ThreadContextConfig.");

int originalPriority = Thread.currentThread().getPriority();
int newPriority = originalPriority == 2 ? 1 : 2;
try {
Expand Down Expand Up @@ -469,26 +475,29 @@ public void testInjectThreadContextNoConfig() {
* types are propagated, except for Transaction context, which is cleared.
*/
public void testInjectThreadContextEmptyConfig() throws Exception {
Assert.assertNotNull(defaultContextWithEmptyAnno,
"Container must produce ThreadContext instance for injection point that is annotated with ThreadContextConfig.");

int originalPriority = Thread.currentThread().getPriority();
int newPriority = originalPriority == 2 ? 1 : 2;
try {
Thread.currentThread().setPriority(newPriority);
Label.set("testInjectThreadContextEmptyConfig-label");
Buffer.set(new StringBuffer("testInjectThreadContextEmptyConfig-buffer"));

Callable<Boolean> testAllContextPropagated = defaultContext.contextualCallable(() -> {
Callable<Boolean> testAllContextPropagated = defaultContextWithEmptyAnno.contextualCallable(() -> {
Assert.assertEquals(Buffer.get().toString(), "testInjectThreadContextEmptyConfig-buffer",
"Thread context type (Buffer) was not propagated.");
Assert.assertEquals(Label.get(), "testInjectThreadContextEmptyConfig-label",
"Thread context type (Lable) was not propagated.");
"Thread context type (Label) was not propagated.");
Assert.assertEquals(Thread.currentThread().getPriority(), newPriority,
"Thread context type (ThreadPriority) was not propagated.");
return true;
});

Thread.currentThread().setPriority(4);
Label.set("testInjectThreadContextNoConfig-new-label");
Buffer.set(new StringBuffer("testInjectThreadContextNoConfig-new-buffer"));
Label.set("testInjectThreadContextEmptyConfig-new-label");
Buffer.set(new StringBuffer("testInjectThreadContextEmptyConfig-new-buffer"));

testAllContextPropagated.call();
}
Expand Down

0 comments on commit 0da23c0

Please sign in to comment.