Skip to content

Commit

Permalink
Issue #18669 disabled test for context type using vendor properties f…
Browse files Browse the repository at this point in the history
…rom context-service definition
  • Loading branch information
njr-11 committed Apr 21, 2022
1 parent 4c1cae2 commit 79d3ba2
Showing 1 changed file with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
@ContextServiceDefinition(name = "java:app/concurrent/ThreadNameContext",
propagated = { "SyncToOSThread", SECURITY, APPLICATION })

//TODO move to web.xml and include properties?
@ContextServiceDefinition(name = "java:module/concurrent/zosWLMContext",
propagated = { "Classification" },
cleared = { TRANSACTION, "SyncToOSThread", SECURITY },
Expand Down Expand Up @@ -244,4 +243,54 @@ public void testPropagateSimulatedZOSWLMContext() throws Exception {
Enclave.clear();
}
}

/**
* Configure vendor properties for PropagateOrNew and with different default transaction
* classes for zosWLMContext and verify that the fake context type that we are using to simulate it
* propagates or creates the new context on the thread.
*/
// TODO If the spec ever adds a way for vendor properties to be supplied to context types, this test could help provide coverage.
// @Test
public void testVendorPropertiesSimulatedZOSWLMContext() throws Exception {
// Instead of testing the real z/OS WLM context behavior,
// the fake context provider updates the state of a mock Enclave class.
ContextService contextSvc = InitialContext.doLookup("java:comp/concurrent/zosWLMContextPropagateOrNew");

String originalName = Thread.currentThread().getName();
try {
Enclave.setTransactionClass("TX_CLASS_D");

Supplier<String> txClassSupplier = contextSvc.contextualSupplier(Enclave::getTransactionClass);

Enclave.setTransactionClass("TX_CLASS_E");

assertEquals("TX_CLASS_D", txClassSupplier.get());

assertEquals("TX_CLASS_E", Enclave.getTransactionClass());

// Propagate the absence of context:

Enclave.clear();

txClassSupplier = contextSvc.contextualSupplier(Enclave::getTransactionClass);

Enclave.setTransactionClass("TX_CLASS_F");

assertEquals("DEFAULT_TX", txClassSupplier.get());

assertEquals("TX_CLASS_F", Enclave.getTransactionClass());

// Long running task:

@SuppressWarnings("unchecked")
Supplier<String> longRunningTxSupplier = contextSvc.createContextualProxy(Enclave::getTransactionClass,
Collections.singletonMap(ManagedTask.LONGRUNNING_HINT, "true"),
Supplier.class);
assertEquals("DAEMON_TX", longRunningTxSupplier.get());

assertEquals("TX_CLASS_F", Enclave.getTransactionClass());
} finally {
Enclave.clear();
}
}
}

0 comments on commit 79d3ba2

Please sign in to comment.