From ed4e7c5a065e58f7beca4677a1792b6fa6f52e8a Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Wed, 16 Aug 2023 17:11:31 -0500 Subject: [PATCH 1/3] Add assertion annotation --- .../AbortedExceptionTests.java | 38 +--- .../ContextService/ContextServiceTests.java | 167 ++++-------------- .../api/LastExecution/LastExecutionTests.java | 43 +---- .../ManagedExecutorsTests.java | 126 +++---------- .../ManagedScheduledExecutorServiceTests.java | 48 +---- .../api/ManagedTask/ManagedTaskTests.java | 25 +-- .../ManagedTaskListenerTests.java | 57 ++---- .../ManagedThreadFactoryTests.java | 36 +--- .../SkippedExceptionTests.java | 38 +--- .../concurrent/api/Trigger/TriggerTests.java | 33 +--- .../framework/junit/anno/Assertion.java | 37 ++++ .../ContextPropagationFullTests.java | 151 ++++------------ .../ContextPropagationWebTests.java | 154 ++++------------ .../ContextPropagationServletTests.java | 32 +--- .../ContextService/tx/TransactionTests.java | 100 +++-------- .../inheritedapi/InheritedAPITests.java | 31 +--- .../forbiddenapi/ForbiddenAPIEJBTests.java | 53 +----- .../ForbiddenAPIServletTests.java | 100 +++-------- .../managed/forbiddenapi/TestEjb.java | 46 ++--- .../ManagedExecutorDefinitionFullTests.java | 38 ++-- .../ManagedExecutorDefinitionWebTests.java | 38 ++-- .../security/SecurityFullTests.java | 25 +-- .../security/SecurityWebTests.java | 19 +- .../tx/TransactionTests.java | 51 ++---- .../inheritedapi/InheritedAPIFullTests.java | 65 +------ .../InheritedAPIServletTests.java | 67 +------ .../inheritedapi/InheritedAPIWebTests.java | 67 +------ .../forbiddenapi/ForbiddenAPIEJBTests.java | 47 +---- .../ForbiddenAPIServletTests.java | 88 ++------- .../managed/forbiddenapi/TestEjb.java | 41 ++--- ...dScheduledExecutorDefinitionFullTests.java | 53 ++++-- ...edScheduledExecutorDefinitionWebTests.java | 59 +++++-- .../tx/TransactionTests.java | 51 ++---- .../context/ContextFullTests.java | 14 +- .../context/ContextWebTests.java | 14 +- ...nagedThreadFactoryDefinitionFullTests.java | 28 +-- ...anagedThreadFactoryDefinitionWebTests.java | 29 +-- .../tx/TransactionTests.java | 54 ++---- .../dd/DeploymentDescriptorFullTests.java | 12 +- .../dd/DeploymentDescriptorServlet.java | 12 -- .../dd/DeploymentDescriptorWebTests.java | 17 +- .../spec/signature/SignatureTests.java | 5 +- 42 files changed, 584 insertions(+), 1625 deletions(-) create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Assertion.java rename tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/{servlet => }/InheritedAPIServletTests.java (88%) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/AbortedException/AbortedExceptionTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/AbortedException/AbortedExceptionTests.java index 1bec135b..18bf5564 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/AbortedException/AbortedExceptionTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/AbortedException/AbortedExceptionTests.java @@ -24,8 +24,8 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; import jakarta.enterprise.concurrent.AbortedException; @@ -37,14 +37,7 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class).addPackages(true, AbortedExceptionTests.class.getPackage()); } - /* - * @testName: abortedExceptionNoArgTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:1 - * - * @test_Strategy: Constructs an AbortedException. - */ - @Test + @Assertion(id = "JAVADOC:1", strategy = "Constructs an AbortedException") public void abortedExceptionNoArgTest() { AbortedException thrown = assertThrows(AbortedException.class, () -> { throw new AbortedException(); @@ -53,14 +46,7 @@ public void abortedExceptionNoArgTest() { assertNull(thrown.getMessage()); } - /* - * @testName: abortedExceptionStringTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:3 - * - * @test_Strategy: Constructs an AbortedException. - */ - @Test + @Assertion(id = "JAVADOC:3", strategy = "Constructs an AbortedException") public void abortedExceptionStringTest() { final String expected = "thisisthedetailmessage"; @@ -72,14 +58,7 @@ public void abortedExceptionStringTest() { assertEquals(expected, thrown.getMessage()); } - /* - * @testName: abortedExceptionThrowableTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:4 - * - * @test_Strategy: Constructs an AbortedException. - */ - @Test + @Assertion(id = "JAVADOC:4", strategy = "Constructs an AbortedException") public void abortedExceptionThrowableTest() { AbortedException thrown; @@ -101,14 +80,7 @@ public void abortedExceptionThrowableTest() { assertNull(thrown.getCause()); } - /* - * @testName: abortedExceptionStringThrowableTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:2 - * - * @test_Strategy: Constructs an AbortedException. - */ - @Test + @Assertion(id = "JAVADOC:2", strategy = "Constructs an AbortedException") public void abortedExceptionStringThrowableTest() { AbortedException thrown; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ContextService/ContextServiceTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ContextService/ContextServiceTests.java index 4be4d552..690f2494 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ContextService/ContextServiceTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ContextService/ContextServiceTests.java @@ -28,11 +28,11 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.fixed.counter.CounterRunnableTask; import ee.jakarta.tck.concurrent.common.fixed.counter.WorkInterface; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -53,15 +53,7 @@ public static WebArchive createDeployment() { @Resource(lookup = TestConstants.defaultContextService) private ContextService context; - /* - * @testName: contextServiceWithIntf - * - * @assertion_ids: CONCURRENCY:JAVADOC:5 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using instance and interface. - */ - @Test + @Assertion(id = "JAVADOC:5", strategy = "Lookup default ContextService object and create proxy object using instance and interface.") public void contextServiceWithIntf() { assertAll(() -> { Runnable proxy = (Runnable) context.createContextualProxy(new CounterRunnableTask(), Runnable.class); @@ -69,47 +61,23 @@ public void contextServiceWithIntf() { }); } - /* - * @testName: contextServiceWithIntfAndIntfNoImplemented - * - * @assertion_ids: CONCURRENCY:JAVADOC:6 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using instance and interface. if the instance does not implement the - * specified interface, IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:6", strategy = "Lookup default ContextService object and create proxy object using instance and interface." + + " If the instance does not implement the specified interface, IllegalArgumentException will be thrown") public void contextServiceWithIntfAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(new Object(), Runnable.class); }); } - /* - * @testName: contextServiceWithIntfAndInstanceIsNull - * - * @assertion_ids: CONCURRENCY:JAVADOC:6 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using instance and interface. if the instance is null, - * IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:6", strategy = "Lookup default ContextService object and create proxy object using instance and interface." + + " If the instance is null, IllegalArgumentException will be thrown") public void contextServiceWithIntfAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(null, Runnable.class); }); } - /* - * @testName: contextServiceWithMultiIntfs - * - * @assertion_ids: CONCURRENCY:JAVADOC:7 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using instance and multiple interfaces. - */ - @Test + @Assertion(id = "JAVADOC:7", strategy = "Lookup default ContextService object and create proxy object using instance and multiple interfaces.") public void contextServiceWithMultiIntfs() { assertAll(() -> { Object proxy = context.createContextualProxy(new CounterRunnableTask(), Runnable.class, @@ -120,16 +88,8 @@ public void contextServiceWithMultiIntfs() { }); } - /* - * @testName: contextServiceWithMultiIntfsAndIntfNoImplemented - * - * @assertion_ids: CONCURRENCY:JAVADOC:8 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using instance and multi interfaces. if the instance does not implement the - * specified interface, IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:8", strategy = "Lookup default ContextService object and create proxy object using instance and multi interfaces." + + "If the instance does not implement the specified interface, IllegalArgumentException will be thrown") public void contextServiceWithMultiIntfsAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(new CounterRunnableTask(), Runnable.class, WorkInterface.class, @@ -137,31 +97,15 @@ public void contextServiceWithMultiIntfsAndIntfNoImplemented() { }); } - /* - * @testName: contextServiceWithMultiIntfsAndInstanceIsNull - * - * @assertion_ids: CONCURRENCY:JAVADOC:8 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using object and multi interfaces. if the instance is null, - * IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:8", strategy = "Lookup default ContextService object and create proxy object using object and multi interfaces." + + " If the instance is null, IllegalArgumentException will be thrown") public void contextServiceWithMultiIntfsAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(null, Runnable.class, WorkInterface.class); }); } - /* - * @testName: ContextServiceWithIntfAndProperties - * - * @assertion_ids: CONCURRENCY:JAVADOC:9 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using ExecutionProperties and interface. - */ - @Test + @Assertion(id = "JAVADOC:9", strategy = "Lookup default ContextService object and create proxy object using ExecutionProperties and interface.") public void contextServiceWithIntfAndProperties() { assertAll(() -> { Map execProps = new HashMap(); @@ -174,15 +118,8 @@ public void contextServiceWithIntfAndProperties() { }); } - /* - * @testName: ContextServiceWithMultiIntfsAndProperties - * - * @assertion_ids: CONCURRENCY:JAVADOC:11 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using ExecutionProperties and multiple interfaces. - */ - @Test + @Assertion(id = "JAVADOC:11", + strategy = "Lookup default ContextService object and create proxy object using ExecutionProperties and multiple interfaces.") public void contextServiceWithMultiIntfsAndProperties() { assertAll(() -> { Map execProps = new HashMap(); @@ -197,16 +134,9 @@ public void contextServiceWithMultiIntfsAndProperties() { }); } - /* - * @testName: ContextServiceWithIntfAndPropertiesAndIntfNoImplemented - * - * @assertion_ids: CONCURRENCY:JAVADOC:10 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using ExecutionProperties and interface. if the instance does not implement - * the specified interface, IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:10", + strategy = "Lookup default ContextService object and create proxy object using ExecutionProperties and interface." + + " If the instance does not implement the specified interface, IllegalArgumentException will be thrown") public void contextServiceWithIntfAndPropertiesAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); @@ -218,16 +148,9 @@ public void contextServiceWithIntfAndPropertiesAndIntfNoImplemented() { }); } - /* - * @testName: ContextServiceWithIntfsAndPropertiesAndInstanceIsNull - * - * @assertion_ids: CONCURRENCY:JAVADOC:10 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using ExecutionProperties and interfaces. if the instance is null, - * IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:10", + strategy = "Lookup default ContextService object and create proxy object using ExecutionProperties and interfaces." + + "If the instance is null, IllegalArgumentException will be thrown") public void contextServiceWithIntfsAndPropertiesAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); @@ -238,16 +161,9 @@ public void contextServiceWithIntfsAndPropertiesAndInstanceIsNull() { }); } - /* - * @testName: ContextServiceWithMultiIntfsAndPropertiesAndIntfNoImplemented - * - * @assertion_ids: CONCURRENCY:JAVADOC:12 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using ExecutionProperties and multiple interfaces. if the instance does not - * implement the specified interface, IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:12", + strategy = "Lookup default ContextService object and create proxy object using ExecutionProperties and multiple interfaces." + + "If the instance does not implement the specified interface, IllegalArgumentException will be thrown") public void contextServiceWithMultiIntfsAndPropertiesAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); @@ -259,16 +175,9 @@ public void contextServiceWithMultiIntfsAndPropertiesAndIntfNoImplemented() { }); } - /* - * @testName: contextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull - * - * @assertion_ids: CONCURRENCY:JAVADOC:12 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using ExecutionProperties and multiple interfaces. if the instance is null, - * IllegalArgumentException will be thrown - */ - @Test + @Assertion(id = "JAVADOC:12", + strategy = "Lookup default ContextService object and create proxy object using ExecutionProperties and multiple interfaces." + + " If the instance is null, IllegalArgumentException will be thrown") public void contextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); @@ -279,16 +188,9 @@ public void contextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull() { }); } - /* - * @testName: getExecutionProperties - * - * @assertion_ids: CONCURRENCY:JAVADOC:13 - * - * @test_Strategy: Lookup default ContextService object and create proxy object - * using ExecutionProperties and multiple interfaces. Retrieve - * ExecutionProperties from proxy object and verify property value. - */ - @Test + @Assertion(id = "JAVADOC:13", + strategy = "Lookup default ContextService object and create proxy object using ExecutionProperties and multiple interfaces." + + " Retrieve ExecutionProperties from proxy object and verify property value.") public void getExecutionProperties() { assertAll(() -> { Map execProps = new HashMap(); @@ -303,15 +205,8 @@ public void getExecutionProperties() { }); } - /* - * @testName: getExecutionPropertiesNoProxy - * - * @assertion_ids: CONCURRENCY:JAVADOC:14 - * - * @test_Strategy: Lookup default ContextService object. Retrieve - * ExecutionProperties from plain object. - */ - @Test + @Assertion(id = "JAVADOC:14", + strategy = "Lookup default ContextService object. Retrieve ExecutionProperties from plain object.") public void getExecutionPropertiesNoProxy() { assertAll(() -> { try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LastExecutionTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LastExecutionTests.java index e9f26457..e0973d96 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LastExecutionTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LastExecutionTests.java @@ -26,12 +26,12 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.fixed.counter.CounterCallableTask; import ee.jakarta.tck.concurrent.common.fixed.counter.CounterRunnableTask; import ee.jakarta.tck.concurrent.common.fixed.counter.StaticCounter; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -64,16 +64,9 @@ public void reset() { @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) private ManagedScheduledExecutorService scheduledExecutor; - /* - * @testName: lastExecutionGetIdentityNameTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:15 - * - * @test_Strategy: The name or ID of the identifiable object, as specified in - * the ManagedTask#IDENTITY_NAME execution property of the task if it also - * implements the ManagedTask interface. - */ - @Test + @Assertion(id = "JAVADOC:15", strategy = "The name or ID of the identifiable object," + + " as specified in the ManagedTask#IDENTITY_NAME execution property of the task " + + "if it also implements the ManagedTask interface.") public void lastExecutionGetIdentityNameTest() { Map executionProperties = new HashMap(); @@ -89,14 +82,7 @@ public void lastExecutionGetIdentityNameTest() { "Got wrong identity name. See server log for more details."); } - /* - * @testName: lastExecutionGetResultTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:16 - * - * @test_Strategy: Result of the last execution. - */ - @Test + @Assertion(id = "JAVADOC:16", strategy = "Result of the last execution.") public void lastExecutionGetResultRunnableTest() { // test with runnable, LastExecution should return null ScheduledFuture sf = scheduledExecutor.schedule( @@ -109,14 +95,7 @@ public void lastExecutionGetResultRunnableTest() { "Got wrong last execution result. See server log for more details."); } - /* - * @testName: lastExecutionGetResultTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:16 - * - * @test_Strategy: Result of the last execution. - */ - @Test + @Assertion(id = "JAVADOC:16", strategy = "Result of the last execution.") public void lastExecutionGetResultCallableTest() { // test with callable, LastExecution should return 1 ScheduledFuture sf = scheduledExecutor.schedule( @@ -129,15 +108,7 @@ public void lastExecutionGetResultCallableTest() { "Got wrong last execution result. See server log for more details."); } - /* - * @testName: lastExecutionGetRunningTimeTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:17; CONCURRENCY:JAVADOC:18; - * CONCURRENCY:JAVADOC:19 - * - * @test_Strategy: The last time in which the task was completed. - */ - @Test + @Assertion(id = "JAVADOC:17 JAVADOC:18 JAVADOC:19", strategy = "The last time in which the task was completed.") public void lastExecutionGetRunningTimeTest() { ScheduledFuture sf = scheduledExecutor.schedule( ManagedExecutors.managedTask(new CounterRunnableTask(TestConstants.pollInterval), null, null), diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedExecutors/ManagedExecutorsTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedExecutors/ManagedExecutorsTests.java index 321f8ca0..224b1794 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedExecutors/ManagedExecutorsTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedExecutors/ManagedExecutorsTests.java @@ -31,13 +31,13 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.managed.task.listener.ListenerEvent; import ee.jakarta.tck.concurrent.common.managed.task.listener.ManagedTaskListenerImpl; import ee.jakarta.tck.concurrent.common.tasks.CallableTask; import ee.jakarta.tck.concurrent.common.tasks.RunnableTask; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -110,16 +110,7 @@ private void assertListenerComplete(final RunnableTask task) { } - /* - * @testName: isCurrentThreadShutdown - * - * @assertion_ids: CONCURRENCY:JAVADOC:21 - * - * @test_Strategy: Use a regular thread(non-Manageable thread) and verify - * isCurrentThreadShutdown() returns false - * - */ - @Test + @Assertion(id = "JAVADOC:21", strategy = "Use a regular thread(non-Manageable thread) and verify isCurrentThreadShutdown() returns false") public void isCurrentThreadShutdown() { Thread createdThread = threadFactory.newThread(new Runnable() { @Override @@ -135,15 +126,7 @@ public void run() { assertFalse(shutdown, "Failed because shutdown is set to be true when running job"); } - /* - * @testName: isCurrentThreadShutdown_ManageableThread - * - * @assertion_ids: CONCURRENCY:JAVADOC:21 - * - * @test_Strategy: Create a ManageableThread from ManagedThreadFactory and check - * the shutdown status. - */ - @Test + @Assertion(id = "JAVADOC:21", strategy = "Create a ManageableThread from ManagedThreadFactory and check the shutdown status.") public void isCurrentThreadShutdownManageableThread() { Thread createdThread = threadFactory.newThread(new Runnable() { @Override @@ -159,19 +142,10 @@ public void run() { assertFalse(shutdown, "Failed because shutdown is set to be true when running job"); } - /* - * @testName: manageRunnableTaskWithTaskListener - * - * @assertion_ids: CONCURRENCY:JAVADOC:22;CONCURRENCY:SPEC:7; - * CONCURRENCY:SPEC:7.1;CONCURRENCY:SPEC:7.2; - * CONCURRENCY:SPEC:4;CONCURRENCY:SPEC:4.2; CONCURRENCY:SPEC:18; - * - * @test_Strategy: Returns a Runnable object that also implements ManagedTask - * interface so it can receive notification of life cycle events with the - * provided ManagedTaskListener when the task is submitted to a - * ManagedExecutorService or a ManagedScheduledExecutorService. - */ - @Test + @Assertion(id = "JAVADOC:22 SPEC:7 SPEC:7.1 SPEC:7.2 SPEC:4 SPEC:4.2 SPEC:18", + strategy = "Returns a Runnable object that also implements ManagedTask interface" + + " so it can receive notification of life cycle events with the provided ManagedTaskListener" + + " when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.") public void manageRunnableTaskWithTaskListener() { RunnableTask runnableTask = createRunnableTask(); Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); @@ -179,15 +153,7 @@ public void manageRunnableTaskWithTaskListener() { assertTaskAndListenerComplete(futureResult, runnableTask); } - /* - * @testName: manageRunnableTaskWithNullArg - * - * @assertion_ids: CONCURRENCY:JAVADOC:23 - * - * @test_Strategy: Catch IllegalArgumentException when get the manage task with - * null runnable task. - */ - @Test + @Assertion(id = "JAVADOC:23", strategy = "Catch IllegalArgumentException when get the manage task with null runnable task.") public void manageRunnableTaskWithNullArg() { Runnable nullTask = null; assertThrows(IllegalArgumentException.class, () -> { @@ -195,17 +161,10 @@ public void manageRunnableTaskWithNullArg() { }); } - /* - * @testName: manageRunnableTaskWithTaskListenerAndMap - * - * @assertion_ids: CONCURRENCY:JAVADOC:24;CONCURRENCY:SPEC:13; - * - * @test_Strategy: Returns a Runnable object that also implements ManagedTask - * interface so it can receive notification of life cycle events with the - * provided ManagedTaskListener and to provide additional execution properties - * when the task is submitted to a ManagedExecutorService - */ - @Test + @Assertion(id = "JAVADOC:24 SPEC:13", + strategy = "Returns a Runnable object that also implements ManagedTask interface" + + " so it can receive notification of life cycle events with the provided ManagedTaskListener" + + " and to provide additional execution properties when the task is submitted to a ManagedExecutorService") public void manageRunnableTaskWithTaskListenerAndMap() { Map properties = new HashMap(); properties.put("key", "value"); @@ -220,15 +179,7 @@ public void manageRunnableTaskWithTaskListenerAndMap() { assertTaskAndListenerComplete(executor.submit(task), runnableTask); } - /* - * @testName: manageRunnableTaskWithMapAndNullArg - * - * @assertion_ids: CONCURRENCY:JAVADOC:25 - * - * @test_Strategy: Catch IllegalArgumentException when get the manage task with - * null runnable task and additional execution properties. - */ - @Test + @Assertion(id = "JAVADOC:25", strategy = "Catch IllegalArgumentException when get the manage task with null runnable task and additional execution properties.") public void manageRunnableTaskWithMapAndNullArg() { Runnable nullTask = null; Map properties = new HashMap(); @@ -238,17 +189,10 @@ public void manageRunnableTaskWithMapAndNullArg() { }); } - /* - * @testName: manageCallableTaskWithTaskListener - * - * @assertion_ids: CONCURRENCY:JAVADOC:26 - * - * @test_Strategy: Returns a Callable object that also implements ManagedTask - * interface so it can receive notification of life cycle events with the - * provided ManagedTaskListener when the task is submitted to a - * ManagedExecutorService - */ - @Test + @Assertion(id = "JAVADOC:26", + strategy = "Returns a Callable object that also implements ManagedTask interface" + + " so it can receive notification of life cycle events with the provided ManagedTaskListener" + + " when the task is submitted to a ManagedExecutorService") public void manageCallableTaskWithTaskListener() { String expectedResultStr = "expected something"; CallableTask callableTask = createCallableTask(expectedResultStr); @@ -258,15 +202,7 @@ public void manageCallableTaskWithTaskListener() { assertTaskAndListenerComplete(expectedResultStr, futureResult, callableTask); } - /* - * @testName: manageCallableTaskWithNullArg - * - * @assertion_ids: CONCURRENCY:JAVADOC:27 - * - * @test_Strategy: Catch IllegalArgumentException when get the manage task with - * null Callable task. - */ - @Test + @Assertion(id = "JAVADOC:27", strategy = "Catch IllegalArgumentException when get the manage task with null Callable task.") public void manageCallableTaskWithNullArg() { Callable nullTask = null; assertThrows(IllegalArgumentException.class, () -> { @@ -274,18 +210,10 @@ public void manageCallableTaskWithNullArg() { }); } - /* - * @testName: manageCallableTaskWithTaskListenerAndMap - * - * @assertion_ids: CONCURRENCY:JAVADOC:28;CONCURRENCY:SPEC:13.1; - * CONCURRENCY:SPEC:45;CONCURRENCY:SPEC:45.1; - * - * @test_Strategy: Returns a Callable object that also implements ManagedTask - * interface so it can receive notification of life cycle events with the - * provided ManagedTaskListener and to provide additional execution properties - * when the task is submitted to a ManagedExecutorService - */ - @Test + @Assertion(id = "JAVADOC:28 SPEC:13.1 SPEC:45 SPEC:45.1", + strategy = "Returns a Callable object that also implements ManagedTask interface" + + " so it can receive notification of life cycle events with the provided ManagedTaskListener" + + " and to provide additional execution properties when the task is submitted to a ManagedExecutorService") public void manageCallableTaskWithTaskListenerAndMap() { Map properties = new HashMap(); properties.put("key", "value"); @@ -305,15 +233,7 @@ public void manageCallableTaskWithTaskListenerAndMap() { assertTaskAndListenerComplete(expectedResultStr, executor.submit(task), callableTask); } - /* - * @testName: manageCallableTaskWithMapAndNullArg - * - * @assertion_ids: CONCURRENCY:JAVADOC:29 - * - * @test_Strategy: Catch IllegalArgumentException when get the manage task with - * null Callable task and additional execution properties. - */ - @Test + @Assertion(id = "JAVADOC:29", strategy = "Catch IllegalArgumentException when get the manage task with null Callable task and additional execution properties.") public void manageCallableTaskWithMapAndNullArg() { Callable nullTask = null; Map properties = new HashMap(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedScheduledExecutorService/ManagedScheduledExecutorServiceTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedScheduledExecutorService/ManagedScheduledExecutorServiceTests.java index f9b8295e..2ef75234 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedScheduledExecutorService/ManagedScheduledExecutorServiceTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedScheduledExecutorService/ManagedScheduledExecutorServiceTests.java @@ -26,12 +26,12 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.tasks.CallableTask; import ee.jakarta.tck.concurrent.common.tasks.CommonTriggers; import ee.jakarta.tck.concurrent.common.tasks.RunnableTask; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -62,17 +62,9 @@ public static WebArchive createDeployment() { @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) private ManagedScheduledExecutorService scheduledExecutor; - /* - * @testName: normalScheduleProcess1Test - * - * @assertion_ids: CONCURRENCY:JAVADOC:30;CONCURRENCY:SPEC:42; - * CONCURRENCY:SPEC:42.2;CONCURRENCY:SPEC:43;CONCURRENCY:SPEC:43.1; - * CONCURRENCY:SPEC:49;CONCURRENCY:SPEC:51; CONCURRENCY:SPEC:54; - * - * @test_Strategy: Creates and executes a task based on a Trigger. The Trigger - * determines when the task should run and how often. - */ - @Test + @Assertion(id = "JAVADOC:30 SPEC:42 SPEC:42.2 SPEC:43 SPEC:43.1 SPEC:49 SPEC:51 SPEC:54", + strategy = "Creates and executes a task based on a Trigger." + + " The Trigger determines when the task should run and how often.") public void normalScheduleProcess1Test() throws Exception { ScheduledFuture result = scheduledExecutor.schedule( new RunnableTask(TEST_JNDI_EVN_ENTRY_JNDI_NAME, TEST_JNDI_EVN_ENTRY_VALUE, TEST_CLASSLOADER_CLASS_NAME), @@ -81,14 +73,7 @@ public void normalScheduleProcess1Test() throws Exception { assertNull(result.get()); } - /* - * @testName: nullCommandScheduleProcessTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:32 - * - * @test_Strategy: if command is null. - */ - @Test + @Assertion(id = "JAVADOC:32", strategy = "If command is null.") public void nullCommandScheduleProcessTest() { Runnable command = null; @@ -97,17 +82,9 @@ public void nullCommandScheduleProcessTest() { }); } - /* - * @testName: normalScheduleProcess2Test - * - * @assertion_ids: - * CONCURRENCY:JAVADOC:33;CONCURRENCY:SPEC:43;CONCURRENCY:SPEC:43.2; - * CONCURRENCY:SPEC:54;CONCURRENCY:SPEC:52; - * - * @test_Strategy: Creates and executes a task based on a Trigger. The Trigger - * determines when the task should run and how often. - */ - @Test + @Assertion(id = "JAVADOC:33 SPEC:43 SPEC:43.2 SPEC:54 SPEC:52", + strategy = "Creates and executes a task based on a Trigger." + + " The Trigger determines when the task should run and how often.") public void normalScheduleProcess2Test() throws Exception { ScheduledFuture result = scheduledExecutor .schedule( @@ -120,14 +97,7 @@ public void normalScheduleProcess2Test() throws Exception { } - /* - * @testName: nullCallableScheduleProcessTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:35 - * - * @test_Strategy: if callable is null. - */ - @Test + @Assertion(id = "JAVADOC:35", strategy = "If callable is null.") public void nullCallableScheduleProcessTest() { Callable callable = null; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTask/ManagedTaskTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTask/ManagedTaskTests.java index 0d022d4c..8180d482 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTask/ManagedTaskTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTask/ManagedTaskTests.java @@ -25,10 +25,10 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.managed.task.listener.ManagedTaskListenerImpl; import ee.jakarta.tck.concurrent.common.tasks.RunnableTask; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -52,16 +52,8 @@ private RunnableTask createRunnableTask() { return new RunnableTask("java:comp/env/StringValue", "FakeValue", this.getClass().getName()); } - /* - * @testName: getExecutionProperties - * - * @assertion_ids: CONCURRENCY:JAVADOC:36 - * - * @test_Strategy: Get ManagedTask to provides additional information to the - * ManagedExecutorService or ManagedScheduledExecutorService when executing this - * task. - */ - @Test + @Assertion(id = "JAVADOC:36", strategy = "Get ManagedTask to provides additional information to the ManagedExecutorService" + + " or ManagedScheduledExecutorService when executing this task.") public void getExecutionProperties() { Map properties = new HashMap(); properties.put("key", "value"); @@ -75,15 +67,8 @@ public void getExecutionProperties() { assertEquals("value", managedTask.getExecutionProperties().get("key")); } - /* - * @testName: getManagedTaskListener - * - * @assertion_ids: CONCURRENCY:JAVADOC:37 - * - * @test_Strategy: Get ManagedTask with ManagedTaskListener to receive - * notification of life cycle events of this task. - */ - @Test + @Assertion(id = "JAVADOC:37", strategy = "Get ManagedTask with ManagedTaskListener to receive notification" + + " of life cycle events of this task.") public void getManagedTaskListener() { Map properties = new HashMap(); properties.put("key", "value"); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/ManagedTaskListenerTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/ManagedTaskListenerTests.java index 0ca73cd0..493868e5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/ManagedTaskListenerTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/ManagedTaskListenerTests.java @@ -28,13 +28,13 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.managed.task.listener.ListenerEvent; import ee.jakarta.tck.concurrent.common.managed.task.listener.ManagedTaskListenerImpl; import ee.jakarta.tck.concurrent.common.managed.task.listener.RunnableTaskWithStatus; import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.TestLogger; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -65,17 +65,8 @@ public void cleanup() { managedTaskListener.clearEvents(); } - /* - * @testName: taskAborted - * - * @assertion_ids: - * CONCURRENCY:JAVADOC:38;CONCURRENCY:SPEC:7;CONCURRENCY:SPEC:7.1;CONCURRENCY: - * SPEC:45.3; - * - * @test_Strategy: taskAborted of ManagedTaskListener is Called when a task's - * Future has been cancelled anytime during the life of a task. - */ - @Test + @Assertion(id = "JAVADOC:38 SPEC:7 SPEC:7.1 SPEC:45.3", + strategy = "taskAborted of ManagedTaskListener is Called when a task's Future has been cancelled anytime during the life of a task.") public void taskAborted() throws InterruptedException { final Duration blockTime = Duration.ofMillis(3000); Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener, blockTime); @@ -91,16 +82,8 @@ public void taskAborted() throws InterruptedException { assertTrue(futureResult.isCancelled(), "Listener taskAborted failed"); } - /* - * @testName: taskDone - * - * @assertion_ids: - * CONCURRENCY:JAVADOC:39;CONCURRENCY:SPEC:13.3;CONCURRENCY:SPEC:45.3; - * - * @test_Strategy: TaskDone is called when a submitted task has completed - * running, either successfully or failed . - */ - @Test + @Assertion(id = "JAVADOC:39 SPEC:13.3 SPEC:45.3", + strategy = "TaskDone is called when a submitted task has completed running, either successfully or failed.") public void taskDone() throws InterruptedException { // in cancel case final Duration blockTime = Duration.ofMillis(3000); @@ -135,18 +118,9 @@ public void taskDone() throws InterruptedException { "Listener TaskDone failed with exception task."); } - /* - * @testName: taskStarting - * - * @assertion_ids: - * CONCURRENCY:JAVADOC:40;CONCURRENCY:SPEC:7;CONCURRENCY:SPEC:7.3;CONCURRENCY: - * SPEC:45.3; - * - * @test_Strategy: TaskStarting is called before the task is about to start. The - * task will not enter the starting state until the taskSubmitted listener has - * completed. - */ - @Test + @Assertion(id = "JAVADOC:40 SPEC:7 SPEC:7.3 SPEC:45.3", + strategy = "TaskStarting is called before the task is about to start." + + " The task will not enter the starting state until the taskSubmitted listener has completed.") public void taskStarting() { Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); @@ -161,18 +135,9 @@ public void taskStarting() { } } - /* - * @testName: taskSubmitted - * - * @assertion_ids: - * CONCURRENCY:JAVADOC:41;CONCURRENCY:SPEC:7;CONCURRENCY:SPEC:7.2;CONCURRENCY: - * SPEC:45.3; - * - * @test_Strategy: TaskSubmitted is called after the task has been submitted to - * the Executor. The task will not enter the starting state until the - * taskSubmitted listener has completed. - */ - @Test + @Assertion(id = "JAVADOC:41 SPEC:7 SPEC:7.2 SPEC:45.3", + strategy = "TaskSubmitted is called after the task has been submitted to the Executor." + + " The task will not enter the starting state until the taskSubmitted listener has completed.") public void taskSubmitted() { Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedThreadFactory/ManagedThreadFactoryTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedThreadFactory/ManagedThreadFactoryTests.java index 5e1023a9..b371a447 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedThreadFactory/ManagedThreadFactoryTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedThreadFactory/ManagedThreadFactoryTests.java @@ -23,12 +23,12 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.fixed.counter.CounterRunnableTask; import ee.jakarta.tck.concurrent.common.fixed.counter.StaticCounter; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -49,31 +49,16 @@ public static WebArchive createDeployment() { @Resource(lookup = TestConstants.defaultManagedThreadFactory) private ManagedThreadFactory threadFactory; - /* - * @testName: isShutdown - * - * @assertion_ids: CONCURRENCY:JAVADOC:20;CONCURRENCY:SPEC:99.1; - * - * @test_Strategy: Lookup default ManagedThreadFactory object and create new - * thread. Check return value of method isShutdown of new thread. - */ - @Test + @Assertion(id = "JAVADOC:20 SPEC:99.1", + strategy = "Lookup default ManagedThreadFactory object and create new thread." + + " Check return value of method isShutdown of new thread.") public void isShutdown() { ManageableThread m = (ManageableThread) threadFactory.newThread(new CounterRunnableTask()); assertFalse(m.isShutdown()); } - /* - * @testName: interruptThreadApiTest - * - * @assertion_ids: CONCURRENCY:SPEC:83; CONCURRENCY:SPEC:83.1; - * CONCURRENCY:SPEC:83.2; CONCURRENCY:SPEC:83.3; CONCURRENCY:SPEC:103; - * CONCURRENCY:SPEC:96.5; CONCURRENCY:SPEC:96.6; CONCURRENCY:SPEC:105; - * CONCURRENCY:SPEC:96; CONCURRENCY:SPEC:93; CONCURRENCY:SPEC:96.3; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:83 SPEC:83.1 SPEC:83.2 SPEC:83.3 SPEC:103 SPEC:96.5 SPEC:96.6 SPEC:105 SPEC:96 SPEC:93 SPEC:96.3", + strategy = "Interrupt thread and ensure the thread did not run.") public void interruptThreadApiTest() { CounterRunnableTask task = new CounterRunnableTask(TestConstants.pollInterval); Thread thread = threadFactory.newThread(task); @@ -83,14 +68,7 @@ public void interruptThreadApiTest() { assertEquals(0, StaticCounter.getCount()); } - /* - * @testName: implementsManageableThreadInterfaceTest - * - * @assertion_ids: CONCURRENCY:SPEC:97; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:97;", strategy = "Create thread and ensure the thread is an instance of ManageableThread") public void implementsManageableThreadInterfaceTest() { CounterRunnableTask task = new CounterRunnableTask(); Thread thread = threadFactory.newThread(task); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/SkippedException/SkippedExceptionTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/SkippedException/SkippedExceptionTests.java index 6bd5ca4e..00ceded8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/SkippedException/SkippedExceptionTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/SkippedException/SkippedExceptionTests.java @@ -24,8 +24,8 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; import jakarta.enterprise.concurrent.SkippedException; @@ -38,14 +38,7 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class).addPackages(true, SkippedExceptionTests.class.getPackage()); } - /* - * @testName: SkippedExceptionNoArgTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:42 - * - * @test_Strategy: Constructs an SkippedException. - */ - @Test + @Assertion(id = "JAVADOC:42", strategy = "Constructs an SkippedException.") public void skippedExceptionNoArgTest() { SkippedException thrown = assertThrows(SkippedException.class, () -> { throw new SkippedException(); @@ -54,14 +47,7 @@ public void skippedExceptionNoArgTest() { assertNull(thrown.getMessage()); } - /* - * @testName: SkippedExceptionStringTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:43 - * - * @test_Strategy: Constructs an SkippedException. - */ - @Test + @Assertion(id = "JAVADOC:43", strategy = "Constructs an SkippedException.") public void skippedExceptionStringTest() { final String expected = "thisisthedetailmessage"; @@ -73,14 +59,7 @@ public void skippedExceptionStringTest() { assertEquals(expected, thrown.getMessage()); } - /* - * @testName: SkippedExceptionThrowableTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:45 - * - * @test_Strategy: Constructs an SkippedException. - */ - @Test + @Assertion(id = "JAVADOC:45", strategy = "Constructs an SkippedException.") public void skippedExceptionThrowableTest() { SkippedException thrown; @@ -102,14 +81,7 @@ public void skippedExceptionThrowableTest() { assertNull(thrown.getCause()); } - /* - * @testName: SkippedExceptionStringThrowableTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:44 - * - * @test_Strategy: Constructs an SkippedException. - */ - @Test + @Assertion(id = "JAVADOC:44", strategy = "Constructs an SkippedException.") public void skippedExceptionStringThrowableTest() { SkippedException thrown; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/Trigger/TriggerTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/Trigger/TriggerTests.java index ed571740..2c41f5d8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/Trigger/TriggerTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/Trigger/TriggerTests.java @@ -26,14 +26,13 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.fixed.counter.CounterRunnableTask; import ee.jakarta.tck.concurrent.common.fixed.counter.StaticCounter; import ee.jakarta.tck.concurrent.common.tasks.CommonTasks; import ee.jakarta.tck.concurrent.common.tasks.CommonTriggers; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -61,17 +60,7 @@ public void reset() { StaticCounter.reset(); } - /* - * @testName: triggerGetNextRunTimeTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:46 - * - * @test_Strategy: Retrieve the next time that the task should run after. fix: - * https://github.com/jakartaee/concurrency/pull/222 Accepted TCK challenge: - * https://github.com/jakartaee/concurrency/issues/228 Can be reenabled in next - * release of Jakarta Concurrency - */ - @Disabled + @Assertion(id = "JAVADOC:46", strategy = "Retrieve the next time that the task should run after.") public void triggerGetNextRunTimeTest() throws Exception { Future result = scheduledExecutor.schedule(new CounterRunnableTask(), new CommonTriggers.TriggerFixedRate(new Date(), TestConstants.pollInterval.toMillis())); @@ -87,22 +76,14 @@ public void triggerGetNextRunTimeTest() throws Exception { } } - /* - * @testName: triggerSkipRunTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:47 - * - * @test_Strategy: Return true if this run instance should be skipped. This is - * useful if the task shouldn't run because it is late or if the task is paused - * or suspended. Once this task is skipped, the state of it's Future's result - * will throw a SkippedException. Unchecked exceptions will be wrapped in a - * SkippedException. - */ - @Test + @Assertion(id = "JAVADOC:47", strategy = "Return true if this run instance should be skipped." + + " This is useful if the task shouldn't run because it is late or if the task is paused or suspended." + + " Once this task is skipped, the state of it's Future's result will throw a SkippedException." + + " Unchecked exceptions will be wrapped in a SkippedException.") public void triggerSkipRunTest() { ScheduledFuture sf = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), new CommonTriggers.OnceTriggerDelaySkip(TestConstants.pollInterval)); - + try { Wait.waitTillFutureThrowsException(sf, SkippedException.class); } finally { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Assertion.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Assertion.java new file mode 100644 index 00000000..46a3f04b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Assertion.java @@ -0,0 +1,37 @@ +package ee.jakarta.tck.concurrent.framework.junit.anno; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.Test; + +/** + * Test metadata to track what assertion from GitHub is being tested, and the + * strategy used to test that assertion. + * + * Aggregates the @Test annotation from Junit + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Test +public @interface Assertion { + /** + * Identifies where the assertion comes from consisting of two components + * 1. JAVADOC, SPEC, or GIT - Identifies the source document + * 2. Unique ID - A unique ID for further specification + * + * The Unique ID for JAVADOC and SPEC is a legacy artifact from the TCK Platform + * and might map to a specific line number or document section, however, a meaningful link cannot be guaranteed. + * + * The Unique ID for GIT will map to an issue or pull request in the Jakarta Concurrency + * GitHub repository https://github.com/jakartaee/concurrency + */ + String id(); + + /** + * A longer description of the assertion being made to keep method names concise + */ + String strategy() default ""; +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java index df11ad9f..f2c43a9e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java @@ -26,7 +26,6 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; @@ -34,6 +33,7 @@ import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -92,7 +92,7 @@ public static EnterpriseArchive createDeployment() { // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from // another thread or the current user is changed - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/pull/206") public void testSecurityClearedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); @@ -100,71 +100,37 @@ public void testSecurityClearedContext() { // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from // another thread or the current user is changed - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/pull/206") public void testSecurityUnchangedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", strategy = "From a JSP, use a ManagedExecutorService that is defined by a ManagedExecutorDefinition " + + "elsewhere within the application to propagate Security context.") public void testSecurityPropagatedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); } - /* - * @testName: testJNDIContextAndCreateProxyInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:2;CONCURRENCY:SPEC:4.1; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify JNDI Context. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:2 SPEC:4.1", + strategy = "Create proxy in servlet and pass it into ejb container, then verify JNDI Context.") public void testJNDIContextAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jndiURL).withPaths("JNDIServlet").withTestName(testname); String resp = runTestWithResponse(requestURL, null); this.assertStringInResponse(testname + "failed to get correct result.", "JNDIContextWeb", resp); } - /* - * @testName: testJNDIContextAndCreateProxyInEJB - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:3;CONCURRENCY:SPEC:3.1; - * CONCURRENCY:SPEC:3.2;CONCURRENCY:SPEC:3.3;CONCURRENCY:SPEC:3.4; - * CONCURRENCY:SPEC:4; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify JNDI Context. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:3 SPEC:3.1 SPEC:3.2 SPEC:3.3 SPEC:3.4 SPEC:4", + strategy = "Create proxy in servlet and pass it into ejb container, then verify JNDI Context.") public void testJNDIContextAndCreateProxyInEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jndiURL).withPaths("JNDIServlet").withTestName(testname); String resp = runTestWithResponse(requestURL, null); this.assertStringInResponse(testname + "failed to get correct result.", "JNDIContextEJB", resp); } - /* - * @testName: testClassloaderAndCreateProxyInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:4.2;CONCURRENCY:SPEC:4.4; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify classloader. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:4.2 SPEC:4.4;", + strategy = "Create proxy in servlet and pass it into ejb container, then verify classloader.") public void testClassloaderAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet") .withTestName(testname); @@ -172,20 +138,8 @@ public void testClassloaderAndCreateProxyInServlet() { this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } - /* - * @testName: testSecurityAndCreateProxyInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:4.3;CONCURRENCY:SPEC:4.4; - * CONCURRENCY:SPEC:4.4; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify permission. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:4.3 SPEC:4.4 SPEC:4.4", + strategy = "Create proxy in servlet and pass it into ejb container, then verify permission.") public void testSecurityAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet") .withTestName(testname); @@ -193,74 +147,44 @@ public void testSecurityAndCreateProxyInServlet() { this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } - /** - * A ContextServiceDefinition with all attributes configured - * propagates/clears/ignores context types as configured. ContextA, which is - * tested here, propagates Application context and IntContext, clears - * StringContext, and leaves Transaction context unchanged. - */ - @Test + @Assertion(id = "GIT:154", strategy = "ContextServiceDefinition with all attributes configured propagates/clears/ignores context types as configured") public void testContextServiceDefinitionAllAttributes() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition defined in an EJB with all attributes configured - * propagates/clears/ignores context types as configured. ContextA, which is - * tested here, propagates Application context and IntContext, clears - * StringContext, and leaves Transaction context unchanged. - */ - @Test + @Assertion(id = "GIT:154", strategy = "ContextServiceDefinition with all attributes configured propagates/clears/ignores context types as configured") public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition with minimal attributes configured clears - * transaction context and propagates other types. - */ - @Test + @Assertion(id = "GIT:154", strategy = "A ContextServiceDefinition with minimal attributes configured clears transaction context and propagates other types.") public void testContextServiceDefinitionDefaults() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition defined in an EJB with minimal attributes - * configured clears transaction context and propagates other types. - */ - @Test + @Assertion(id = "GIT:154", strategy = "A ContextServiceDefinition defined in an EJB with minimal attributes configured clears transaction context and propagates other types.") public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition can specify a third-party context type to be - * propagated/cleared/ignored. This test uses 2 ContextServiceDefinitions: - * ContextA with IntContext propagated and StringContext cleared. ContextB with - * IntContext unchanged and StringContext propagated (per ALL_REMAINING). - */ - @Test + @Assertion(id = "GIT:154", strategy = "A ContextServiceDefinition can specify a third-party context type to be propagated/cleared/ignored") public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextService contextualizes a Consumer, which can be supplied as a - * dependent stage action to an unmanaged CompletableFuture. The dependent stage - * action runs with the thread context of the thread that contextualizes the - * Consumer, per the configuration of the ContextServiceDefinition. - */ - @Test + @Assertion(id = "GIT:154", + strategy = "ContextService contextualizes a java.util.function.Consumer, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + + " The dependent stage action runs with the thread context of the thread that contextualizes the Consumer, per the configuration of the ContextServiceDefinition.") public void testContextualConsumer() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); @@ -268,29 +192,24 @@ public void testContextualConsumer() throws Throwable { } /** - * A ContextService contextualizes a Function, which can be supplied as a - * dependent stage action to an unmanaged CompletableFuture. The dependent stage - * action runs with the thread context of the thread that contextualizes the - * Function, per the configuration of the ContextServiceDefinition. - * - * Assertions on results[0] and results[1] are both invalid because treating - * those two UNCHANGED context types as though they were CLEARED. TCK challenge: - * https://github.com/jakartaee/concurrency/issues/253 + * FIXME Assertions on results[0] and results[1] are both invalid because treating + * those two UNCHANGED context types as though they were CLEARED. */ - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/253") + @Assertion(id = "GIT:154", + strategy = "A ContextService contextualizes a Function, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + + " The dependent stage action runs with the thread context of the thread that contextualizes the Function," + + " per the configuration of the ContextServiceDefinition.") public void testContextualFunction() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextService contextualizes a Supplier, which can be supplied as a - * dependent stage action to an unmanaged CompletableFuture. The dependent stage - * action runs with the thread context of the thread that contextualizes the - * Supplier, per the configuration of the ContextServiceDefinition. - */ - @Test + @Assertion(id = "GIT:154", + strategy = "A ContextService contextualizes a Supplier, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + + " The dependent stage action runs with the thread context of the thread that contextualizes the Supplier," + + " per the configuration of the ContextServiceDefinition.") public void testContextualSupplier() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); @@ -300,11 +219,7 @@ public void testContextualSupplier() throws Throwable { runTest(requestURL); } - /** - * ContextService can create a contextualized copy of an unmanaged - * CompletableFuture. - */ - @Test + @Assertion(id = "GIT:154", strategy = "ContextService can create a contextualized copy of an unmanaged CompletableFuture.") public void testCopyWithContextCapture() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java index 63fa63af..231d3ba9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java @@ -24,7 +24,6 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; @@ -32,6 +31,7 @@ import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -81,7 +81,7 @@ public static WebArchive createDeployment() { // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from // another thread or the current user is changed - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/pull/206") public void testSecurityClearedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); @@ -89,72 +89,39 @@ public void testSecurityClearedContext() { // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from // another thread or the current user is changed - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/pull/206") public void testSecurityUnchangedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", strategy = "From a JSP, use a ManagedExecutorService that is defined by a ManagedExecutorDefinition " + + "elsewhere within the application to propagate Security context.") public void testSecurityPropagatedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); } - /* - * @testName: testJNDIContextAndCreateProxyInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:2;CONCURRENCY:SPEC:4.1; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify JNDI Context. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:2 SPEC:4.1", + strategy = "Create proxy in servlet and pass it into ejb container, then verify JNDI Context.") public void testJNDIContextAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jndiURL).withPaths("JNDIServlet").withTestName(testname); String resp = runTestWithResponse(requestURL, null); this.assertStringInResponse(testname + "failed to get correct result.", "JNDIContextWeb", resp); } - /* - * @testName: testJNDIContextAndCreateProxyInEJB - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:3;CONCURRENCY:SPEC:3.1; - * CONCURRENCY:SPEC:3.2;CONCURRENCY:SPEC:3.3;CONCURRENCY:SPEC:3.4; - * CONCURRENCY:SPEC:4; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify JNDI Context. - * - */ - @Disabled // This test will return JNDIContextWeb because we are running with web.xml and - // not ejb-jar.xml + // FIXME This test will return JNDIContextWeb because we are running with web.xml and not ejb-jar.xml + @Disabled("https://github.com/jakartaee/concurrency/pull/260") + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:3 SPEC:3.1 SPEC:3.2 SPEC:3.3 SPEC:3.4 SPEC:4", + strategy = "Create proxy in servlet and pass it into ejb container, then verify JNDI Context.") public void testJNDIContextAndCreateProxyInEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jndiURL).withPaths("JNDIServlet").withTestName(testname); String resp = runTestWithResponse(requestURL, null); this.assertStringInResponse(testname + "failed to get correct result.", "JNDIContextEJB", resp); } - /* - * @testName: testClassloaderAndCreateProxyInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:4.2;CONCURRENCY:SPEC:4.4; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify classloader. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:4.2 SPEC:4.4;", + strategy = "Create proxy in servlet and pass it into ejb container, then verify classloader.") public void testClassloaderAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet") .withTestName(testname); @@ -162,20 +129,8 @@ public void testClassloaderAndCreateProxyInServlet() { this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } - /* - * @testName: testSecurityAndCreateProxyInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:4.3;CONCURRENCY:SPEC:4.4; - * CONCURRENCY:SPEC:4.4; - * - * @test_Strategy: create proxy in servlet and pass it into ejb container, then - * verify permission. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:4.3 SPEC:4.4", + strategy = "Create proxy in servlet and pass it into ejb container, then verify permission.") public void testSecurityAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet") .withTestName(testname); @@ -183,74 +138,44 @@ public void testSecurityAndCreateProxyInServlet() { this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } - /** - * A ContextServiceDefinition with all attributes configured - * propagates/clears/ignores context types as configured. ContextA, which is - * tested here, propagates Application context and IntContext, clears - * StringContext, and leaves Transaction context unchanged. - */ - @Test + @Assertion(id = "GIT:154", strategy = "ContextServiceDefinition with all attributes configured propagates/clears/ignores context types as configured") public void testContextServiceDefinitionAllAttributes() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition defined in an EJB with all attributes configured - * propagates/clears/ignores context types as configured. ContextA, which is - * tested here, propagates Application context and IntContext, clears - * StringContext, and leaves Transaction context unchanged. - */ - @Test + @Assertion(id = "GIT:154", strategy = "ContextServiceDefinition with all attributes configured propagates/clears/ignores context types as configured") public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition with minimal attributes configured clears - * transaction context and propagates other types. - */ - @Test + @Assertion(id = "GIT:154", strategy = "A ContextServiceDefinition with minimal attributes configured clears transaction context and propagates other types.") public void testContextServiceDefinitionDefaults() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition defined in an EJB with minimal attributes - * configured clears transaction context and propagates other types. - */ - @Test + @Assertion(id = "GIT:154", strategy = "A ContextServiceDefinition defined in an EJB with minimal attributes configured clears transaction context and propagates other types.") public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); runTest(requestURL); } - /** - * A ContextServiceDefinition can specify a third-party context type to be - * propagated/cleared/ignored. This test uses 2 ContextServiceDefinitions: - * ContextA with IntContext propagated and StringContext cleared. ContextB with - * IntContext unchanged and StringContext propagated (per ALL_REMAINING). - */ - @Test + @Assertion(id = "GIT:154", strategy = "A ContextServiceDefinition can specify a third-party context type to be propagated/cleared/ignored") public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextService contextualizes a Consumer, which can be supplied as a - * dependent stage action to an unmanaged CompletableFuture. The dependent stage - * action runs with the thread context of the thread that contextualizes the - * Consumer, per the configuration of the ContextServiceDefinition. - */ - @Test + @Assertion(id = "GIT:154", + strategy = "ContextService contextualizes a java.util.function.Consumer, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + + " The dependent stage action runs with the thread context of the thread that contextualizes the Consumer, per the configuration of the ContextServiceDefinition.") public void testContextualConsumer() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); @@ -258,29 +183,24 @@ public void testContextualConsumer() throws Throwable { } /** - * A ContextService contextualizes a Function, which can be supplied as a - * dependent stage action to an unmanaged CompletableFuture. The dependent stage - * action runs with the thread context of the thread that contextualizes the - * Function, per the configuration of the ContextServiceDefinition. - * - * Assertions on results[0] and results[1] are both invalid because treating - * those two UNCHANGED context types as though they were CLEARED. TCK challenge: - * https://github.com/jakartaee/concurrency/issues/253 + * FIXME Assertions on results[0] and results[1] are both invalid because treating + * those two UNCHANGED context types as though they were CLEARED. */ - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/253") + @Assertion(id = "GIT:154", + strategy = "A ContextService contextualizes a Function, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + + " The dependent stage action runs with the thread context of the thread that contextualizes the Function," + + " per the configuration of the ContextServiceDefinition.") public void testContextualFunction() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); runTest(requestURL); } - /** - * A ContextService contextualizes a Supplier, which can be supplied as a - * dependent stage action to an unmanaged CompletableFuture. The dependent stage - * action runs with the thread context of the thread that contextualizes the - * Supplier, per the configuration of the ContextServiceDefinition. - */ - @Test + @Assertion(id = "GIT:154", + strategy = "A ContextService contextualizes a Supplier, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + + " The dependent stage action runs with the thread context of the thread that contextualizes the Supplier," + + " per the configuration of the ContextServiceDefinition.") public void testContextualSupplier() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); @@ -290,11 +210,7 @@ public void testContextualSupplier() throws Throwable { runTest(requestURL); } - /** - * ContextService can create a contextualized copy of an unmanaged - * CompletableFuture. - */ - @Test + @Assertion(id = "GIT:154", strategy = "ContextService can create a contextualized copy of an unmanaged CompletableFuture.") public void testCopyWithContextCapture() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") .withTestName(testname); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ContextPropagationServletTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ContextPropagationServletTests.java index e9b0c1c2..0cb3b5c7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ContextPropagationServletTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ContextPropagationServletTests.java @@ -27,11 +27,11 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -81,19 +81,8 @@ protected String getServletPath() { return "ProxyCreatorServlet"; } - /* - * @testName: testJNDIContextInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:78;CONCURRENCY:SPEC:82;CONCURRENCY:SPEC:84; - * - * @test_Strategy: create proxy in servlet and pass it to other servlet in other - * web module, then verify JNDI Context. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:78 SPEC:82 SPEC:84", + strategy = "Create proxy in servlet and pass it to other servlet in other web module, then verify JNDI Context.") public void testJNDIContextInServlet() { URL proxyURL = URLBuilder.get().withBaseURL(workInterfaceURL).withPaths("WorkInterfaceServlet").build(); URLBuilder requestURL = URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()) @@ -108,19 +97,8 @@ public void testJNDIContextInServlet() { assertStringInResponse(testname + " failed to get correct result.", "JNDIContextWeb", resp.trim()); } - /* - * @testName: testClassloaderInServlet - * - * @assertion_ids: - * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; - * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; - * CONCURRENCY:SPEC:78;CONCURRENCY:SPEC:82;CONCURRENCY:SPEC:84; - * - * @test_Strategy: create proxy in servlet and pass it into other servlet in - * other web module, then verify classloader. - * - */ - @Test + @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:78 SPEC:82 SPEC:84", + strategy = "Create proxy in servlet and pass it into other servlet in other web module, then verify classloader.") public void testClassloaderInServlet() { URL proxyURL = URLBuilder.get().withBaseURL(workInterfaceURL).withPaths("WorkInterfaceServlet").build(); URLBuilder requestURL = URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionTests.java index dc4feae3..3d99dde4 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionTests.java @@ -23,9 +23,9 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -52,95 +52,45 @@ protected String getServletPath() { @TestName private String testname; - /* - * @testName: testTransactionOfExecuteThreadAndCommit - * - * @assertion_ids: CONCURRENCY:SPEC:86; CONCURRENCY:SPEC:87; - * CONCURRENCY:SPEC:88; CONCURRENCY:SPEC:89; CONCURRENCY:SPEC:90; - * CONCURRENCY:SPEC:31.2; CONCURRENCY:SPEC:32; CONCURRENCY:SPEC:34; - * CONCURRENCY:SPEC:8.1; CONCURRENCY:SPEC:9; - * - * @test_Strategy: Get UserTransaction in Servlet and insert 2 row data. Create - * a proxy with Transaction property "TransactionOfExecuteThread". Invoke proxy - * in Servlet. In proxy, insert 1 row data commit in Servlet. Expect insert - * actions in servlet and in proxy will be committed. - */ - @Test + @Assertion(id = "SPEC:86 SPEC:87 SPEC:88 SPEC:89 SPEC:90 SPEC:31.2 SPEC:32 SPEC:34 SPEC:8.1 SPEC:9", + strategy = "Get UserTransaction in Servlet and insert 2 row data." + + " Create a proxy with Transaction property TransactionOfExecuteThread." + + " Invoke proxy in Servlet. In proxy, insert 1 row data commit in Servlet." + + " Expect insert actions in servlet and in proxy will be committed.") public void testTransactionOfExecuteThreadAndCommit() { runTest(baseURL, testname); } - - /* - * @testName: testTransactionOfExecuteThreadAndRollback - * - * @assertion_ids: CONCURRENCY:SPEC:86; CONCURRENCY:SPEC:87; - * CONCURRENCY:SPEC:88; CONCURRENCY:SPEC:89; CONCURRENCY:SPEC:90; - * CONCURRENCY:SPEC:31.2; CONCURRENCY:SPEC:32; CONCURRENCY:SPEC:34; - * CONCURRENCY:SPEC:8.1; CONCURRENCY:SPEC:9; - * - * @test_Strategy: Get UserTransaction in Servlet and insert 2 row data. Create - * a proxy with Transaction property "TransactionOfExecuteThread". Invoke proxy - * in Servlet. In proxy, insert 1 row data rollback in Servlet. Expect insert - * actions in servlet and in proxy will be roll backed. - */ - @Test + + @Assertion(id = "SPEC:86 SPEC:87 SPEC:88 SPEC:89 SPEC:90 SPEC:31.2 SPEC:32 SPEC:34 SPEC:8.1 SPEC:9", + strategy = "Get UserTransaction in Servlet and insert 2 row data." + + " Create a proxy with Transaction property TransactionOfExecuteThread." + + " Invoke proxy in Servlet. In proxy, insert 1 row data rollback in Servlet." + + " Expect insert actions in servlet and in proxy will be roll backed.") public void testTransactionOfExecuteThreadAndRollback() { runTest(baseURL, testname); } - /* - * @testName: testSuspendAndCommit - * - * @assertion_ids: CONCURRENCY:SPEC:86; CONCURRENCY:SPEC:87; - * CONCURRENCY:SPEC:88; CONCURRENCY:SPEC:89; CONCURRENCY:SPEC:90; - * CONCURRENCY:SPEC:31.2; CONCURRENCY:SPEC:32; CONCURRENCY:SPEC:34; - * CONCURRENCY:SPEC:8.1; CONCURRENCY:SPEC:9; - * - * @test_Strategy: Get UserTransaction in Servlet and insert 2 row data. Create - * a proxy with Transaction property "SUSPEND". Invoke proxy in Servlet. In - * proxy, get UserTransaction then insert 1 row data and commit Rollback in - * Servlet. Expect insert action in servlet will be roll backed and insert - * action in proxy will be committed. - */ - @Test + @Assertion(id = "SPEC:86 SPEC:87 SPEC:88 SPEC:89 SPEC:90 SPEC:31.2 SPEC:32 SPEC:34 SPEC:8.1 SPEC:9", + strategy = "Get UserTransaction in Servlet and insert 2 row data. " + + "Create a proxy with Transaction property SUSPEND. Invoke proxy in Servlet." + + " In proxy, get UserTransaction then insert 1 row data and commit Rollback in Servlet." + + " Expect insert action in servlet will be roll backed and insert action in proxy will be committed.") public void testSuspendAndCommit() { runTest(baseURL, testname); } - /* - * @testName: testSuspendAndRollback - * - * @assertion_ids: CONCURRENCY:SPEC:86; CONCURRENCY:SPEC:87; - * CONCURRENCY:SPEC:88; CONCURRENCY:SPEC:89; CONCURRENCY:SPEC:90; - * CONCURRENCY:SPEC:31.2; CONCURRENCY:SPEC:32; CONCURRENCY:SPEC:34; - * CONCURRENCY:SPEC:8.1; CONCURRENCY:SPEC:9; - * - * @test_Strategy: Get UserTransaction in Servlet and insert 2 row data. Create - * a proxy with Transaction property "SUSPEND". Invoke proxy in Servlet. In - * proxy, get UserTransaction then insert 1 row data and rollback Commit in - * Servlet. Expect insert action in servlet will be committed and insert action - * in proxy will be roll backed. - */ - @Test + @Assertion(id = "SPEC:86 SPEC:87 SPEC:88 SPEC:89 SPEC:90 SPEC:31.2 SPEC:32 SPEC:34 SPEC:8.1 SPEC:9", + strategy = "Get UserTransaction in Servlet and insert 2 row data. Create a proxy with Transaction property SUSPEND." + + " Invoke proxy in Servlet. In proxy, get UserTransaction then insert 1 row data and rollback Commit in Servlet." + + " Expect insert action in servlet will be committed and insert action in proxy will be roll backed.") public void testSuspendAndRollback() { runTest(baseURL, testname); } - /* - * @testName: testDefaultAndCommit - * - * @assertion_ids: CONCURRENCY:SPEC:86; CONCURRENCY:SPEC:87; - * CONCURRENCY:SPEC:88; CONCURRENCY:SPEC:89; CONCURRENCY:SPEC:90; - * CONCURRENCY:SPEC:91; CONCURRENCY:SPEC:31.2; CONCURRENCY:SPEC:32; - * CONCURRENCY:SPEC:34; CONCURRENCY:SPEC:8.1; CONCURRENCY:SPEC:9; - * - * @test_Strategy: Get UserTransaction in Servlet and insert 2 row data. Create - * a proxy with default Transaction property. Invoke proxy in Servlet. In proxy, - * get UserTransaction then insert 1 row data and commit Rollback in Servlet. - * Expect insert action in servlet will be roll backed and insert action in - * proxy will be committed. - */ - @Test + @Assertion(id = "SPEC:86; SPEC:87; SPEC:88; SPEC:89; SPEC:90; SPEC:91; SPEC:31.2; SPEC:32; SPEC:34; SPEC:8.1; SPEC:9", + strategy = "Get UserTransaction in Servlet and insert 2 row data. Create a proxy with default Transaction property." + + " Invoke proxy in Servlet. In proxy, get UserTransaction then insert 1 row data and commit Rollback in Servlet." + + " Expect insert action in servlet will be roll backed and insert action in proxy will be committed.") public void testDefaultAndCommit() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/inheritedapi/InheritedAPITests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/inheritedapi/InheritedAPITests.java index b895fb3e..cb15fb0e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/inheritedapi/InheritedAPITests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/inheritedapi/InheritedAPITests.java @@ -31,12 +31,12 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.fixed.counter.CounterRunnableTask; import ee.jakarta.tck.concurrent.common.fixed.counter.StaticCounter; import ee.jakarta.tck.concurrent.common.tasks.CommonTasks; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -57,24 +57,8 @@ public static WebArchive createDeployment() { @Resource(lookup = TestConstants.defaultManagedExecutorService) private ManagedExecutorService executor; - /* - * @testName: testBasicManagedExecutorService - * - * @assertion_ids: - * CONCURRENCY:SPEC:10.2;CONCURRENCY:SPEC:13;CONCURRENCY:SPEC:13.1;CONCURRENCY - * :SPEC:13.2; - * CONCURRENCY:SPEC:14;CONCURRENCY:SPEC:14.1;CONCURRENCY:SPEC:14.2;CONCURRENCY - * :SPEC:14.3; - * CONCURRENCY:SPEC:14.4;CONCURRENCY:SPEC:6.1;CONCURRENCY:SPEC:6.2;CONCURRENCY - * :SPEC:8; - * CONCURRENCY:SPEC:8.1;CONCURRENCY:SPEC:9;CONCURRENCY:SPEC:10;CONCURRENCY: - * SPEC:10.2; CONCURRENCY:SPEC:12;CONCURRENCY:SPEC:19;CONCURRENCY:SPEC:27; - * - * @test_Strategy: test basic function for ManagedExecutorService include - * execute, submit, invokeAny, invokeAll, atMostOnce - */ - - @Test + @Assertion(id = "SPEC:10.2; SPEC:13; SPEC:13.1; SPEC:13.2", + strategy = "Test basic function for ManagedExecutorService: execute") public void testExecute() { try { executor.execute(new CounterRunnableTask()); @@ -84,7 +68,8 @@ public void testExecute() { } } - @Test + @Assertion(id = "SPEC:14; SPEC:14.1; SPEC:14.2; SPEC:14.3", + strategy = "Test basic function for ManagedExecutorService: submit") public void testSubmit() throws Exception { Future result = executor.submit(new CommonTasks.SimpleCallable()); Wait.waitTillFutureIsDone(result); @@ -99,7 +84,8 @@ public void testSubmit() throws Exception { assertEquals(result.get(), TestConstants.simpleReturnValue); } - @Test + @Assertion(id = "SPEC:14.4; SPEC:6.1; SPEC:6.2; SPEC:8", + strategy = "Test basic function for ManagedExecutorService: invokeAny") public void testInvokeAny() { try { List> taskList = new ArrayList<>(); @@ -123,7 +109,8 @@ public void testInvokeAny() { }); } - @Test + @Assertion(id = "SPEC:8.1; SPEC:9; SPEC:10; SPEC:10.2; SPEC:12; SPEC:19; SPEC:27", + strategy = "Test basic function for ManagedExecutorService: invokeAll") public void testInvokeAll() { try { List> taskList = new ArrayList<>(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java index 653f82ca..82db1c61 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java @@ -19,8 +19,8 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Test; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; import jakarta.ejb.EJB; @@ -35,68 +35,27 @@ public static JavaArchive createDeployment() { @EJB private TestEjbInterface testEjb; - /* - * @testName: testAwaitTermination - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.1; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.1", strategy = "Test basic function for ManagedExecutorService: awaitTermination") public void testAwaitTermination() { testEjb.testAwaitTermination(); } - /* - * @testName: testIsShutdown - * - * @assertion_ids: - * - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.2; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.2", strategy = "Test basic function for ManagedExecutorService: isShutdown") public void testIsShutdown() { testEjb.testIsShutdown(); } - /* - * @testName: testIsTerminated - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.3; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.3", strategy = "Test basic function for ManagedExecutorService: isTerminated") public void testIsTerminated() { testEjb.testIsTerminated(); } - /* - * @testName: testShutdown - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.4; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.4", strategy = "Test basic function for ManagedExecutorService: shutdown") public void testShutdown() { testEjb.testShutdown(); } - /* - * @testName: testShutdownNow - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.5; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.5", strategy = "Test basic function for ManagedExecutorService: shutdownNow") public void testShutdownNow() { testEjb.testShutdownNow(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java index e501bc35..8e7a5bb6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java @@ -16,16 +16,16 @@ package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.managed.forbiddenapi; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.concurrent.TimeUnit; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; import jakarta.annotation.Resource; import jakarta.enterprise.concurrent.ManagedExecutorService; @@ -41,98 +41,38 @@ public static WebArchive createDeployment() { @Resource(lookup = TestConstants.defaultManagedExecutorService) private ManagedExecutorService mes; - /* - * @testName: testAwaitTermination - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.1; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.1", strategy = "Test basic function for ManagedExecutorService: awaitTermination") public void testAwaitTermination() { - try { + assertThrows(IllegalStateException.class, () -> { mes.awaitTermination(10, TimeUnit.SECONDS); - } catch (IllegalStateException e) { // what expected. - return; - } catch (Exception e) { - fail(e.toString()); - } + }); } - /* - * @testName: testIsShutdown - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.2; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.2", strategy = "Test basic function for ManagedExecutorService: isShutdown") public void testIsShutdown() { - try { - mes.isShutdown(); - } catch (IllegalStateException e) { // what expected - return; - } catch (Exception e) { - fail(e.toString()); - } + assertThrows(IllegalStateException.class, () -> { + + }); } - /* - * @testName: testIsTerminated - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.3; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.3", strategy = "Test basic function for ManagedExecutorService: isTerminated") public void testIsTerminated() { - try { - mes.isTerminated(); - } catch (IllegalStateException e) { // what expected - return; - } catch (Exception e) { - fail(e.toString()); - } + assertThrows(IllegalStateException.class, () -> { + + }); } - /* - * @testName: testShutdown - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.4; - * - * @test_Strategy: - */ - @Test - public void testShutdown() { - try { + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.4", strategy = "Test basic function for ManagedExecutorService: shutdown") + public void testShutdown() { + assertThrows(IllegalStateException.class, () -> { mes.shutdown(); - } catch (IllegalStateException e) { // what expected - return; - } catch (Exception e) { - fail(e.toString()); - } + }); } - /* - * @testName: testShutdownNow - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.5; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:23 SPEC:24 SPEC:24.5", strategy = "Test basic function for ManagedExecutorService: shutdownNow") public void testShutdownNow() { - try { + assertThrows(IllegalStateException.class, () -> { mes.shutdownNow(); - } catch (IllegalStateException e) { // what expected - return; - } catch (Exception e) { - fail(e.toString()); - } + }); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjb.java index 6ef1c36b..45bd702d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjb.java @@ -16,7 +16,7 @@ package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.managed.forbiddenapi; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.concurrent.TimeUnit; @@ -28,61 +28,37 @@ @Stateless public class TestEjb implements TestEjbInterface { - private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - @Resource(lookup = TestConstants.defaultManagedExecutorService) private ManagedExecutorService executor; public void testAwaitTermination() { - try { + assertThrows(IllegalStateException.class, () -> { executor.awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - fail(e.toString()); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testIsShutdown() { - try { + assertThrows(IllegalStateException.class, () -> { executor.isShutdown(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testIsTerminated() { - try { + assertThrows(IllegalStateException.class, () -> { executor.isTerminated(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testShutdown() { - try { + assertThrows(IllegalStateException.class, () -> { executor.shutdown(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testShutdownNow() { - try { + assertThrows(IllegalStateException.class, () -> { executor.shutdownNow(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java index 0616a020..6d4523db 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java @@ -25,12 +25,12 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -82,62 +82,74 @@ protected String getServletPath() { return "ManagedExecutorDefinitionServlet"; } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorService submits an action to run asynchronously as a CompletionStage." + + " Dependent stages can be chained to the CompletionStage," + + " and all stages run with the thread context of the thread from which they were created, per ManagedExecutorDefinition config.") public void testAsyncCompletionStage() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method that returns CompletableFuture") public void testAsynchronousMethodReturnsCompletableFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method that returns CompletionStage") public void testAsynchronousMethodReturnsCompletionStage() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method that returns void") public void testAsynchronousMethodVoidReturnType() { runTest(baseURL, testname); } - // TCK Accepted Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + + " The dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedExecutorDefinition config.") public void testCompletedFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedExecutorService can create a contextualized copy of an unmanaged CompletableFuture.") public void testCopyCompletableFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Use another managed executor from ManagedExecutorDefinition that was defined in an EJB") public void testCopyCompletableFutureEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorService creates an incomplete CompletableFuture to which dependent stages can be chained." + + " The CompletableFuture can be completed from another thread lacking the same context," + + " but the dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedExecutorDefinition config.") public void testIncompleteFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Use managed executor from ManagedExecutorDefinition that was defined in an EJB") public void testIncompleteFutureEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedExecutorDefinition with all attributes configured") public void testManagedExecutorDefinitionAllAttributes() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorDefinition with minimal attributes can run multiple async tasks concurrently" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing.") public void testManagedExecutorDefinitionDefaults() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java index d4db0aac..4e1a58a6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java @@ -23,12 +23,12 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -71,62 +71,74 @@ protected String getServletPath() { return "ManagedExecutorDefinitionServlet"; } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorService submits an action to run asynchronously as a CompletionStage." + + " Dependent stages can be chained to the CompletionStage," + + " and all stages run with the thread context of the thread from which they were created, per ManagedExecutorDefinition config.") public void testAsyncCompletionStage() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method that returns CompletableFuture") public void testAsynchronousMethodReturnsCompletableFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method that returns CompletionStage") public void testAsynchronousMethodReturnsCompletionStage() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method that returns void") public void testAsynchronousMethodVoidReturnType() { runTest(baseURL, testname); } - // TCK Accepted Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + + " The dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedExecutorDefinition config.") public void testCompletedFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedExecutorService can create a contextualized copy of an unmanaged CompletableFuture.") public void testCopyCompletableFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Use another managed executor from ManagedExecutorDefinition that was defined in an EJB") public void testCopyCompletableFutureEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorService creates an incomplete CompletableFuture to which dependent stages can be chained." + + " The CompletableFuture can be completed from another thread lacking the same context," + + " but the dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedExecutorDefinition config.") public void testIncompleteFuture() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Use managed executor from ManagedExecutorDefinition that was defined in an EJB") public void testIncompleteFutureEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedExecutorDefinition with all attributes configured") public void testManagedExecutorDefinitionAllAttributes() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedExecutorDefinition with minimal attributes can run multiple async tasks concurrently" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing.") public void testManagedExecutorDefinitionDefaults() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java index ac6c5fef..89088456 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java @@ -29,6 +29,7 @@ import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -45,10 +46,8 @@ public static EnterpriseArchive createDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "security_web.war") .addPackages(true, SecurityFullTests.class.getPackage()) .addPackages(true, PACKAGE.TASKS.getPackageName()) - .deleteClasses(SecurityTestInterface.class, SecurityTestEjb.class); // SecurityTestEjb and - // SecurityTestInterface are in the - // jar; - + .deleteClasses(SecurityTestInterface.class, SecurityTestEjb.class); + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class); @@ -67,21 +66,11 @@ protected String getServletPath() { } /* - * @testName: managedExecutorServiceAPISecurityTest - * - * @assertion_ids: CONCURRENCY:SPEC:4.3; CONCURRENCY:SPEC:50; - * CONCURRENCY:SPEC:85; CONCURRENCY:SPEC:96.6; CONCURRENCY:SPEC:106; - * CONCURRENCY:SPEC:22; - * - * @test_Strategy: login in a servlet with username "javajoe(in role manager)", - * then submit a task by ManagedExecutorService in which call a ejb that - * requires role manager. - * - * Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/227 - * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in - * next release of Concurrency + * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in next release of Concurrency */ - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/227") + @Assertion(id = "SPEC:4.3 SPEC:50 SPEC:85 SPEC:96.6 SPEC:106 SPEC:22", + strategy = "Login in a servlet with username javajoe(in role manager), then submit a task by ManagedExecutorService in which call a ejb that requires role manager.") public void managedExecutorServiceAPISecurityTest() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java index ae88133b..38919935 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java @@ -27,6 +27,7 @@ import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -58,21 +59,11 @@ protected String getServletPath() { } /* - * @testName: managedExecutorServiceAPISecurityTest - * - * @assertion_ids: CONCURRENCY:SPEC:4.3; CONCURRENCY:SPEC:50; - * CONCURRENCY:SPEC:85; CONCURRENCY:SPEC:96.6; CONCURRENCY:SPEC:106; - * CONCURRENCY:SPEC:22; - * - * @test_Strategy: login in a servlet with username "javajoe(in role manager)", - * then submit a task by ManagedExecutorService in which call a ejb that - * requires role manager. - * - * Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/227 - * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in - * next release of Concurrency + * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in next release of Concurrency */ - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/227") + @Assertion(id = "SPEC:4.3 SPEC:50 SPEC:85 SPEC:96.6 SPEC:106 SPEC:22", + strategy = "Login in a servlet with username javajoe(in role manager), then submit a task by ManagedExecutorService in which call a ejb that requires role manager.") public void managedExecutorServiceAPISecurityTest() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionTests.java index 35467025..1e24047d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionTests.java @@ -24,11 +24,11 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.transaction.Constants; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -45,58 +45,31 @@ public class TransactionTests extends TestClient { public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class).addPackages(true, TransactionTests.class.getPackage()); } + + // TODO rewrite test logic to avoid duplicate key violation - /* - * @testName: testRollbackTransactionWithManagedExecutorService - * - * @assertion_ids: CONCURRENCY:SPEC:31.3;CONCURRENCY:SPEC:39.3; - * CONCURRENCY:SPEC:92.2;CONCURRENCY:SPEC:92.3; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedExecutorService. test roll back function in the submitted task. - */ - @Test @Order(1) + @Assertion(id = "SPEC:31.3 SPEC:39.3 SPEC:92.2 SPEC:92.3", + strategy = "Get UserTransaction inside one task submitted by ManagedExecutorService." + + " Test rollback function in the submitted task.") public void testRollbackTransactionWithManagedExecutorService() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); } - /* - * @testName: testCommitTransactionWithManagedExecutorService - * - * @assertion_ids: - * CONCURRENCY:SPEC:30;CONCURRENCY:SPEC:31;CONCURRENCY:SPEC:31.1; - * CONCURRENCY:SPEC:31.2;CONCURRENCY:SPEC:32;CONCURRENCY:SPEC:33; - * CONCURRENCY:SPEC:34;CONCURRENCY:SPEC:36; CONCURRENCY:SPEC:38; - * CONCURRENCY:SPEC:8.1;CONCURRENCY:SPEC:9;CONCURRENCY:SPEC:39; - * CONCURRENCY:SPEC:39.1;CONCURRENCY:SPEC:39.2;CONCURRENCY:SPEC:4.1; - * CONCURRENCY:SPEC:4.4;CONCURRENCY:SPEC:92.2;CONCURRENCY:SPEC:92.3; - * CONCURRENCY:SPEC:92.5;CONCURRENCY:SPEC:41; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedExecutorService.it support user-managed global transaction demarcation - * using the jakarta.transaction.UserTransaction interface. - */ - @Test // TODO rewrite test logic to avoid duplicate key violation @Order(2) + @Assertion(id = "SPEC:30 SPEC:31 SPEC:31.1 SPEC:31.2 SPEC:32 SPEC:33 SPEC:34 SPEC:36 SPEC:38 SPEC:8.1" + + " SPEC:9 SPEC:39 SPEC:39.1 SPEC:39.2 SPEC:4.1 SPEC:4.4 SPEC:92.2 SPEC:92.3 SPEC:92.5 SPEC:41", + strategy = "Get UserTransaction inside one task submitted by ManagedExecutorService." + + " It support user-managed global transaction demarcation using the jakarta.transaction.UserTransaction interface.") public void testCommitTransactionWithManagedExecutorService() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_TRUE).withTestName("transactionTest")); } - /* - * @testName: testCancelTransactionWithManagedExecutorService - * - * @assertion_ids: - * CONCURRENCY:SPEC:112;CONCURRENCY:SPEC:35;CONCURRENCY:SPEC:68;CONCURRENCY: - * SPEC:91.4; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedExecutorService.cancel the task after submit one task. - */ - @Test @Order(3) + @Assertion(id = " SPEC:112 SPEC:35 SPEC:68 SPEC:91.4", + strategy = "Get UserTransaction inside one task submitted by ManagedExecutorService.cancel the task after submit one task.") public void testCancelTransactionWithManagedExecutorService() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_CANCEL).withTestName("cancelTest")); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java index 06ae639c..998df129 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java @@ -20,10 +20,10 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import jakarta.ejb.EJB; @@ -48,86 +48,37 @@ public static EnterpriseArchive createDeployment() { @EJB private TestEjbInterface testEjb; - /* - * @testName: testApiSubmit - * - * @assertion_ids: CONCURRENCY:SPEC:44.1 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.1", strategy = "Test basic function for ManagedScheduledExecutorService: submit") public void testApiSubmit() { testEjb.testApiSubmit(); } - /* - * @testName: testApiExecute - * - * @assertion_ids: CONCURRENCY:SPEC:44.2 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.2", strategy = "Test basic function for ManagedScheduledExecutorService: execute") public void testApiExecute() { testEjb.testApiExecute(); } - /* - * @testName: testApiInvokeAll - * - * @assertion_ids: CONCURRENCY:SPEC:44.3 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.3", strategy = "Test basic function for ManagedScheduledExecutorService: invokeAll") public void testApiInvokeAll() { testEjb.testApiInvokeAll(); } - /* - * @testName: testApiInvokeAny - * - * @assertion_ids: CONCURRENCY:SPEC:44.4 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.4", strategy = "Test basic function for ManagedScheduledExecutorService: invokeAny") public void testApiInvokeAny() { testEjb.testApiInvokeAny(); } - /* - * @testName: testApiSchedule - * - * @assertion_ids: CONCURRENCY:SPEC:44.5 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.5", strategy = "Test basic function for ManagedScheduledExecutorService: schedule") public void testApiSchedule() { testEjb.testApiSchedule(); } - /* - * @testName: testApiScheduleAtFixedRate - * - * @assertion_ids: CONCURRENCY:SPEC:44.6 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.6", strategy = "Test basic function for ManagedScheduledExecutorService: scheduleAtFixedRate") public void testApiScheduleAtFixedRate() { testEjb.testApiScheduleAtFixedRate(); } - /* - * @testName: testApiScheduleWithFixedDelay - * - * @assertion_ids: CONCURRENCY:SPEC:44.7 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.7", strategy = "Test basic function for ManagedScheduledExecutorService: scheduleWithFixedDelay") public void testApiScheduleWithFixedDelay() { testEjb.testApiScheduleWithFixedDelay(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/servlet/InheritedAPIServletTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIServletTests.java similarity index 88% rename from tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/servlet/InheritedAPIServletTests.java rename to tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIServletTests.java index cba12dea..6662b7a2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/servlet/InheritedAPIServletTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIServletTests.java @@ -14,7 +14,7 @@ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 */ -package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.inheritedapi.servlet; +package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.inheritedapi; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -33,12 +33,12 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.fixed.counter.CounterRunnableTask; import ee.jakarta.tck.concurrent.common.fixed.counter.StaticCounter; import ee.jakarta.tck.concurrent.common.tasks.CommonTasks; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -64,14 +64,7 @@ public void before() { StaticCounter.reset(); } - /* - * @testName: testApiSubmit - * - * @assertion_ids: CONCURRENCY:SPEC:44.1 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.1", strategy = "Test basic function for ManagedScheduledExecutorService: submit") public void testApiSubmit() throws Exception { Future result = scheduledExecutor.submit(new CommonTasks.SimpleCallable()); Wait.waitTillFutureIsDone(result); @@ -86,14 +79,7 @@ public void testApiSubmit() throws Exception { assertEquals(result.get(), TestConstants.simpleReturnValue); } - /* - * @testName: testApiExecute - * - * @assertion_ids: CONCURRENCY:SPEC:44.2 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.2", strategy = "Test basic function for ManagedScheduledExecutorService: execute") public void testApiExecute() { try { scheduledExecutor.execute(new CounterRunnableTask()); @@ -103,14 +89,7 @@ public void testApiExecute() { } } - /* - * @testName: testApiInvokeAll - * - * @assertion_ids: CONCURRENCY:SPEC:44.3 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.3", strategy = "Test basic function for ManagedScheduledExecutorService: invokeAll") public void testApiInvokeAll() throws Exception { try { List> taskList = new ArrayList<>(); @@ -150,14 +129,7 @@ public void testApiInvokeAll() throws Exception { } } - /* - * @testName: testApiInvokeAny - * - * @assertion_ids: CONCURRENCY:SPEC:44.4 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.4", strategy = "Test basic function for ManagedScheduledExecutorService: invokeAny") public void testApiInvokeAny() throws Exception { List> taskList = new ArrayList<>(); @@ -178,14 +150,7 @@ public void testApiInvokeAny() throws Exception { }); } - /* - * @testName: testApiSchedule - * - * @assertion_ids: CONCURRENCY:SPEC:44.5 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.5", strategy = "Test basic function for ManagedScheduledExecutorService: schedule") public void testApiSchedule() throws Exception { Future result = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); @@ -198,14 +163,7 @@ public void testApiSchedule() throws Exception { assertEquals(result.get(), null); } - /* - * @testName: testApiScheduleAtFixedRate - * - * @assertion_ids: CONCURRENCY:SPEC:44.6 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.6", strategy = "Test basic function for ManagedScheduledExecutorService: scheduleAtFixedRate") public void testApiScheduleAtFixedRate() { ScheduledFuture result = null; @@ -224,14 +182,7 @@ public void testApiScheduleAtFixedRate() { } } - /* - * @testName: testApiScheduleWithFixedDelay - * - * @assertion_ids: CONCURRENCY:SPEC:44.7 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.7", strategy = "Test basic function for ManagedScheduledExecutorService: scheduleWithFixedDelay") public void testApiScheduleWithFixedDelay() { ScheduledFuture result = null; try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java index 2cf3613d..9755d34f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java @@ -19,13 +19,13 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -import jakarta.ejb.EJB;; +import jakarta.ejb.EJB; @Web @Common({ PACKAGE.TASKS, PACKAGE.COUNTER, PACKAGE.FIXED_COUNTER }) @@ -42,86 +42,37 @@ public static WebArchive createDeployment() { @EJB private TestEjbInterface testEjb; - /* - * @testName: testApiSubmit - * - * @assertion_ids: CONCURRENCY:SPEC:44.1 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.1", strategy = "Test basic function for ManagedScheduledExecutorService: submit") public void testApiSubmit() { testEjb.testApiSubmit(); } - /* - * @testName: testApiExecute - * - * @assertion_ids: CONCURRENCY:SPEC:44.2 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.2", strategy = "Test basic function for ManagedScheduledExecutorService: execute") public void testApiExecute() { testEjb.testApiExecute(); } - /* - * @testName: testApiInvokeAll - * - * @assertion_ids: CONCURRENCY:SPEC:44.3 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.3", strategy = "Test basic function for ManagedScheduledExecutorService: invokeAll") public void testApiInvokeAll() { testEjb.testApiInvokeAll(); } - /* - * @testName: testApiInvokeAny - * - * @assertion_ids: CONCURRENCY:SPEC:44.4 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.4", strategy = "Test basic function for ManagedScheduledExecutorService: invokeAny") public void testApiInvokeAny() { testEjb.testApiInvokeAny(); } - /* - * @testName: testApiSchedule - * - * @assertion_ids: CONCURRENCY:SPEC:44.5 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.5", strategy = "Test basic function for ManagedScheduledExecutorService: schedule") public void testApiSchedule() { testEjb.testApiSchedule(); } - /* - * @testName: testApiScheduleAtFixedRate - * - * @assertion_ids: CONCURRENCY:SPEC:44.6 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.6", strategy = "Test basic function for ManagedScheduledExecutorService: scheduleAtFixedRate") public void testApiScheduleAtFixedRate() { testEjb.testApiScheduleAtFixedRate(); } - /* - * @testName: testApiScheduleWithFixedDelay - * - * @assertion_ids: CONCURRENCY:SPEC:44.7 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:44.7", strategy = "Test basic function for ManagedScheduledExecutorService: scheduleWithFixedDelay") public void testApiScheduleWithFixedDelay() { testEjb.testApiScheduleWithFixedDelay(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java index f19dc537..abf55a90 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIEJBTests.java @@ -19,8 +19,8 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.jupiter.api.Test; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -38,62 +38,27 @@ public static JavaArchive createDeployment() { @EJB private TestEjbInterface testEjb; - /* - * @testName: testAwaitTermination - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.1 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.1", strategy = "Test basic function for ManagedScheduledExecutorService: awaitTermination") public void testAwaitTermination() { testEjb.testAwaitTermination(); } - /* - * @testName: testIsShutdown - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.2 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.2", strategy = "Test basic function for ManagedScheduledExecutorService: isShutdown") public void testIsShutdown() { testEjb.testIsShutdown(); } - /* - * @testName: testIsTerminated - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.3 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.3", strategy = "Test basic function for ManagedScheduledExecutorService: isTerminated") public void testIsTerminated() { testEjb.testIsTerminated(); } - /* - * @testName: testShutdown - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.4 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.4", strategy = "Test basic function for ManagedScheduledExecutorService: shutdown") public void testShutdown() { testEjb.testShutdown(); } - /* - * @testName: testShutdownNow - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.5 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.5", strategy = "Test basic function for ManagedScheduledExecutorService: shutdownNow") public void testShutdownNow() { testEjb.testShutdownNow(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java index aa1fc413..95b9db02 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/ForbiddenAPIServletTests.java @@ -16,7 +16,7 @@ package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.managed.forbiddenapi; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.concurrent.TimeUnit; @@ -24,10 +24,10 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.fixed.counter.StaticCounter; import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -43,8 +43,6 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class); } - private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) private ManagedScheduledExecutorService scheduledExecutor; @@ -53,90 +51,38 @@ protected void before() { StaticCounter.reset(); } - /* - * @testName: testAwaitTermination - * - * @assertion_ids: CONCURRENCY:SPEC:57.1 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.1", strategy = "Test basic function for ManagedScheduledExecutorService: awaitTermination") public void testAwaitTermination() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - fail(e.getMessage()); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } - /* - * @testName: testIsShutdown - * - * @assertion_ids: CONCURRENCY:SPEC:57.2 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.2", strategy = "Test basic function for ManagedScheduledExecutorService: isShutdown") public void testIsShutdown() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.isShutdown(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } - /* - * @testName: testIsTerminated - * - * @assertion_ids: CONCURRENCY:SPEC:57.3 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.3", strategy = "Test basic function for ManagedScheduledExecutorService: isTerminated") public void testIsTerminated() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.isTerminated(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } - /* - * @testName: testShutdown - * - * @assertion_ids: CONCURRENCY:SPEC:57.4 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.4", strategy = "Test basic function for ManagedScheduledExecutorService: shutdown") public void testShutdown() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.shutdown(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } - /* - * @testName: testShutdownNow - * - * @assertion_ids: CONCURRENCY:SPEC:57.5 - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:56 SPEC:57.5", strategy = "Test basic function for ManagedScheduledExecutorService: shutdownNow") public void testShutdownNow() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.shutdownNow(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/TestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/TestEjb.java index a397fff8..ab6bbcda 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/TestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/TestEjb.java @@ -16,7 +16,7 @@ package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.managed.forbiddenapi; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertThrows; import java.util.concurrent.TimeUnit; @@ -28,56 +28,37 @@ @Stateless public class TestEjb implements TestEjbInterface { - private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) private ManagedScheduledExecutorService scheduledExecutor; public void testAwaitTermination() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - fail(e.getMessage()); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testIsShutdown() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.isShutdown(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testIsTerminated() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.isTerminated(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testShutdown() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.shutdown(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } public void testShutdownNow() { - try { + assertThrows(IllegalStateException.class, () -> { scheduledExecutor.shutdownNow(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + }); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java index f60735fd..beb3e00c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java @@ -25,12 +25,12 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -82,74 +82,97 @@ protected String getServletPath() { return "ManagedScheduledExecutorDefinitionServlet"; } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService submits an action to run asynchronously as a CompletionStage." + + " Dependent stages can be chained to the CompletionStage," + + " and all stages run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testAsyncCompletionStageMSE() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method runs with thread context captured from caller") public void testAsynchronousMethodRunsWithContext() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method execution is constrained by executor's maxAsync") public void testAsynchronousMethodWithMaxAsync3() { runTest(baseURL, testname); } - // Accepted TCK Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + + " The dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testCompletedFutureMSE() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService creates an incomplete CompletableFuture to which dependent stages can be chained." + + " The CompletableFuture can be completed from another thread lacking the same context," + + " but the dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testIncompleteFutureMSE() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService creates an incomplete CompletableFuture to which dependent stages can be chained." + + " The CompletableFuture can be completed from another thread lacking the same context," + + " but the dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testIncompleteFutureMSEEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedScheduledExecutorDefinition with all attributes configured") public void testManagedScheduledExecutorDefinitionAllAttributes() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorDefinition defined on an EJB with all attributes configured enforces maxAsync and propagates context") public void testManagedScheduledExecutorDefinitionAllAttributesEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorDefinition with minimal attributes can run multiple async tasks concurrently" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing.") public void testManagedScheduledExecutorDefinitionDefaults() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorDefinition defined on an EJB with minimal attributes can run multiple async tasks concurrently" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing") public void testManagedScheduledExecutorDefinitionDefaultsEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", + strategy = "A method that lacks the Asynchronous annotation does not run as an asynchronous method," + + " even if it returns a CompletableFuture.") public void testNotAnAsynchronousMethod() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedScheduledExecutorService can schedule a task with a CronTrigger") public void testScheduleWithCronTrigger() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService can schedule a task with a ZonedTrigger implementation that uses the LastExecution methods with ZonedDateTime parameters") public void testScheduleWithZonedTrigger() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java index dce266b5..793dcf0b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java @@ -23,12 +23,12 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -71,75 +71,98 @@ protected String getServletPath() { return "ManagedScheduledExecutorDefinitionServlet"; } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService submits an action to run asynchronously as a CompletionStage." + + " Dependent stages can be chained to the CompletionStage," + + " and all stages run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testAsyncCompletionStageMSE() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method runs with thread context captured from caller") public void testAsynchronousMethodRunsWithContext() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "Asynchronous method execution is constrained by executor's maxAsync") public void testAsynchronousMethodWithMaxAsync3() { runTest(baseURL, testname); } - // Accepted TCK Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + + " The dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testCompletedFutureMSE() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService creates an incomplete CompletableFuture to which dependent stages can be chained." + + " The CompletableFuture can be completed from another thread lacking the same context," + + " but the dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testIncompleteFutureMSE() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService creates an incomplete CompletableFuture to which dependent stages can be chained." + + " The CompletableFuture can be completed from another thread lacking the same context," + + " but the dependent stages all run with the thread context of the thread from which they were created," + + " per ManagedScheduledExecutorDefinition config.") public void testIncompleteFutureMSEEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedScheduledExecutorDefinition with all attributes configured") public void testManagedScheduledExecutorDefinitionAllAttributes() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorDefinition defined on an EJB with all attributes configured enforces maxAsync and propagates context") public void testManagedScheduledExecutorDefinitionAllAttributesEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorDefinition with minimal attributes can run multiple async tasks concurrently" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing.") public void testManagedScheduledExecutorDefinitionDefaults() { runTest(baseURL, testname); } - @Test - public void testManagedScheduledExecutorDefinitionDefaultsEJB() { + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorDefinition with minimal attributes can run multiple async tasks concurrently" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing.") + public void testManagedScheduledExecutorDefinitionDefaultsEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test - public void testNotAnAsynchronousMethod() { + @Assertion(id = "GIT:154", + strategy = "A method that lacks the Asynchronous annotation does not run as an asynchronous method," + + " even if it returns a CompletableFuture.") + public void testNotAnAsynchronousMethod() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:154", strategy = "ManagedScheduledExecutorService can schedule a task with a CronTrigger") public void testScheduleWithCronTrigger() { runTest(baseURL, testname); } - @Test - public void testScheduleWithZonedTrigger() { + @Assertion(id = "GIT:154", + strategy = "ManagedScheduledExecutorService can schedule a task with a ZonedTrigger implementation that uses the LastExecution methods with ZonedDateTime parameters") + public void testScheduleWithZonedTrigger() { runTest(baseURL, testname); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionTests.java index 21699786..31a72ce5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionTests.java @@ -24,11 +24,11 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.transaction.Constants; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -45,59 +45,30 @@ public class TransactionTests extends TestClient { public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class).addPackages(true, TransactionTests.class.getPackage()); } + + // TODO rewrite test logic to avoid duplicate key violation - /* - * @testName: testRollbackTransactionWithManagedScheduledExecutorService - * - * @assertion_ids: CONCURRENCY:SPEC:63;CONCURRENCY:SPEC:64; - * CONCURRENCY:SPEC:65;CONCURRENCY:SPEC:66; - * CONCURRENCY:SPEC:67;CONCURRENCY:SPEC:69; - * CONCURRENCY:SPEC:71;CONCURRENCY:SPEC:72; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedScheduledExecutorService. test roll back function in the submitted - * task. - */ - @Test @Order(1) + @Assertion(id = "SPEC:63 SPEC:64 SPEC:65 SPEC:66 SPEC:67 SPEC:69 SPEC:71 SPEC:72", + strategy = "Get UserTransaction inside one task submitted by ManagedScheduledExecutorService." + + " Test rollback function in the submitted task.") public void testRollbackTransactionWithManagedScheduledExecutorService() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); } - /* - * @testName: testCommitTransactionWithManagedScheduledExecutorService - * - * @assertion_ids: CONCURRENCY:SPEC:63;CONCURRENCY:SPEC:64; - * CONCURRENCY:SPEC:65;CONCURRENCY:SPEC:66;CONCURRENCY:SPEC:67; - * CONCURRENCY:SPEC:69;CONCURRENCY:SPEC:8.1;CONCURRENCY:SPEC:9; - * CONCURRENCY:SPEC:71;CONCURRENCY:SPEC:72; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedScheduledExecutorService.it support user-managed global transaction - * demarcation using the jakarta.transaction.UserTransaction interface. - */ - @Test // TODO rewrite test logic to avoid duplicate key violation @Order(2) + @Assertion(id = "SPEC:63 SPEC:64 SPEC:65 SPEC:66 SPEC:67 SPEC:69 SPEC:8.1 SPEC:9 SPEC:71 SPEC:72", + strategy = "Get UserTransaction inside one task submitted by ManagedScheduledExecutorService." + + " It support user-managed global transaction demarcation using the jakarta.transaction.UserTransaction interface.") public void testCommitTransactionWithManagedScheduledExecutorService() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_TRUE).withTestName("transactionTest")); } - /* - * @testName: testCancelTransactionWithManagedScheduledExecutorService - * - * @assertion_ids: CONCURRENCY:SPEC:42.1;CONCURRENCY:SPEC:42.3; - * CONCURRENCY:SPEC:63;CONCURRENCY:SPEC:64; - * CONCURRENCY:SPEC:65;CONCURRENCY:SPEC:66; - * CONCURRENCY:SPEC:67;CONCURRENCY:SPEC:69; - * CONCURRENCY:SPEC:71;CONCURRENCY:SPEC:72; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedScheduledExecutorService.cancel the task after submit one task. - */ - @Test @Order(3) + @Assertion(id = "SPEC:42.1 SPEC:42.3 SPEC:63 SPEC:64 SPEC:65 SPEC:66 SPEC:67 SPEC:69 SPEC:71 SPEC:72", + strategy = "Get UserTransaction inside one task submitted by ManagedScheduledExecutorService.cancel the task after submit one task.") public void testCancelTransactionWithManagedScheduledExecutorService() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_CANCEL).withTestName("cancelTest")); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextFullTests.java index df529cab..d6621ae6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextFullTests.java @@ -25,9 +25,9 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -62,20 +62,12 @@ protected String getServletPath() { return "SecurityServlet"; } - /* - * @testName: jndiClassloaderPropagationTest - * - * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; - * CONCURRENCY:SPEC:106; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:96.7 SPEC:100 SPEC:106", strategy = "Ensures classloader context is propogated to ThreadFactory task.") public void jndiClassloaderPropagationTest() { runTest(baseURL, testname); } - @Test + @Assertion(id = "SPEC:96.7 SPEC:100 SPEC:106", strategy = "Ensures classloader context is propogated to ThreadFactory task that uses a security role.") public void jndiClassloaderPropagationWithSecurityTest() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java index b9723c90..dcff603a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java @@ -23,9 +23,9 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -55,20 +55,12 @@ protected String getServletPath() { return "SecurityServlet"; } - /* - * @testName: jndiClassloaderPropagationTest - * - * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; - * CONCURRENCY:SPEC:106; - * - * @test_Strategy: - */ - @Test + @Assertion(id = "SPEC:96.7 SPEC:100 SPEC:106", strategy = "Ensures classloader context is propogated to ThreadFactory task.") public void jndiClassloaderPropagationTest() { runTest(baseURL, testname); } - @Test + @Assertion(id = "SPEC:96.7 SPEC:100 SPEC:106", strategy = "Ensures classloader context is propogated to ThreadFactory task that uses a security role.") public void jndiClassloaderPropagationWithSecurityTest() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java index e1bdf111..1cf1a076 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java @@ -25,13 +25,13 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionBean; @@ -82,40 +82,46 @@ protected String getServletPath() { return "ManagedThreadFactoryDefinitionServlet"; } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition with all attributes configured") public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { runTest(baseURL, testname); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", + strategy = "A ManagedThreadFactoryDefinition defined on an EJB with all attributes configured enforces priority and propagates context.") public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition with minimal attributes configured") public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:156", + strategy = "ManagedThreadFactoryDefinition defined on an EJB with minimal attributes creates threads with normal priority" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing") public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", + strategy = "ManagedThreadFactory can be supplied to a ForkJoinPool, which manages thread context and priority as configured") public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { runTest(baseURL, testname); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", + strategy = "ManagedThreadFactoryDefinition defined on an EJB is supplied to a ForkJoinPool" + + " and uses java:comp/DefaultContextService to determine context propagation and priority.") public void testParallelStreamBackedByManagedThreadFactoryEJB() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java index 076c295e..1d10e71e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java @@ -23,12 +23,12 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -73,40 +73,47 @@ protected String getServletPath() { return "ManagedThreadFactoryDefinitionServlet"; } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition with all attributes configured") public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { runTest(baseURL, testname); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", + strategy = "A ManagedThreadFactoryDefinition defined on an EJB with all attributes configured enforces priority and propagates context.") public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - @Test + @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition with minimal attributes configured") public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:156", + strategy = "ManagedThreadFactoryDefinition defined on an EJB with minimal attributes creates threads with normal priority" + + " and uses java:comp/DefaultContextService to determine context propagation and clearing") public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", + strategy = "ManagedThreadFactory can be supplied to a ForkJoinPool," + + " which manages thread context and priority as configured") public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { runTest(baseURL, testname); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:156", + strategy = "ManagedThreadFactoryDefinition defined on an EJB is supplied to a ForkJoinPool" + + " and uses java:comp/DefaultContextService to determine context propagation and priority.") public void testParallelStreamBackedByManagedThreadFactoryEJB() throws Throwable { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionTests.java index 3156d367..37a1a959 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionTests.java @@ -24,11 +24,11 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.transaction.Constants; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -45,61 +45,31 @@ public class TransactionTests extends TestClient { public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class).addPackages(true, TransactionTests.class.getPackage()); } + + // TODO rewrite test logic to avoid duplicate key violation - /* - * @testName: testRollbackTransactionWithManagedThreadFactory - * - * @assertion_ids: - * CONCURRENCY:SPEC:107;CONCURRENCY:SPEC:108;CONCURRENCY:SPEC:110; - * CONCURRENCY:SPEC:111;CONCURRENCY:SPEC:115;CONCURRENCY:SPEC:116; - * CONCURRENCY:SPEC:8.1;CONCURRENCY:SPEC:9;CONCURRENCY:SPEC:107; - * CONCURRENCY:SPEC:108;CONCURRENCY:SPEC:109; - * - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedThreadFactory. test roll back function in the submitted task. - */ - @Test @Order(1) + @Assertion(id = "SPEC:107 SPEC:108 SPEC:110 SPEC:111 SPEC:115 SPEC:116 SPEC:8.1 SPEC:9 SPEC:107 SPEC:108 SPEC:109", + strategy = "Get UserTransaction inside one task submitted by ManagedThreadFactory." + + " Test rollback function in the submitted task.") public void testRollbackTransactionWithManagedThreadFactory() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); } - /* - * @testName: testCommitTransactionWithManagedThreadFactory - * - * @assertion_ids: - * CONCURRENCY:SPEC:107;CONCURRENCY:SPEC:108;CONCURRENCY:SPEC:110; - * CONCURRENCY:SPEC:111;CONCURRENCY:SPEC:115;CONCURRENCY:SPEC:116; - * CONCURRENCY:SPEC:8.1;CONCURRENCY:SPEC:9;CONCURRENCY:SPEC:107; - * CONCURRENCY:SPEC:109;CONCURRENCY:SPEC:113;CONCURRENCY:SPEC:118; - * CONCURRENCY:SPEC:113;CONCURRENCY:SPEC:118; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedThreadFactory.it support user-managed global transaction demarcation - * using the jakarta.transaction.UserTransaction interface. - */ - @Test // TODO rewrite test logic to avoid duplicate key violation @Order(2) + @Assertion(id = "SPEC:107 SPEC:108 SPEC:110 SPEC:111 SPEC:115 SPEC:116 SPEC:8.1 SPEC:9" + + " SPEC:107 SPEC:109 SPEC:113 SPEC:118 SPEC:113 SPEC:118", + strategy = "Get UserTransaction inside one task submitted by ManagedThreadFactory." + + " It support user-managed global transaction demarcation using the jakarta.transaction.UserTransaction interface.") public void testCommitTransactionWithManagedThreadFactory() throws InterruptedException { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_TRUE).withTestName("transactionTest")); } - /* - * @testName: testCancelTransactionWithManagedThreadFactory - * - * @assertion_ids: - * CONCURRENCY:SPEC:107;CONCURRENCY:SPEC:108;CONCURRENCY:SPEC:110; - * CONCURRENCY:SPEC:111;CONCURRENCY:SPEC:115;CONCURRENCY:SPEC:116; - * CONCURRENCY:SPEC:8.1;CONCURRENCY:SPEC:9; - * - * @test_Strategy: get UserTransaction inside one task submitted by - * ManagedThreadFactory.cancel the task after submit one task. - */ - @Test @Order(3) + @Assertion(id = "SPEC:107 SPEC:108 SPEC:110 SPEC:111 SPEC:115 SPEC:116 SPEC:8.1 SPEC:9", + strategy = "Get UserTransaction inside one task submitted by ManagedThreadFactory.cancel the task after submit one task.") public void testCancelTransactionWithManagedThreadFactory() { runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) .withQueries(Constants.COMMIT_CANCEL).withTestName("cancelTest")); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java index c4d5291d..56747644 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java @@ -25,11 +25,11 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -74,23 +74,23 @@ protected String getServletPath() { return "DeploymentDescriptorServlet"; } - @Test + @Assertion(id = "GIT:186", strategy = "Tests context-service defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesContextService() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:186", strategy = "Tests managed-executor defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedExecutor() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:186", strategy = "Tests managed-scheduled-executor defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedScheduledExecutor() { runTest(baseURL, testname); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:186", strategy = "Tests managed-thread-factory defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedThreadFactory() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorServlet.java index 9af6866f..fdec3126 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorServlet.java @@ -52,9 +52,6 @@ public class DeploymentDescriptorServlet extends TestServlet { @Resource private UserTransaction tx; - /** - * Tests context-service defined in a deployment descriptor. - */ public void testDeploymentDescriptorDefinesContextService() throws Throwable { ContextService contextSvc = InitialContext.doLookup("java:global/concurrent/ContextD"); @@ -89,9 +86,6 @@ public void testDeploymentDescriptorDefinesContextService() throws Throwable { assertEquals(status, Status.STATUS_NO_TRANSACTION); } - /** - * Tests managed-executor defined in a deployment descriptor. - */ public void testDeploymentDescriptorDefinesManagedExecutor() throws Throwable { LinkedBlockingQueue started = new LinkedBlockingQueue(); CountDownLatch taskCanEnd = new CountDownLatch(1); @@ -147,16 +141,10 @@ public void testDeploymentDescriptorDefinesManagedExecutor() throws Throwable { } } - /** - * Tests managed-scheduled-executor defined in a deployment descriptor. - */ public void testDeploymentDescriptorDefinesManagedScheduledExecutor() throws Throwable { enterpriseBean.testDeploymentDescriptorDefinesManagedScheduledExecutor(); } - /** - * Tests managed-thread-factory defined in a deployment descriptor. - */ public void testDeploymentDescriptorDefinesManagedThreadFactory() throws Throwable { enterpriseBean.testDeploymentDescriptorDefinesManagedThreadFactory(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java index bd5e71fb..be7c0eb4 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java @@ -23,11 +23,11 @@ import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -48,14 +48,11 @@ public class DeploymentDescriptorWebTests extends TestClient { @Deployment(name = "DeploymentDescriptorTests") public static WebArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "DeploymentDescriptorTests_web.war") + return ShrinkWrap.create(WebArchive.class, "DeploymentDescriptorTests_web.war") .addPackages(false, DeploymentDescriptorWebTests.class.getPackage()) .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()) .addAsWebInfResource(DeploymentDescriptorWebTests.class.getPackage(), "web.xml", "web.xml"); - - return war; } @TestName @@ -66,23 +63,23 @@ protected String getServletPath() { return "DeploymentDescriptorServlet"; } - @Test + @Assertion(id = "GIT:186", strategy = "Tests context-service defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesContextService() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:186", strategy = "Tests managed-executor defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedExecutor() { runTest(baseURL, testname); } - @Test + @Assertion(id = "GIT:186", strategy = "Tests managed-scheduled-executor defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedScheduledExecutor() { runTest(baseURL, testname); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Assertion(id = "GIT:186", strategy = "Tests managed-thread-factory defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedThreadFactory() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/signature/SignatureTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/signature/SignatureTests.java index 7c10e56d..469e3bb2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/signature/SignatureTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/signature/SignatureTests.java @@ -18,9 +18,9 @@ import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Test; import ee.jakarta.tck.concurrent.common.signature.ConcurrencySignatureTestRunner; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; import ee.jakarta.tck.concurrent.framework.junit.anno.Signature; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; @@ -33,7 +33,8 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class, "signatureTest.war"); } - @Test + @Assertion(id = "GIT:156", + strategy = "Ensure API signatures used by vendor match the signatures expected for this version of the API.") public void testSignatures() throws Exception { ConcurrencySignatureTestRunner.assertProjectSetup(); ConcurrencySignatureTestRunner sigTest = new ConcurrencySignatureTestRunner(); From f471526113bff3aa3aed94c12caf631de4439dd7 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Wed, 23 Aug 2023 10:49:23 -0500 Subject: [PATCH 2/3] Introduce challenge annotation --- .../framework/junit/anno/Challenge.java | 48 +++++++++++++++++++ .../ContextPropagationFullTests.java | 23 +++++---- .../ContextPropagationWebTests.java | 28 +++++------ .../ManagedExecutorDefinitionFullTests.java | 4 +- .../ManagedExecutorDefinitionWebTests.java | 4 +- .../security/SecurityFullTests.java | 8 ++-- .../security/SecurityWebTests.java | 8 ++-- .../inheritedapi/InheritedAPIFullTests.java | 2 +- ...dScheduledExecutorDefinitionFullTests.java | 4 +- ...edScheduledExecutorDefinitionWebTests.java | 4 +- .../security/SecurityFullTests.java | 21 +++----- .../security/SecurityWebTests.java | 21 +++----- ...nagedThreadFactoryDefinitionFullTests.java | 12 ++--- ...anagedThreadFactoryDefinitionWebTests.java | 10 ++-- .../dd/DeploymentDescriptorFullTests.java | 4 +- .../dd/DeploymentDescriptorWebTests.java | 4 +- 16 files changed, 115 insertions(+), 90 deletions(-) create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Challenge.java diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Challenge.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Challenge.java new file mode 100644 index 00000000..bcc7f8a1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Challenge.java @@ -0,0 +1,48 @@ +package ee.jakarta.tck.concurrent.framework.junit.anno; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.junit.jupiter.api.Disabled; + +/** + * Challenge metadata to track where challenges from GitHub came from, + * what version was affected by the challenge, + * and if the issue has been fixed. + * + * Aggregates the @Disabled annotation from Junit + */ +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Disabled +public @interface Challenge { + + /** + * REQUIRED: Link to the challenge on GitHub + */ + String link(); + + /** + * REQUIRED: The version of the TCK where the challenge was found. + */ + String version(); + + /** + * OPTIONAL: Link to the pull request on GitHub that fixes the challenge + */ + String fix() default ""; + + /** + * OPTIONAL: The version of the TCK where the test can be re-enabled + */ + String reintroduce() default ""; + + /** + * OPTIONAL: The reason the TCK was disabled + */ + String reason() default ""; + + +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java index f2c43a9e..a4d38462 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationFullTests.java @@ -25,7 +25,6 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; @@ -34,6 +33,7 @@ import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -90,17 +90,19 @@ public static EnterpriseArchive createDeployment() { @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) private URL ejbContextURL; - // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from - // another thread or the current user is changed - @Disabled("https://github.com/jakartaee/concurrency/pull/206") + @Challenge(link = "https://github.com/jakartaee/concurrency/pull/206", version = "3.0.0", + reason = "HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed") + @Assertion(id = "GIT:154", strategy = "From a JSP, use a ContextService that is defined by a ContextServiceDefinition" + + " elsewhere within the application to clear Security context from the thread of execution while the task is running.") public void testSecurityClearedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); } - // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from - // another thread or the current user is changed - @Disabled("https://github.com/jakartaee/concurrency/pull/206") + @Challenge(link = "https://github.com/jakartaee/concurrency/pull/206", version = "3.0.0", + reason = "HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed") + @Assertion(id = "GIT:154", strategy = "From a JSP, use a ContextService that is defined by a ContextServiceDefinition" + + " elsewhere within the application to leave Security context unchanged on the executing thread.") public void testSecurityUnchangedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); @@ -191,11 +193,8 @@ public void testContextualConsumer() throws Throwable { runTest(requestURL); } - /** - * FIXME Assertions on results[0] and results[1] are both invalid because treating - * those two UNCHANGED context types as though they were CLEARED. - */ - @Disabled("https://github.com/jakartaee/concurrency/issues/253") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/253", version = "3.0.1", + reason = "Assertions on results[0] and results[1] are both invalid because treating those two UNCHANGED context types as though they were CLEARED.") @Assertion(id = "GIT:154", strategy = "A ContextService contextualizes a Function, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + " The dependent stage action runs with the thread context of the thread that contextualizes the Function," diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java index 231d3ba9..93eb0d80 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java @@ -23,7 +23,6 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; @@ -32,6 +31,7 @@ import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -79,17 +79,19 @@ public static WebArchive createDeployment() { @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) private URL ejbContextURL; - // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from - // another thread or the current user is changed - @Disabled("https://github.com/jakartaee/concurrency/pull/206") + @Challenge(link = "https://github.com/jakartaee/concurrency/pull/206", version = "3.0.0", + reason = "HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed") + @Assertion(id = "GIT:154", strategy = "From a JSP, use a ContextService that is defined by a ContextServiceDefinition" + + " elsewhere within the application to clear Security context from the thread of execution while the task is running.") public void testSecurityClearedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); } - // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from - // another thread or the current user is changed - @Disabled("https://github.com/jakartaee/concurrency/pull/206") + @Challenge(link = "https://github.com/jakartaee/concurrency/pull/206", version = "3.0.0", + reason = "HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed") + @Assertion(id = "GIT:154", strategy = "From a JSP, use a ContextService that is defined by a ContextServiceDefinition" + + " elsewhere within the application to leave Security context unchanged on the executing thread.") public void testSecurityUnchangedContext() { URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); runTest(requestURL); @@ -110,8 +112,8 @@ public void testJNDIContextAndCreateProxyInServlet() { this.assertStringInResponse(testname + "failed to get correct result.", "JNDIContextWeb", resp); } - // FIXME This test will return JNDIContextWeb because we are running with web.xml and not ejb-jar.xml - @Disabled("https://github.com/jakartaee/concurrency/pull/260") + @Challenge(link = "https://github.com/jakartaee/concurrency/pull/260", version = "3.0.0", + reason = "This test will return JNDIContextWeb because we are running with web.xml and not ejb-jar.xml") @Assertion(id = "SPEC:85 SPEC:76 SPEC:76.1 SPEC:76.2 SPEC:76.3 SPEC:77 SPEC:84 SPEC:3 SPEC:3.1 SPEC:3.2 SPEC:3.3 SPEC:3.4 SPEC:4", strategy = "Create proxy in servlet and pass it into ejb container, then verify JNDI Context.") public void testJNDIContextAndCreateProxyInEJB() { @@ -182,11 +184,9 @@ public void testContextualConsumer() throws Throwable { runTest(requestURL); } - /** - * FIXME Assertions on results[0] and results[1] are both invalid because treating - * those two UNCHANGED context types as though they were CLEARED. - */ - @Disabled("https://github.com/jakartaee/concurrency/issues/253") + + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/253", version = "3.0.1", + reason = "Assertions on results[0] and results[1] are both invalid because treating those two UNCHANGED context types as though they were CLEARED.") @Assertion(id = "GIT:154", strategy = "A ContextService contextualizes a Function, which can be supplied as a dependent stage action to an unmanaged CompletableFuture." + " The dependent stage action runs with the thread context of the thread that contextualizes the Function," diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java index 6d4523db..e87400cc 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionFullTests.java @@ -24,13 +24,13 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -105,7 +105,7 @@ public void testAsynchronousMethodVoidReturnType() { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/224", version = "3.0.0") @Assertion(id = "GIT:154", strategy = "ManagedExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + " The dependent stages all run with the thread context of the thread from which they were created," diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java index 4e1a58a6..80f4cc6a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java @@ -22,13 +22,13 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -94,7 +94,7 @@ public void testAsynchronousMethodVoidReturnType() { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/224", version = "3.0.0") @Assertion(id = "GIT:154", strategy = "ManagedExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + " The dependent stages all run with the thread context of the thread from which they were created," diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java index 89088456..8dd71b02 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityFullTests.java @@ -25,11 +25,11 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -65,10 +65,8 @@ protected String getServletPath() { return "SecurityServlet"; } - /* - * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in next release of Concurrency - */ - @Disabled("https://github.com/jakartaee/concurrency/issues/227") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/227", version = "3.0.0", + fix = "https://github.com/jakartaee/concurrency/pull/218", reintroduce = "3.1.0") @Assertion(id = "SPEC:4.3 SPEC:50 SPEC:85 SPEC:96.6 SPEC:106 SPEC:22", strategy = "Login in a servlet with username javajoe(in role manager), then submit a task by ManagedExecutorService in which call a ejb that requires role manager.") public void managedExecutorServiceAPISecurityTest() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java index 38919935..a6f97c1b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java @@ -23,11 +23,11 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -58,10 +58,8 @@ protected String getServletPath() { return "SecurityServlet"; } - /* - * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in next release of Concurrency - */ - @Disabled("https://github.com/jakartaee/concurrency/issues/227") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/227", version = "3.0.0", + fix = "https://github.com/jakartaee/concurrency/pull/218", reintroduce = "3.1.0") @Assertion(id = "SPEC:4.3 SPEC:50 SPEC:85 SPEC:96.6 SPEC:106 SPEC:22", strategy = "Login in a servlet with username javajoe(in role manager), then submit a task by ManagedExecutorService in which call a ejb that requires role manager.") public void managedExecutorServiceAPISecurityTest() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java index 998df129..73358c5e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIFullTests.java @@ -22,8 +22,8 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; -import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import jakarta.ejb.EJB; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java index beb3e00c..4a51e1d6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionFullTests.java @@ -24,13 +24,13 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -101,7 +101,7 @@ public void testAsynchronousMethodWithMaxAsync3() { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/224", version = "3.0.0") @Assertion(id = "GIT:154", strategy = "ManagedScheduledExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + " The dependent stages all run with the thread context of the thread from which they were created," diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java index 793dcf0b..8729c83a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java @@ -22,13 +22,13 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -90,7 +90,7 @@ public void testAsynchronousMethodWithMaxAsync3() { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/224") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/224", version = "3.0.0") @Assertion(id = "GIT:154", strategy = "ManagedScheduledExecutorService creates a completed CompletableFuture to which async dependent stages can be chained." + " The dependent stages all run with the thread context of the thread from which they were created," diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityFullTests.java index e5b5d51c..89bf0c0b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityFullTests.java @@ -25,10 +25,11 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -66,20 +67,10 @@ protected String getServletPath() { return "SecurityServlet"; } - /* - * @testName: managedScheduledExecutorServiceAPISecurityTest - * - * @assertion_ids: CONCURRENCY:SPEC:4.3; CONCURRENCY:SPEC:50; - * - * @test_Strategy: login in a servlet with username "javajoe(in role manager)", - * then submit a task by ManagedScheduledExecutorService in which call a ejb - * that requires role manager. - * - * Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/227 - * fix: https://github.com/jakartaee/concurrency/pull/221 Can be reenabled in - * the next release of Jakarta Concurrency - */ - @Disabled + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/227", version = "3.0.0", + fix = "https://github.com/jakartaee/concurrency/pull/218", reintroduce = "3.1.0") + @Assertion(id = "SPEC:4.3 SPEC:50", strategy = "Login in a servlet with username javajoe(in role manager)," + + " then submit a task by ManagedScheduledExecutorService in which call a ejb that requires role manager.") public void managedScheduledExecutorServiceAPISecurityTest() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java index 7a023b11..fccead8f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java @@ -23,10 +23,11 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -57,20 +58,10 @@ protected String getServletPath() { return "SecurityServlet"; } - /* - * @testName: managedScheduledExecutorServiceAPISecurityTest - * - * @assertion_ids: CONCURRENCY:SPEC:4.3; CONCURRENCY:SPEC:50; - * - * @test_Strategy: login in a servlet with username "javajoe(in role manager)", - * then submit a task by ManagedScheduledExecutorService in which call a ejb - * that requires role manager. - * - * Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/227 - * fix: https://github.com/jakartaee/concurrency/pull/221 Can be reenabled in - * the next release of Jakarta Concurrency - */ - @Disabled + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/227", version = "3.0.0", + fix = "https://github.com/jakartaee/concurrency/pull/218", reintroduce = "3.1.0") + @Assertion(id = "SPEC:4.3 SPEC:50", strategy = "Login in a servlet with username javajoe(in role manager)," + + " then submit a task by ManagedScheduledExecutorService in which call a ejb that requires role manager.") public void managedScheduledExecutorServiceAPISecurityTest() { runTest(baseURL, testname); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java index 1cf1a076..0872d09b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionFullTests.java @@ -24,14 +24,14 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; -import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; +import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionBean; @@ -82,13 +82,13 @@ protected String getServletPath() { return "ManagedThreadFactoryDefinitionServlet"; } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition with all attributes configured") public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "A ManagedThreadFactoryDefinition defined on an EJB with all attributes configured enforces priority and propagates context.") public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { @@ -111,14 +111,14 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { runTest(requestURL); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "ManagedThreadFactory can be supplied to a ForkJoinPool, which manages thread context and priority as configured") public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition defined on an EJB is supplied to a ForkJoinPool" + " and uses java:comp/DefaultContextService to determine context propagation and priority.") diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java index 1d10e71e..e47ac95a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java @@ -22,13 +22,13 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.URLBuilder; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -73,13 +73,13 @@ protected String getServletPath() { return "ManagedThreadFactoryDefinitionServlet"; } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition with all attributes configured") public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "A ManagedThreadFactoryDefinition defined on an EJB with all attributes configured enforces priority and propagates context.") public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { @@ -102,7 +102,7 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { runTest(requestURL); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "ManagedThreadFactory can be supplied to a ForkJoinPool," + " which manages thread context and priority as configured") @@ -110,7 +110,7 @@ public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:156", strategy = "ManagedThreadFactoryDefinition defined on an EJB is supplied to a ForkJoinPool" + " and uses java:comp/DefaultContextService to determine context propagation and priority.") diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java index 56747644..01666295 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorFullTests.java @@ -24,12 +24,12 @@ import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -89,7 +89,7 @@ public void testDeploymentDescriptorDefinesManagedScheduledExecutor() { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:186", strategy = "Tests managed-thread-factory defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedThreadFactory() { runTest(baseURL, testname); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java index be7c0eb4..5e9dd894 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java @@ -22,12 +22,12 @@ import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; -import org.junit.jupiter.api.Disabled; import ee.jakarta.tck.concurrent.common.context.providers.IntContextProvider; import ee.jakarta.tck.concurrent.common.context.providers.StringContextProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; @@ -78,7 +78,7 @@ public void testDeploymentDescriptorDefinesManagedScheduledExecutor() { runTest(baseURL, testname); } - @Disabled("https://github.com/jakartaee/concurrency/issues/226") + @Challenge(link = "https://github.com/jakartaee/concurrency/issues/226", version = "3.0.0") @Assertion(id = "GIT:186", strategy = "Tests managed-thread-factory defined in a deployment descriptor.") public void testDeploymentDescriptorDefinesManagedThreadFactory() { runTest(baseURL, testname); From 60984e42a8bf1332dbb6d73c570b2c117634cf2e Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Wed, 23 Aug 2023 12:29:01 -0500 Subject: [PATCH 3/3] Auto generate TCK Distribution sections --- tck-dist/pom.xml | 101 +++- .../concurrency-tck-reference-guide.adoc | 148 +----- .../src/main/asciidoc/generated/.gitignore | 5 + .../tck/data/metadata/CollectMetaData.java | 481 ++++++++++++++++++ .../tck/data/metadata/package-info.java | 16 + .../concurrent/framework/junit/anno/Core.java | 46 ++ .../framework/junit/anno/Standalone.java | 42 ++ .../junit/extensions/AssertionExtension.java | 49 +- 8 files changed, 732 insertions(+), 156 deletions(-) create mode 100644 tck-dist/src/main/asciidoc/generated/.gitignore create mode 100644 tck-dist/src/main/java/ee/jakarta/tck/data/metadata/CollectMetaData.java create mode 100644 tck-dist/src/main/java/ee/jakarta/tck/data/metadata/package-info.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Core.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Standalone.java diff --git a/tck-dist/pom.xml b/tck-dist/pom.xml index 2e5671cb..ccf5101a 100644 --- a/tck-dist/pom.xml +++ b/tck-dist/pom.xml @@ -1,22 +1,22 @@ - + 4.0.0 @@ -26,8 +26,6 @@ jakarta.enterprise.concurrent-tck-dist - pom - Jakarta Concurrency TCK Distribution Jakarta Concurrency TCK Distribution @@ -38,7 +36,8 @@ repo - GNU General Public License, version 2 with the GNU Classpath Exception + GNU General Public License, version 2 with the GNU Classpath + Exception https://projects.eclipse.org/license/secondary-gpl-2.0-cp repo @@ -60,14 +59,65 @@ jakarta.enterprise.concurrent - jakarta.enterprise.concurrent.parent + jakarta.enterprise.concurrent-api ${jakarta.concurrent.tck.version} - pom + + + org.apache.maven.plugins + maven-compiler-plugin + 3.11.0 + + 17 + 17 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.6.0 + + + initialize + + properties + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + + generate-asciidoc + process-classes + + java + + + + + ee.jakarta.tck.data.metadata.CollectMetaData + + true + + ${jakarta.enterprise.concurrent:jakarta.enterprise.concurrent-tck:jar} + + ${project.basedir}/src/main/asciidoc/generated + + + + org.asciidoctor @@ -83,7 +133,7 @@ asciidoc-to-html - generate-resources + prepare-package process-asciidoc @@ -96,7 +146,7 @@ asciidoc-to-pdf - generate-resources + prepare-package process-asciidoc @@ -117,7 +167,7 @@ ${maven.adoc.skip} - + maven-assembly-plugin @@ -132,7 +182,8 @@ src/main/assembly/assembly.xml - concurrency-tck-${jakarta.concurrent.tck.version} + + concurrency-tck-${jakarta.concurrent.tck.version} diff --git a/tck-dist/src/main/asciidoc/concurrency-tck-reference-guide.adoc b/tck-dist/src/main/asciidoc/concurrency-tck-reference-guide.adoc index ba5b85bc..409962a1 100644 --- a/tck-dist/src/main/asciidoc/concurrency-tck-reference-guide.adoc +++ b/tck-dist/src/main/asciidoc/concurrency-tck-reference-guide.adoc @@ -1,7 +1,7 @@ = Jakarta Concurrency TCK Reference Guide :author: Kyle Aure :email: cu-dev@eclipse.org -:revnumber: v1.0 +:revnumber: v1.1 :toc: :sectnums: @@ -13,7 +13,6 @@ :APIEclipseSite: https://projects.eclipse.org/projects/ee4j.cu :APIGitSite: https://github.com/jakartaee/concurrency :TCKTestPlatform: Junit5 -:RuntimeTestCount: 164 :SigPluginGAV: org.netbeans.tools:sigtest-maven-plugin:1.6 == Preface @@ -182,11 +181,12 @@ Because there is flexibility regarding how a user could use Maven to configure a === Runtime tests -For the runtime test (JUnit) component of the TCK: +For the {TCKTestPlatform} runtime tests of the TCK, +the following table shows the number of tests that should pass based on platform: -* {RuntimeTestCount} tests must be passed to successfully execute the EE TCK suite +include::generated/runtime-tests.adoc[] -**Note:* This count includes the signature test +**Note:** Counts include signature test, but do not include disabled tests. == Example runner @@ -343,44 +343,9 @@ $ mvn clean test === Expected Output -Here is example output when we, as in the starter runner, run successfully: +Here is example output when the starter runner runs successfully: -[source, sh] ----- - $ mvn clean test - ... - - ------------------------------------------------------- - T E S T S - ------------------------------------------------------- - Running TestSuite - ... - ... - - Tests run: 162, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 410.985 sec - in TestSuite - - Results : - - Tests run: 162, Failures: 0, Errors: 0, Skipped: 0 - - 16:05:47,343 [INFO] - 16:05:47,344 [INFO] ------< io.openliberty.jakarta.enterprise.concurrent:tck.runner >------- - 16:05:47,345 [INFO] Building Jakarta Concurrency TCK Runner 1.0-SNAPSHOT [2/2] - 16:05:47,346 [INFO] --------------------------------[ pom ]--------------------------------- - 16:05:47,351 [INFO] - 16:05:47,351 [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tck.runner --- - 16:05:47,359 [INFO] ------------------------------------------------------------------------ - 16:05:47,380 [INFO] Reactor Summary for Jakarta Concurrency TCK Runner 1.0-SNAPSHOT: - 16:05:47,381 [INFO] - 16:05:47,382 [INFO] Jakarta Concurrency TCK Runner TCK Module .......... SUCCESS [06:55 min] - 16:05:47,383 [INFO] Jakarta Concurrency TCK Runner ..................... SUCCESS [ 0.017 s] - 16:05:47,384 [INFO] ------------------------------------------------------------------------ - 16:05:47,385 [INFO] BUILD SUCCESS - 16:05:47,385 [INFO] ------------------------------------------------------------------------ - 16:05:47,386 [INFO] Total time: 06:55 min - 16:05:47,387 [INFO] Finished at: 2022-03-30T16:05:47-05:00 - 16:05:47,387 [INFO] ------------------------------------------------------------------------ ----- +include::generated/expected-output.adoc[] == Signature Tests @@ -433,92 +398,7 @@ As mentioned in the prerequisite section the signature file formats across the v The the Signature Test plugin will log output to `System.out`. Whereas, the Signature Test framework we use to set up the test will log using `java.util.logging` so you may see these logs output to two separate locations depending on your application server. -[source, txt] ----- -[3/30/22, 16:01:03:250 CDT] 00000045 TestServlet I --> testSignatures -[3/30/22, 16:01:12:618 CDT] 00000045 SystemOut O ********** BEGIN PACKAGE LEVEL SIGNATURE VALIDATION ********** -[3/30/22, 16:01:12:618 CDT] 00000045 SystemOut O ********** BEGIN VALIDATE PACKAGE 'jakarta.enterprise.concurrent' ********** -[3/30/22, 16:01:12:618 CDT] 00000045 SystemOut O ********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES **** -[3/30/22, 16:01:12:619 CDT] 00000045 SystemOut O Static mode supports checks of static constants values -[3/30/22, 16:01:12:622 CDT] 00000045 SystemOut O Setting static mode flag to allow constant checking. -... -[3/30/22, 16:01:13:392 CDT] 00000045 SystemOut O ********** Status Report 'jakarta.enterprise.concurrent' ********** -[3/30/22, 16:01:13:392 CDT] 00000045 SystemOut O SignatureTest report -Base version: 3.0.0-SNAPSHOT -Tested version: -Check mode: src [throws normalized] -Constant checking: on - -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future can't be resolved - -[3/30/22, 16:01:13:392 CDT] 00000045 SystemOut O ********** Package 'jakarta.enterprise.concurrent' - PASSED (STATIC MODE) ********** -[3/30/22, 16:01:13:393 CDT] 00000045 SystemOut O ********** VALIDATE IN REFLECTIVE MODE **** -[3/30/22, 16:01:13:393 CDT] 00000045 SystemOut O Reflective mode supports verification within containers (ie ejb, servlet, etc) -[3/30/22, 16:01:13:394 CDT] 00000045 SystemOut O Not Setting static mode flag to allow constant checking. -[3/30/22, 16:01:13:404 CDT] 00000045 SystemOut O Calling: com.sun.tdk.signaturetest.SignatureTest() with following args: -... -[3/30/22, 16:01:13:892 CDT] 00000045 SystemOut O ********** Status Report 'jakarta.enterprise.concurrent' ********** -[3/30/22, 16:01:13:892 CDT] 00000045 SystemOut O SignatureTest report -Base version: 3.0.0-SNAPSHOT -Tested version: -Check mode: src [throws normalized] -Constant checking: on - -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future can't be resolved - -[3/30/22, 16:01:13:893 CDT] 00000045 SystemOut O ********** Package 'jakarta.enterprise.concurrent' - PASSED (REFLECTION MODE) ********** -[3/30/22, 16:01:13:893 CDT] 00000045 SystemOut O ********** END VALIDATE PACKAGE 'jakarta.enterprise.concurrent' ********** -[3/30/22, 16:01:13:893 CDT] 00000045 SystemOut O ********** BEGIN VALIDATE PACKAGE 'jakarta.enterprise.concurrent.spi' ********** -[3/30/22, 16:01:13:893 CDT] 00000045 SystemOut O ********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES **** -[3/30/22, 16:01:13:893 CDT] 00000045 SystemOut O Static mode supports checks of static constants values -[3/30/22, 16:01:13:894 CDT] 00000045 SystemOut O Setting static mode flag to allow constant checking. -[3/30/22, 16:01:13:909 CDT] 00000045 SystemOut O Calling: com.sun.tdk.signaturetest.SignatureTest() with following args: -... -[3/30/22, 16:01:14:292 CDT] 00000045 SystemOut O ********** Status Report 'jakarta.enterprise.concurrent.spi' ********** -[3/30/22, 16:01:14:293 CDT] 00000045 SystemOut O SignatureTest report -Base version: 3.0.0-SNAPSHOT -Tested version: -Check mode: src [throws normalized] -Constant checking: on - -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future can't be resolved - -[3/30/22, 16:01:14:293 CDT] 00000045 SystemOut O ********** Package 'jakarta.enterprise.concurrent.spi' - PASSED (STATIC MODE) ********** -[3/30/22, 16:01:14:293 CDT] 00000045 SystemOut O ********** VALIDATE IN REFLECTIVE MODE **** -[3/30/22, 16:01:14:293 CDT] 00000045 SystemOut O Reflective mode supports verification within containers (ie ejb, servlet, etc) -[3/30/22, 16:01:14:294 CDT] 00000045 SystemOut O Not Setting static mode flag to allow constant checking. -[3/30/22, 16:01:14:301 CDT] 00000045 SystemOut O Calling: com.sun.tdk.signaturetest.SignatureTest() with following args: -... -[3/30/22, 16:01:14:616 CDT] 00000045 SystemOut O ********** Status Report 'jakarta.enterprise.concurrent.spi' ********** -[3/30/22, 16:01:14:616 CDT] 00000045 SystemOut O SignatureTest report -Base version: 3.0.0-SNAPSHOT -Tested version: -Check mode: src [throws normalized] -Constant checking: on - -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future<{%%0}> can't be resolved -Warning: The return type java.util.concurrent.Future can't be resolved - -[3/30/22, 16:01:14:617 CDT] 00000045 SystemOut O ********** Package 'jakarta.enterprise.concurrent.spi' - PASSED (REFLECTION MODE) ********** -[3/30/22, 16:01:14:617 CDT] 00000045 SystemOut O ********** END VALIDATE PACKAGE 'jakarta.enterprise.concurrent.spi' ********** -[3/30/22, 16:01:14:618 CDT] 00000045 ConcurrencySigTest I -****************************************************** -All package signatures passed. - Passed packages listed below: - jakarta.enterprise.concurrent(static mode) - jakarta.enterprise.concurrent(reflection mode) - jakarta.enterprise.concurrent.spi(static mode) - jakarta.enterprise.concurrent.spi(reflection mode) -****************************************************** -[3/30/22, 16:01:14:620 CDT] 00000045 TestServlet I <-- testSignatures ----- +include::generated/expected-sig-output.adoc[] == TCK Challenges/Appeals Process @@ -536,7 +416,14 @@ The challenge process is defined within the [underline]#Challenges# section with Challenges will be tracked via the {APIGitSite}/issues[issues] of the {APILongName} Specification repository. -As a shortcut through the challenge process mentioned in the *Jakarta EE TCK Process 1.1* you can click {APIGitSite}/issues/new?labels=challenge[here], though it is recommended that you read through the challenge process to understand it in detail. +The challenge process mentioned in the *Jakarta EE TCK Process 1.1* can be started by clicking {APIGitSite}/issues/new?assignees=&labels=challenge&projects=&template=tck-challenge.yml&title=TCK+Challenge[here], +it is recommended that you read through the challenge process to understand it in detail. + +=== Successful Challenges + +The following tests are exempt from TCK testing due to challenges: + +include::generated/successful-challenges.adoc[] == Certification of Compatibility @@ -553,7 +440,8 @@ The certification of compatibility process is defined within the [underline]#Cer Certifications will be tracked via the {APIGitSite}/issues[issues] of the {APILongName} Specification repository. -As a shortcut through the certification of compatibility process mentioned in the *Jakarta EE TCK Process 1.1* you can click {APIGitSite}/issues/new?labels=certification[here], though it is recommended that you read through the certification process to understand it in detail. +The certification of compatibility process mentioned in the *Jakarta EE TCK Process 1.1* can be started by clicking {APIGitSite}/issues/new?assignees=&labels=certification&projects=&template=certification.yml&title=Certification[here], +it is recommended that you read through the certification process to understand it in detail. == Rules for {APILongName} Products diff --git a/tck-dist/src/main/asciidoc/generated/.gitignore b/tck-dist/src/main/asciidoc/generated/.gitignore new file mode 100644 index 00000000..c7694c03 --- /dev/null +++ b/tck-dist/src/main/asciidoc/generated/.gitignore @@ -0,0 +1,5 @@ +runtime-tests.adoc +successful-challenges.adoc +expected-sig-output.adoc +expected-output.adoc +test-properties.adoc diff --git a/tck-dist/src/main/java/ee/jakarta/tck/data/metadata/CollectMetaData.java b/tck-dist/src/main/java/ee/jakarta/tck/data/metadata/CollectMetaData.java new file mode 100644 index 00000000..85b14e5d --- /dev/null +++ b/tck-dist/src/main/java/ee/jakarta/tck/data/metadata/CollectMetaData.java @@ -0,0 +1,481 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.data.metadata; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarInputStream; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Tags; +import org.junit.jupiter.api.Test; +import org.junit.platform.commons.support.AnnotationSupport; +import org.junit.platform.commons.support.HierarchyTraversalMode; + +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; + +/** + * This is a utility class that will analyze the TCK and generate documentation for the following information: + * 1. The name of tests that are disabled (due to challenges) + * 2. The number of tests that need to pass for certification + * 3. Expected JUnit output + * 4. Expected Signature test output + * + * This will be run automatically each time the tck-dist module is built. + * Meaning that we don't need to update our doc each time we add/remove/disable a test. + * + * Files are output to: + * ${project.basedir}/src/main/asciidoc/generated/ + * + * File names are: + * expected-output.adoc + * expected-sig-output.adoc + * runtime-tests.adoc + * successful-challenges.adoc + */ +public final class CollectMetaData { + // Constants + private static final String FRAMEWORK_PACKAGE_PREFIX = "ee/jakarta/tck/concurrent/framework"; + + private static final String RUNTIME_TESTS_FILE = "runtime-tests.adoc"; + private static final String CHALLENGED_TESTS_FILE = "successful-challenges.adoc"; + private static final String SIG_OUTPUT_FILE = "expected-sig-output.adoc"; + private static final String EXPECTED_OUTPUT_FILE = "expected-output.adoc"; + private static final String TEST_PROPERTIES_FILE = "test-properties.adoc"; + + // Data holders + private static boolean debug = false; + private static List apiPackages; + private static List> testClasses; + private static File adocGeneratedLocation; + + private CollectMetaData() { + //Do nothing + } + + /** + * Main method, expects three inputs: + * 0. boolean - enable debug + * 1. path to TCK jar - used to collect metadata + * 2. output directory - where generated pages should be output + * + * @param args - the arguments needed to run + * @throws Exception - thrown if any documentation cannot be generated + */ + public static void main(final String[] args) throws Exception { + if (args.length != 3) { + throw new RuntimeException("CollectMetaData expected exactly 3 arguments [debug, path-to-tck, output-file-location]"); + } + + //Load arguments + debug = Boolean.valueOf(args[0]); + testClasses = getClassNames(args[1]); + adocGeneratedLocation = new File(args[2]); + + //Check asciidoctor generated folder exists + if (!adocGeneratedLocation.exists()) { + adocGeneratedLocation.mkdirs(); + } + + //Collect test metadata + final List testMetaData = collectMetaData(); + + //Write the generated asciidoc files + writeTestCounts(testMetaData, new File(adocGeneratedLocation, RUNTIME_TESTS_FILE)); + writeSuccessfulChallenges(testMetaData, new File(adocGeneratedLocation, CHALLENGED_TESTS_FILE)); + writeSigOutput(new File(adocGeneratedLocation, SIG_OUTPUT_FILE)); + writeOutput(testMetaData, new File(adocGeneratedLocation, EXPECTED_OUTPUT_FILE)); + writeGitIgnore(new File(adocGeneratedLocation, ".gitignore"), RUNTIME_TESTS_FILE, CHALLENGED_TESTS_FILE, SIG_OUTPUT_FILE, EXPECTED_OUTPUT_FILE, TEST_PROPERTIES_FILE); + } + + /** + * Writes generated files to a .gitignore file. + * + * @param outputLocation - the output file + * @param ignoredFiles - files to ignore + * @throws IOException - exception if we cannot write to this location + */ + private static void writeGitIgnore(final File outputLocation, final String... ignoredFiles) throws IOException { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputLocation))) { + for (String ignoredFile : ignoredFiles) { + writer.write(ignoredFile + System.lineSeparator()); + } + } + } + + /** + * Writes example output to the generated adoc folder. + * + * @param testMetaData - the test metadata we previously collected + * @param outputLocation - the output file + * @throws IOException - exception if we cannot write to this location + */ + private static void writeOutput(final List testMetaData, final File outputLocation) throws IOException { + String output = + """ + [source, txt] + ---- + $ mvn clean test + ... + [INFO] --- maven-surefire-plugin:3.0.0-M7:test (default-test) @ tck.runner --- + [INFO] Using auto detected provider org.apache.maven.surefire.junitplatform.JUnitPlatformProvider + [INFO] + [INFO] ------------------------------------------------------- + [INFO] T E S T S + [INFO] ------------------------------------------------------- + $indiviualTests + [INFO] Results: + [INFO] + $totalTests + [INFO] + [INFO] ------------------------------------------------------- + [INFO] BUILD SUCCESS + [INFO] ------------------------------------------------------- + [INFO] Total time: xx.xxx s + [INFO] Finished at: yyyy-mm-ddThh:mm:ss.mmmm + [INFO] ------------------------------------------------------- + ----""" + .replaceAll("\\$indiviualTests", getIndividualTests(testMetaData)) + .replaceAll("\\$totalTests", getTotalTests(testMetaData)); + + try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputLocation))) { + writer.write(output.trim() + System.lineSeparator()); + } + } + + /** + * Collect all distinct test classes, count the number of test classes that should be run, and return to the output. + * + * @param testMetaData + * @return String output + */ + private static String getIndividualTests(final List testMetaData) { + StringBuffer output = new StringBuffer(); + final String nl = System.lineSeparator(); + for (String testClass : testMetaData.stream().map(metaData -> metaData.testClass).distinct().collect(Collectors.toList())) { + List theseTests = testMetaData.stream().filter(metaData -> metaData.testClass == testClass).collect(Collectors.toList()); + long testCount = theseTests.stream().filter(metaData -> !metaData.isDisabled).count(); + long disabledCount = theseTests.stream().filter(metaData -> metaData.isDisabled).count(); + output.append("[INFO] Running " + testClass + nl); + + if (disabledCount > 0) { + output.append("[WARNING] Tests run: " + testCount + ", Failures: 0, Errors: 0, Skipped: " + disabledCount + ","); + } else { + output.append("[INFO] Tests run: " + testCount + ", Failures: 0, Errors: 0, Skipped: " + disabledCount + ","); + } + + output.append("Time elapsed: y.yy s - in " + testClass + nl); + output.append("[INFO]" + nl); + } + return output.toString().trim(); + } + + /** + * Collect the total number of tests, and return the output. + * + * @param testMetaData + * @return String output + */ + private static String getTotalTests(final List testMetaData) { + long totalTestCount = testMetaData.stream().filter(metaData -> !metaData.isDisabled).count(); + long totalDisabledCount = testMetaData.stream().filter(metaData -> metaData.isDisabled).count(); + + if (totalDisabledCount > 0) { + return "[WARNING] Tests run: " + totalTestCount + ", Failures: 0, Errors: 0, Skipped: " + totalDisabledCount; + } else { + return "[INFO] Tests run: " + totalTestCount + ", Failures: 0, Errors: 0, Skipped: " + totalDisabledCount; + } + + } + + /** + * Writes example signature test output to the generated adoc folder. + * + * @param outputLocation - the output file + * @throws IOException - exception if we cannot write to this location + */ + private static void writeSigOutput(final File outputLocation) throws IOException { + String output = + """ + [source, txt] + ---- + ****************************************************** + All package signatures passed. + Passed packages listed below: + $packages + ****************************************************** + ----""".replaceAll("\\$packages", getPackages()); + + try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputLocation))) { + writer.write(output.trim() + System.lineSeparator()); + } + } + + /** + * Collect API packages and return the output. + * + * @return String output + */ + private static String getPackages() { + String output = ""; + for (String apiPackage : apiPackages) { + output += + """ + $package(static mode) + $package(reflection mode) + """.indent(8).replaceAll("\\$package", apiPackage); + } + return output; + } + + /** + * Writes successful challenges to the generated adoc folder. + * + * @param testMetaData - the test metadata we previously collected + * @param outputLocation - the output file + * @throws IOException - exception if we cannot write to this location + */ + private static void writeSuccessfulChallenges(final List testMetaData, final File outputLocation) throws IOException { + String output = + """ + |=== + |Class |Method |Link |Version + $disabledTests + |===""".replaceAll("\\$disabledTests", getDisabledTests(testMetaData)); + + try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputLocation))) { + writer.write(output.trim() + System.lineSeparator()); + } + + } + + private static String getDisabledTests(final List testMetaData) { + List disabledTests = testMetaData.stream().filter(TestMetaData::isDisabled).toList(); + String output = ""; + for (TestMetaData disabledTest : disabledTests) { + output += + """ + + |%s |%s |%s |%s + """.formatted(disabledTest.testClass.substring(disabledTest.testClass.lastIndexOf('.') + 1), + disabledTest.testName, disabledTest.challengeIssue, disabledTest.challengeVersion); + } + return output; + } + + /** + * Writes expected test counts output to the generated adoc folder. + * + * @param testMetaData - the test metadata we previously collected + * @param outputLocation - the output file + * @throws IOException - exception if we cannot write to this location + */ + private static void writeTestCounts(final List testMetaData, final File outputLocation) throws IOException { + String output = + """ + |=== + |standalone |core |web |full + + |%d |%d |%d |%d + + |===""".formatted(getTestCounts(testMetaData)); + try (BufferedWriter writer = new BufferedWriter(new FileWriter(outputLocation))) { + writer.write(output.trim() + System.lineSeparator()); + } + } + + private static Object[] getTestCounts(final List testMetaData) { + List runnableTestMetaData = testMetaData.stream().filter(TestMetaData::isRunnable).collect(Collectors.toList()); + + List results = new ArrayList<>(); + + results.add(runnableTestMetaData.stream().filter(TestMetaData::isStandalone).count()); + results.add(runnableTestMetaData.stream().filter(TestMetaData::isCore).count()); + results.add(runnableTestMetaData.stream().filter(TestMetaData::isWeb).count()); + results.add(runnableTestMetaData.stream().filter(TestMetaData::isFull).count()); + + return results.toArray(); + } + + /** + * Inspects each class for methods and annotations and constructs a metadata object. + * Collects all metadata objects and returns them as a list. + * + * @return list of metadata for each test + */ + private static List collectMetaData() { + return testClasses.stream() + .flatMap(clazz -> AnnotationSupport.findAnnotatedMethods(clazz, Test.class, HierarchyTraversalMode.TOP_DOWN).stream()) + .map(method -> { + boolean isDisabled = method.isAnnotationPresent(Challenge.class); + TestMetaData metaData = new TestMetaData( + method.getDeclaringClass().getCanonicalName(), + method.getName(), + method.getAnnotation(Assertion.class).strategy(), + isDisabled, + isDisabled ? method.getAnnotation(Challenge.class).link() : "", + isDisabled ? method.getAnnotation(Challenge.class).version() : "", + findTags(method.getDeclaringClass()) + ); + return metaData; + }).collect(Collectors.toList()); + } + + /** + * Finds the tag(s) on a test class which could be a {@Tag} or {@Tags} annotation. + * + * @param clazz - the test class + * @return - a list of tag values on this class + */ + private static List findTags(final Class clazz) { + return Arrays.stream(clazz.getAnnotations()) + // Get 1st level nested annotations + .flatMap(anno -> Stream.concat(Arrays.stream(anno.annotationType().getAnnotations()), Stream.of(anno))) + // Get all tag annotations + .flatMap(anno -> { + if (anno instanceof Tag) + return Stream.of((Tag) anno); + if (anno instanceof Tags) + return Arrays.stream(((Tags) anno).value()); + return Stream.empty(); + }) + .map(anno -> anno.value()) + .collect(Collectors.toList()); + } + + /** + * Finds and loads all test classes inside of a TCK jar. + * + * @param jarLocation - Path to the TCK jar + * @return List of test classes + * @throws Exception - throws exception if jar cannot be located, or classes cannot be loaded. + */ + private static List> getClassNames(final String jarLocation) throws Exception { + ArrayList> classList = new ArrayList<>(); + + try (JarInputStream jar = new JarInputStream(new FileInputStream(jarLocation));) { + for (JarEntry entry = jar.getNextJarEntry(); entry != null; entry = jar.getNextJarEntry()) { + if (isTestClass(entry.getName())) { + debug("Attempting to load test class: " + entry.getName()); + classList.add(getClass(entry.getName().replaceAll("/", "\\."))); + } else if (entry.getName().contains("sig-test-pkg-list.txt")) { + debug("Attempting to read package list" + entry.getName()); + apiPackages = new String(jar.readAllBytes(), StandardCharsets.UTF_8).lines() + .filter(line -> !line.contains("#")) + .filter(line -> !line.isBlank()) + .collect(Collectors.toList()); + debug("apiPackages populated with: " + apiPackages.toString()); + } + jar.closeEntry(); + } + } + + return classList; + } + + /** + * Determines if a jar resource is a test class or not. + * + * @param entryName - The fully qualified resource name + * @return true - if resource is a test class, false otherwise + */ + private static boolean isTestClass(final String entryName) { + if (!entryName.endsWith(".class")) + return false; + if (entryName.contains(FRAMEWORK_PACKAGE_PREFIX)) + return false; + if (!entryName.substring(entryName.lastIndexOf("/"), entryName.lastIndexOf(".")).toLowerCase().contains("tests")) + return false; + + return true; + } + + /** + * Loads a given class and returns it. + * + * @param className - The name of the class with or without the .class suffix + * @return The class object + */ + private static Class getClass(final String className) { + try { + return Class.forName(className.substring(0, className.lastIndexOf('.'))); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + } + + /** + * Prints message if debugging is enabled. + * + * @param message - The message to print + */ + private static void debug(final String message) { + if (debug) + System.out.println(message); + } + + /** + * A data structure that represents data associated with test methods. + * + * @param testClass - Name of the test class. + * @param testName - Name of the test method. + * @param assertion - The test strategy. + * @param isDisabled - True, if the test is disabled, false otherwise. + * @param challengeIssue - The issue number if the test is challenged. + * @param challengeVersion - The spec version if the test is challneged. + * @param tags - A list of all the tags on the test class. + */ + public record TestMetaData(String testClass, String testName, String assertion, + boolean isDisabled, String challengeIssue, String challengeVersion, List tags) { + + boolean isStandalone() { + return tags.contains("standalone"); + } + + boolean isCore() { + return tags.contains("core"); + } + + boolean isWeb() { + return tags.contains("web"); + } + + boolean isFull() { + return tags.contains("full"); + } + + boolean isRunnable() { + return !isDisabled; + } + + @Override + public String toString() { + return "TestMetaData [testName=" + testName + ", assertion=" + assertion + ", isDisabled=" + isDisabled + + ", challengeIssue=" + challengeIssue + ", challengeVersion" + challengeVersion + ", tags=" + tags + "]"; + } + } +} diff --git a/tck-dist/src/main/java/ee/jakarta/tck/data/metadata/package-info.java b/tck-dist/src/main/java/ee/jakarta/tck/data/metadata/package-info.java new file mode 100644 index 00000000..e543de7a --- /dev/null +++ b/tck-dist/src/main/java/ee/jakarta/tck/data/metadata/package-info.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.data.metadata; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Core.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Core.java new file mode 100644 index 00000000..20d585f9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Core.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.concurrent.framework.junit.anno; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.extension.ExtendWith; + +import ee.jakarta.tck.concurrent.framework.junit.extensions.AssertionExtension; + +/** + *

These are test classes that REQUIRE core profile to be executed. For these + * tests to run they must deploy an application to a Jakarta EE server using the + * Arquillian {@code @Deployment} annotation.

+ * + *

At runtime the Arquillian REST protocol must be used for communication with + * the Jakarta EE server.

+ * + * NOTE: The Jakarta Concurrency project is part of Web Profile, this annotation is here for completeness. + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Tag("core") +@Tag("web") +@Tag("full") +@ExtendWith({ ArquillianExtension.class, AssertionExtension.class }) +public @interface Core { +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Standalone.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Standalone.java new file mode 100644 index 00000000..17bcff3c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Standalone.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2023 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.concurrent.framework.junit.anno; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.jboss.arquillian.junit5.ArquillianExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.extension.ExtendWith; + +import ee.jakarta.tck.concurrent.framework.junit.extensions.AssertionExtension; + +/** + *

These are test classes that DO NOT depend on any Jakarta EE profile technologies.

+ * + * Note: Concurrency TCK does not currently support running in standalone mode, this annotation is here for completeness. + */ +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Tag("standalone") +@Tag("core") +@Tag("web") +@Tag("full") +@ExtendWith({ ArquillianExtension.class, AssertionExtension.class }) +public @interface Standalone { +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/AssertionExtension.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/AssertionExtension.java index d23018fd..956c7ae5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/AssertionExtension.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/AssertionExtension.java @@ -15,22 +15,69 @@ */ package ee.jakarta.tck.concurrent.framework.junit.extensions; +import java.lang.reflect.Method; +import java.util.Optional; import java.util.logging.Logger; import java.util.stream.Stream; import org.junit.jupiter.api.extension.AfterTestExecutionCallback; import org.junit.jupiter.api.extension.BeforeTestExecutionCallback; import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestWatcher; +import ee.jakarta.tck.concurrent.framework.junit.anno.Assertion; +import ee.jakarta.tck.concurrent.framework.junit.anno.Challenge; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; /** * Logs before and after test execution, and injects the name of the test into * the @TestName field. */ -public class AssertionExtension implements BeforeTestExecutionCallback, AfterTestExecutionCallback { +public class AssertionExtension implements TestWatcher, BeforeTestExecutionCallback, AfterTestExecutionCallback { private static final Logger log = Logger.getLogger(AssertionExtension.class.getCanonicalName()); + private static final String nl = System.lineSeparator(); + + @Override + public void testFailed(final ExtensionContext context, final Throwable cause) { + Method testMethod = context.getRequiredTestMethod(); + Assertion instance = testMethod.getAnnotation(Assertion.class); + if (instance != null) { + log.warning(testMethod.getName() + " failed " + nl + + " @Assertion.ids: " + instance.id() + nl + + " @Assertion.strategy: " + instance.strategy() + nl + + " Throwable.cause: " + cause.getLocalizedMessage()); + } + } + + @Override + public void testAborted(final ExtensionContext context, final Throwable cause) { + Method testMethod = context.getRequiredTestMethod(); + Assertion instance = testMethod.getAnnotation(Assertion.class); + if (instance != null) { + log.warning(testMethod.getName() + " was aborted " + nl + + " @Assertion.ids: " + instance.id() + nl + + " @Assertion.strategy: " + instance.strategy() + nl + + " Throwable.cause: " + cause.getLocalizedMessage()); + } + } + + @Override + public void testDisabled(final ExtensionContext context, final Optional reason) { + Method testMethod = context.getRequiredTestMethod(); + Assertion instance = testMethod.getAnnotation(Assertion.class); + boolean isChallenge = testMethod.isAnnotationPresent(Challenge.class); + Challenge challenge = isChallenge ? testMethod.getAnnotation(Challenge.class) : null; + if (instance != null) { + log.warning(testMethod.getName() + " is disabled" + nl + + " @Assertion.id: #" + instance.id() + nl + + " @Assertion.strategy: " + instance.strategy() + nl + + (isChallenge + ? " @Challenge.issue:" + challenge.link() + nl + + " @Challenge.version: " + challenge.version() + : " @Disabled.reason:" + reason.get())); + } + } @Override public void beforeTestExecution(final ExtensionContext context) throws Exception {