From 79d3ba23bc26756ed9233bfcd190c8421bfdb86b Mon Sep 17 00:00:00 2001 From: Nathan Rauh Date: Thu, 21 Apr 2022 11:06:37 -0500 Subject: [PATCH] Issue #18669 disabled test for context type using vendor properties from context-service definition --- .../context/web/SimZOSContextTestServlet.java | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/dev/com.ibm.ws.concurrent_fat_zcontext/test-applications/SimZOSContextWeb/src/test/concurrent/sim/zos/context/web/SimZOSContextTestServlet.java b/dev/com.ibm.ws.concurrent_fat_zcontext/test-applications/SimZOSContextWeb/src/test/concurrent/sim/zos/context/web/SimZOSContextTestServlet.java index 0ab31352d912..aaca33b4c7c4 100644 --- a/dev/com.ibm.ws.concurrent_fat_zcontext/test-applications/SimZOSContextWeb/src/test/concurrent/sim/zos/context/web/SimZOSContextTestServlet.java +++ b/dev/com.ibm.ws.concurrent_fat_zcontext/test-applications/SimZOSContextWeb/src/test/concurrent/sim/zos/context/web/SimZOSContextTestServlet.java @@ -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 }, @@ -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 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 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(); + } + } }