From f9b41e3947cbc63a83713e0f1f8f8496bed6c8cf Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 09:04:38 -0500 Subject: [PATCH 01/14] Fix API formatting --- api/etc/config/checkstyle.xml | 214 +++++++++--------- api/pom.xml | 20 -- .../enterprise/concurrent/CronTrigger.java | 65 +++++- .../concurrent/ManagedExecutors.java | 3 + .../enterprise/concurrent/Schedule.java | 1 - pom.xml | 62 +++-- tck-dist/src/main/starter/logging.properties | 2 +- 7 files changed, 218 insertions(+), 149 deletions(-) diff --git a/api/etc/config/checkstyle.xml b/api/etc/config/checkstyle.xml index d2fa540f..89ad7db8 100755 --- a/api/etc/config/checkstyle.xml +++ b/api/etc/config/checkstyle.xml @@ -1,7 +1,7 @@ - + + + + + + + + + + + + + + + + + @@ -64,74 +82,50 @@ - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -140,81 +134,51 @@ - - - - - + + - - - - - - - - - - - - - - - + + - - - - - - - - + - - - - - - + + + + + + + + + + + + + + + + + - - - - - - - + @@ -225,14 +189,46 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/api/pom.xml b/api/pom.xml index 516f164a..36d548f0 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -236,26 +236,6 @@ Use is subject to - - org.apache.maven.plugins - maven-checkstyle-plugin - 3.3.0 - - 17 - ${project.build.directory}/checkstyle - ${project.build.directory}/checkstyle/checkstyle-result.xml - etc/config/checkstyle.xml - **/module-info.java - - - - - checkstyle - - - - - maven-surefire-plugin 3.1.2 diff --git a/api/src/main/java/jakarta/enterprise/concurrent/CronTrigger.java b/api/src/main/java/jakarta/enterprise/concurrent/CronTrigger.java index c7621a49..17f6574f 100644 --- a/api/src/main/java/jakarta/enterprise/concurrent/CronTrigger.java +++ b/api/src/main/java/jakarta/enterprise/concurrent/CronTrigger.java @@ -406,6 +406,11 @@ public String toString() { /** * Utility method for repeated logic in toString. + * + * @param s The string builder + * @param label The cron expression + * @param list Cron expression as list + * @param max Max value of cron expression */ private void toStringBuilder(final StringBuilder s, final String label, final int[] list, final int max) { if (list.length == max) { @@ -482,6 +487,13 @@ protected ZonedDateTime next(final ZonedDateTime from) { /** * Advance to next day of month. + * + * @param d day + * @param l ?? + * @param m month + * @param year year + * @param time Date/Time + * @return ZonedDateTime for next month */ private ZonedDateTime nextDayOfMonth(final int d, final int l, final int m, final int year, final ZonedDateTime time) { @@ -498,6 +510,15 @@ private ZonedDateTime nextDayOfMonth(final int d, final int l, final int m, /** * Advance to next hour. + * + * @param h hour + * @param d day + * @param l ?? + * @param dayOfMonth day of month + * @param m minute + * @param year year + * @param time Date/Time + * @return ZonedDateTime for next hour */ private ZonedDateTime nextHour(final int h, final int d, final int l, final int dayOfMonth, final int m, final int year, final ZonedDateTime time) { @@ -521,6 +542,16 @@ private ZonedDateTime nextHour(final int h, final int d, final int l, final int /** * Advance to next minute. + * + * @param min minute + * @param h hour + * @param d day + * @param l ?? + * @param dayOfMonth day of month + * @param m minute + * @param year year + * @param time Date/Time + * @return ZonedDateTime for next second */ private ZonedDateTime nextMinute(final int min, final int h, final int d, final int l, final int dayOfMonth, final int m, final int year, final ZonedDateTime time) { @@ -533,9 +564,17 @@ private ZonedDateTime nextMinute(final int min, final int h, final int d, final /** * Advance to next month. + * + * @param month the month + * @param year the year + * @return ZonedDateTime for next month */ private ZonedDateTime nextMonth(final int month, final int year) { - int dayOfMonth, lastDayOfMonth, cycles = 0, m = month, y = year; + int dayOfMonth; + int lastDayOfMonth; + int cycles = 0; + int m = month; + int y = year; do { if (++m >= months.length) { m = 0; @@ -558,6 +597,17 @@ private ZonedDateTime nextMonth(final int month, final int year) { /** * Advance to next second. + * + * @param s second + * @param min minute + * @param h hour + * @param d day + * @param l ?? + * @param dayOfMonth day of month + * @param m month + * @param year year + * @param time Date/Time + * @return ZonedDateTime for next second */ private ZonedDateTime nextSecond(final int s, final int min, final int h, final int d, final int l, final int dayOfMonth, @@ -602,7 +652,7 @@ private int[] parse(final String type, final int min, final int max, final int[] /** * Validate that the supplied list values are within the allowed range for the cron field type. * - * @param type cron field type, such as months or hours. + * @param name cron field type, such as months or hours. * @param min minimum allowed normal value * @param max maximum allowed normal value * @param maxExt maximum allowed special value (L or SUN#L), or max if no special values allowed for this field. @@ -664,6 +714,9 @@ private int[] parse(final String name, final int min, final int max, final int m /** * Convert dayOfMonth value to 1-31, or negative for days from the end of the month * For example, L is the last day (-1) and 2L is the second to last day (-2). + * @param day name of day of month + * @return integer representation of day of month + * @throws IllegalArgumentException */ private static int parseDayOfMonth(final String day) throws IllegalArgumentException { try { @@ -688,6 +741,10 @@ private static int parseDayOfMonth(final String day) throws IllegalArgumentExcep /** * Convert dayOfWeek value to 1-49 where first 7 are standard week days, * next 35 are ordinal 1st-5th of each day, and final 7 are ordinal last for each day. + * + * @param dayName name of day of the week + * @return integer representation of day of week + * @throws IllegalArgumentException */ private static int parseDayOfWeek(final String dayName) throws IllegalArgumentException { String day = dayName; @@ -718,6 +775,10 @@ private static int parseDayOfWeek(final String dayName) throws IllegalArgumentEx /** * Convert month value to 1-12. + * + * @param monthName name of month (January) + * @return integer representation of month + * @throws IllegalArgumentException */ private static int parseMonth(final String monthName) throws IllegalArgumentException { String month = monthName; diff --git a/api/src/main/java/jakarta/enterprise/concurrent/ManagedExecutors.java b/api/src/main/java/jakarta/enterprise/concurrent/ManagedExecutors.java index 91de8450..81fec606 100644 --- a/api/src/main/java/jakarta/enterprise/concurrent/ManagedExecutors.java +++ b/api/src/main/java/jakarta/enterprise/concurrent/ManagedExecutors.java @@ -33,6 +33,9 @@ public final class ManagedExecutors { private ManagedExecutors() { }; + /** + * Error message for null tasks. + */ static final String NULL_TASK_ERROR_MSG = "Task cannot be null"; /** diff --git a/api/src/main/java/jakarta/enterprise/concurrent/Schedule.java b/api/src/main/java/jakarta/enterprise/concurrent/Schedule.java index accd587c..39cb199f 100644 --- a/api/src/main/java/jakarta/enterprise/concurrent/Schedule.java +++ b/api/src/main/java/jakarta/enterprise/concurrent/Schedule.java @@ -23,7 +23,6 @@ import java.lang.annotation.Target; import java.time.DayOfWeek; import java.time.Month; -import java.util.concurrent.TimeUnit; /** *

Defines schedules for diff --git a/pom.xml b/pom.xml index 23c66f8c..8c5b561f 100644 --- a/pom.xml +++ b/pom.xml @@ -1,20 +1,18 @@ 4.0.0 @@ -56,7 +54,9 @@ api + specification tck + tck-dist @@ -69,6 +69,10 @@ UTF-8 UTF-8 17 + + 3.3.0 + 10.12.0 + 5.9.3 @@ -130,7 +134,6 @@ org.apache.maven.plugins maven-enforcer-plugin - 3.3.0 enforce-maven @@ -147,6 +150,33 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven.checkstyle.plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + + verify-style + process-classes + + check + + + + + **/module-info.java,${checkstyle.excludes} + true + true + api/etc/config/checkstyle.xml + + diff --git a/tck-dist/src/main/starter/logging.properties b/tck-dist/src/main/starter/logging.properties index 891082e1..587a73c3 100644 --- a/tck-dist/src/main/starter/logging.properties +++ b/tck-dist/src/main/starter/logging.properties @@ -37,4 +37,4 @@ java.util.logging.FileHandler.level=CONFIG # Console Logging java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter -java.util.logging.ConsoleHandler.level=WARNING \ No newline at end of file +java.util.logging.ConsoleHandler.level=WARNING From 5c7d53f235a26cb34b1f4435573973c462575f86 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 09:11:04 -0500 Subject: [PATCH 02/14] tck tabs to spaces --- .../ContextService/ContextServiceTests.java | 7 +- .../api/LastExecution/LastExecutionTests.java | 201 ++- .../api/LastExecution/LogicDrivenTrigger.java | 223 ++-- .../ManagedExecutorsTests.java | 29 +- .../ManagedScheduledExecutorServiceTests.java | 13 +- .../api/ManagedTask/ManagedTaskTests.java | 109 +- .../ManagedTaskListenerTests.java | 267 ++-- .../RunnableTaskWithException.java | 16 +- .../ManagedThreadFactoryTests.java | 70 +- .../SkippedExceptionTests.java | 115 +- .../concurrent/api/Trigger/TriggerTests.java | 12 +- .../context/providers/IntContextProvider.java | 3 +- .../context/providers/IntContextRestorer.java | 5 +- .../context/providers/IntContextSnapshot.java | 3 +- .../providers/StringContextProvider.java | 3 +- .../providers/StringContextRestorer.java | 5 +- .../providers/StringContextSnapshot.java | 3 +- .../common/counter/CounterCallableTask.java | 26 +- .../common/counter/CounterInterface.java | 6 +- .../common/counter/CounterRunnableTask.java | 40 +- .../common/counter/CounterSingleton.java | 20 +- .../common/fixed/counter/StaticCounter.java | 10 +- .../managed/task/listener/ListenerEvent.java | 2 +- .../listener/ManagedTaskListenerImpl.java | 68 +- .../task/listener/RunnableTaskWithStatus.java | 42 +- .../common/signature/ApiCheckDriver.java | 154 +-- .../ConcurrencySignatureTestRunner.java | 606 +++++---- .../common/signature/PackageList.java | 638 ++++----- .../concurrent/common/signature/SigTest.java | 664 +++++----- .../common/signature/SigTestData.java | 70 +- .../common/signature/SigTestDriver.java | 406 +++--- .../common/signature/SigTestEE.java | 710 +++++----- .../common/signature/SigTestResult.java | 138 +- .../common/signature/SignatureTestDriver.java | 1174 ++++++++--------- .../signature/SignatureTestDriverFactory.java | 78 +- .../concurrent/common/tasks/CallableTask.java | 70 +- .../concurrent/common/tasks/CommonTasks.java | 88 +- .../common/tasks/CommonTriggers.java | 144 +- .../concurrent/common/tasks/RunnableTask.java | 176 +-- .../common/transaction/Connections.java | 12 +- .../common/transaction/Counter.java | 12 +- .../concurrent/framework/EJBJNDIProvider.java | 15 +- .../tck/concurrent/framework/TestClient.java | 275 ++-- .../concurrent/framework/TestConstants.java | 44 +- .../tck/concurrent/framework/TestLogger.java | 261 ++-- .../tck/concurrent/framework/TestServlet.java | 253 ++-- .../tck/concurrent/framework/URLBuilder.java | 309 +++-- .../extensions/TCKArchiveProcessor.java | 33 +- .../extensions/TCKFrameworkAppender.java | 24 +- .../extensions/TCKSignatureProcessor.java | 41 +- .../framework/junit/anno/Common.java | 17 +- .../concurrent/framework/junit/anno/Full.java | 12 +- .../framework/junit/anno/Signature.java | 6 +- .../concurrent/framework/junit/anno/Web.java | 12 +- .../junit/extensions/AssertionExtension.java | 38 +- .../junit/extensions/Assertions.java | 36 +- .../framework/junit/extensions/Wait.java | 83 +- .../BaseTestRunnableWork.java | 24 +- .../contextPropagate/ClassloaderServlet.java | 18 +- .../contextPropagate/ContextEJBProvider.java | 36 +- .../ContextPropagateBean.java | 46 +- .../ContextPropagateInterface.java | 4 +- .../ContextPropagationFullTests.java | 437 +++--- .../ContextPropagationWebTests.java | 395 +++--- .../ContextServiceDefinitionBean.java | 42 +- ...ontextServiceDefinitionFromEJBServlet.java | 122 +- .../ContextServiceDefinitionInterface.java | 16 +- .../ContextServiceDefinitionServlet.java | 287 ++-- .../ContextServiceDefinitionWebBean.java | 36 +- .../contextPropagate/JNDIServlet.java | 28 +- .../contextPropagate/JSPSecurityServlet.java | 9 +- .../contextPropagate/LimitedBean.java | 8 +- .../contextPropagate/LimitedInterface.java | 2 +- .../contextPropagate/SecurityServlet.java | 21 +- .../TestClassloaderRunnableWork.java | 20 +- .../TestJNDIRunnableWork.java | 8 +- .../TestSecurityRunnableWork.java | 12 +- .../contextPropagate/TestWorkInterface.java | 4 +- .../servlet/BaseTestRunnableWork.java | 26 +- .../ContextPropagationServletTests.java | 194 +-- .../servlet/DeserializeServlet.java | 36 +- .../servlet/ProxyCreatorServlet.java | 96 +- .../servlet/TestClassloaderRunnableWork.java | 20 +- .../servlet/TestJNDIRunnableWork.java | 8 +- .../servlet/TestWorkInterface.java | 4 +- .../servlet/WorkInterfaceServlet.java | 22 +- .../ContextService/tx/TransactionServlet.java | 397 +++--- .../ContextService/tx/TransactionTests.java | 6 +- .../inheritedapi/InheritedAPITests.java | 9 +- .../forbiddenapi/ForbiddenAPIEJBTests.java | 137 +- .../managed/forbiddenapi/TestEjb.java | 108 +- .../forbiddenapi/TestEjbInterface.java | 10 +- .../resourcedef/AppBean.java | 4 +- .../ManagedExecutorDefinitionBean.java | 19 +- .../ManagedExecutorDefinitionFullTests.java | 140 +- .../ManagedExecutorDefinitionInterface.java | 2 +- ...ManagedExecutorDefinitionOnEJBServlet.java | 227 ++-- .../ManagedExecutorDefinitionServlet.java | 235 ++-- .../ManagedExecutorDefinitionWebBean.java | 15 +- .../ManagedExecutorDefinitionWebTests.java | 116 +- .../security/SecurityEJBProvider.java | 36 +- .../security/SecurityFullTests.java | 91 +- .../security/SecurityServlet.java | 15 +- .../security/SecurityTestEjb.java | 8 +- .../security/SecurityTestInterface.java | 3 +- .../security/SecurityTestTask.java | 18 +- .../security/SecurityWebTests.java | 75 +- .../tx/TransactionServlet.java | 114 +- .../tx/TransactionTests.java | 87 +- .../inheritedapi/CounterEJBProvider.java | 36 +- .../inheritedapi/InheritedAPIFullTests.java | 201 +-- .../inheritedapi/InheritedAPIWebTests.java | 176 +-- .../inheritedapi/TestEjb.java | 302 ++--- .../inheritedapi/TestEjbInterface.java | 15 +- .../servlet/InheritedAPIServletTests.java | 22 +- .../forbiddenapi/ForbiddenAPIEJBTests.java | 127 +- .../managed/forbiddenapi/TestEjb.java | 88 +- .../forbiddenapi/TestEjbInterface.java | 10 +- ...edScheduleExecutorDefinitionInterface.java | 2 +- ...anagedScheduledExecutorDefinitionBean.java | 23 +- ...dScheduledExecutorDefinitionFullTests.java | 155 ++- ...heduledExecutorDefinitionOnEJBServlet.java | 220 +-- ...gedScheduledExecutorDefinitionServlet.java | 278 ++-- ...gedScheduledExecutorDefinitionWebBean.java | 19 +- ...edScheduledExecutorDefinitionWebTests.java | 132 +- .../resourcedef/ReqBean.java | 2 +- .../security/SecurityEJBProvider.java | 36 +- .../security/SecurityFullTests.java | 86 +- .../security/SecurityServlet.java | 20 +- .../security/SecurityTestEjb.java | 10 +- .../security/SecurityTestInterface.java | 3 +- .../security/SecurityTestTask.java | 18 +- .../security/SecurityWebTests.java | 71 +- .../tx/OnceTrigger.java | 18 +- .../tx/TransactionServlet.java | 107 +- .../tx/TransactionTests.java | 97 +- .../context/ContextFullTests.java | 93 +- .../context/ContextWebTests.java | 76 +- .../context/SecurityServlet.java | 129 +- .../context/SecurityTestEjb.java | 8 +- .../context/SecurityTestInterface.java | 3 +- .../ManagedThreadFactoryDefinitionBean.java | 15 +- ...nagedThreadFactoryDefinitionFullTests.java | 124 +- ...nagedThreadFactoryDefinitionInterface.java | 2 +- ...edThreadFactoryDefinitionOnEJBServlet.java | 121 +- ...ManagedThreadFactoryDefinitionServlet.java | 89 +- ...anagedThreadFactoryDefinitionWebTests.java | 104 +- .../tx/TransactionServlet.java | 99 +- .../tx/TransactionTests.java | 97 +- .../dd/DeploymentDescriptorFullTests.java | 34 +- .../dd/DeploymentDescriptorServlet.java | 16 +- .../dd/DeploymentDescriptorTestBean.java | 22 +- .../dd/DeploymentDescriptorWebTests.java | 29 +- .../spec/signature/SignatureTests.java | 16 +- 154 files changed, 7575 insertions(+), 7526 deletions(-) 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 7c944bf7..7c3b7a96 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 @@ -41,7 +41,7 @@ import jakarta.enterprise.concurrent.ManagedTaskListener; @Web -@Common( { PACKAGE.FIXED_COUNTER } ) +@Common({ PACKAGE.FIXED_COUNTER }) public class ContextServiceTests { // TODO deploy as EJB and JSP artifacts @@ -213,7 +213,8 @@ public void ContextServiceWithIntfAndPropertiesAndIntfNoImplemented() { execProps.put("vendor_a.security.tokenexpiration", "15000"); execProps.put("USE_PARENT_TRANSACTION", "true"); - context.createContextualProxy(new CounterRunnableTask(), execProps, Runnable.class, ManagedTaskListener.class); + context.createContextualProxy(new CounterRunnableTask(), execProps, Runnable.class, + ManagedTaskListener.class); }); } @@ -296,7 +297,7 @@ public void GetExecutionProperties() { Object proxy = context.createContextualProxy(new CounterRunnableTask(), execProps, Runnable.class, WorkInterface.class); assertNotNull(proxy); - + Map returnedExecProps = context.getExecutionProperties(proxy); assertEquals("true", returnedExecProps.get("USE_PARENT_TRANSACTION")); }); 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 d8dfe4d2..5be982c1 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 @@ -43,112 +43,109 @@ import jakarta.enterprise.concurrent.ManagedTask; @Web -@Common({PACKAGE.FIXED_COUNTER}) +@Common({ PACKAGE.FIXED_COUNTER }) public class LastExecutionTests { - public static final String IDENTITY_NAME_TEST_ID = "lastExecutionGetIdentityNameTest"; - - @Deployment(name="LastExecutionTests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, LastExecutionTests.class.getPackage()); - } - - @BeforeEach - public void reset() { - StaticCounter.reset(); - } - - @TestName - public String testname; - + public static final String IDENTITY_NAME_TEST_ID = "lastExecutionGetIdentityNameTest"; + + @Deployment(name = "LastExecutionTests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class).addPackages(true, LastExecutionTests.class.getPackage()); + } + + @BeforeEach + public void reset() { + StaticCounter.reset(); + } + + @TestName + public String testname; + @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) public 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 - public void lastExecutionGetIdentityNameTest() { - - Map executionProperties = new HashMap(); - executionProperties.put(ManagedTask.IDENTITY_NAME, IDENTITY_NAME_TEST_ID); - - ScheduledFuture sf = scheduledExecutor.schedule( - ManagedExecutors.managedTask(new CounterRunnableTask(), executionProperties, null), - new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); - Wait.waitTillFutureIsDone(sf); - - assertEquals( LogicDrivenTrigger.RIGHT_COUNT, // expected - StaticCounter.getCount(), // actual - "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 - public void lastExecutionGetResultRunnableTest() { - // test with runnable, LastExecution should return null - ScheduledFuture sf = scheduledExecutor - .schedule(ManagedExecutors.managedTask(new CounterRunnableTask(), null, null), new LogicDrivenTrigger( - TestConstants.PollInterval.toMillis(), testname)); - Wait.waitTillFutureIsDone(sf); - - assertEquals( - LogicDrivenTrigger.RIGHT_COUNT, // expected - StaticCounter.getCount(), // actual - "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 - public void lastExecutionGetResultCallableTest() { - // test with callable, LastExecution should return 1 - ScheduledFuture sf = scheduledExecutor.schedule(ManagedExecutors.managedTask( - new CounterCallableTask(), null, null), - new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); - Wait.waitTillFutureIsDone(sf); - - assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected - StaticCounter.getCount(), // actual - "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 - public void lastExecutionGetRunningTimeTest() { - ScheduledFuture sf = scheduledExecutor.schedule(ManagedExecutors.managedTask( - new CounterRunnableTask(TestConstants.PollInterval), null, null), - new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); - Wait.waitTillFutureIsDone(sf); - assertEquals( - LogicDrivenTrigger.RIGHT_COUNT, // expected - StaticCounter.getCount(), // actual - "Got wrong last execution result."); - } + /* + * @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 + public void lastExecutionGetIdentityNameTest() { + + Map executionProperties = new HashMap(); + executionProperties.put(ManagedTask.IDENTITY_NAME, IDENTITY_NAME_TEST_ID); + + ScheduledFuture sf = scheduledExecutor.schedule( + ManagedExecutors.managedTask(new CounterRunnableTask(), executionProperties, null), + new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + Wait.waitTillFutureIsDone(sf); + + assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected + StaticCounter.getCount(), // actual + "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 + public void lastExecutionGetResultRunnableTest() { + // test with runnable, LastExecution should return null + ScheduledFuture sf = scheduledExecutor.schedule( + ManagedExecutors.managedTask(new CounterRunnableTask(), null, null), + new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + Wait.waitTillFutureIsDone(sf); + + assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected + StaticCounter.getCount(), // actual + "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 + public void lastExecutionGetResultCallableTest() { + // test with callable, LastExecution should return 1 + ScheduledFuture sf = scheduledExecutor.schedule( + ManagedExecutors.managedTask(new CounterCallableTask(), null, null), + new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + Wait.waitTillFutureIsDone(sf); + + assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected + StaticCounter.getCount(), // actual + "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 + public void lastExecutionGetRunningTimeTest() { + ScheduledFuture sf = scheduledExecutor.schedule( + ManagedExecutors.managedTask(new CounterRunnableTask(TestConstants.PollInterval), null, null), + new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + Wait.waitTillFutureIsDone(sf); + assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected + StaticCounter.getCount(), // actual + "Got wrong last execution result."); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java index 23ee5552..b6a87b31 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java @@ -33,119 +33,112 @@ */ public class LogicDrivenTrigger implements Trigger { - private static final TestLogger log = TestLogger.get(LogicDrivenTrigger.class); - - private long delta; - private String testName; - private boolean moreThanTwice = false; - private Date startTime; - - private static final long TIME_COMPARE_INACCURACY = 2 * 1000; - public static final int RIGHT_COUNT = 2; - public static final int WRONG_COUNT = 1; - - public LogicDrivenTrigger(long delta, String testName) { - this.delta = delta; - this.testName = testName; - this.startTime = new Date(); - } - - private String getErrStr4NotEqual(String testName, Object expected, Object real) { - String result = testName + "failed, "; - result += "expected " + expected + ","; - result += "but got " + real; - return result; - } - - private boolean validateDateTimeEquals(Date time1, Date time2) { - long diff = time1.getTime() - time2.getTime(); - - if (Math.abs(diff) < TIME_COMPARE_INACCURACY) { - return true; - } else { - return false; - } - } - - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (lastExecutionInfo == null) { - return new Date(); - } - - if(moreThanTwice) { - return null; - } - - Method testMethod; - try { - testMethod = getClass().getMethod(testName, LastExecution.class, Date.class); - return (Date) testMethod.invoke(this, lastExecutionInfo, taskScheduledTime); - } catch (Exception e) { - throw new RuntimeException("Could not run test", e); - } - - } - - - public Date lastExecutionGetIdentityNameTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (!LastExecutionTests.IDENTITY_NAME_TEST_ID.equals(lastExecutionInfo.getIdentityName())) { - log.warning(getErrStr4NotEqual(testName, LastExecutionTests.IDENTITY_NAME_TEST_ID, lastExecutionInfo.getIdentityName())); - return null; - } - - moreThanTwice = true; - return new Date(new Date().getTime() + delta); - } - - - public Date lastExecutionGetResultRunnableTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (lastExecutionInfo.getResult() != null) { - log.warning(getErrStr4NotEqual(testName, null, - lastExecutionInfo.getResult())); - return null; - } - - moreThanTwice = true; - return new Date(new Date().getTime() + delta); - } - - - public Date lastExecutionGetResultCallableTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (!Integer.valueOf(1).equals(lastExecutionInfo.getResult())) { - log.warning(getErrStr4NotEqual(testName, 1, - lastExecutionInfo.getResult())); - return null; - } - moreThanTwice = true; - return new Date(new Date().getTime() + delta); - } - - public Date lastExecutionGetRunningTimeTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (!validateDateTimeEquals(this.startTime, lastExecutionInfo.getScheduledStart())) { - log.warning(getErrStr4NotEqual(testName, this.startTime, - lastExecutionInfo.getScheduledStart())); - return null; - } - - if (lastExecutionInfo.getScheduledStart().getTime() > lastExecutionInfo.getRunStart().getTime()) { - log.warning(testName - + "failed, getRunStart time should not be earlier than getScheduledStart"); - return null; - } - - if ((lastExecutionInfo.getRunEnd().getTime() - - lastExecutionInfo.getRunStart().getTime()) < TestConstants.PollInterval.toMillis()) { - log.warning(testName - + "failed, the difference between getRunEnd and getRunStart " - + "is shorter than the real running time"); - return null; - } - - moreThanTwice = true; - return new Date(new Date().getTime() + delta); - } - - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { - return false; - } + private static final TestLogger log = TestLogger.get(LogicDrivenTrigger.class); + + private long delta; + private String testName; + private boolean moreThanTwice = false; + private Date startTime; + + private static final long TIME_COMPARE_INACCURACY = 2 * 1000; + public static final int RIGHT_COUNT = 2; + public static final int WRONG_COUNT = 1; + + public LogicDrivenTrigger(long delta, String testName) { + this.delta = delta; + this.testName = testName; + this.startTime = new Date(); + } + + private String getErrStr4NotEqual(String testName, Object expected, Object real) { + String result = testName + "failed, "; + result += "expected " + expected + ","; + result += "but got " + real; + return result; + } + + private boolean validateDateTimeEquals(Date time1, Date time2) { + long diff = time1.getTime() - time2.getTime(); + + if (Math.abs(diff) < TIME_COMPARE_INACCURACY) { + return true; + } else { + return false; + } + } + + public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (lastExecutionInfo == null) { + return new Date(); + } + + if (moreThanTwice) { + return null; + } + + Method testMethod; + try { + testMethod = getClass().getMethod(testName, LastExecution.class, Date.class); + return (Date) testMethod.invoke(this, lastExecutionInfo, taskScheduledTime); + } catch (Exception e) { + throw new RuntimeException("Could not run test", e); + } + + } + + public Date lastExecutionGetIdentityNameTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (!LastExecutionTests.IDENTITY_NAME_TEST_ID.equals(lastExecutionInfo.getIdentityName())) { + log.warning(getErrStr4NotEqual(testName, LastExecutionTests.IDENTITY_NAME_TEST_ID, + lastExecutionInfo.getIdentityName())); + return null; + } + + moreThanTwice = true; + return new Date(new Date().getTime() + delta); + } + + public Date lastExecutionGetResultRunnableTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (lastExecutionInfo.getResult() != null) { + log.warning(getErrStr4NotEqual(testName, null, lastExecutionInfo.getResult())); + return null; + } + + moreThanTwice = true; + return new Date(new Date().getTime() + delta); + } + + public Date lastExecutionGetResultCallableTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (!Integer.valueOf(1).equals(lastExecutionInfo.getResult())) { + log.warning(getErrStr4NotEqual(testName, 1, lastExecutionInfo.getResult())); + return null; + } + moreThanTwice = true; + return new Date(new Date().getTime() + delta); + } + + public Date lastExecutionGetRunningTimeTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (!validateDateTimeEquals(this.startTime, lastExecutionInfo.getScheduledStart())) { + log.warning(getErrStr4NotEqual(testName, this.startTime, lastExecutionInfo.getScheduledStart())); + return null; + } + + if (lastExecutionInfo.getScheduledStart().getTime() > lastExecutionInfo.getRunStart().getTime()) { + log.warning(testName + "failed, getRunStart time should not be earlier than getScheduledStart"); + return null; + } + + if ((lastExecutionInfo.getRunEnd().getTime() + - lastExecutionInfo.getRunStart().getTime()) < TestConstants.PollInterval.toMillis()) { + log.warning(testName + "failed, the difference between getRunEnd and getRunStart " + + "is shorter than the real running time"); + return null; + } + + moreThanTwice = true; + return new Date(new Date().getTime() + delta); + } + + public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + return false; + } } 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 52496536..8dbf1e92 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 @@ -58,8 +58,8 @@ public class ManagedExecutorsTests { // TODO deploy as EJB and JSP artifacts @Deployment(name = "ManagedExecutorsTests") public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addAsWebInfResource(ManagedExecutorsTests.class.getPackage(), "web.xml", "web.xml"); + return ShrinkWrap.create(WebArchive.class).addAsWebInfResource(ManagedExecutorsTests.class.getPackage(), + "web.xml", "web.xml"); } private static final String ENV_ENTRY_JNDI_NAME = "java:comp/env/StringValue"; @@ -69,10 +69,10 @@ public static WebArchive createDeployment() { private ManagedTaskListenerImpl managedTaskListener = new ManagedTaskListenerImpl(); private boolean shutdown = true; - + @Resource(lookup = TestConstants.DefaultManagedThreadFactory) public ManagedThreadFactory threadFactory; - + @Resource(lookup = TestConstants.DefaultManagedExecutorService) public ManagedExecutorService executor; @@ -105,12 +105,12 @@ private void assertTaskAndListenerComplete(String expectedResult, Future private void assertListenerComplete(RunnableTask task) { // wait for the listener run done. Wait.waitForListenerComplete(managedTaskListener); - + // check listener status. assertTrue(managedTaskListener.eventCalled(ListenerEvent.SUBMITTED)); assertTrue(managedTaskListener.eventCalled(ListenerEvent.STARTING)); assertTrue(managedTaskListener.eventCalled(ListenerEvent.DONE)); - + } /* @@ -214,10 +214,10 @@ public void ManageRunnableTaskWithTaskListenerAndMap() { properties.put("key", "value"); RunnableTask runnableTask = createRunnableTask(); Runnable task = ManagedExecutors.managedTask(runnableTask, properties, managedTaskListener); - + assertTrue(task instanceof ManagedTask); ManagedTask managedTask = (ManagedTask) task; - + assertEquals("value", managedTask.getExecutionProperties().get("key")); assertTaskAndListenerComplete(executor.submit(task), runnableTask); @@ -235,7 +235,7 @@ public void ManageRunnableTaskWithTaskListenerAndMap() { public void ManageRunnableTaskWithMapAndNullArg() { Runnable nullTask = null; Map properties = new HashMap(); - + assertThrows(IllegalArgumentException.class, () -> { ManagedExecutors.managedTask(nullTask, properties, managedTaskListener); }); @@ -298,15 +298,14 @@ public void ManageCallableTaskWithTaskListenerAndMap() { CallableTask callableTask = createCallableTask(expectedResultStr); Callable task = ManagedExecutors.managedTask((Callable) callableTask, properties, managedTaskListener); - + assertTrue(task instanceof ManagedTask); - + ManagedTask managedTask = (ManagedTask) task; - + assertEquals("value", managedTask.getExecutionProperties().get("key")); - assertTaskAndListenerComplete(expectedResultStr, executor.submit(task), - callableTask); + assertTaskAndListenerComplete(expectedResultStr, executor.submit(task), callableTask); } /* @@ -321,7 +320,7 @@ public void ManageCallableTaskWithTaskListenerAndMap() { public void ManageCallableTaskWithMapAndNullArg() { Callable nullTask = null; Map properties = new HashMap(); - + assertThrows(IllegalArgumentException.class, () -> { ManagedExecutors.managedTask(nullTask, properties, managedTaskListener); }); 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 4183b739..c5850ffb 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 @@ -58,7 +58,7 @@ public static WebArchive createDeployment() { private static final String TEST_CLASSLOADER_CLASS_NAME = ManagedScheduledExecutorServiceTests.class .getCanonicalName(); - + @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; @@ -91,7 +91,7 @@ public void normalScheduleProcess1Test() throws Exception { @Test public void nullCommandScheduleProcessTest() { Runnable command = null; - + assertThrows(NullPointerException.class, () -> { scheduledExecutor.schedule(command, new CommonTriggers.OnceTrigger()); }); @@ -110,12 +110,13 @@ public void nullCommandScheduleProcessTest() { */ @Test public void normalScheduleProcess2Test() throws Exception { - ScheduledFuture result = scheduledExecutor.schedule( (Callable) - new CallableTask(TEST_JNDI_EVN_ENTRY_JNDI_NAME, TEST_JNDI_EVN_ENTRY_VALUE, + ScheduledFuture result = scheduledExecutor + .schedule( + (Callable) new CallableTask(TEST_JNDI_EVN_ENTRY_JNDI_NAME, TEST_JNDI_EVN_ENTRY_VALUE, TEST_CLASSLOADER_CLASS_NAME, CALLABLETESTTASK1_RUN_RESULT), new CommonTriggers.OnceTrigger()); Wait.waitForTaskComplete(result); - + assertEquals(CALLABLETESTTASK1_RUN_RESULT, result.get()); } @@ -130,7 +131,7 @@ public void normalScheduleProcess2Test() throws Exception { @Test public void nullCallableScheduleProcessTest() { Callable callable = null; - + assertThrows(NullPointerException.class, () -> { scheduledExecutor.schedule(callable, new CommonTriggers.OnceTrigger()); }); 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 dfa3ef65..3fb5206d 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 @@ -36,65 +36,64 @@ import jakarta.enterprise.concurrent.ManagedTask; @Web -@Common({PACKAGE.MANAGED_TASK_LISTENER, PACKAGE.TASKS}) +@Common({ PACKAGE.MANAGED_TASK_LISTENER, PACKAGE.TASKS }) public class ManagedTaskTests { - - //TODO deploy as EJB and JSP artifacts - @Deployment(name="ManagedTaskTests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, ManagedTaskTests.class.getPackage()); - } - - private ManagedTaskListenerImpl managedTaskListener = new ManagedTaskListenerImpl(); - - private RunnableTask createRunnableTask() { - //Task never actually run - 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 - public void GetExecutionProperties() { - Map properties = new HashMap(); - properties.put("key", "value"); - Runnable runnableTask = createRunnableTask(); - Runnable task = ManagedExecutors.managedTask(runnableTask, properties, managedTaskListener); - - assertTrue(task instanceof ManagedTask); - + + // TODO deploy as EJB and JSP artifacts + @Deployment(name = "ManagedTaskTests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class).addPackages(true, ManagedTaskTests.class.getPackage()); + } + + private ManagedTaskListenerImpl managedTaskListener = new ManagedTaskListenerImpl(); + + private RunnableTask createRunnableTask() { + // Task never actually run + 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 + public void GetExecutionProperties() { + Map properties = new HashMap(); + properties.put("key", "value"); + Runnable runnableTask = createRunnableTask(); + Runnable task = ManagedExecutors.managedTask(runnableTask, properties, managedTaskListener); + + assertTrue(task instanceof ManagedTask); + ManagedTask managedTask = (ManagedTask) task; - + 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 - public void GetManagedTaskListener() { - Map properties = new HashMap(); - properties.put("key", "value"); - RunnableTask runnableTask = createRunnableTask(); - Runnable task = ManagedExecutors.managedTask(runnableTask, properties, managedTaskListener); - - assertTrue(task instanceof ManagedTask); - + } + + /* + * @testName: GetManagedTaskListener + * + * @assertion_ids: CONCURRENCY:JAVADOC:37 + * + * @test_Strategy: Get ManagedTask with ManagedTaskListener to receive + * notification of life cycle events of this task. + */ + @Test + public void GetManagedTaskListener() { + Map properties = new HashMap(); + properties.put("key", "value"); + RunnableTask runnableTask = createRunnableTask(); + Runnable task = ManagedExecutors.managedTask(runnableTask, properties, managedTaskListener); + + assertTrue(task instanceof ManagedTask); + ManagedTask managedTask = (ManagedTask) task; assertEquals(managedTaskListener, managedTask.getManagedTaskListener()); - } + } } 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 3632dafb..1dde9531 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 @@ -44,144 +44,143 @@ import jakarta.enterprise.concurrent.ManagedExecutors; @Web -@Common({PACKAGE.MANAGED_TASK_LISTENER, PACKAGE.TASKS}) +@Common({ PACKAGE.MANAGED_TASK_LISTENER, PACKAGE.TASKS }) public class ManagedTaskListenerTests { - private static final TestLogger log = TestLogger.get(ManagedTaskListenerTests.class); - - //TODO deploy as EJB and JSP artifacts - @Deployment(name="ManagedTaskListenerTests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, ManagedTaskListenerTests.class.getPackage()); - } - - private ManagedTaskListenerImpl managedTaskListener = new ManagedTaskListenerImpl(); - + private static final TestLogger log = TestLogger.get(ManagedTaskListenerTests.class); + + // TODO deploy as EJB and JSP artifacts + @Deployment(name = "ManagedTaskListenerTests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class).addPackages(true, ManagedTaskListenerTests.class.getPackage()); + } + + private ManagedTaskListenerImpl managedTaskListener = new ManagedTaskListenerImpl(); + @Resource(lookup = TestConstants.DefaultManagedExecutorService) public ManagedExecutorService executor; - @AfterEach - 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 - public void TaskAborted() throws InterruptedException { - final Duration blockTime = Duration.ofMillis(3000); - Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener, blockTime); - Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); - Future futureResult = executor.submit(taskWithListener); - Wait.sleep(Duration.ofMillis(1000)); - futureResult.cancel(true); - Wait.waitForListenerComplete(managedTaskListener, TestConstants.WaitTimeout.plus(blockTime), - TestConstants.PollInterval); - List events = managedTaskListener.events(); - - assertTrue(events.contains(ListenerEvent.ABORTED), "Listener taskAborted failed"); - 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 - public void TaskDone() throws InterruptedException { - // in cancel case - final Duration blockTime = Duration.ofMillis(3000); - Runnable taskToCancelled = new RunnableTaskWithStatus(managedTaskListener, blockTime); - Runnable taskToCancelledWithListener = ManagedExecutors.managedTask(taskToCancelled, managedTaskListener); - Future futureResult = executor.submit(taskToCancelledWithListener); - Wait.sleep(Duration.ofMillis(1000)); - futureResult.cancel(true); - Wait.waitForListenerComplete(managedTaskListener, TestConstants.WaitTimeout.plus(blockTime), - TestConstants.PollInterval); - List events = managedTaskListener.events(); - assertTrue(events.contains(ListenerEvent.DONE), "Listener taskDone failed in cancel case"); - managedTaskListener.clearEvents(); - - // in normal case - Runnable runTask = new RunnableTaskWithStatus(managedTaskListener); - Runnable runtaskWithListener = ManagedExecutors.managedTask(runTask, managedTaskListener); - executor.submit(runtaskWithListener); - Wait.waitForListenerComplete(managedTaskListener); - List runevents = managedTaskListener.events(); - assertTrue(runevents.contains(ListenerEvent.DONE), "Listener TaskDone failed"); - managedTaskListener.clearEvents(); - - // in exception case - Runnable taskWithException = new RunnableTaskWithException(managedTaskListener); - Runnable taskWithExceptionListener = ManagedExecutors.managedTask(taskWithException, managedTaskListener); - executor.submit(taskWithExceptionListener); - Wait.waitForListenerComplete(managedTaskListener); - List runeventsWithException = managedTaskListener.events(); - log.fine("++ runeventsWithException : " + runeventsWithException); - assertTrue(runeventsWithException.contains(ListenerEvent.DONE), - "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 - public void TaskStarting() { - Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); - Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); - executor.submit(taskWithListener); - Wait.waitForListenerComplete(managedTaskListener); - List events = managedTaskListener.events(); - int submitAt = events.indexOf(ListenerEvent.SUBMITTED); - int startAt = events.indexOf(ListenerEvent.STARTING); - int runAt = events.indexOf(ListenerEvent.TASK_RUN); - if (!(submitAt == 0 && startAt == 1) && runAt == 2) { - fail("Listener TaskStarting failed to run in expected order"); - } - } - - /* - * @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 - public void TaskSubmitted() { - Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); - Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); - executor.submit(taskWithListener); - Wait.waitForListenerComplete(managedTaskListener); - List events = managedTaskListener.events(); - int submitAt = events.indexOf(ListenerEvent.SUBMITTED); - assertEquals(0, submitAt, "Listener TaskSubmitted failed to run in expected order"); - } + @AfterEach + 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 + public void TaskAborted() throws InterruptedException { + final Duration blockTime = Duration.ofMillis(3000); + Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener, blockTime); + Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); + Future futureResult = executor.submit(taskWithListener); + Wait.sleep(Duration.ofMillis(1000)); + futureResult.cancel(true); + Wait.waitForListenerComplete(managedTaskListener, TestConstants.WaitTimeout.plus(blockTime), + TestConstants.PollInterval); + List events = managedTaskListener.events(); + + assertTrue(events.contains(ListenerEvent.ABORTED), "Listener taskAborted failed"); + 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 + public void TaskDone() throws InterruptedException { + // in cancel case + final Duration blockTime = Duration.ofMillis(3000); + Runnable taskToCancelled = new RunnableTaskWithStatus(managedTaskListener, blockTime); + Runnable taskToCancelledWithListener = ManagedExecutors.managedTask(taskToCancelled, managedTaskListener); + Future futureResult = executor.submit(taskToCancelledWithListener); + Wait.sleep(Duration.ofMillis(1000)); + futureResult.cancel(true); + Wait.waitForListenerComplete(managedTaskListener, TestConstants.WaitTimeout.plus(blockTime), + TestConstants.PollInterval); + List events = managedTaskListener.events(); + assertTrue(events.contains(ListenerEvent.DONE), "Listener taskDone failed in cancel case"); + managedTaskListener.clearEvents(); + + // in normal case + Runnable runTask = new RunnableTaskWithStatus(managedTaskListener); + Runnable runtaskWithListener = ManagedExecutors.managedTask(runTask, managedTaskListener); + executor.submit(runtaskWithListener); + Wait.waitForListenerComplete(managedTaskListener); + List runevents = managedTaskListener.events(); + assertTrue(runevents.contains(ListenerEvent.DONE), "Listener TaskDone failed"); + managedTaskListener.clearEvents(); + + // in exception case + Runnable taskWithException = new RunnableTaskWithException(managedTaskListener); + Runnable taskWithExceptionListener = ManagedExecutors.managedTask(taskWithException, managedTaskListener); + executor.submit(taskWithExceptionListener); + Wait.waitForListenerComplete(managedTaskListener); + List runeventsWithException = managedTaskListener.events(); + log.fine("++ runeventsWithException : " + runeventsWithException); + assertTrue(runeventsWithException.contains(ListenerEvent.DONE), + "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 + public void TaskStarting() { + Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); + Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); + executor.submit(taskWithListener); + Wait.waitForListenerComplete(managedTaskListener); + List events = managedTaskListener.events(); + int submitAt = events.indexOf(ListenerEvent.SUBMITTED); + int startAt = events.indexOf(ListenerEvent.STARTING); + int runAt = events.indexOf(ListenerEvent.TASK_RUN); + if (!(submitAt == 0 && startAt == 1) && runAt == 2) { + fail("Listener TaskStarting failed to run in expected order"); + } + } + + /* + * @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 + public void TaskSubmitted() { + Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); + Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); + executor.submit(taskWithListener); + Wait.waitForListenerComplete(managedTaskListener); + List events = managedTaskListener.events(); + int submitAt = events.indexOf(ListenerEvent.SUBMITTED); + assertEquals(0, submitAt, "Listener TaskSubmitted failed to run in expected order"); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java index 883b587b..4c528c49 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java @@ -22,13 +22,13 @@ public class RunnableTaskWithException extends RunnableTaskWithStatus implements Runnable { - public RunnableTaskWithException(ManagedTaskListenerImpl listener) { - super(listener); - } + public RunnableTaskWithException(ManagedTaskListenerImpl listener) { + super(listener); + } - @Override - public void run() { - listener.update(ListenerEvent.TASK_RUN); - throw new RuntimeException("wrong happend"); - } + @Override + public void run() { + listener.update(ListenerEvent.TASK_RUN); + throw new RuntimeException("wrong happend"); + } } 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 68cf16a8..b521bb1e 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 @@ -38,19 +38,17 @@ import jakarta.enterprise.concurrent.ManagedThreadFactory; @Web -@Common({PACKAGE.TASKS, PACKAGE.FIXED_COUNTER}) +@Common({ PACKAGE.TASKS, PACKAGE.FIXED_COUNTER }) public class ManagedThreadFactoryTests extends TestClient { - - @Deployment(name="APITests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, ManagedThreadFactoryTests.class.getPackage()); - } - + + @Deployment(name = "APITests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class).addPackages(true, ManagedThreadFactoryTests.class.getPackage()); + } @Resource(lookup = TestConstants.DefaultManagedThreadFactory) public ManagedThreadFactory threadFactory; - + /* * @testName: isShutdown * @@ -64,40 +62,40 @@ 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 - public void interruptThreadApiTest() { - CounterRunnableTask task = new CounterRunnableTask(TestConstants.PollInterval); + /* + * @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 + public void interruptThreadApiTest() { + CounterRunnableTask task = new CounterRunnableTask(TestConstants.PollInterval); Thread thread = threadFactory.newThread(task); thread.start(); thread.interrupt(); Wait.waitTillThreadFinish(thread); assertEquals(0, StaticCounter.getCount()); - } + } - /* - * @testName: implementsManageableThreadInterfaceTest - * - * @assertion_ids: CONCURRENCY:SPEC:97; - * - * @test_Strategy: - */ - @Test - public void implementsManageableThreadInterfaceTest() { - CounterRunnableTask task = new CounterRunnableTask(); + /* + * @testName: implementsManageableThreadInterfaceTest + * + * @assertion_ids: CONCURRENCY:SPEC:97; + * + * @test_Strategy: + */ + @Test + public void implementsManageableThreadInterfaceTest() { + CounterRunnableTask task = new CounterRunnableTask(); Thread thread = threadFactory.newThread(task); - assertTrue(thread instanceof ManageableThread, "The thread returned by ManagedThreadFactory should be instance of ManageableThread."); - } + assertTrue(thread instanceof ManageableThread, + "The thread returned by ManagedThreadFactory should be instance of ManageableThread."); + } } 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 18e78553..df3fd8bf 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 @@ -31,39 +31,38 @@ @Web // TODO couldn't this be a unit test? public class SkippedExceptionTests { - - //TODO deploy as EJB and JSP artifacts - @Deployment(name="SkippedExceptionTests") - 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 - public void SkippedExceptionNoArgTest() { - SkippedException thrown = assertThrows(SkippedException.class, () -> { - throw new SkippedException(); - }); - - assertNull(thrown.getMessage()); - } - - /* - * @testName: SkippedExceptionStringTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:43 - * - * @test_Strategy: Constructs an SkippedException. - */ - @Test - public void SkippedExceptionStringTest() { + + // TODO deploy as EJB and JSP artifacts + @Deployment(name = "SkippedExceptionTests") + 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 + public void SkippedExceptionNoArgTest() { + SkippedException thrown = assertThrows(SkippedException.class, () -> { + throw new SkippedException(); + }); + + assertNull(thrown.getMessage()); + } + + /* + * @testName: SkippedExceptionStringTest + * + * @assertion_ids: CONCURRENCY:JAVADOC:43 + * + * @test_Strategy: Constructs an SkippedException. + */ + @Test + public void SkippedExceptionStringTest() { final String expected = "thisisthedetailmessage"; SkippedException thrown = assertThrows(SkippedException.class, () -> { @@ -72,18 +71,18 @@ public void SkippedExceptionStringTest() { assertNotNull(thrown.getMessage()); assertEquals(expected, thrown.getMessage()); - } - - /* - * @testName: SkippedExceptionThrowableTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:45 - * - * @test_Strategy: Constructs an SkippedException. - */ - @Test - public void SkippedExceptionThrowableTest() { - SkippedException thrown; + } + + /* + * @testName: SkippedExceptionThrowableTest + * + * @assertion_ids: CONCURRENCY:JAVADOC:45 + * + * @test_Strategy: Constructs an SkippedException. + */ + @Test + public void SkippedExceptionThrowableTest() { + SkippedException thrown; final Throwable expected = new Throwable("thisisthethrowable"); @@ -101,18 +100,18 @@ public void SkippedExceptionThrowableTest() { }); assertNull(thrown.getCause()); - } - - /* - * @testName: SkippedExceptionStringThrowableTest - * - * @assertion_ids: CONCURRENCY:JAVADOC:44 - * - * @test_Strategy: Constructs an SkippedException. - */ - @Test - public void SkippedExceptionStringThrowableTest() { - SkippedException thrown; + } + + /* + * @testName: SkippedExceptionStringThrowableTest + * + * @assertion_ids: CONCURRENCY:JAVADOC:44 + * + * @test_Strategy: Constructs an SkippedException. + */ + @Test + public void SkippedExceptionStringThrowableTest() { + SkippedException thrown; String sExpected = "thisisthedetailmessage"; String sExpectedNull = null; @@ -150,5 +149,5 @@ public void SkippedExceptionStringThrowableTest() { assertNull(thrown.getMessage()); assertNull(thrown.getCause()); - } + } } 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 94edd1b4..aa27ffef 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 @@ -75,13 +75,14 @@ public void reset() { public void triggerGetNextRunTimeTest() throws Exception { Future result = scheduledExecutor.schedule(new CounterRunnableTask(), new CommonTriggers.TriggerFixedRate(new Date(), TestConstants.PollInterval.toMillis())); - + assertFalse(StaticCounter.getCount() == 0, "The first trigger is too fast."); try { Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(StaticCounter.getCount(), TestConstants.PollsPerTimeout - 2, TestConstants.PollsPerTimeout + 2); - } finally { + Assertions.assertBetween(StaticCounter.getCount(), TestConstants.PollsPerTimeout - 2, + TestConstants.PollsPerTimeout + 2); + } finally { Wait.waitTillFutureIsDone(result); } } @@ -99,10 +100,9 @@ public void triggerGetNextRunTimeTest() throws Exception { */ @Test public void triggerSkipRunTest() { - ScheduledFuture sf = scheduledExecutor.schedule( - new CommonTasks.SimpleCallable(), + 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/common/context/providers/IntContextProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextProvider.java index ea4c6d20..d0df7403 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextProvider.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextProvider.java @@ -22,7 +22,8 @@ import jakarta.enterprise.concurrent.spi.ThreadContextSnapshot; /** - * Thread context provider for a mock context type that consists of an int value. + * Thread context provider for a mock context type that consists of an int + * value. */ public class IntContextProvider implements ThreadContextProvider { public ThreadContextSnapshot currentContext(final Map props) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextRestorer.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextRestorer.java index dc0700df..8fdc734d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextRestorer.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextRestorer.java @@ -19,7 +19,8 @@ import jakarta.enterprise.concurrent.spi.ThreadContextRestorer; /** - * Thread context restorer for a mock context type that consists of an int value. + * Thread context restorer for a mock context type that consists of an int + * value. */ public class IntContextRestorer implements ThreadContextRestorer { private final int contextToRestore; @@ -29,7 +30,7 @@ public class IntContextRestorer implements ThreadContextRestorer { contextToRestore = s; } - public void endContext() throws IllegalStateException { + public void endContext() throws IllegalStateException { if (restored) throw new IllegalStateException("already restored"); IntContext.set(contextToRestore); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextSnapshot.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextSnapshot.java index e05c4d59..5a3b6348 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextSnapshot.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/IntContextSnapshot.java @@ -20,7 +20,8 @@ import jakarta.enterprise.concurrent.spi.ThreadContextSnapshot; /** - * Thread context snapshot for a mock context type that consists of an int value. + * Thread context snapshot for a mock context type that consists of an int + * value. */ public class IntContextSnapshot implements ThreadContextSnapshot { private final int contextSnapshot; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextProvider.java index 3c42e387..aa3e6d0f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextProvider.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextProvider.java @@ -22,7 +22,8 @@ import jakarta.enterprise.concurrent.spi.ThreadContextSnapshot; /** - * Thread context provider for a mock context type that consists of a String value. + * Thread context provider for a mock context type that consists of a String + * value. */ public class StringContextProvider implements ThreadContextProvider { public ThreadContextSnapshot currentContext(final Map props) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextRestorer.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextRestorer.java index 901a138b..7acda1a2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextRestorer.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextRestorer.java @@ -19,7 +19,8 @@ import jakarta.enterprise.concurrent.spi.ThreadContextRestorer; /** - * Thread context restorer for a mock context type that consists of a String value. + * Thread context restorer for a mock context type that consists of a String + * value. */ public class StringContextRestorer implements ThreadContextRestorer { private final String contextToRestore; @@ -29,7 +30,7 @@ public class StringContextRestorer implements ThreadContextRestorer { contextToRestore = s; } - public void endContext() throws IllegalStateException { + public void endContext() throws IllegalStateException { if (restored) throw new IllegalStateException("already restored"); StringContext.set(contextToRestore); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextSnapshot.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextSnapshot.java index 0fcc2414..b708e6d6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextSnapshot.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/providers/StringContextSnapshot.java @@ -20,7 +20,8 @@ import jakarta.enterprise.concurrent.spi.ThreadContextSnapshot; /** - * Thread context snapshot for a mock context type that consists of a String value. + * Thread context snapshot for a mock context type that consists of a String + * value. */ public class StringContextSnapshot implements ThreadContextSnapshot { private final String contextSnapshot; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java index b4c3a8af..ce10452e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java @@ -22,21 +22,21 @@ public class CounterCallableTask implements Callable { - private String countSingletionJndi = ""; + private String countSingletionJndi = ""; - public CounterCallableTask(String countSingletionJndi) { - this.countSingletionJndi = countSingletionJndi; - } + public CounterCallableTask(String countSingletionJndi) { + this.countSingletionJndi = countSingletionJndi; + } - public Integer call() { - try { - CounterInterface counter = InitialContext.doLookup(countSingletionJndi); - counter.inc(); - return counter.getCount(); + public Integer call() { + try { + CounterInterface counter = InitialContext.doLookup(countSingletionJndi); + counter.inc(); + return counter.getCount(); - } catch (Exception e) { - throw new RuntimeException(e); - } + } catch (Exception e) { + throw new RuntimeException(e); + } - } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterInterface.java index 42223f89..ece8fb4f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterInterface.java @@ -18,9 +18,9 @@ public interface CounterInterface { - public void inc(); + public void inc(); - public int getCount(); + public int getCount(); - public void reset(); + public void reset(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java index 9c0c55b7..1f6b0775 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java @@ -24,30 +24,30 @@ public class CounterRunnableTask implements Runnable { - private String countSingletionJndi = ""; - private Duration sleepTime = Duration.ZERO; + private String countSingletionJndi = ""; + private Duration sleepTime = Duration.ZERO; - public CounterRunnableTask(String countSingletionJndi) { - this.countSingletionJndi = countSingletionJndi; - } + public CounterRunnableTask(String countSingletionJndi) { + this.countSingletionJndi = countSingletionJndi; + } - public CounterRunnableTask(String countSingletionJndi, Duration sleepTime) { - this.countSingletionJndi = countSingletionJndi; - this.sleepTime = sleepTime; - } + public CounterRunnableTask(String countSingletionJndi, Duration sleepTime) { + this.countSingletionJndi = countSingletionJndi; + this.sleepTime = sleepTime; + } - public void run() { - try { - if (! sleepTime.isZero()) { - Wait.sleep(sleepTime); - } + public void run() { + try { + if (!sleepTime.isZero()) { + Wait.sleep(sleepTime); + } - CounterInterface counter = InitialContext.doLookup(countSingletionJndi); - counter.inc(); + CounterInterface counter = InitialContext.doLookup(countSingletionJndi); + counter.inc(); - } catch (Exception e) { - throw new RuntimeException(e); - } + } catch (Exception e) { + throw new RuntimeException(e); + } - } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterSingleton.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterSingleton.java index 70ba296d..0a658ab7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterSingleton.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterSingleton.java @@ -21,17 +21,17 @@ @Singleton public class CounterSingleton implements CounterInterface { - private int count = 0; + private int count = 0; - public void inc() { - count++; - } + public void inc() { + count++; + } - public int getCount() { - return count; - } + public int getCount() { + return count; + } - public void reset() { - count = 0; - } + public void reset() { + count = 0; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java index 38df7536..4d6fc516 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java @@ -38,16 +38,18 @@ public static void inc() { public static void reset() { count.set(0); } - + public static void waitTill(int expected) { assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for(; expected != StaticCounter.getCount(); Wait.sleep(TestConstants.PollInterval)); + for (; expected != StaticCounter.getCount(); Wait.sleep(TestConstants.PollInterval)) + ; }); } - + public static void waitTillSurpassed(int expected) { assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for(; expected <= StaticCounter.getCount(); Wait.sleep(TestConstants.PollInterval)); + for (; expected <= StaticCounter.getCount(); Wait.sleep(TestConstants.PollInterval)) + ; }); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ListenerEvent.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ListenerEvent.java index 1bd6a01e..09340366 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ListenerEvent.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ListenerEvent.java @@ -17,5 +17,5 @@ package ee.jakarta.tck.concurrent.common.managed.task.listener; public enum ListenerEvent { - SUBMITTED, STARTING, TASK_RUN, DONE, ABORTED; + SUBMITTED, STARTING, TASK_RUN, DONE, ABORTED; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java index 1de68589..bc656561 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java @@ -27,47 +27,47 @@ public class ManagedTaskListenerImpl implements ManagedTaskListener { - private static final TestLogger log = TestLogger.get(ManagedTaskListenerImpl.class); + private static final TestLogger log = TestLogger.get(ManagedTaskListenerImpl.class); - private final List events = Collections.synchronizedList(new ArrayList()); + private final List events = Collections.synchronizedList(new ArrayList()); - @Override - public void taskAborted(Future future, ManagedExecutorService mes, Object arg2, Throwable arg3) { - events.add(ListenerEvent.ABORTED); - log.info("task aborted"); - } + @Override + public void taskAborted(Future future, ManagedExecutorService mes, Object arg2, Throwable arg3) { + events.add(ListenerEvent.ABORTED); + log.info("task aborted"); + } - @Override - public void taskDone(Future future, ManagedExecutorService mes, Object arg2, Throwable arg3) { - events.add(ListenerEvent.DONE); - log.info("task done"); - } + @Override + public void taskDone(Future future, ManagedExecutorService mes, Object arg2, Throwable arg3) { + events.add(ListenerEvent.DONE); + log.info("task done"); + } - @Override - public void taskStarting(Future future, ManagedExecutorService mes, Object arg2) { - events.add(ListenerEvent.STARTING); - log.info("task starting"); - } + @Override + public void taskStarting(Future future, ManagedExecutorService mes, Object arg2) { + events.add(ListenerEvent.STARTING); + log.info("task starting"); + } - @Override - public void taskSubmitted(Future future, ManagedExecutorService mes, Object arg2) { - events.add(ListenerEvent.SUBMITTED); - log.info("task submitted"); - } + @Override + public void taskSubmitted(Future future, ManagedExecutorService mes, Object arg2) { + events.add(ListenerEvent.SUBMITTED); + log.info("task submitted"); + } - public boolean eventCalled(ListenerEvent event) { - return events.contains(event); - } + public boolean eventCalled(ListenerEvent event) { + return events.contains(event); + } - public void clearEvents() { - events.clear(); - } + public void clearEvents() { + events.clear(); + } - public void update(ListenerEvent event) { - events.add(event); - } + public void update(ListenerEvent event) { + events.add(event); + } - public List events() { - return events; - } + public List events() { + return events; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java index a4d2c198..dce0eb5f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java @@ -21,26 +21,26 @@ import ee.jakarta.tck.concurrent.framework.junit.extensions.Wait; public class RunnableTaskWithStatus implements Runnable { - - protected final ManagedTaskListenerImpl listener; - - private final Duration blockTime; - - public RunnableTaskWithStatus(ManagedTaskListenerImpl listener) { - this.listener = listener; - blockTime = Duration.ZERO; - } - - public RunnableTaskWithStatus(ManagedTaskListenerImpl listener, Duration blockTime) { - this.listener = listener; - this.blockTime = blockTime; - } - - public void run() { - listener.update(ListenerEvent.TASK_RUN); - if (! blockTime.isZero()) { - Wait.sleep(blockTime); - } - } + + protected final ManagedTaskListenerImpl listener; + + private final Duration blockTime; + + public RunnableTaskWithStatus(ManagedTaskListenerImpl listener) { + this.listener = listener; + blockTime = Duration.ZERO; + } + + public RunnableTaskWithStatus(ManagedTaskListenerImpl listener, Duration blockTime) { + this.listener = listener; + this.blockTime = blockTime; + } + + public void run() { + listener.update(ListenerEvent.TASK_RUN); + if (!blockTime.isZero()) { + Wait.sleep(blockTime); + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java index a89a9cdc..8b4b7e15 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java @@ -33,113 +33,113 @@ public final class ApiCheckDriver extends SignatureTestDriver implements Seriali private static final long serialVersionUID = 1L; /* flags for the Diff utility argument list */ - private static final String BASE_FLAG = "-base"; + private static final String BASE_FLAG = "-base"; - private static final String TEST_FLAG = "-test"; + private static final String TEST_FLAG = "-test"; - private static final String PACKAGE_NO_SUBS_FLAG = "-PackageWithoutSubpackages"; + private static final String PACKAGE_NO_SUBS_FLAG = "-PackageWithoutSubpackages"; - private static final String PACKAGE_FLAG = "-package"; + private static final String PACKAGE_FLAG = "-package"; - private static final String EXPACKAGE_FLAG = "-expackage"; + private static final String EXPACKAGE_FLAG = "-expackage"; - private static final String REFLECT_FLAG = "-reflect"; + private static final String REFLECT_FLAG = "-reflect"; - private static final String CONST_FLAG = "-constvalues"; + private static final String CONST_FLAG = "-constvalues"; - // ---------------------------------------- Methods from SignatureTestDriver + // ---------------------------------------- Methods from SignatureTestDriver - @Override - protected String normalizeFileName(File f) { - return f.getPath(); - } + @Override + protected String normalizeFileName(File f) { + return f.getPath(); + } - @Override - protected String[] createTestArguments(String packageListFile, String mapFile, String signatureRepositoryDir, - String packageOrClassUnderTest, String classpath, boolean bStaticMode) throws Exception { + @Override + protected String[] createTestArguments(String packageListFile, String mapFile, String signatureRepositoryDir, + String packageOrClassUnderTest, String classpath, boolean bStaticMode) throws Exception { - Class pkgListClass = Class.forName("javasoft.sqe.apiCheck.PackageList"); - Constructor pkgCtor = pkgListClass.getDeclaredConstructor(new Class[] { String.class }); - Object pkgInstance = pkgCtor.newInstance(new Object[] { packageListFile }); + Class pkgListClass = Class.forName("javasoft.sqe.apiCheck.PackageList"); + Constructor pkgCtor = pkgListClass.getDeclaredConstructor(new Class[] { String.class }); + Object pkgInstance = pkgCtor.newInstance(new Object[] { packageListFile }); - Method pkgMethod = pkgListClass.getDeclaredMethod("getSubPackagesFormatted", new Class[] { String.class }); + Method pkgMethod = pkgListClass.getDeclaredMethod("getSubPackagesFormatted", new Class[] { String.class }); - String excludePkgs = (String) pkgMethod.invoke(pkgInstance, new Object[] { packageOrClassUnderTest }); + String excludePkgs = (String) pkgMethod.invoke(pkgInstance, new Object[] { packageOrClassUnderTest }); - List sigArgsList = new LinkedList<>(); + List sigArgsList = new LinkedList<>(); - sigArgsList.add(BASE_FLAG); - sigArgsList.add(getSigFileInfo(packageOrClassUnderTest, mapFile, signatureRepositoryDir).getFile()); + sigArgsList.add(BASE_FLAG); + sigArgsList.add(getSigFileInfo(packageOrClassUnderTest, mapFile, signatureRepositoryDir).getFile()); - if (classpath != null && classpath.length() > 0) { - sigArgsList.add(TEST_FLAG); - sigArgsList.add(classpath); - } + if (classpath != null && classpath.length() > 0) { + sigArgsList.add(TEST_FLAG); + sigArgsList.add(classpath); + } - sigArgsList.add(REFLECT_FLAG); - sigArgsList.add(CONST_FLAG); - sigArgsList.add(PACKAGE_FLAG); - sigArgsList.add(packageOrClassUnderTest); + sigArgsList.add(REFLECT_FLAG); + sigArgsList.add(CONST_FLAG); + sigArgsList.add(PACKAGE_FLAG); + sigArgsList.add(packageOrClassUnderTest); - if (excludePkgs != null && excludePkgs.length() > 0) { - sigArgsList.add(EXPACKAGE_FLAG); - sigArgsList.add(excludePkgs); - } + if (excludePkgs != null && excludePkgs.length() > 0) { + sigArgsList.add(EXPACKAGE_FLAG); + sigArgsList.add(excludePkgs); + } - return (String[]) (sigArgsList.toArray(new String[sigArgsList.size()])); + return (String[]) (sigArgsList.toArray(new String[sigArgsList.size()])); - } // END createTestArguments + } // END createTestArguments - @Override - protected boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception { + @Override + protected boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception { - Class diffClass = Class.forName("javasoft.sqe.apiCheck.Diff"); - Method mainMethod = diffClass.getDeclaredMethod("main", new Class[] { String[].class }); - mainMethod.invoke(null, new Object[] { testArguments }); + Class diffClass = Class.forName("javasoft.sqe.apiCheck.Diff"); + Method mainMethod = diffClass.getDeclaredMethod("main", new Class[] { String[].class }); + mainMethod.invoke(null, new Object[] { testArguments }); - Method diffMethod = diffClass.getDeclaredMethod("diffsFound", new Class[] {}); - return (!((Boolean) diffMethod.invoke(null, new Object[] {})).booleanValue()); + Method diffMethod = diffClass.getDeclaredMethod("diffsFound", new Class[] {}); + return (!((Boolean) diffMethod.invoke(null, new Object[] {})).booleanValue()); - } // END runSignatureTest + } // END runSignatureTest - @Override - protected boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception { - Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); - Object sigTestInstance = sigTestClass.getConstructor().newInstance(); + @Override + protected boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception { + Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.getConstructor().newInstance(); - ByteArrayOutputStream output = new ByteArrayOutputStream(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); - // we want to replace the PACKAGE_FLAG with PACKAGE_NO_SUBS_FLAG - for (int ii = 0; ii < testArguments.length; ii++) { - if (testArguments[ii].equals(PACKAGE_FLAG)) { - testArguments[ii] = PACKAGE_NO_SUBS_FLAG; - } - } + // we want to replace the PACKAGE_FLAG with PACKAGE_NO_SUBS_FLAG + for (int ii = 0; ii < testArguments.length; ii++) { + if (testArguments[ii].equals(PACKAGE_FLAG)) { + testArguments[ii] = PACKAGE_NO_SUBS_FLAG; + } + } - // dump args for debugging aid - System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); - for (int ii = 0; ii < testArguments.length; ii++) { - System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); - } + // dump args for debugging aid + System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii = 0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + } - Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); - String rawMessages = output.toString(); + String rawMessages = output.toString(); - // currently, there is no way to determine if there are error msgs in - // the rawmessages, so we will always dump this and call it a status. - System.out.println("********** Status Report '" + packageOrClassName + "' **********\n"); - System.out.println(rawMessages); - return sigTestInstance.toString().substring(7).startsWith("Passed."); - } + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println("********** Status Report '" + packageOrClassName + "' **********\n"); + System.out.println(rawMessages); + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } - @Override - protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception { - // Need to find out whether implementing this method is really required now. - // By default, signature test framework will use sigtest - return true; - } + @Override + protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception { + // Need to find out whether implementing this method is really required now. + // By default, signature test framework will use sigtest + return true; + } } // END ApiCheckDriver diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index 901f509d..8a8749b7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -40,272 +40,265 @@ import ee.jakarta.tck.concurrent.framework.TestLogger; public class ConcurrencySignatureTestRunner extends SigTestEE { - + public static final String SIG_FILE_NAME = "jakarta.enterprise.concurrent.sig"; public static final String SIG_MAP_NAME = "sig-test.map"; public static final String SIG_PKG_NAME = "sig-test-pkg-list.txt"; - - public static final String[] SIG_RESOURCES = {SIG_FILE_NAME, SIG_MAP_NAME, SIG_PKG_NAME}; - - private static final TestLogger log = TestLogger.get(ConcurrencySignatureTestRunner.class); - - public ConcurrencySignatureTestRunner() { - setup(); - } - - /** - * Returns a list of strings where each string represents a package name. Each - * package name will have it's signature tested by the signature test framework. - * - * @return String[] The names of the packages whose signatures should be - * verified. - */ - @Override - protected String[] getPackages(String vehicleName) { - return new String[] { "jakarta.enterprise.concurrent", "jakarta.enterprise.concurrent.spi" }; - - } - - /** - * Returns the classpath for the packages we are interested in. - */ - protected String getClasspath() { - final String defined = System.getProperty("signature.sigTestClasspath"); - if (defined != null && !defined.isBlank()) { - return defined; - } - // The Jakarta artifacts we want added to our classpath - String[] classes = new String[] { - "jakarta.enterprise.concurrent.AbortedException", // For jakarta.enterprise.concurrent-api-3.0.0.jar - "jakarta.enterprise.util.Nonbinding", // For jakarta.enterprise.cdi-api-4.0.0.jar - "jakarta.interceptor.InterceptorBinding" // For jakarta.interceptor-api-2.1.0.jar - }; - - // The JDK modules we want added to our classpath - String[] JDKModules = new String[] { - "java.base", - "java.rmi", - "java.sql", - "java.naming" - }; - - //Get Jakarta artifacts from application server - Set classPaths = new HashSet(); - for(String c : classes) { - try { - Class clazz = Class.forName(c); - final CodeSource codeSource = clazz.getProtectionDomain().getCodeSource(); - final URL location = codeSource == null ? null : codeSource.getLocation(); - // Likely not null, but if so we cannot find the location of the JAR or class - if (codeSource == null || location == null) { - log.warning(String.format("Could not resolve the the library for %s.", clazz.getName())); - continue; - } - String path = resolvePath(location); - if(!classPaths.contains(path)) { - classPaths.add(path); - } - } catch (ClassNotFoundException e) { - throw new RuntimeException("Unable to load class " + c + " from application server."); - } - } - - - //Get JDK modules from jimage - //Add JDK classes to classpath - File jimageOutput = new File(testInfo.getJImageDir()); - for (String module : JDKModules) { - Path modulePath = Paths.get(jimageOutput.getAbsolutePath(), module); - if(Files.isDirectory(modulePath)) { - classPaths.add(modulePath.toString()); - } else { - throw new RuntimeException("Unable to load JDK module " + module + " from jimage output " + System.lineSeparator() - + "Searched in directory: " + modulePath.toString()); - } - } - - return String.join(":", classPaths); - - } - - protected File writeStreamToTempFile(InputStream inputStream, String tempFilePrefix, String tempFileSuffix) - throws IOException { - FileOutputStream outputStream = null; - - try { - File file = File.createTempFile(tempFilePrefix, tempFileSuffix); - outputStream = new FileOutputStream(file); - byte[] buffer = new byte[1024]; - while (true) { - int bytesRead = inputStream.read(buffer); - if (bytesRead == -1) { - break; - } - outputStream.write(buffer, 0, bytesRead); - } - return file; - } - - finally { - if (outputStream != null) { - outputStream.close(); - } - } - } - - protected File writeStreamToSigFile(InputStream inputStream) throws IOException { - FileOutputStream outputStream = null; - String tmpdir = System.getProperty("java.io.tmpdir"); - try { - File sigfile = new File( - tmpdir + File.separator + SIG_FILE_NAME); - if (sigfile.exists()) { - sigfile.delete(); - log.info("Existing signature file deleted to create new one"); - } - if (!sigfile.createNewFile()) { - log.info("signature file is not created"); - } - outputStream = new FileOutputStream(sigfile); - byte[] buffer = new byte[1024]; - while (true) { - int bytesRead = inputStream.read(buffer); - if (bytesRead == -1) { - break; - } - outputStream.write(buffer, 0, bytesRead); - } - return sigfile; - } - - finally { - if (outputStream != null) { - outputStream.close(); - } - } - } - - /***** - * Boilerplate Code - * - * /* The following comments are specified in the base class that defines the - * signature tests. This is done so the test finders will find the right class - * to run. The implementation of these methods is inherited from the super class - * which is part of the signature test framework. - */ - - // NOTE: If the API under test is not part of your testing runtime - // environment, you may use the property sigTestClasspath to specify - // where the API under test lives. This should almost never be used. - // Normally the API under test should be specified in the classpath - // of the VM running the signature tests. Use either the first - // comment or the one below it depending on which properties your - // signature tests need. Please do not use both comments. - - public void signatureTest() throws Fault { - log.info("ConcurrencySigTest.signatureTest() called"); - SigTestResult results = null; - String mapFile = null; - String packageListFile = null; - String signatureRepositoryDir = null; - try { - - InputStream inStreamMapfile = ConcurrencySignatureTestRunner.class.getClassLoader() - .getResourceAsStream("ee/jakarta/tck/concurrent/common/signature/" + SIG_MAP_NAME); - File mFile = writeStreamToTempFile(inStreamMapfile, "sig-test", ".map"); - mapFile = mFile.getCanonicalPath(); - log.info("mapFile location is :" + mapFile); - - InputStream inStreamPackageFile = ConcurrencySignatureTestRunner.class.getClassLoader() - .getResourceAsStream("ee/jakarta/tck/concurrent/common/signature/" + SIG_PKG_NAME); - File pFile = writeStreamToTempFile(inStreamPackageFile, "sig-test-pkg-list", ".txt"); - packageListFile = pFile.getCanonicalPath(); - log.info("packageFile location is :" + packageListFile); - - InputStream inStreamSigFile = ConcurrencySignatureTestRunner.class.getClassLoader() - .getResourceAsStream("ee/jakarta/tck/concurrent/common/signature/" + SIG_FILE_NAME); - File sigFile = writeStreamToSigFile(inStreamSigFile); - log.info("signature File location is :" + sigFile.getCanonicalPath()); - signatureRepositoryDir = System.getProperty("java.io.tmpdir"); - - } catch (IOException ex) { - log.info("Exception while creating temp files :" + ex); - } - - String[] packagesUnderTest = getPackages(testInfo.getVehicle()); - String[] classesUnderTest = getClasses(testInfo.getVehicle()); - String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); - - // unlisted optional packages are technology packages for those optional - // technologies (e.g. jsr-88) that might not have been specified by the - // user. - // We want to ensure there are no full or partial implementations of an - // optional technology which were not declared - ArrayList unlistedTechnologyPkgs = getUnlistedOptionalPackages(); - - // If testing with Java 9+, extract the JDK's modules so they can be used - // on the testcase's classpath. - Properties sysProps = System.getProperties(); - String version = (String) sysProps.get("java.version"); - if (!version.startsWith("1.")) { - String jimageDir = testInfo.getJImageDir(); - File f = new File(jimageDir); - f.mkdirs(); - - String javaHome = (String) sysProps.get("java.home"); - log.info("Executing JImage"); - - try { - ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/jimage", "extract", "--dir=" + jimageDir, - javaHome + "/lib/modules"); - System.out - .println(javaHome + "/bin/jimage extract --dir=" + jimageDir + " " + javaHome + "/lib/modules"); - pb.redirectErrorStream(true); - Process proc = pb.start(); - BufferedReader out = new BufferedReader(new InputStreamReader(proc.getInputStream())); - String line = null; - while ((line = out.readLine()) != null) { - log.info(line); - } - - int rc = proc.waitFor(); - log.info("JImage RC = " + rc); - out.close(); - } catch (Exception e) { - log.info("Exception while executing JImage! Some tests may fail."); - e.printStackTrace(); - } - } - - String classpath = getClasspath(); - - try { - results = getSigTestDriver().executeSigTest( // - packageListFile, // file containing the packages/classes that are to be verified - mapFile, // sig-test.map file - signatureRepositoryDir, // directory containing the recorded signatures - packagesUnderTest, // packages, defined by the test client, that should be tested - classesUnderTest, // classes, defined by the test client, that should be tested - classpath, //The location of the API being verified. - unlistedTechnologyPkgs, // packages that should not exist within the technology under test. - optionalPkgToIgnore); // packages that should be ignored if found. - log.info(results.toString()); - if (!results.passed()) { - log.info("results.passed() returned false"); - throw new Exception(); - } - - log.info("$$$ ConcurrencySigTest.signatureTest() returning"); - } catch (Exception e) { - if (results != null && !results.passed()) { - throw new Fault("ConcurrencySigTest.signatureTest() failed!, diffs found"); - } else { - log.info("Unexpected exception " + e.getMessage()); - throw new Fault("ConcurrencySigTest.signatureTest() failed with an unexpected exception", e); - } - } - } - + + public static final String[] SIG_RESOURCES = { SIG_FILE_NAME, SIG_MAP_NAME, SIG_PKG_NAME }; + + private static final TestLogger log = TestLogger.get(ConcurrencySignatureTestRunner.class); + + public ConcurrencySignatureTestRunner() { + setup(); + } + + /** + * Returns a list of strings where each string represents a package name. Each + * package name will have it's signature tested by the signature test framework. + * + * @return String[] The names of the packages whose signatures should be + * verified. + */ + @Override + protected String[] getPackages(String vehicleName) { + return new String[] { "jakarta.enterprise.concurrent", "jakarta.enterprise.concurrent.spi" }; + + } + + /** + * Returns the classpath for the packages we are interested in. + */ + protected String getClasspath() { + final String defined = System.getProperty("signature.sigTestClasspath"); + if (defined != null && !defined.isBlank()) { + return defined; + } + // The Jakarta artifacts we want added to our classpath + String[] classes = new String[] { "jakarta.enterprise.concurrent.AbortedException", // For + // jakarta.enterprise.concurrent-api-3.0.0.jar + "jakarta.enterprise.util.Nonbinding", // For jakarta.enterprise.cdi-api-4.0.0.jar + "jakarta.interceptor.InterceptorBinding" // For jakarta.interceptor-api-2.1.0.jar + }; + + // The JDK modules we want added to our classpath + String[] JDKModules = new String[] { "java.base", "java.rmi", "java.sql", "java.naming" }; + + // Get Jakarta artifacts from application server + Set classPaths = new HashSet(); + for (String c : classes) { + try { + Class clazz = Class.forName(c); + final CodeSource codeSource = clazz.getProtectionDomain().getCodeSource(); + final URL location = codeSource == null ? null : codeSource.getLocation(); + // Likely not null, but if so we cannot find the location of the JAR or class + if (codeSource == null || location == null) { + log.warning(String.format("Could not resolve the the library for %s.", clazz.getName())); + continue; + } + String path = resolvePath(location); + if (!classPaths.contains(path)) { + classPaths.add(path); + } + } catch (ClassNotFoundException e) { + throw new RuntimeException("Unable to load class " + c + " from application server."); + } + } + + // Get JDK modules from jimage + // Add JDK classes to classpath + File jimageOutput = new File(testInfo.getJImageDir()); + for (String module : JDKModules) { + Path modulePath = Paths.get(jimageOutput.getAbsolutePath(), module); + if (Files.isDirectory(modulePath)) { + classPaths.add(modulePath.toString()); + } else { + throw new RuntimeException("Unable to load JDK module " + module + " from jimage output " + + System.lineSeparator() + "Searched in directory: " + modulePath.toString()); + } + } + + return String.join(":", classPaths); + + } + + protected File writeStreamToTempFile(InputStream inputStream, String tempFilePrefix, String tempFileSuffix) + throws IOException { + FileOutputStream outputStream = null; + + try { + File file = File.createTempFile(tempFilePrefix, tempFileSuffix); + outputStream = new FileOutputStream(file); + byte[] buffer = new byte[1024]; + while (true) { + int bytesRead = inputStream.read(buffer); + if (bytesRead == -1) { + break; + } + outputStream.write(buffer, 0, bytesRead); + } + return file; + } + + finally { + if (outputStream != null) { + outputStream.close(); + } + } + } + + protected File writeStreamToSigFile(InputStream inputStream) throws IOException { + FileOutputStream outputStream = null; + String tmpdir = System.getProperty("java.io.tmpdir"); + try { + File sigfile = new File(tmpdir + File.separator + SIG_FILE_NAME); + if (sigfile.exists()) { + sigfile.delete(); + log.info("Existing signature file deleted to create new one"); + } + if (!sigfile.createNewFile()) { + log.info("signature file is not created"); + } + outputStream = new FileOutputStream(sigfile); + byte[] buffer = new byte[1024]; + while (true) { + int bytesRead = inputStream.read(buffer); + if (bytesRead == -1) { + break; + } + outputStream.write(buffer, 0, bytesRead); + } + return sigfile; + } + + finally { + if (outputStream != null) { + outputStream.close(); + } + } + } + + /***** + * Boilerplate Code + * + * /* The following comments are specified in the base class that defines the + * signature tests. This is done so the test finders will find the right class + * to run. The implementation of these methods is inherited from the super class + * which is part of the signature test framework. + */ + + // NOTE: If the API under test is not part of your testing runtime + // environment, you may use the property sigTestClasspath to specify + // where the API under test lives. This should almost never be used. + // Normally the API under test should be specified in the classpath + // of the VM running the signature tests. Use either the first + // comment or the one below it depending on which properties your + // signature tests need. Please do not use both comments. + + public void signatureTest() throws Fault { + log.info("ConcurrencySigTest.signatureTest() called"); + SigTestResult results = null; + String mapFile = null; + String packageListFile = null; + String signatureRepositoryDir = null; + try { + + InputStream inStreamMapfile = ConcurrencySignatureTestRunner.class.getClassLoader() + .getResourceAsStream("ee/jakarta/tck/concurrent/common/signature/" + SIG_MAP_NAME); + File mFile = writeStreamToTempFile(inStreamMapfile, "sig-test", ".map"); + mapFile = mFile.getCanonicalPath(); + log.info("mapFile location is :" + mapFile); + + InputStream inStreamPackageFile = ConcurrencySignatureTestRunner.class.getClassLoader() + .getResourceAsStream("ee/jakarta/tck/concurrent/common/signature/" + SIG_PKG_NAME); + File pFile = writeStreamToTempFile(inStreamPackageFile, "sig-test-pkg-list", ".txt"); + packageListFile = pFile.getCanonicalPath(); + log.info("packageFile location is :" + packageListFile); + + InputStream inStreamSigFile = ConcurrencySignatureTestRunner.class.getClassLoader() + .getResourceAsStream("ee/jakarta/tck/concurrent/common/signature/" + SIG_FILE_NAME); + File sigFile = writeStreamToSigFile(inStreamSigFile); + log.info("signature File location is :" + sigFile.getCanonicalPath()); + signatureRepositoryDir = System.getProperty("java.io.tmpdir"); + + } catch (IOException ex) { + log.info("Exception while creating temp files :" + ex); + } + + String[] packagesUnderTest = getPackages(testInfo.getVehicle()); + String[] classesUnderTest = getClasses(testInfo.getVehicle()); + String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); + + // unlisted optional packages are technology packages for those optional + // technologies (e.g. jsr-88) that might not have been specified by the + // user. + // We want to ensure there are no full or partial implementations of an + // optional technology which were not declared + ArrayList unlistedTechnologyPkgs = getUnlistedOptionalPackages(); + + // If testing with Java 9+, extract the JDK's modules so they can be used + // on the testcase's classpath. + Properties sysProps = System.getProperties(); + String version = (String) sysProps.get("java.version"); + if (!version.startsWith("1.")) { + String jimageDir = testInfo.getJImageDir(); + File f = new File(jimageDir); + f.mkdirs(); + + String javaHome = (String) sysProps.get("java.home"); + log.info("Executing JImage"); + + try { + ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/jimage", "extract", "--dir=" + jimageDir, + javaHome + "/lib/modules"); + System.out + .println(javaHome + "/bin/jimage extract --dir=" + jimageDir + " " + javaHome + "/lib/modules"); + pb.redirectErrorStream(true); + Process proc = pb.start(); + BufferedReader out = new BufferedReader(new InputStreamReader(proc.getInputStream())); + String line = null; + while ((line = out.readLine()) != null) { + log.info(line); + } + + int rc = proc.waitFor(); + log.info("JImage RC = " + rc); + out.close(); + } catch (Exception e) { + log.info("Exception while executing JImage! Some tests may fail."); + e.printStackTrace(); + } + } + + String classpath = getClasspath(); + + try { + results = getSigTestDriver().executeSigTest( // + packageListFile, // file containing the packages/classes that are to be verified + mapFile, // sig-test.map file + signatureRepositoryDir, // directory containing the recorded signatures + packagesUnderTest, // packages, defined by the test client, that should be tested + classesUnderTest, // classes, defined by the test client, that should be tested + classpath, // The location of the API being verified. + unlistedTechnologyPkgs, // packages that should not exist within the technology under test. + optionalPkgToIgnore); // packages that should be ignored if found. + log.info(results.toString()); + if (!results.passed()) { + log.info("results.passed() returned false"); + throw new Exception(); + } + + log.info("$$$ ConcurrencySigTest.signatureTest() returning"); + } catch (Exception e) { + if (results != null && !results.passed()) { + throw new Fault("ConcurrencySigTest.signatureTest() failed!, diffs found"); + } else { + log.info("Unexpected exception " + e.getMessage()); + throw new Fault("ConcurrencySigTest.signatureTest() failed with an unexpected exception", e); + } + } + } + /** * Ensures the test project to configured correctly to run signature tests * before attempting to run signature tests. @@ -332,50 +325,51 @@ public static void assertProjectSetup() { throw new RuntimeException("Unable to load an internal JDK class", e); } - for (Method m : intf.getDeclaredMethods()) { - try { - m.setAccessible(true); - } catch (InaccessibleObjectException ioe) { - // This means that this application (module) does not have access to JDK - // internals via reflection - String message = "Tried to call setAccessible on JDK internal method and received an InaccessibleObjectException from the JDK. " - + "Give this application (module) access to internal messages using the following JVM properties: " - + "--add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED " - + "--add-opens java.base/jdk.internal.vm.annotation=ALL-UNNAMED"; - fail(message, ioe); - } catch (SecurityException se) { - // This means that this application was running under a security manager that - // did not allow the method call - String message = "Tried to call setAccessible on JDK internal method and received SecurityException from the security manager. " - + "Give this application permission to make this method call with the security manager using the following permissions:" - + "permission java.lang.RuntimePermission \"accessClassInPackage.jdk.internal\"; " - + "permission java.lang.RuntimePermission \"accessClassInPackage.jdk.internal.reflect\"; " - + "permission java.lang.RuntimePermission \"accessClassInPackage.jdk.internal.vm.annotation\";"; - fail(message, se); - } + for (Method m : intf.getDeclaredMethods()) { + try { + m.setAccessible(true); + } catch (InaccessibleObjectException ioe) { + // This means that this application (module) does not have access to JDK + // internals via reflection + String message = "Tried to call setAccessible on JDK internal method and received an InaccessibleObjectException from the JDK. " + + "Give this application (module) access to internal messages using the following JVM properties: " + + "--add-exports java.base/jdk.internal.vm.annotation=ALL-UNNAMED " + + "--add-opens java.base/jdk.internal.vm.annotation=ALL-UNNAMED"; + fail(message, ioe); + } catch (SecurityException se) { + // This means that this application was running under a security manager that + // did not allow the method call + String message = "Tried to call setAccessible on JDK internal method and received SecurityException from the security manager. " + + "Give this application permission to make this method call with the security manager using the following permissions:" + + "permission java.lang.RuntimePermission \"accessClassInPackage.jdk.internal\"; " + + "permission java.lang.RuntimePermission \"accessClassInPackage.jdk.internal.reflect\"; " + + "permission java.lang.RuntimePermission \"accessClassInPackage.jdk.internal.vm.annotation\";"; + fail(message, se); + } } } - private static String resolvePath(final URL resource) { - if (resource == null) { - return null; - } - final String path = resource.getPath(); - final String protocol = resource.getProtocol(); - - // Possibly only specific to JBoss Modules. However, executing this will not be an issue for non-jboss-modules - // implementations. - if ("jar".equals(protocol)) { - // The last path segment before "!/" should be the JAR name - final int sepIdx = path.lastIndexOf("!/"); - // We need to ignore jar:file: and use the real filesystem path - final int start = path.startsWith("file:") ? 5 : 0; - if (sepIdx != -1) { - // hit! - return path.substring(start, sepIdx); - } - return path.substring(start); - } - return path; - } + private static String resolvePath(final URL resource) { + if (resource == null) { + return null; + } + final String path = resource.getPath(); + final String protocol = resource.getProtocol(); + + // Possibly only specific to JBoss Modules. However, executing this will not be + // an issue for non-jboss-modules + // implementations. + if ("jar".equals(protocol)) { + // The last path segment before "!/" should be the JAR name + final int sepIdx = path.lastIndexOf("!/"); + // We need to ignore jar:file: and use the real filesystem path + final int start = path.startsWith("file:") ? 5 : 0; + if (sepIdx != -1) { + // hit! + return path.substring(start, sepIdx); + } + return path.substring(start); + } + return path; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java index 64b3ad30..8cf9509f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java @@ -64,347 +64,347 @@ */ class PackageList { - // Any line in the packageFile starting with this character is a comment - private static final char COMMENT_CHAR = '#'; + // Any line in the packageFile starting with this character is a comment + private static final char COMMENT_CHAR = '#'; - private static final String BACKUP_EXT = ".bak"; + private static final String BACKUP_EXT = ".bak"; - // File containing the list of packages and sub-packages - private File packageFile; + // File containing the list of packages and sub-packages + private File packageFile; - // Signature file where the package signatures were recorded - private File sigFile; + // Signature file where the package signatures were recorded + private File sigFile; - // Name of the package being recorded - private String additionalPackageName; + // Name of the package being recorded + private String additionalPackageName; - // Name of packages and sub-packages in the - private Set packageNames = new TreeSet<>(); + // Name of packages and sub-packages in the + private Set packageNames = new TreeSet<>(); - /** - * Creates an instance of the PackageList class. The PackageList instance reads - * the specified package file and populates it's internal state with the package - * names found in this file. Users should use this c'tor when playing back - * signature files. Users can init the PackageList instance then use the - * "String[] getSubPackages(String packageName)" method to get the list of valid - * sub-packages for every package who's signature is being verified. - * - * @param packageFileName The name of the file that contains the package list. - * This file contains the names of all the packages that - * exist across all the signature files that makeup this - * deliverable. This file is used to generate a list of - * valid sub-packages that must be exclued when testing - * theor parent package's signature. - * - * @throws Exception when the packageFileName does not exist. - */ - public PackageList(String packageFileName) throws Exception { - packageFile = new File(packageFileName); - if (packageFile.exists() && packageFile.isFile()) { - extractExistingPackageNames(); - } else { - throw new FileNotFoundException(packageFileName); - } - } + /** + * Creates an instance of the PackageList class. The PackageList instance reads + * the specified package file and populates it's internal state with the package + * names found in this file. Users should use this c'tor when playing back + * signature files. Users can init the PackageList instance then use the + * "String[] getSubPackages(String packageName)" method to get the list of valid + * sub-packages for every package who's signature is being verified. + * + * @param packageFileName The name of the file that contains the package list. + * This file contains the names of all the packages that + * exist across all the signature files that makeup this + * deliverable. This file is used to generate a list of + * valid sub-packages that must be exclued when testing + * theor parent package's signature. + * + * @throws Exception when the packageFileName does not exist. + */ + public PackageList(String packageFileName) throws Exception { + packageFile = new File(packageFileName); + if (packageFile.exists() && packageFile.isFile()) { + extractExistingPackageNames(); + } else { + throw new FileNotFoundException(packageFileName); + } + } - /** - * Creates an instance of the PackageList class. The PackageList instance reads - * the contents of the packageFileName and stores it in it's internal state. - * Next, any packages whos name starts with the specified packageName are - * removed from the internal package list. This is done because this is the - * package being recorded and we need to remove any previously recorded package - * names in case any sub-packages have been removed since the last time the - * signatures were recorded. Users should use this c'tor when they are recording - * signature files never during playback. - * - * @param packageName The name of the package whos signatures are being - * recorded (along with sub-packages). - * @param sigFileName The name of the file that contains the recored - * signatures. - * @param packageFileName The name of the file that contains the package list. - * This file contains the names of all the packages that - * exist across all the signature files that makeup this - * deliverable. This file is used to generate a list of - * valid sub-packages that must be exclued when testing - * their parent package's signature. - * - * @throws Exception when an error occurs reading the packageFileName or the - * sigFileName does not exist. - */ - public PackageList(String packageName, String sigFileName, String packageFileName) throws Exception { - this.additionalPackageName = packageName; - sigFile = new File(sigFileName); - if (!sigFile.exists() || !sigFile.isFile()) { - throw new FileNotFoundException(sigFileName); - } - packageFile = new File(packageFileName); - if (packageFile.exists() && packageFile.isFile()) { - extractExistingPackageNames(); - removeExistingPackage(); - } - } + /** + * Creates an instance of the PackageList class. The PackageList instance reads + * the contents of the packageFileName and stores it in it's internal state. + * Next, any packages whos name starts with the specified packageName are + * removed from the internal package list. This is done because this is the + * package being recorded and we need to remove any previously recorded package + * names in case any sub-packages have been removed since the last time the + * signatures were recorded. Users should use this c'tor when they are recording + * signature files never during playback. + * + * @param packageName The name of the package whos signatures are being + * recorded (along with sub-packages). + * @param sigFileName The name of the file that contains the recored + * signatures. + * @param packageFileName The name of the file that contains the package list. + * This file contains the names of all the packages that + * exist across all the signature files that makeup this + * deliverable. This file is used to generate a list of + * valid sub-packages that must be exclued when testing + * their parent package's signature. + * + * @throws Exception when an error occurs reading the packageFileName or the + * sigFileName does not exist. + */ + public PackageList(String packageName, String sigFileName, String packageFileName) throws Exception { + this.additionalPackageName = packageName; + sigFile = new File(sigFileName); + if (!sigFile.exists() || !sigFile.isFile()) { + throw new FileNotFoundException(sigFileName); + } + packageFile = new File(packageFileName); + if (packageFile.exists() && packageFile.isFile()) { + extractExistingPackageNames(); + removeExistingPackage(); + } + } - /** - * Read the package names stored in the package list file. Each package name - * found in the package list file is added to the internal tree set. - * - * @throws Exception if there is an error opening or reading the package list - * file. - */ - private void extractExistingPackageNames() throws Exception { - BufferedReader in = new BufferedReader(new FileReader(packageFile)); - String line; - String trimLine; - try { - while ((line = in.readLine()) != null) { - trimLine = line.trim(); - if (isComment(trimLine) || "".equals(trimLine)) { - continue; - } - packageNames.add(trimLine); - } - } finally { - try { - in.close(); - } catch (Exception e) { - } - } - } + /** + * Read the package names stored in the package list file. Each package name + * found in the package list file is added to the internal tree set. + * + * @throws Exception if there is an error opening or reading the package list + * file. + */ + private void extractExistingPackageNames() throws Exception { + BufferedReader in = new BufferedReader(new FileReader(packageFile)); + String line; + String trimLine; + try { + while ((line = in.readLine()) != null) { + trimLine = line.trim(); + if (isComment(trimLine) || "".equals(trimLine)) { + continue; + } + packageNames.add(trimLine); + } + } finally { + try { + in.close(); + } catch (Exception e) { + } + } + } - /** - * Returns true if the specified string starts with a comment character as - * denoted by the COMMENT_CHAR constant. - * - * @param line Determins of this line is a comment line - * - * @return boolean True if the specified line is a comment line else false. - */ - private boolean isComment(String line) { - if (line == null) { - return false; - } - String theLine = line.trim(); - if (theLine.length() > 0) { - return (theLine.charAt(0) == COMMENT_CHAR); - } + /** + * Returns true if the specified string starts with a comment character as + * denoted by the COMMENT_CHAR constant. + * + * @param line Determins of this line is a comment line + * + * @return boolean True if the specified line is a comment line else false. + */ + private boolean isComment(String line) { + if (line == null) { + return false; + } + String theLine = line.trim(); + if (theLine.length() > 0) { + return (theLine.charAt(0) == COMMENT_CHAR); + } - return false; - } + return false; + } - /** - * Removes package names from the package list file. The packages that are - * removed are the ones currently being recorded. The packages being recorded is - * denoted by this.additionalPackageName. This includes any sub-packages of the - * additionalPackageName. This step is necessary in the cases where a - * sub-package has been removed from a parent package in between signature - * recordings. - */ - private void removeExistingPackage() { - String delPackage = this.additionalPackageName; - String packageName; - List delPkgs = new ArrayList<>(); - // iterate over package set and find package names to remove - for (Iterator i = packageNames.iterator(); i.hasNext();) { - packageName = i.next(); - if (packageName.startsWith(delPackage)) { - delPkgs.add(packageName); - } - } - // actually remove the package names from the set - for (int i = 0; i < delPkgs.size(); i++) { - packageName = delPkgs.get(i); - packageNames.remove(packageName); - System.out.println("PackageList.removeExistingPackage() \"" + packageName + "\""); - } - } + /** + * Removes package names from the package list file. The packages that are + * removed are the ones currently being recorded. The packages being recorded is + * denoted by this.additionalPackageName. This includes any sub-packages of the + * additionalPackageName. This step is necessary in the cases where a + * sub-package has been removed from a parent package in between signature + * recordings. + */ + private void removeExistingPackage() { + String delPackage = this.additionalPackageName; + String packageName; + List delPkgs = new ArrayList<>(); + // iterate over package set and find package names to remove + for (Iterator i = packageNames.iterator(); i.hasNext();) { + packageName = i.next(); + if (packageName.startsWith(delPackage)) { + delPkgs.add(packageName); + } + } + // actually remove the package names from the set + for (int i = 0; i < delPkgs.size(); i++) { + packageName = delPkgs.get(i); + packageNames.remove(packageName); + System.out.println("PackageList.removeExistingPackage() \"" + packageName + "\""); + } + } - /** - * Write the package list out to the package list file. This is done by reading - * all the package names in the specified signature file and adding them to the - * internal tree set. Then the old package list file is removed and the new - * package list file is written out. - * - * @throws Exception if there is a problem removing the existing package file or - * writting the new package list file. - */ - public void writePkgListFile() throws Exception { - readPkgsFromSigFile(); - removePkgFile(); - writePkgFile(); - } + /** + * Write the package list out to the package list file. This is done by reading + * all the package names in the specified signature file and adding them to the + * internal tree set. Then the old package list file is removed and the new + * package list file is written out. + * + * @throws Exception if there is a problem removing the existing package file or + * writting the new package list file. + */ + public void writePkgListFile() throws Exception { + readPkgsFromSigFile(); + removePkgFile(); + writePkgFile(); + } - /** - * Extract the package name from the specified string. The specified string - * should have the form: "package jakarta.ejb;" - * - * @param packageLine The string containing the package name. - * - * @return String The extracted package name. - * - * @throws Exception if the specified string does not conform to the expected - * format. - */ - private String parsePackageName(String packageLine) throws Exception { + /** + * Extract the package name from the specified string. The specified string + * should have the form: "package jakarta.ejb;" + * + * @param packageLine The string containing the package name. + * + * @return String The extracted package name. + * + * @throws Exception if the specified string does not conform to the expected + * format. + */ + private String parsePackageName(String packageLine) throws Exception { - // sig test framework doesn't have the concept of package entries - // as the ApiCheck signature format does. - // Instead, we need to parse an entry similar to this: - // CLSS public jakarta.some.package.SomeClass + // sig test framework doesn't have the concept of package entries + // as the ApiCheck signature format does. + // Instead, we need to parse an entry similar to this: + // CLSS public jakarta.some.package.SomeClass - return packageLine.substring(packageLine.lastIndexOf(' ') + 1, packageLine.lastIndexOf('.')); - } + return packageLine.substring(packageLine.lastIndexOf(' ') + 1, packageLine.lastIndexOf('.')); + } - /** - * Reads the package names from the signature file. Each package name that is - * read is added to this classes internal tree set. - * - * @throws Exception if there is an error opening or reading the signature file. - */ - private void readPkgsFromSigFile() throws Exception { - BufferedReader in = new BufferedReader(new FileReader(sigFile)); - String line; - String trimLine; - try { - while ((line = in.readLine()) != null) { - trimLine = line.trim(); - if (trimLine.startsWith("CLSS")) { - packageNames.add(parsePackageName(trimLine)); - } - } - } finally { - try { - in.close(); - } catch (Exception e) { - } - } - } + /** + * Reads the package names from the signature file. Each package name that is + * read is added to this classes internal tree set. + * + * @throws Exception if there is an error opening or reading the signature file. + */ + private void readPkgsFromSigFile() throws Exception { + BufferedReader in = new BufferedReader(new FileReader(sigFile)); + String line; + String trimLine; + try { + while ((line = in.readLine()) != null) { + trimLine = line.trim(); + if (trimLine.startsWith("CLSS")) { + packageNames.add(parsePackageName(trimLine)); + } + } + } finally { + try { + in.close(); + } catch (Exception e) { + } + } + } - /** - * Removes the existing package list file. The package list file is actually - * moved to a backup file if it exists. The old backup is lost. - * - * @throws Exception if there is an error moving the current package list file - * to a backup file. - */ - private void removePkgFile() throws Exception { - File backupPkgFile = new File(packageFile.getPath() + BACKUP_EXT); - if (backupPkgFile.exists() && backupPkgFile.isFile()) { - backupPkgFile.delete(); - } - if (packageFile.isFile() && packageFile.exists()) { - File copyPackageFile = new File(packageFile.getPath()); - copyPackageFile.renameTo(backupPkgFile); - } - } + /** + * Removes the existing package list file. The package list file is actually + * moved to a backup file if it exists. The old backup is lost. + * + * @throws Exception if there is an error moving the current package list file + * to a backup file. + */ + private void removePkgFile() throws Exception { + File backupPkgFile = new File(packageFile.getPath() + BACKUP_EXT); + if (backupPkgFile.exists() && backupPkgFile.isFile()) { + backupPkgFile.delete(); + } + if (packageFile.isFile() && packageFile.exists()) { + File copyPackageFile = new File(packageFile.getPath()); + copyPackageFile.renameTo(backupPkgFile); + } + } - /** - * Write a simple header to the package list file to explain what the file is. - * - * @param out The BufferedWriter to dump the header to. - * - * @throws Exception if there is any errors writing the header to the specified - * BufferedWriter. - */ - private void writeHeader(BufferedWriter out) throws Exception { - out.write(COMMENT_CHAR); - out.write(COMMENT_CHAR); - out.newLine(); - out.write(COMMENT_CHAR + " This file contains a list of all the packages"); - out.newLine(); - out.write(COMMENT_CHAR + " contained in the signature files for this"); - out.newLine(); - out.write(COMMENT_CHAR + " deliverable. This file is used to exclude valid"); - out.newLine(); - out.write(COMMENT_CHAR + " sub-packages from being verified when their"); - out.newLine(); - out.write(COMMENT_CHAR + " parent package's signature is checked."); - out.newLine(); - out.write(COMMENT_CHAR); - out.write(COMMENT_CHAR); - out.newLine(); - out.newLine(); - } + /** + * Write a simple header to the package list file to explain what the file is. + * + * @param out The BufferedWriter to dump the header to. + * + * @throws Exception if there is any errors writing the header to the specified + * BufferedWriter. + */ + private void writeHeader(BufferedWriter out) throws Exception { + out.write(COMMENT_CHAR); + out.write(COMMENT_CHAR); + out.newLine(); + out.write(COMMENT_CHAR + " This file contains a list of all the packages"); + out.newLine(); + out.write(COMMENT_CHAR + " contained in the signature files for this"); + out.newLine(); + out.write(COMMENT_CHAR + " deliverable. This file is used to exclude valid"); + out.newLine(); + out.write(COMMENT_CHAR + " sub-packages from being verified when their"); + out.newLine(); + out.write(COMMENT_CHAR + " parent package's signature is checked."); + out.newLine(); + out.write(COMMENT_CHAR); + out.write(COMMENT_CHAR); + out.newLine(); + out.newLine(); + } - /** - * Write the list of package names out to a package list file. - * - * @throws Exception if there is an error creating and writting the package list - * file. - */ - private void writePkgFile() throws Exception { - BufferedWriter out = null; - try { - out = new BufferedWriter(new FileWriter(packageFile)); - writeHeader(out); - for (Iterator i = packageNames.iterator(); i.hasNext();) { - String packageName = i.next(); - out.write(packageName); - out.newLine(); - System.out.println("PackageList.writePkgFile() \"" + packageName + "\""); - } - } finally { - if (out != null) { - out.close(); - } - } - } + /** + * Write the list of package names out to a package list file. + * + * @throws Exception if there is an error creating and writting the package list + * file. + */ + private void writePkgFile() throws Exception { + BufferedWriter out = null; + try { + out = new BufferedWriter(new FileWriter(packageFile)); + writeHeader(out); + for (Iterator i = packageNames.iterator(); i.hasNext();) { + String packageName = i.next(); + out.write(packageName); + out.newLine(); + System.out.println("PackageList.writePkgFile() \"" + packageName + "\""); + } + } finally { + if (out != null) { + out.close(); + } + } + } - /** - * Returns the list of sub-packages that exist in the specified package name. - * - * @param pkgName The name of the package we want the sub-package list for. - * - * @return String[] The sub-packages that live under the specified parent - * package. - */ - public String[] getSubPackages(String pkgName) { - List result = new ArrayList<>(); - String subPackageName = pkgName + "."; - for (Iterator i = packageNames.iterator(); i.hasNext();) { - String packageName = i.next(); - if (packageName.startsWith(subPackageName)) { - result.add(packageName); - } - } - return (String[]) (result.toArray(new String[result.size()])); - } + /** + * Returns the list of sub-packages that exist in the specified package name. + * + * @param pkgName The name of the package we want the sub-package list for. + * + * @return String[] The sub-packages that live under the specified parent + * package. + */ + public String[] getSubPackages(String pkgName) { + List result = new ArrayList<>(); + String subPackageName = pkgName + "."; + for (Iterator i = packageNames.iterator(); i.hasNext();) { + String packageName = i.next(); + if (packageName.startsWith(subPackageName)) { + result.add(packageName); + } + } + return (String[]) (result.toArray(new String[result.size()])); + } - /** - * Returns the list of sub-packages that exist in the specified package name. - * The returned string matches the API check format of specifying multiple - * packages with a single string. Each package name is separated with the "+" - * character. - * - * @param pkgName The name of the package we want the sub-package list for. - * - * @return String The sub-packages that live under the specified parent package. - */ - public String getSubPackagesFormatted(String pkgName) { - StringBuffer formattedResult = new StringBuffer(); - String[] result = getSubPackages(pkgName); - for (int i = 0; i < result.length; i++) { - formattedResult.append(result[i]); - if (i < (result.length - 1)) { - formattedResult.append("+"); - } - } - return formattedResult.toString(); - } + /** + * Returns the list of sub-packages that exist in the specified package name. + * The returned string matches the API check format of specifying multiple + * packages with a single string. Each package name is separated with the "+" + * character. + * + * @param pkgName The name of the package we want the sub-package list for. + * + * @return String The sub-packages that live under the specified parent package. + */ + public String getSubPackagesFormatted(String pkgName) { + StringBuffer formattedResult = new StringBuffer(); + String[] result = getSubPackages(pkgName); + for (int i = 0; i < result.length; i++) { + formattedResult.append(result[i]); + if (i < (result.length - 1)) { + formattedResult.append("+"); + } + } + return formattedResult.toString(); + } - /* - * Test Driver - */ - public static void main(String[] args) throws Exception { - System.out.println("\n\n*** Creating package list file ***\n\n"); - PackageList list = new PackageList("jakarta.ejb", - "/home/ryano/cts-tools-master/tools/api-check/test/jakarta.ejb.sig_2.1", - "/home/ryano/cts-tools-master/tools/api-check/test/pkg-list.txt"); - list.writePkgListFile(); + /* + * Test Driver + */ + public static void main(String[] args) throws Exception { + System.out.println("\n\n*** Creating package list file ***\n\n"); + PackageList list = new PackageList("jakarta.ejb", + "/home/ryano/cts-tools-master/tools/api-check/test/jakarta.ejb.sig_2.1", + "/home/ryano/cts-tools-master/tools/api-check/test/pkg-list.txt"); + list.writePkgListFile(); - System.out.println("\n\n*** Reading sub-packages from package list file ***\n\n"); - PackageList readList = new PackageList("/home/ryano/cts-tools-master/tools/api-check/test/pkg-list.txt"); - System.out.println(Arrays.asList(readList.getSubPackages("jakarta.ejb"))); - System.out.println(readList.getSubPackagesFormatted("jakarta.ejb")); - } + System.out.println("\n\n*** Reading sub-packages from package list file ***\n\n"); + PackageList readList = new PackageList("/home/ryano/cts-tools-master/tools/api-check/test/pkg-list.txt"); + System.out.println(Arrays.asList(readList.getSubPackages("jakarta.ejb"))); + System.out.println(readList.getSubPackagesFormatted("jakarta.ejb")); + } } // end class PackageList diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java index c2efd4fd..bd32c718 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java @@ -33,337 +33,337 @@ */ public abstract class SigTest { - protected SignatureTestDriver driver; - - /** - *

- * Returns a {@link SignatureTestDriver} appropriate for the particular TCK - * (using API check or the Signature Test Framework). - *

- * - *

- * The default implementation of this method will return a - * {@link SignatureTestDriver} that will use API Check. TCK developers can - * override this to return the desired {@link SignatureTestDriver} for their - * TCK. - */ - protected SignatureTestDriver getSigTestDriver() { - - if (driver == null) { - driver = SignatureTestDriverFactory.getInstance(SignatureTestDriverFactory.SIG_TEST); - } - - return driver; - - } // END getSigTestDriver - - /** - * Returns the location of the package list file. This file denotes the valid - * sub-packages of any package being verified in the signature tests. - * - * Sub-classes are free to override this method if they use a different path or - * filename for their package list file. Most users should be able to use this - * default implementation. - * - * @return String The path and name of the package list file. - */ - protected String getPackageFile() { - return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); - } - - /** - * Returns the path and name of the signature map file that this TCK uses when - * conducting signature tests. The signature map file tells the signature test - * framework which API versions of tested packages to use. To keep this code - * platform independent, be sure to use the File.separator string (or the - * File.separatorChar) to denote path separators. - * - * Sub-classes are free to override this method if they use a different path or - * filename for their signature map file. Most users should be able to use this - * default implementation. - * - * @return String The path and name of the signature map file. - */ - protected String getMapFile() { - return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); - } - - /** - * Returns the directory that contains the signature files. - * - * Sub-classes are free to override this method if they use a different - * signature repository directory. Most users should be able to use this default - * implementation. - * - * @return String The signature repository directory. - */ - protected String getRepositoryDir() { - return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); - } - - /** - * Returns the list of Optional Packages which are not accounted for. By - * 'unlisted optional' we mean the packages which are Optional to the technology - * under test that the user did NOT specifically list for testing. For example, - * with Java EE 7 implementation, a user could additionally opt to test a JSR-88 - * technology along with the Java EE technology. But if the user chooses NOT to - * list this optional technology for testing (via ts.jte javaee.level prop) then - * this method will return the packages for JSR-88 technology with this method - * call. - *

- * This is useful for checking for a scenarios when a user may have forgotten to - * identify a whole or partial technology implementation and in such cases, Java - * EE platform still requires testing it. - *

- * Any partial or complete impl of an unlistedOptionalPackage sends up a red - * flag indicating that the user must also pass tests for this optional - * technology area. - *

- * Sub-classes are free to override this method if they use a different - * signature repository directory. Most users should be able to use this default - * implementation - which means that there was NO optional technology packages - * that need to be tested. - * - * @return ArrayList - */ - protected ArrayList getUnlistedOptionalPackages() { - return null; - } - - /** - * Returns the list of packages that must be tested by the siganture test - * framework. TCK developers must implement this method in their signature test - * sub-class. - * - * @return String A list of packages that the developer wishes to test using the - * signature test framework. - */ - protected abstract String[] getPackages(); - - /** - * Returns an array of individual classes that must be tested by the signature - * test framwork. TCK developers may override this method when this - * functionality is needed. Most will only need package level granularity. - * - * @return an Array of Strings containing the individual classes the framework - * should test. The default implementation of this method returns a - * zero-length array. - */ - protected String[] getClasses() { - - return new String[] {}; - - } // END getClasses - - protected SigTestData testInfo; // holds the bin.dir property - - /** - * Called by the test framework to initialize this test. The method simply - * retrieves some state information that is necessary to run the test when when - * the test framework invokes the run method (actually the test1 method). - * - * @throws Fault When an error occurs reading or saving the state information - * processed by this method. - */ - public void setup() { - try { - System.out.println("$$$ SigTest.setup() called"); - this.testInfo = new SigTestData(); - System.out.println("$$$ SigTest.setup() complete"); - } catch (Exception e) { - System.out.println("Unexpected exception " + e.getMessage()); - // throw new Fault("setup failed!", e); - } - } - - /** - * Called by the test framework to cleanup any outstanding state. This method - * simply passes the message through to the utility class so the implementation - * can be used by both framework base classes. - * - * @throws Fault When an error occurs cleaning up the state of this test. - */ - public void cleanup() throws Fault { - System.out.println("$$$ SigTest.cleanup() called"); - try { - getSigTestDriver().cleanupImpl(); - System.out.println("$$$ SigTest.cleanup() returning"); - } catch (Exception e) { - throw new Fault("Cleanup failed!", e); - } - } - - public static class Fault extends Exception { - private static final long serialVersionUID = -1574745208867827913L; - - public Throwable t; - - /** - * creates a Fault with a message - */ - public Fault(String msg) { - super(msg); - System.out.println(msg); - } - - /** - * creates a Fault with a message. - * - * @param msg the message - * @param t prints this exception's stacktrace - */ - public Fault(String msg, Throwable t) { - super(msg); - this.t = t; - // System.out.println(msg, t); - } - - /** - * creates a Fault with a Throwable. - * - * @param t the Throwable - */ - public Fault(Throwable t) { - super(t); - this.t = t; - } - - /** - * Prints this Throwable and its backtrace to the standard error stream. - * - */ - public void printStackTrace() { - if (this.t != null) { - this.t.printStackTrace(); - } else { - super.printStackTrace(); - } - } - - /** - * Prints this throwable and its backtrace to the specified print stream. - * - * @param s PrintStream to use for output - */ - public void printStackTrace(PrintStream s) { - if (this.t != null) { - this.t.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - /** - * Prints this throwable and its backtrace to the specified print writer. - * - * @param s PrintWriter to use for output - */ - public void printStackTrace(PrintWriter s) { - if (this.t != null) { - this.t.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - @Override - public Throwable getCause() { - return t; - } - - @Override - public synchronized Throwable initCause(Throwable cause) { - if (t != null) - throw new IllegalStateException("Can't overwrite cause"); - if (!Exception.class.isInstance(cause)) - throw new IllegalArgumentException("Cause not permitted"); - this.t = (Exception) cause; - return this; - } - } - - /** - * This exception is used only by EETest. Overrides 3 printStackTrace methods to - * preserver the original stack trace. Using setStackTraceElement() would be - * more elegant but it is not available prior to j2se 1.4. - * - * @author Kyle Grucci - */ - public static class SetupException extends Exception { - private static final long serialVersionUID = -7616313680616499158L; - - public Exception e; - - /** - * creates a Fault with a message - */ - public SetupException(String msg) { - super(msg); - } - - /** - * creates a SetupException with a message - * - * @param msg the message - * @param e prints this exception's stacktrace - */ - public SetupException(String msg, Exception e) { - super(msg); - this.e = e; - } - - /** - * Prints this Throwable and its backtrace to the standard error stream. - * - */ - public void printStackTrace() { - if (this.e != null) { - this.e.printStackTrace(); - } else { - super.printStackTrace(); - } - } - - /** - * Prints this throwable and its backtrace to the specified print stream. - * - * @param s PrintStream to use for output - */ - public void printStackTrace(PrintStream s) { - if (this.e != null) { - this.e.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - /** - * Prints this throwable and its backtrace to the specified print writer. - * - * @param s PrintWriter to use for output - */ - public void printStackTrace(PrintWriter s) { - if (this.e != null) { - this.e.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - @Override - public Throwable getCause() { - return e; - } - - @Override - public synchronized Throwable initCause(Throwable cause) { - if (e != null) - throw new IllegalStateException("Can't overwrite cause"); - if (!Exception.class.isInstance(cause)) - throw new IllegalArgumentException("Cause not permitted"); - this.e = (Exception) cause; - return this; - } - } + protected SignatureTestDriver driver; + + /** + *

+ * Returns a {@link SignatureTestDriver} appropriate for the particular TCK + * (using API check or the Signature Test Framework). + *

+ * + *

+ * The default implementation of this method will return a + * {@link SignatureTestDriver} that will use API Check. TCK developers can + * override this to return the desired {@link SignatureTestDriver} for their + * TCK. + */ + protected SignatureTestDriver getSigTestDriver() { + + if (driver == null) { + driver = SignatureTestDriverFactory.getInstance(SignatureTestDriverFactory.SIG_TEST); + } + + return driver; + + } // END getSigTestDriver + + /** + * Returns the location of the package list file. This file denotes the valid + * sub-packages of any package being verified in the signature tests. + * + * Sub-classes are free to override this method if they use a different path or + * filename for their package list file. Most users should be able to use this + * default implementation. + * + * @return String The path and name of the package list file. + */ + protected String getPackageFile() { + return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the path and name of the signature map file that this TCK uses when + * conducting signature tests. The signature map file tells the signature test + * framework which API versions of tested packages to use. To keep this code + * platform independent, be sure to use the File.separator string (or the + * File.separatorChar) to denote path separators. + * + * Sub-classes are free to override this method if they use a different path or + * filename for their signature map file. Most users should be able to use this + * default implementation. + * + * @return String The path and name of the signature map file. + */ + protected String getMapFile() { + return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the directory that contains the signature files. + * + * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this default + * implementation. + * + * @return String The signature repository directory. + */ + protected String getRepositoryDir() { + return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); + } + + /** + * Returns the list of Optional Packages which are not accounted for. By + * 'unlisted optional' we mean the packages which are Optional to the technology + * under test that the user did NOT specifically list for testing. For example, + * with Java EE 7 implementation, a user could additionally opt to test a JSR-88 + * technology along with the Java EE technology. But if the user chooses NOT to + * list this optional technology for testing (via ts.jte javaee.level prop) then + * this method will return the packages for JSR-88 technology with this method + * call. + *

+ * This is useful for checking for a scenarios when a user may have forgotten to + * identify a whole or partial technology implementation and in such cases, Java + * EE platform still requires testing it. + *

+ * Any partial or complete impl of an unlistedOptionalPackage sends up a red + * flag indicating that the user must also pass tests for this optional + * technology area. + *

+ * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this default + * implementation - which means that there was NO optional technology packages + * that need to be tested. + * + * @return ArrayList + */ + protected ArrayList getUnlistedOptionalPackages() { + return null; + } + + /** + * Returns the list of packages that must be tested by the siganture test + * framework. TCK developers must implement this method in their signature test + * sub-class. + * + * @return String A list of packages that the developer wishes to test using the + * signature test framework. + */ + protected abstract String[] getPackages(); + + /** + * Returns an array of individual classes that must be tested by the signature + * test framwork. TCK developers may override this method when this + * functionality is needed. Most will only need package level granularity. + * + * @return an Array of Strings containing the individual classes the framework + * should test. The default implementation of this method returns a + * zero-length array. + */ + protected String[] getClasses() { + + return new String[] {}; + + } // END getClasses + + protected SigTestData testInfo; // holds the bin.dir property + + /** + * Called by the test framework to initialize this test. The method simply + * retrieves some state information that is necessary to run the test when when + * the test framework invokes the run method (actually the test1 method). + * + * @throws Fault When an error occurs reading or saving the state information + * processed by this method. + */ + public void setup() { + try { + System.out.println("$$$ SigTest.setup() called"); + this.testInfo = new SigTestData(); + System.out.println("$$$ SigTest.setup() complete"); + } catch (Exception e) { + System.out.println("Unexpected exception " + e.getMessage()); + // throw new Fault("setup failed!", e); + } + } + + /** + * Called by the test framework to cleanup any outstanding state. This method + * simply passes the message through to the utility class so the implementation + * can be used by both framework base classes. + * + * @throws Fault When an error occurs cleaning up the state of this test. + */ + public void cleanup() throws Fault { + System.out.println("$$$ SigTest.cleanup() called"); + try { + getSigTestDriver().cleanupImpl(); + System.out.println("$$$ SigTest.cleanup() returning"); + } catch (Exception e) { + throw new Fault("Cleanup failed!", e); + } + } + + public static class Fault extends Exception { + private static final long serialVersionUID = -1574745208867827913L; + + public Throwable t; + + /** + * creates a Fault with a message + */ + public Fault(String msg) { + super(msg); + System.out.println(msg); + } + + /** + * creates a Fault with a message. + * + * @param msg the message + * @param t prints this exception's stacktrace + */ + public Fault(String msg, Throwable t) { + super(msg); + this.t = t; + // System.out.println(msg, t); + } + + /** + * creates a Fault with a Throwable. + * + * @param t the Throwable + */ + public Fault(Throwable t) { + super(t); + this.t = t; + } + + /** + * Prints this Throwable and its backtrace to the standard error stream. + * + */ + public void printStackTrace() { + if (this.t != null) { + this.t.printStackTrace(); + } else { + super.printStackTrace(); + } + } + + /** + * Prints this throwable and its backtrace to the specified print stream. + * + * @param s PrintStream to use for output + */ + public void printStackTrace(PrintStream s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + /** + * Prints this throwable and its backtrace to the specified print writer. + * + * @param s PrintWriter to use for output + */ + public void printStackTrace(PrintWriter s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public Throwable getCause() { + return t; + } + + @Override + public synchronized Throwable initCause(Throwable cause) { + if (t != null) + throw new IllegalStateException("Can't overwrite cause"); + if (!Exception.class.isInstance(cause)) + throw new IllegalArgumentException("Cause not permitted"); + this.t = (Exception) cause; + return this; + } + } + + /** + * This exception is used only by EETest. Overrides 3 printStackTrace methods to + * preserver the original stack trace. Using setStackTraceElement() would be + * more elegant but it is not available prior to j2se 1.4. + * + * @author Kyle Grucci + */ + public static class SetupException extends Exception { + private static final long serialVersionUID = -7616313680616499158L; + + public Exception e; + + /** + * creates a Fault with a message + */ + public SetupException(String msg) { + super(msg); + } + + /** + * creates a SetupException with a message + * + * @param msg the message + * @param e prints this exception's stacktrace + */ + public SetupException(String msg, Exception e) { + super(msg); + this.e = e; + } + + /** + * Prints this Throwable and its backtrace to the standard error stream. + * + */ + public void printStackTrace() { + if (this.e != null) { + this.e.printStackTrace(); + } else { + super.printStackTrace(); + } + } + + /** + * Prints this throwable and its backtrace to the specified print stream. + * + * @param s PrintStream to use for output + */ + public void printStackTrace(PrintStream s) { + if (this.e != null) { + this.e.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + /** + * Prints this throwable and its backtrace to the specified print writer. + * + * @param s PrintWriter to use for output + */ + public void printStackTrace(PrintWriter s) { + if (this.e != null) { + this.e.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public Throwable getCause() { + return e; + } + + @Override + public synchronized Throwable initCause(Throwable cause) { + if (e != null) + throw new IllegalStateException("Can't overwrite cause"); + if (!Exception.class.isInstance(cause)) + throw new IllegalArgumentException("Cause not permitted"); + this.e = (Exception) cause; + return this; + } + } } // end class SigTest diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java index 1ad6c5b9..691aa4af 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java @@ -29,50 +29,50 @@ */ public class SigTestData { - private Properties props; + private Properties props; - public SigTestData() { - this.props = System.getProperties(); - ; - } + public SigTestData() { + this.props = System.getProperties(); + ; + } - public String getVehicle() { - return props.getProperty("vehicle", ""); - } + public String getVehicle() { + return props.getProperty("vehicle", ""); + } - public String getBinDir() { - return props.getProperty("bin.dir", ""); - } + public String getBinDir() { + return props.getProperty("bin.dir", ""); + } - public String getTSHome() { - return props.getProperty("ts_home", ""); - } + public String getTSHome() { + return props.getProperty("ts_home", ""); + } - public String getTestClasspath() { - return props.getProperty("sigTestClasspath", ""); - } + public String getTestClasspath() { + return props.getProperty("sigTestClasspath", ""); + } - public String getJavaeeLevel() { - return props.getProperty("javaee.level", ""); - } + public String getJavaeeLevel() { + return props.getProperty("javaee.level", ""); + } - public String getCurrentKeywords() { - return props.getProperty("current.keywords", ""); - } + public String getCurrentKeywords() { + return props.getProperty("current.keywords", ""); + } - public String getProperty(String prop) { - return props.getProperty(prop); - } + public String getProperty(String prop) { + return props.getProperty(prop); + } - public String getOptionalTechPackagesToIgnore() { - return props.getProperty("optional.tech.packages.to.ignore", ""); - } + public String getOptionalTechPackagesToIgnore() { + return props.getProperty("optional.tech.packages.to.ignore", ""); + } - public String getJtaJarClasspath() { - return props.getProperty("jtaJarClasspath", ""); - } + public String getJtaJarClasspath() { + return props.getProperty("jtaJarClasspath", ""); + } - public String getJImageDir() { - return props.getProperty("jimage.dir", ""); - } + public String getJImageDir() { + return props.getProperty("jimage.dir", ""); + } } // end class SigTestData diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java index 6c1d811c..79865014 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java @@ -30,229 +30,215 @@ */ public class SigTestDriver extends SignatureTestDriver { - private static final String CLASSPATH_FLAG = "-Classpath"; + private static final String CLASSPATH_FLAG = "-Classpath"; - private static final String FILENAME_FLAG = "-FileName"; + private static final String FILENAME_FLAG = "-FileName"; - private static final String PACKAGE_FLAG = "-Package"; + private static final String PACKAGE_FLAG = "-Package"; - private static final String PACKAGE_NO_SUBS_FLAG = "-PackageWithoutSubpackages"; + private static final String PACKAGE_NO_SUBS_FLAG = "-PackageWithoutSubpackages"; - private static final String API_VERSION_FLAG = "-ApiVersion"; + private static final String API_VERSION_FLAG = "-ApiVersion"; - private static final String EXCLUDE_FLAG = "-Exclude"; + private static final String EXCLUDE_FLAG = "-Exclude"; - private static final String STATIC_FLAG = "-Static"; + private static final String STATIC_FLAG = "-Static"; - private static final String CHECKVALUE_FLAG = "-CheckValue"; // only valid w/ - // -static + private static final String CHECKVALUE_FLAG = "-CheckValue"; // only valid w/ + // -static // private static final String NO_CHECKVALUE_FLAG = "-NoCheckValue"; - private static final String SMODE_FLAG = "-mode"; // requires arg of bin or - // src + private static final String SMODE_FLAG = "-mode"; // requires arg of bin or + // src // private static final String DEBUG_FLAG = "-Debug"; // private static final String FORMATPLAIN_FLAG = "-FormatPlain"; - private static final String EXCLUDE_JDK_CLASS_FLAG = "-IgnoreJDKClass"; - - private static String[] excludeJdkClasses = { - "java.util.Map", - "java.lang.Object", - "java.io.ByteArrayInputStream", - "java.io.InputStream", - "java.lang.Deprecated", - "java.io.Writer", - "java.io.OutputStream", - "java.util.List", - "java.util.Collection", - "java.lang.instrument.IllegalClassFormatException", - "javax.transaction.xa.XAException", - "java.lang.annotation.Repeatable", - "java.lang.InterruptedException", - "java.lang.CloneNotSupportedException", - "java.lang.Throwable", - "java.lang.Thread", - "java.lang.Enum" - }; - - // ---------------------------------------- Methods from SignatureTestDriver - - @Override - protected String normalizeFileName(File f) { - String sURL = null; - try { - sURL = f.toURI().toURL().toExternalForm(); - } catch (Exception e) { - throw new RuntimeException(e); - } - return sURL; - } - - @Override - protected String[] createTestArguments(String packageListFile, String mapFile, String signatureRepositoryDir, - String packageOrClassUnderTest, String classpath, boolean bStaticMode) throws Exception { - - SignatureFileInfo info = getSigFileInfo(packageOrClassUnderTest, mapFile, signatureRepositoryDir); - - PackageList packageList = new PackageList(packageListFile); - String[] subPackages = packageList.getSubPackages(packageOrClassUnderTest); - - List command = new ArrayList<>(); - - if (bStaticMode) { - // static mode allows finer level of constants checking - // -CheckValue says to check the actual const values - System.out.println("Setting static mode flag to allow constant checking."); - command.add(STATIC_FLAG); - command.add(CHECKVALUE_FLAG); - - // specifying "-mode src" allows stricter 2 way verification of constant - // vals - // (note that using "-mode bin" mode is less strict) - command.add(SMODE_FLAG); - // command.add("bin"); - command.add("src"); - } else { - System.out.println("Not Setting static mode flag to allow constant checking."); - } - - command.add("-Verbose"); - - command.add(FILENAME_FLAG); - command.add(info.getFile()); - - command.add(CLASSPATH_FLAG); - command.add(classpath); - - command.add(PACKAGE_FLAG); - command.add(packageOrClassUnderTest); - - for (int i = 0; i < subPackages.length; i++) { - command.add(EXCLUDE_FLAG); - command.add(subPackages[i]); - } - - for (String jdkClassName : excludeJdkClasses) { - command.add(EXCLUDE_JDK_CLASS_FLAG); - command.add(jdkClassName); - } - - command.add(API_VERSION_FLAG); - command.add(info.getVersion()); - - return ((String[]) command.toArray(new String[command.size()])); - - } // END createTestArguments - - @Override - protected boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception { - - Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); - Object sigTestInstance = sigTestClass.getConstructor().newInstance(); - - ByteArrayOutputStream output = new ByteArrayOutputStream(); - - // do some logging to help with troubleshooting - System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); - for (int ii = 0; ii < testArguments.length; ii++) { - System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); - } - - Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); - - String rawMessages = output.toString(); - - // currently, there is no way to determine if there are error msgs in - // the rawmessages, so we will always dump this and call it a status. - System.out.println("********** Status Report '" + packageOrClassName + "' **********\n"); - System.out.println(rawMessages); - - return sigTestInstance.toString().substring(7).startsWith("Passed."); - } // END runSignatureTest - - /* - * - * @return This returns true if the packageOrClassName is found in the impl. - */ - @Override - protected boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception { - - Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); - Object sigTestInstance = sigTestClass.getConstructor().newInstance(); - - ByteArrayOutputStream output = new ByteArrayOutputStream(); - - // we want to replace the PACKAGE_FLAG with PACKAGE_NO_SUBS_FLAG - for (int ii = 0; ii < testArguments.length; ii++) { - if (testArguments[ii].equals(PACKAGE_FLAG)) { - testArguments[ii] = PACKAGE_NO_SUBS_FLAG; - } - } - - // dump args for debugging aid - System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); - for (int ii = 0; ii < testArguments.length; ii++) { - System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); - } - - Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); - - String rawMessages = output.toString(); - - // currently, there is no way to determine if there are error msgs in - // the rawmessages, so we will always dump this and call it a status. - System.out.println("********** Status Report '" + packageOrClassName + "' **********\n"); - System.out.println(rawMessages); - - return sigTestInstance.toString().substring(7).startsWith("Passed."); - } - - /* - * @return This returns true if javax.transaction.xa is not found in the JTA API - * jar - */ - protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception { - - System.out.println("SigTestDriver#verifyJTAJarForNoXA - Starting:"); - List command = new ArrayList<>(); - - // Build Commandline for com.sun.tdk.signaturetest.SignatureTest - command.add(STATIC_FLAG); - command.add(FILENAME_FLAG); - command.add(repositoryDir + "empty.sig"); - command.add(PACKAGE_FLAG); - command.add("javax.transaction.xa"); - command.add(CLASSPATH_FLAG); - command.add(classpath); - - String testArguments[] = (String[]) command.toArray(new String[command.size()]); - - // do some logging to help with troubleshooting - System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); - for (int ii = 0; ii < testArguments.length; ii++) { - System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); - } - - Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); - Object sigTestInstance = sigTestClass.getConstructor().newInstance(); - ByteArrayOutputStream output = new ByteArrayOutputStream(); - - Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); - String rawMessages = output.toString(); - - // currently, there is no way to determine if there are error msgs in - // the rawmessages, so we will always dump this and call it a status. - System.out.println("********** Status Report JTA JAR validation **********\n"); - System.out.println(rawMessages); - return sigTestInstance.toString().substring(7).startsWith("Passed."); - } + private static final String EXCLUDE_JDK_CLASS_FLAG = "-IgnoreJDKClass"; + + private static String[] excludeJdkClasses = { "java.util.Map", "java.lang.Object", "java.io.ByteArrayInputStream", + "java.io.InputStream", "java.lang.Deprecated", "java.io.Writer", "java.io.OutputStream", "java.util.List", + "java.util.Collection", "java.lang.instrument.IllegalClassFormatException", + "javax.transaction.xa.XAException", "java.lang.annotation.Repeatable", "java.lang.InterruptedException", + "java.lang.CloneNotSupportedException", "java.lang.Throwable", "java.lang.Thread", "java.lang.Enum" }; + + // ---------------------------------------- Methods from SignatureTestDriver + + @Override + protected String normalizeFileName(File f) { + String sURL = null; + try { + sURL = f.toURI().toURL().toExternalForm(); + } catch (Exception e) { + throw new RuntimeException(e); + } + return sURL; + } + + @Override + protected String[] createTestArguments(String packageListFile, String mapFile, String signatureRepositoryDir, + String packageOrClassUnderTest, String classpath, boolean bStaticMode) throws Exception { + + SignatureFileInfo info = getSigFileInfo(packageOrClassUnderTest, mapFile, signatureRepositoryDir); + + PackageList packageList = new PackageList(packageListFile); + String[] subPackages = packageList.getSubPackages(packageOrClassUnderTest); + + List command = new ArrayList<>(); + + if (bStaticMode) { + // static mode allows finer level of constants checking + // -CheckValue says to check the actual const values + System.out.println("Setting static mode flag to allow constant checking."); + command.add(STATIC_FLAG); + command.add(CHECKVALUE_FLAG); + + // specifying "-mode src" allows stricter 2 way verification of constant + // vals + // (note that using "-mode bin" mode is less strict) + command.add(SMODE_FLAG); + // command.add("bin"); + command.add("src"); + } else { + System.out.println("Not Setting static mode flag to allow constant checking."); + } + + command.add("-Verbose"); + + command.add(FILENAME_FLAG); + command.add(info.getFile()); + + command.add(CLASSPATH_FLAG); + command.add(classpath); + + command.add(PACKAGE_FLAG); + command.add(packageOrClassUnderTest); + + for (int i = 0; i < subPackages.length; i++) { + command.add(EXCLUDE_FLAG); + command.add(subPackages[i]); + } + + for (String jdkClassName : excludeJdkClasses) { + command.add(EXCLUDE_JDK_CLASS_FLAG); + command.add(jdkClassName); + } + + command.add(API_VERSION_FLAG); + command.add(info.getVersion()); + + return ((String[]) command.toArray(new String[command.size()])); + + } // END createTestArguments + + @Override + protected boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception { + + Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.getConstructor().newInstance(); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + // do some logging to help with troubleshooting + System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii = 0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + } + + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + + String rawMessages = output.toString(); + + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println("********** Status Report '" + packageOrClassName + "' **********\n"); + System.out.println(rawMessages); + + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } // END runSignatureTest + + /* + * + * @return This returns true if the packageOrClassName is found in the impl. + */ + @Override + protected boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception { + + Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.getConstructor().newInstance(); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + // we want to replace the PACKAGE_FLAG with PACKAGE_NO_SUBS_FLAG + for (int ii = 0; ii < testArguments.length; ii++) { + if (testArguments[ii].equals(PACKAGE_FLAG)) { + testArguments[ii] = PACKAGE_NO_SUBS_FLAG; + } + } + + // dump args for debugging aid + System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii = 0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + } + + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + + String rawMessages = output.toString(); + + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println("********** Status Report '" + packageOrClassName + "' **********\n"); + System.out.println(rawMessages); + + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } + + /* + * @return This returns true if javax.transaction.xa is not found in the JTA API + * jar + */ + protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception { + + System.out.println("SigTestDriver#verifyJTAJarForNoXA - Starting:"); + List command = new ArrayList<>(); + + // Build Commandline for com.sun.tdk.signaturetest.SignatureTest + command.add(STATIC_FLAG); + command.add(FILENAME_FLAG); + command.add(repositoryDir + "empty.sig"); + command.add(PACKAGE_FLAG); + command.add("javax.transaction.xa"); + command.add(CLASSPATH_FLAG); + command.add(classpath); + + String testArguments[] = (String[]) command.toArray(new String[command.size()]); + + // do some logging to help with troubleshooting + System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii = 0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + } + + Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.getConstructor().newInstance(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + String rawMessages = output.toString(); + + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println("********** Status Report JTA JAR validation **********\n"); + System.out.println(rawMessages); + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java index ce8bf828..a314342b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java @@ -32,360 +32,360 @@ */ public abstract class SigTestEE { - String[] sVehicles; - - protected SignatureTestDriver driver; - - /** - *

- * Returns a {@link SignatureTestDriver} appropriate for the particular TCK - * (using API check or the Signature Test Framework). - *

- * - *

- * The default implementation of this method will return a - * {@link SignatureTestDriver} that will use API Check. TCK developers can - * override this to return the desired {@link SignatureTestDriver} for their - * TCK. - */ - protected SignatureTestDriver getSigTestDriver() { - - if (driver == null) { - driver = SignatureTestDriverFactory.getInstance(SignatureTestDriverFactory.SIG_TEST); - } - - return driver; - - } // END getSigTestDriver - - /** - * Returns the location of the package list file. This file denotes the valid - * sub-packages of any package being verified in the signature tests. - *

- * Sub-classes are free to override this method if they use a different path or - * filename for their package list file. Most users should be able to use this - * default implementation. - * - * @return String The path and name of the package list file. - */ - protected String getPackageFile() { - return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); - } - - /** - * Returns the path and name of the signature map file that this TCK uses when - * conducting signature tests. The signature map file tells the signature test - * framework which API versions of tested packages to use. To keep this code - * platform independent, be sure to use the File.separator string (or the - * File.separatorChar) to denote path separators. - *

- * Sub-classes are free to override this method if they use a different path or - * filename for their signature map file. Most users should be able to use this - * default implementation. - * - * @return String The path and name of the signature map file. - */ - protected String getMapFile() { - return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); - } - - /** - * Returns the directory that contains the signature files. - *

- * Sub-classes are free to override this method if they use a different - * signature repository directory. Most users should be able to use this default - * implementation. - * - * @return String The signature repository directory. - */ - protected String getRepositoryDir() { - return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); - } - - /** - * Returns the list of Optional Packages which are not accounted for. By - * 'unlisted optional' we mean the packages which are Optional to the technology - * under test that the user did NOT specifically list for testing. For example, - * with Java EE 7 implementation, a user could additionally opt to test a JSR-88 - * technology along with the Java EE technology. But if the user chooses NOT to - * list this optional technology for testing (via ts.jte javaee.level prop) then - * this method will return the packages for JSR-88 technology with this method - * call. - *

- * This is useful for checking for a scenarios when a user may have forgotten to - * identify a whole or partial technology implementation and in such cases, Java - * EE platform still requires testing it. - *

- * Any partial or complete impl of an unlistedOptionalPackage sends up a red - * flag indicating that the user must also pass tests for this optional - * technology area. - *

- * Sub-classes are free to override this method if they use a different - * signature repository directory. Most users should be able to use this default - * implementation - which means that there was NO optional technology packages - * that need to be tested. - * - * @return ArrayList - */ - protected ArrayList getUnlistedOptionalPackages() { - return null; - } - - /** - * Returns the list of packages that must be tested by the signature test - * framework. TCK developers must implement this method in their signature test - * sub-class. - * - * @param vehicleName The name of the vehicle the signature tests should be - * conducted in. Valid values for this property are ejb, - * servlet, ejb and appclient. - * - * @return String[] A list of packages that the developer wishes to test using - * the signature test framework. If the developer does not wish to test - * any package signatures in the specified vehicle this method should - * return null. - *

- * Note, The proper way to insure that this method is not called with a - * vehicle name that has no package signatures to verify is to modify - * the vehicle.properties in the $TS_HOME/src directory. This file - * provides a mapping that maps test directories to a list of vehicles - * where the tests in those directory should be run. As an extra - * precaution users are encouraged to return null from this method if - * the specified vehicle has no package signatures to be verified within - * it. - */ - protected abstract String[] getPackages(String vehicleName); - - /** - *

- * Returns an array of individual classes that must be tested by the signature - * test framework within the specified vehicle. TCK developers may override this - * method when this functionality is needed. Most will only need package level - * granularity. - *

- * - *

- * If the developer doesn't wish to test certain classes within a particular - * vehicle, the implementation of this method must return a zero-length array. - *

- * - * @param vehicleName The name of the vehicle the signature tests should be - * conducted in. Valid values for this property are ejb, - * servlet, ejb and appclient. - * - * @return an Array of Strings containing the individual classes the framework - * should test based on the specifed vehicle. The default implementation - * of this method returns a zero-length array no matter the vehicle - * specified. - */ - protected String[] getClasses(String vehicleName) { - - return new String[] {}; - - } // END getClasses - - protected SigTestData testInfo; // holds the bin.dir and vehicle properties - - /** - * Called by the test framework to initialize this test. The method simply - * retrieves some state information that is necessary to run the test when when - * the test framework invokes the run method (actually the test1 method). - */ - public void setup() { - try { - System.out.println("$$$ SigTestEE.setup() called"); - this.testInfo = new SigTestData(); - System.out.println("$$$ SigTestEE.setup() complete"); - } catch (Exception e) { - System.out.println("Unexpected exception " + e.getMessage()); - } - } - - /** - * Called by the test framework to run this test. This method utilizes the state - * information set in the setup method to run the signature tests. All signature - * test code resides in the utility class so it can be reused by the signature - * test framework base classes. - * - * @throws Fault When an error occurs executing the signature tests. - */ - public void signatureTest() throws Fault { - System.out.println("$$$ SigTestEE.signatureTest() called"); - SigTestResult results = null; - String mapFile = getMapFile(); - String repositoryDir = getRepositoryDir(); - String[] packages = getPackages(testInfo.getVehicle()); - String[] classes = getClasses(testInfo.getVehicle()); - String packageFile = getPackageFile(); - String testClasspath = testInfo.getTestClasspath(); - String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); - - // unlisted optional packages are technology packages for those optional - // technologies (e.g. jsr-88) that might not have been specified by the - // user. - // We want to ensure there are no full or partial implementations of an - // optional technology which were not declared - ArrayList unlistedTechnologyPkgs = getUnlistedOptionalPackages(); - - // If testing with Java 9+, extract the JDK's modules so they can be used - // on the testcase's classpath. - Properties sysProps = System.getProperties(); - String version = (String) sysProps.get("java.version"); - if (!version.startsWith("1.")) { - String jimageDir = testInfo.getJImageDir(); - File f = new File(jimageDir); - f.mkdirs(); - - String javaHome = (String) sysProps.get("java.home"); - System.out.println("Executing JImage"); - - try { - ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/jimage", "extract", "--dir=" + jimageDir, - javaHome + "/lib/modules"); - System.out - .println(javaHome + "/bin/jimage extract --dir=" + jimageDir + " " + javaHome + "/lib/modules"); - pb.redirectErrorStream(true); - Process proc = pb.start(); - BufferedReader out = new BufferedReader(new InputStreamReader(proc.getInputStream())); - String line = null; - while ((line = out.readLine()) != null) { - System.out.println(line); - } - - int rc = proc.waitFor(); - System.out.println("JImage RC = " + rc); - out.close(); - } catch (Exception e) { - System.out.println("Exception while executing JImage! Some tests may fail."); - e.printStackTrace(); - } - } - - try { - results = getSigTestDriver().executeSigTest(packageFile, mapFile, repositoryDir, packages, classes, - testClasspath, unlistedTechnologyPkgs, optionalPkgToIgnore); - System.out.println(results.toString()); - if (!results.passed()) { - System.out.println("results.passed() returned false"); - throw new Exception(); - } - - System.out.println("$$$ SigTestEE.signatureTest() returning"); - } catch (Exception e) { - if (results != null && !results.passed()) { - throw new Fault("SigTestEE.signatureTest() failed!, diffs found"); - } else { - System.out.println("Unexpected exception " + e.getMessage()); - throw new Fault("signatureTest failed with an unexpected exception", e); - } - } - } - - /** - * Called by the test framework to cleanup any outstanding state. This method - * simply passes the message through to the utility class so the implementation - * can be used by both framework base classes. - * - * @throws Fault When an error occurs cleaning up the state of this test. - */ - public void cleanup() throws Fault { - System.out.println("$$$ SigTestEE.cleanup() called"); - try { - getSigTestDriver().cleanupImpl(); - System.out.println("$$$ SigTestEE.cleanup() returning"); - } catch (Exception e) { - throw new Fault("Cleanup failed!", e); - } - } - - public static class Fault extends Exception { - private static final long serialVersionUID = -1574745208867827913L; - - public Throwable t; - - /** - * creates a Fault with a message - */ - public Fault(String msg) { - super(msg); - System.out.println(msg); - } - - /** - * creates a Fault with a message. - * - * @param msg the message - * @param t prints this exception's stacktrace - */ - public Fault(String msg, Throwable t) { - super(msg); - this.t = t; - System.out.println(msg); - t.printStackTrace(); - } - - /** - * creates a Fault with a Throwable. - * - * @param t the Throwable - */ - public Fault(Throwable t) { - super(t); - this.t = t; - } - - /** - * Prints this Throwable and its backtrace to the standard error stream. - * - */ - public void printStackTrace() { - if (this.t != null) { - this.t.printStackTrace(); - } else { - super.printStackTrace(); - } - } - - /** - * Prints this throwable and its backtrace to the specified print stream. - * - * @param s PrintStream to use for output - */ - public void printStackTrace(PrintStream s) { - if (this.t != null) { - this.t.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - /** - * Prints this throwable and its backtrace to the specified print writer. - * - * @param s PrintWriter to use for output - */ - public void printStackTrace(PrintWriter s) { - if (this.t != null) { - this.t.printStackTrace(s); - } else { - super.printStackTrace(s); - } - } - - @Override - public Throwable getCause() { - return t; - } - - @Override - public synchronized Throwable initCause(Throwable cause) { - if (t != null) - throw new IllegalStateException("Can't overwrite cause"); - if (!Exception.class.isInstance(cause)) - throw new IllegalArgumentException("Cause not permitted"); - this.t = (Exception) cause; - return this; - } - } + String[] sVehicles; + + protected SignatureTestDriver driver; + + /** + *

+ * Returns a {@link SignatureTestDriver} appropriate for the particular TCK + * (using API check or the Signature Test Framework). + *

+ * + *

+ * The default implementation of this method will return a + * {@link SignatureTestDriver} that will use API Check. TCK developers can + * override this to return the desired {@link SignatureTestDriver} for their + * TCK. + */ + protected SignatureTestDriver getSigTestDriver() { + + if (driver == null) { + driver = SignatureTestDriverFactory.getInstance(SignatureTestDriverFactory.SIG_TEST); + } + + return driver; + + } // END getSigTestDriver + + /** + * Returns the location of the package list file. This file denotes the valid + * sub-packages of any package being verified in the signature tests. + *

+ * Sub-classes are free to override this method if they use a different path or + * filename for their package list file. Most users should be able to use this + * default implementation. + * + * @return String The path and name of the package list file. + */ + protected String getPackageFile() { + return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the path and name of the signature map file that this TCK uses when + * conducting signature tests. The signature map file tells the signature test + * framework which API versions of tested packages to use. To keep this code + * platform independent, be sure to use the File.separator string (or the + * File.separatorChar) to denote path separators. + *

+ * Sub-classes are free to override this method if they use a different path or + * filename for their signature map file. Most users should be able to use this + * default implementation. + * + * @return String The path and name of the signature map file. + */ + protected String getMapFile() { + return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the directory that contains the signature files. + *

+ * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this default + * implementation. + * + * @return String The signature repository directory. + */ + protected String getRepositoryDir() { + return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); + } + + /** + * Returns the list of Optional Packages which are not accounted for. By + * 'unlisted optional' we mean the packages which are Optional to the technology + * under test that the user did NOT specifically list for testing. For example, + * with Java EE 7 implementation, a user could additionally opt to test a JSR-88 + * technology along with the Java EE technology. But if the user chooses NOT to + * list this optional technology for testing (via ts.jte javaee.level prop) then + * this method will return the packages for JSR-88 technology with this method + * call. + *

+ * This is useful for checking for a scenarios when a user may have forgotten to + * identify a whole or partial technology implementation and in such cases, Java + * EE platform still requires testing it. + *

+ * Any partial or complete impl of an unlistedOptionalPackage sends up a red + * flag indicating that the user must also pass tests for this optional + * technology area. + *

+ * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this default + * implementation - which means that there was NO optional technology packages + * that need to be tested. + * + * @return ArrayList + */ + protected ArrayList getUnlistedOptionalPackages() { + return null; + } + + /** + * Returns the list of packages that must be tested by the signature test + * framework. TCK developers must implement this method in their signature test + * sub-class. + * + * @param vehicleName The name of the vehicle the signature tests should be + * conducted in. Valid values for this property are ejb, + * servlet, ejb and appclient. + * + * @return String[] A list of packages that the developer wishes to test using + * the signature test framework. If the developer does not wish to test + * any package signatures in the specified vehicle this method should + * return null. + *

+ * Note, The proper way to insure that this method is not called with a + * vehicle name that has no package signatures to verify is to modify + * the vehicle.properties in the $TS_HOME/src directory. This file + * provides a mapping that maps test directories to a list of vehicles + * where the tests in those directory should be run. As an extra + * precaution users are encouraged to return null from this method if + * the specified vehicle has no package signatures to be verified within + * it. + */ + protected abstract String[] getPackages(String vehicleName); + + /** + *

+ * Returns an array of individual classes that must be tested by the signature + * test framework within the specified vehicle. TCK developers may override this + * method when this functionality is needed. Most will only need package level + * granularity. + *

+ * + *

+ * If the developer doesn't wish to test certain classes within a particular + * vehicle, the implementation of this method must return a zero-length array. + *

+ * + * @param vehicleName The name of the vehicle the signature tests should be + * conducted in. Valid values for this property are ejb, + * servlet, ejb and appclient. + * + * @return an Array of Strings containing the individual classes the framework + * should test based on the specifed vehicle. The default implementation + * of this method returns a zero-length array no matter the vehicle + * specified. + */ + protected String[] getClasses(String vehicleName) { + + return new String[] {}; + + } // END getClasses + + protected SigTestData testInfo; // holds the bin.dir and vehicle properties + + /** + * Called by the test framework to initialize this test. The method simply + * retrieves some state information that is necessary to run the test when when + * the test framework invokes the run method (actually the test1 method). + */ + public void setup() { + try { + System.out.println("$$$ SigTestEE.setup() called"); + this.testInfo = new SigTestData(); + System.out.println("$$$ SigTestEE.setup() complete"); + } catch (Exception e) { + System.out.println("Unexpected exception " + e.getMessage()); + } + } + + /** + * Called by the test framework to run this test. This method utilizes the state + * information set in the setup method to run the signature tests. All signature + * test code resides in the utility class so it can be reused by the signature + * test framework base classes. + * + * @throws Fault When an error occurs executing the signature tests. + */ + public void signatureTest() throws Fault { + System.out.println("$$$ SigTestEE.signatureTest() called"); + SigTestResult results = null; + String mapFile = getMapFile(); + String repositoryDir = getRepositoryDir(); + String[] packages = getPackages(testInfo.getVehicle()); + String[] classes = getClasses(testInfo.getVehicle()); + String packageFile = getPackageFile(); + String testClasspath = testInfo.getTestClasspath(); + String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); + + // unlisted optional packages are technology packages for those optional + // technologies (e.g. jsr-88) that might not have been specified by the + // user. + // We want to ensure there are no full or partial implementations of an + // optional technology which were not declared + ArrayList unlistedTechnologyPkgs = getUnlistedOptionalPackages(); + + // If testing with Java 9+, extract the JDK's modules so they can be used + // on the testcase's classpath. + Properties sysProps = System.getProperties(); + String version = (String) sysProps.get("java.version"); + if (!version.startsWith("1.")) { + String jimageDir = testInfo.getJImageDir(); + File f = new File(jimageDir); + f.mkdirs(); + + String javaHome = (String) sysProps.get("java.home"); + System.out.println("Executing JImage"); + + try { + ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/jimage", "extract", "--dir=" + jimageDir, + javaHome + "/lib/modules"); + System.out + .println(javaHome + "/bin/jimage extract --dir=" + jimageDir + " " + javaHome + "/lib/modules"); + pb.redirectErrorStream(true); + Process proc = pb.start(); + BufferedReader out = new BufferedReader(new InputStreamReader(proc.getInputStream())); + String line = null; + while ((line = out.readLine()) != null) { + System.out.println(line); + } + + int rc = proc.waitFor(); + System.out.println("JImage RC = " + rc); + out.close(); + } catch (Exception e) { + System.out.println("Exception while executing JImage! Some tests may fail."); + e.printStackTrace(); + } + } + + try { + results = getSigTestDriver().executeSigTest(packageFile, mapFile, repositoryDir, packages, classes, + testClasspath, unlistedTechnologyPkgs, optionalPkgToIgnore); + System.out.println(results.toString()); + if (!results.passed()) { + System.out.println("results.passed() returned false"); + throw new Exception(); + } + + System.out.println("$$$ SigTestEE.signatureTest() returning"); + } catch (Exception e) { + if (results != null && !results.passed()) { + throw new Fault("SigTestEE.signatureTest() failed!, diffs found"); + } else { + System.out.println("Unexpected exception " + e.getMessage()); + throw new Fault("signatureTest failed with an unexpected exception", e); + } + } + } + + /** + * Called by the test framework to cleanup any outstanding state. This method + * simply passes the message through to the utility class so the implementation + * can be used by both framework base classes. + * + * @throws Fault When an error occurs cleaning up the state of this test. + */ + public void cleanup() throws Fault { + System.out.println("$$$ SigTestEE.cleanup() called"); + try { + getSigTestDriver().cleanupImpl(); + System.out.println("$$$ SigTestEE.cleanup() returning"); + } catch (Exception e) { + throw new Fault("Cleanup failed!", e); + } + } + + public static class Fault extends Exception { + private static final long serialVersionUID = -1574745208867827913L; + + public Throwable t; + + /** + * creates a Fault with a message + */ + public Fault(String msg) { + super(msg); + System.out.println(msg); + } + + /** + * creates a Fault with a message. + * + * @param msg the message + * @param t prints this exception's stacktrace + */ + public Fault(String msg, Throwable t) { + super(msg); + this.t = t; + System.out.println(msg); + t.printStackTrace(); + } + + /** + * creates a Fault with a Throwable. + * + * @param t the Throwable + */ + public Fault(Throwable t) { + super(t); + this.t = t; + } + + /** + * Prints this Throwable and its backtrace to the standard error stream. + * + */ + public void printStackTrace() { + if (this.t != null) { + this.t.printStackTrace(); + } else { + super.printStackTrace(); + } + } + + /** + * Prints this throwable and its backtrace to the specified print stream. + * + * @param s PrintStream to use for output + */ + public void printStackTrace(PrintStream s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + /** + * Prints this throwable and its backtrace to the specified print writer. + * + * @param s PrintWriter to use for output + */ + public void printStackTrace(PrintWriter s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public Throwable getCause() { + return t; + } + + @Override + public synchronized Throwable initCause(Throwable cause) { + if (t != null) + throw new IllegalStateException("Can't overwrite cause"); + if (!Exception.class.isInstance(cause)) + throw new IllegalArgumentException("Cause not permitted"); + this.t = (Exception) cause; + return this; + } + } } // end class SigTestEE diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java index 1b462926..96700a90 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java @@ -29,106 +29,106 @@ public class SigTestResult implements Serializable { private static final String NL = System.getProperty("line.separator", "\n"); - private List failedPkgs = new ArrayList<>(); + private List failedPkgs = new ArrayList<>(); - private List passedPkgs = new ArrayList<>(); + private List passedPkgs = new ArrayList<>(); - private List failedClasses = new ArrayList<>(); + private List failedClasses = new ArrayList<>(); - private List passedClasses = new ArrayList<>(); + private List passedClasses = new ArrayList<>(); - // ---------------------------------------------------------- Public Methods + // ---------------------------------------------------------- Public Methods - public synchronized boolean passed() { + public synchronized boolean passed() { - return (failedPkgs.size() == 0 && failedClasses.size() == 0); + return (failedPkgs.size() == 0 && failedClasses.size() == 0); - } // end passed + } // end passed - public synchronized void addFailedPkg(String pkg) { + public synchronized void addFailedPkg(String pkg) { - failedPkgs.add(pkg); + failedPkgs.add(pkg); - } // END addFailedPkg + } // END addFailedPkg - public synchronized void addPassedPkg(String pkg) { + public synchronized void addPassedPkg(String pkg) { - passedPkgs.add(pkg); + passedPkgs.add(pkg); - } // END addPassedPkg + } // END addPassedPkg - public synchronized void addFailedClass(String className) { + public synchronized void addFailedClass(String className) { - failedClasses.add(className); + failedClasses.add(className); - } // END addFailedClass + } // END addFailedClass - public synchronized void addPassedClass(String className) { + public synchronized void addPassedClass(String className) { - passedClasses.add(className); + passedClasses.add(className); - } // END addPassedClass + } // END addPassedClass - public String toString() { + public String toString() { - String delim = "******************************************************" + NL; - if (!pkgsTested() && !classesTested()) { - return (delim + "******** No packages or classes were tested **********" + NL + delim); - } - StringBuffer buf = new StringBuffer(); - buf.append(delim); - buf.append(delim); - if (passed()) { - buf.append("All package signatures passed.").append(NL); - } else { - buf.append("Some signatures failed.").append(NL); - if (failedPkgs.size() > 0) { - buf.append("\tFailed packages listed below: ").append(NL); - formatList(failedPkgs, buf); - } - if (failedClasses.size() > 0) { - buf.append("\tFailed classes listed below: ").append(NL); - formatList(failedClasses, buf); - } - } - if (passedPkgs.size() > 0) { - buf.append("\tPassed packages listed below: ").append(NL); - formatList(passedPkgs, buf); - } - if (passedClasses.size() > 0) { - buf.append("\tPassed classes listed below: ").append(NL); - formatList(passedClasses, buf); - } - buf.append("\t"); - buf.append(delim); - buf.append(delim); - return buf.toString(); + String delim = "******************************************************" + NL; + if (!pkgsTested() && !classesTested()) { + return (delim + "******** No packages or classes were tested **********" + NL + delim); + } + StringBuffer buf = new StringBuffer(); + buf.append(delim); + buf.append(delim); + if (passed()) { + buf.append("All package signatures passed.").append(NL); + } else { + buf.append("Some signatures failed.").append(NL); + if (failedPkgs.size() > 0) { + buf.append("\tFailed packages listed below: ").append(NL); + formatList(failedPkgs, buf); + } + if (failedClasses.size() > 0) { + buf.append("\tFailed classes listed below: ").append(NL); + formatList(failedClasses, buf); + } + } + if (passedPkgs.size() > 0) { + buf.append("\tPassed packages listed below: ").append(NL); + formatList(passedPkgs, buf); + } + if (passedClasses.size() > 0) { + buf.append("\tPassed classes listed below: ").append(NL); + formatList(passedClasses, buf); + } + buf.append("\t"); + buf.append(delim); + buf.append(delim); + return buf.toString(); - } // END toString + } // END toString - // --------------------------------------------------------- Private Methods + // --------------------------------------------------------- Private Methods - private synchronized void formatList(List list, StringBuffer buf) { + private synchronized void formatList(List list, StringBuffer buf) { - synchronized (this) { - for (int i = 0; i < list.size(); i++) { - String pkg = list.get(i); - buf.append("\t\t").append(pkg).append(NL); - } - } + synchronized (this) { + for (int i = 0; i < list.size(); i++) { + String pkg = list.get(i); + buf.append("\t\t").append(pkg).append(NL); + } + } - } // END formatList + } // END formatList - private synchronized boolean pkgsTested() { + private synchronized boolean pkgsTested() { - return (failedPkgs.size() != 0 || passedPkgs.size() != 0); + return (failedPkgs.size() != 0 || passedPkgs.size() != 0); - } // END pkgsTested + } // END pkgsTested - private synchronized boolean classesTested() { + private synchronized boolean classesTested() { - return (failedClasses.size() != 0 || passedClasses.size() != 0); + return (failedClasses.size() != 0 || passedClasses.size() != 0); - } // END classesTested + } // END classesTested } // end class SigTestResult diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java index ef0460a4..7ccd45f3 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java @@ -31,607 +31,607 @@ */ public abstract class SignatureTestDriver { - private static final String SIG_FILE_EXT = ".sig"; - - // ---------------------------------------------------------- Public Methods - - /** - * Implementation of the getPackageFile method defined in both the SigTest and - * SigTestEE class. - */ - public String getPackageFileImpl(String binDir) { - - String thePkgListFile = "sig-test-pkg-list.txt"; - - System.out.println("Using the following as the SigTest Package file: " + thePkgListFile); - - String theFile = binDir + File.separator + thePkgListFile; - File ff = new File(theFile); - if (!ff.exists()) { - // we could not find the map file that coresponded to our SE version so - // lets - // try to default to use the sig-test-pkg-list.txt - System.out.println("The SigTest Package file does not exist: " + thePkgListFile); - theFile = binDir + File.separator + "sig-test-pkg-list.txt"; - File ff2 = new File(theFile); - if (!ff2.exists()) { - System.out.println("The Default SigTest Package file does not exist either: " + theFile); - } else { - System.out.println("Defaulting to using SigTest Package file: " + theFile); - } - } - - return (theFile); - - } // END getPackageFileImpl - - /** - * Implementation of the getMapFile method defined in both the SigTest and - * SigTestEE class. - */ - public String getMapFileImpl(String binDir) { - - String theMapFile = "sig-test.map"; - - System.out.println("Using the following as the sig-Test map file: " + theMapFile); - - String theFile = binDir + File.separator + theMapFile; - File ff = new File(theFile); - if (!ff.exists()) { - // we could not find the map file that coresponded to our SE version so - // lets - // try to default to use the sig-test.map - System.out.println("The SigTest Map file does not exist: " + theMapFile); - theFile = binDir + File.separator + "sig-test.map"; - File ff2 = new File(theFile); - if (!ff2.exists()) { - System.out.println("The SigTest Map file does not exist either: " + theFile); - } else { - System.out.println("Defaulting to using SigTest Map file: " + theFile); - } - } - - return (theFile); - - } // END getMapFileImpl - - /** - * Returns true if the passed in version matches the current Java version being - * used. - * - */ - public Boolean isJavaSEVersion(String ver) { - - String strOSVersion = System.getProperty("java.version"); - if (strOSVersion.startsWith(ver)) { - return true; - } else { - return false; - } - } - - /** - * Implementation of the getRepositoryDir method defined in both the SigTest and - * SigTestEE class. - */ - public String getRepositoryDirImpl(String tsHome) { - - return (tsHome + File.separator + "src" + File.separator + "com" + File.separator + "sun" + File.separator - + "ts" + File.separator + "tests" + File.separator + "signaturetest" + File.separator - + "signature-repository" + File.separator); - - } // END getRepositoryDirImpl - - /** - * Implementation of the cleanup method defined in both the SigTest and - * SigTestEE class. - */ - public void cleanupImpl() throws Exception { - - try { - System.out.println("cleanup"); - } catch (Exception e) { - System.out.println("Exception in cleanup method" + e); - throw e; - } - - } // END cleanupImpl - - /** - *

- * Execute the signature test. By default, this method passes the result of - * {@link #createTestArguments(String, String, String, String, String, boolean)} and - * passes the result to {@link #runSignatureTest(String, String[])}. - * - * @param packageListFile - file containing the packages/classes that are - * to be verified - * @param mapFile sig-test.map file - * @param signatureRepositoryDir directory containing the recorded signatures - * @param packagesUnderTest packages, defined by the test client, that - * should be tested - * @param classesUnderTest classes, defined by the test client, that - * should be tested - * @param classpath The location of the API being verified. - * Normally the checked API will be available in - * the test environment and testClasspath will be - * null. In some rare cases the tested API may not - * be part of the test environment and will have - * to specified using this parameter. - * @param unaccountedTechPkgs packages that should not exist within the - * technology under test. These will be searched - * for and if found, will be flagged as error - * since they were not explicitly declared as - * being under test. Their existence requires - * explicit testing. - * - * @return a {@link SigTestResult} containing the result of the test execution - */ - public SigTestResult executeSigTest(String packageListFile, String mapFile, String signatureRepositoryDir, - String[] packagesUnderTest, String[] classesUnderTest, String classpath, - ArrayList unaccountedTechPkgs, String optionalPkgToIgnore) throws Exception { - - SigTestResult result = new SigTestResult(); - - System.out.println("optionalPkgToIgnore = " + optionalPkgToIgnore); - String[] arrayOptionalPkgsToIgnore = null; - if (optionalPkgToIgnore != null) { - arrayOptionalPkgsToIgnore = optionalPkgToIgnore.split(","); - } - - if (packagesUnderTest != null && packagesUnderTest.length > 0) { - System.out.println("********** BEGIN PACKAGE LEVEL SIGNATURE " + "VALIDATION **********\n\n"); - for (int i = 0; i < packagesUnderTest.length; i++) { - - String packageName = packagesUnderTest[i]; - - System.out.println("********** BEGIN VALIDATE PACKAGE '" + packagesUnderTest[i] + "' **********\n"); - - System.out.println("********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES ****"); - System.out.println("Static mode supports checks of static constants values "); - - String[] args = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, packageName, - classpath, true); - dumpTestArguments(args); - - if (runSignatureTest(packageName, args)) { - System.out.println("********** Package '" + packageName + "' - PASSED (STATIC MODE) **********"); - result.addPassedPkg(packageName + "(static mode)"); - } else { - result.addFailedPkg(packageName + "(static mode)"); - System.out.println("********** Package '" + packageName + "' - FAILED (STATIC MODE) **********"); - } - - System.out.println("\n\n"); - System.out.println("********** VALIDATE IN REFLECTIVE MODE ****"); - System.out.println("Reflective mode supports verification within containers (ie ejb, servlet, etc)"); - - String[] args2 = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, packageName, - classpath, false); - dumpTestArguments(args2); - - if (runSignatureTest(packageName, args2)) { - System.out - .println("********** Package '" + packageName + "' - PASSED (REFLECTION MODE) **********"); - result.addPassedPkg(packageName + "(reflection mode)"); - } else { - result.addFailedPkg(packageName + "(reflection mode)"); - System.out - .println("********** Package '" + packageName + "' - FAILED (REFLECTION MODE) **********"); - } - - System.out.println("********** END VALIDATE PACKAGE '" + packagesUnderTest[i] + "' **********\n"); - - System.out.println("\n"); - System.out.println("\n"); - - } - } - - if (classesUnderTest != null && classesUnderTest.length > 0) { - System.out.println("********** BEGIN CLASS LEVEL SIGNATURE " + "VALIDATION **********\n\n"); - - for (int i = 0; i < classesUnderTest.length; i++) { - - String className = classesUnderTest[i]; - - System.out.println("********** BEGIN VALIDATE CLASS '" + classesUnderTest[i] + "' **********\n"); - - System.out.println("********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES ****"); - System.out.println("Static mode supports checks of static constants values "); - - String[] args = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, className, - classpath, true); - dumpTestArguments(args); - - if (runSignatureTest(className, args)) { - System.out.println("********** Class '" + className + "' - PASSED (STATIC MODE) **********"); - result.addPassedClass(className + "(static mode)"); - } else { - System.out.println("********** Class '" + className + "' - FAILED (STATIC MODE) **********"); - result.addFailedClass(className + "(static mode)"); - } - - System.out.println("\n\n"); - System.out.println("********** VALIDATE IN REFLECTIVE MODE ****"); - System.out.println("Reflective mode supports verification within containers (ie ejb, servlet, etc)"); - - String[] args2 = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, className, - classpath, false); - dumpTestArguments(args2); - - if (runSignatureTest(className, args2)) { - System.out.println("********** Class '" + className + "' - PASSED (REFLECTION MODE) **********"); - result.addPassedClass(className + "(reflection mode)"); - } else { - System.out.println("********** Class '" + className + "' - FAILED (REFLECTION MODE) **********"); - result.addFailedClass(className + "(reflection mode)"); - } - - System.out.println("********** END VALIDATE CLASS '" + classesUnderTest[i] + "' **********\n"); - - System.out.println("\n"); - System.out.println("\n"); - - } - } - - /* - * The following will check if there are Optional Technologies being implemented - * but not explicitly defined thru (ts.jte) javaee.level property. This is a - * problem because if an optional technolgy is defined (either whole or - * partially) than the TCK tests (and sig tests) for those Optional - * Technology(s) MUST be run according to related specs. - */ - if (unaccountedTechPkgs != null) { - for (int ii = 0; ii < unaccountedTechPkgs.size(); ii++) { - // 'unaccountedTechPkgs' are t hose packages which do not beling to - // base technology nor one of the *declared* optionalal technologies. - // 'unaccountedTechPkgs' refers to packages for Optional Technologies - // which were not defined thru (ts.jte) javaee.level property. - // So, make sure there are no whole or partial implementations of - // undeclared optional technologies in the implementation - - String packageName = unaccountedTechPkgs.get(ii); - - // this is a special case exception to our validation of Optional - // Technologies. Normally any partial technology implementations - // would be a compatibility failure. HOWEVER, EE 7 Spec (see section - // EE 6.1.2 of the Platform spec in the footnote on p. 156.) - // requires us to add special handling to avoid testing 'certain' pkgs - // within an optional technology. - if (isIgnorePackageUnderTest(packageName, arrayOptionalPkgsToIgnore)) { - System.out.println("Ignoring special optional technology package: " + packageName); - continue; - } - - System.out.println("\n\n"); - System.out.println("********** CHECK IF OPTIONAL TECHNOLOGIES EXIST IN REFLECTIVE MODE ****"); - System.out.println("Reflective mode supports verification within containers (ie ejb, servlet, etc)"); - - String[] args3 = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, packageName, - classpath, false); - dumpTestArguments(args3); - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - // NOTE: this is the opposite of above in that *if* we find that an - // undeclared - // optional technology package exists - then we want to raise a red - // flag. - // The user would have to either remove the technology from the impl if - // they do not want to include it in their impl -OR- they must - // explicitly - // set javaee.level (in ts.jte) to include that Optional Technology AND - // after setting this property, they have to pass all related TCK tests. - if (runPackageSearch(packageName, args3)) { - // if this passed we have an issue because it should not exist - thus - // should NOT pass. - System.out.println("********** Package '" + packageName - + "' - WAS FOUND BUT SHOULD NOT BE (REFLECTION MODE) **********"); - String err = "ERROR: An area of concern has been identified. "; - err += "You must run sigtests with (ts.jte) javaee.level set to "; - err += "include all optional technology keywords. Whole and/or "; - err += "partial implementations of Optional Technologies "; - err += "must be implemented according to the specs AND must pass "; - err += "all related TCK tests. To properly pass the "; - err += "signature tests - you must identify all Optional Technology "; - err += "areas (via javaee.level) that you wish to pass signature tests for."; - System.out.println(err); - result.addFailedPkg( - packageName + " (Undeclared Optional Technology package found in reflection mode)"); - } else { - System.out.println("********** Undeclared Optional Technology package '" + packageName - + "' - PASSED (REFLECTION MODE) **********"); - } - } - } - - return result; - - } // END executeSigTest - - // ------------------------------------------------------- Protected Methods - - /** - * Using a common set of information, create arguments that are appropriate to - * be used with the underlying signature test framework. - * - * @param packageListFile - file containing the packages/classes that - * are to be verified - * @param mapFile sig-test.map file - * @param signatureRepositoryDir directory containing the recorded signatures - * @param packageOrClassUnderTest the class or package - * @param classpath The location of the API being verified. - * Normally the checked API will be available in - * the test environment and testClasspath will be - * null. In some rare cases the tested API may - * not be part of the test environment and will - * have to specified using this parameter. - */ - protected abstract String[] createTestArguments(String packageListFile, String mapFile, - String signatureRepositoryDir, String packageOrClassUnderTest, String classpath, boolean bStaticMode) - throws Exception; - - /** - * Invoke the underlying signature test framework for the specified package or - * class. - * - * @param packageOrClassName the package or class to be validated - * @param testArguments the arguments necessary to invoke the signature - * test framework - * - * @return true if the test passed, otherwise false - */ - protected abstract boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception; - - /** - * This checks if a class exists or not within the impl. - * - * @param packageOrClassName the package or class to be validated - * - * @return true if the package was found to exist, otherwise - * false - */ - protected abstract boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception; - - /** - * This method checks whether JTA API jar contains classes from - * javax.transaction.xa package - * - * @param classpath the classpath, pointing JTA API jar - * @param repositoryDir the directory containing an empty signature file - * - * @return true if the package javax.transaction.xa is not found in - * the JTA API jar, otherwise false - */ - protected abstract boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception; - - /** - * Loads the specified file into a Properties object provided the specified file - * exists and is a regular file. The call to new FileInputStream verifies that - * the specfied file is a regular file and exists. - * - * @param mapFile the path and name of the map file to be loaded - * - * @return Properties The Properties object initialized with the contents of the - * specified file - * - * @throws java.io.IOException If the specified map file does not exist or is - * not a regular file, can also be thrown if there - * is an error creating an input stream from the - * specified file. - */ - public Properties loadMapFile(String mapFile) throws IOException, FileNotFoundException { - - FileInputStream in = null; - try { - File map = new File(mapFile); - Properties props = new Properties(); - in = new FileInputStream(map); - props.load(in); - return props; - } finally { - try { - if (in != null) { - in.close(); - } - } catch (Throwable t) { - // do nothing - } - } - - } // END loadMapFile - - /** - * This method will attempt to build a fully-qualified filename in the format of - * respositoryDir + baseName + .sig_ + - * version. - * - * @param baseName the base portion of the signature filename - * @param repositoryDir the directory in which the signatures are stored - * @param version the version of the signature file - * @throws FileNotFoundException if the file cannot be validated as existing and - * is in fact a file - * @return a valid, fully qualified filename, appropriate for the system the - * test is being run on - */ - protected String getSigFileName(String baseName, String repositoryDir, String version) - throws FileNotFoundException { - - String sigFile; - if (repositoryDir.endsWith(File.separator)) { - sigFile = repositoryDir + baseName + SIG_FILE_EXT; - } else { - sigFile = repositoryDir + File.separator + baseName + SIG_FILE_EXT; - } - - File testFile = new File(sigFile); - - if (!testFile.exists() && !testFile.isFile()) { - throw new FileNotFoundException("Signature file \"" + sigFile + "\" does not exist."); - } - - // we are actually requiring this normalizeFileName call to get - // things working on Windows. Without this, if we just return the - // testFile; we will fail on windows. (Solaris works either way) - // IMPORTANT UPDATE!! (4/5/2011) - // in sigtest 2.2: they stopped supporting the normalized version which - // created a string filename = - // "file://com/sun/ts/tests/signaturetest/foo.sig" - // so now use file path and name only. - // return normalizeFileName(testFile); - return testFile.toString(); - - } // END getSigFileName - - protected abstract String normalizeFileName(File f); - - /** - * Returns the name and path to the signature file that contains the specified - * package's signatures. - * - * @param packageName The package under test - * @param mapFile The name of the file that maps package names to versions - * @param repositoryDir The directory that conatisn all signature files - * - * @return String The path and name of the siganture file that contains the - * specified package's signatures - * - * @throws Exception if the determined signature file is not a regular file or - * does not exist - */ - protected SignatureFileInfo getSigFileInfo(String packageName, String mapFile, String repositoryDir) - throws Exception { - - String originalPackage = packageName; - String name = null; - String version = null; - Properties props = loadMapFile(mapFile); - - while (true) { - boolean packageFound = false; - for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { - name = (String) (e.nextElement()); - if (name.equals(packageName)) { - version = props.getProperty(name); - packageFound = true; - break; - } // end if - } // end for - - if (packageFound) { - break; - } - - /* - * If we get here we did not find a package name in the properties file that - * matches the package name under test. So we look for a package name in the - * properties file that could be the parent package for the package under test. - * We do this by removing the specified packages last package name section. So - * jakarta.ejb.spi would become jakarta.ejb - */ - int index = packageName.lastIndexOf("."); - if (index <= 0) { - throw new Exception( - "Package \"" + originalPackage + "\" not specified in mapping file \"" + mapFile + "\"."); - } - packageName = packageName.substring(0, index); - } // end while - - /* Return the expected name of the signature file */ - - return new SignatureFileInfo(getSigFileName(name, repositoryDir, version), version); - - } // END getSigFileInfo - - // --------------------------------------------------------- Private Methods - - /* - * This returns true is the passed in packageName matches one of the packages - * that are listed in the arrayOptionalPkgsToIgnore. arrayOptionalPkgsToIgnore - * is ultimately defined in the ts.jte property - * 'optional.tech.packages.to.ignore' If one of the entries in - * arrayOptionalPkgsToIgnore matches the packageName then that means we return - * TRUE to indicate we should ignore and NOT TEST that particular package. - */ - private static boolean isIgnorePackageUnderTest(String packageName, String[] arrayOptionalPkgsToIgnore) { - - // if anything is null - consider no match - if ((packageName == null) || (arrayOptionalPkgsToIgnore == null)) { - return false; - } - - for (int ii = 0; ii < arrayOptionalPkgsToIgnore.length; ii++) { - if (packageName.equals(arrayOptionalPkgsToIgnore[ii])) { - // we found a match - - return true; - } - } - - return false; - } - - /** - * Prints the specified list of parameters to the message log. Used for - * debugging purposes only. - * - * @param params The list of parameters to dump. - */ - private static void dumpTestArguments(String[] params) { - - if (params != null && params.length > 0) { - System.out.println("----------------- BEGIN SIG PARAM DUMP -----------------"); - for (int i = 0; i < params.length; i++) { - System.out.println(" Param[" + i + "]: " + params[i]); - } - System.out.println("------------------ END SIG PARAM DUMP ------------------"); - } - - } // END dumpTestArguments - - // ----------------------------------------------------------- Inner Classes - - /** - * A simple data structure containing the fully qualified path to the signature - * file as well as the version being tested. - */ - protected static class SignatureFileInfo { - - private String file; + private static final String SIG_FILE_EXT = ".sig"; + + // ---------------------------------------------------------- Public Methods + + /** + * Implementation of the getPackageFile method defined in both the SigTest and + * SigTestEE class. + */ + public String getPackageFileImpl(String binDir) { + + String thePkgListFile = "sig-test-pkg-list.txt"; + + System.out.println("Using the following as the SigTest Package file: " + thePkgListFile); + + String theFile = binDir + File.separator + thePkgListFile; + File ff = new File(theFile); + if (!ff.exists()) { + // we could not find the map file that coresponded to our SE version so + // lets + // try to default to use the sig-test-pkg-list.txt + System.out.println("The SigTest Package file does not exist: " + thePkgListFile); + theFile = binDir + File.separator + "sig-test-pkg-list.txt"; + File ff2 = new File(theFile); + if (!ff2.exists()) { + System.out.println("The Default SigTest Package file does not exist either: " + theFile); + } else { + System.out.println("Defaulting to using SigTest Package file: " + theFile); + } + } + + return (theFile); + + } // END getPackageFileImpl + + /** + * Implementation of the getMapFile method defined in both the SigTest and + * SigTestEE class. + */ + public String getMapFileImpl(String binDir) { + + String theMapFile = "sig-test.map"; + + System.out.println("Using the following as the sig-Test map file: " + theMapFile); + + String theFile = binDir + File.separator + theMapFile; + File ff = new File(theFile); + if (!ff.exists()) { + // we could not find the map file that coresponded to our SE version so + // lets + // try to default to use the sig-test.map + System.out.println("The SigTest Map file does not exist: " + theMapFile); + theFile = binDir + File.separator + "sig-test.map"; + File ff2 = new File(theFile); + if (!ff2.exists()) { + System.out.println("The SigTest Map file does not exist either: " + theFile); + } else { + System.out.println("Defaulting to using SigTest Map file: " + theFile); + } + } + + return (theFile); + + } // END getMapFileImpl + + /** + * Returns true if the passed in version matches the current Java version being + * used. + * + */ + public Boolean isJavaSEVersion(String ver) { + + String strOSVersion = System.getProperty("java.version"); + if (strOSVersion.startsWith(ver)) { + return true; + } else { + return false; + } + } + + /** + * Implementation of the getRepositoryDir method defined in both the SigTest and + * SigTestEE class. + */ + public String getRepositoryDirImpl(String tsHome) { + + return (tsHome + File.separator + "src" + File.separator + "com" + File.separator + "sun" + File.separator + + "ts" + File.separator + "tests" + File.separator + "signaturetest" + File.separator + + "signature-repository" + File.separator); + + } // END getRepositoryDirImpl + + /** + * Implementation of the cleanup method defined in both the SigTest and + * SigTestEE class. + */ + public void cleanupImpl() throws Exception { + + try { + System.out.println("cleanup"); + } catch (Exception e) { + System.out.println("Exception in cleanup method" + e); + throw e; + } + + } // END cleanupImpl + + /** + *

+ * Execute the signature test. By default, this method passes the result of + * {@link #createTestArguments(String, String, String, String, String, boolean)} + * and passes the result to {@link #runSignatureTest(String, String[])}. + * + * @param packageListFile - file containing the packages/classes that are + * to be verified + * @param mapFile sig-test.map file + * @param signatureRepositoryDir directory containing the recorded signatures + * @param packagesUnderTest packages, defined by the test client, that + * should be tested + * @param classesUnderTest classes, defined by the test client, that + * should be tested + * @param classpath The location of the API being verified. + * Normally the checked API will be available in + * the test environment and testClasspath will be + * null. In some rare cases the tested API may not + * be part of the test environment and will have + * to specified using this parameter. + * @param unaccountedTechPkgs packages that should not exist within the + * technology under test. These will be searched + * for and if found, will be flagged as error + * since they were not explicitly declared as + * being under test. Their existence requires + * explicit testing. + * + * @return a {@link SigTestResult} containing the result of the test execution + */ + public SigTestResult executeSigTest(String packageListFile, String mapFile, String signatureRepositoryDir, + String[] packagesUnderTest, String[] classesUnderTest, String classpath, + ArrayList unaccountedTechPkgs, String optionalPkgToIgnore) throws Exception { + + SigTestResult result = new SigTestResult(); + + System.out.println("optionalPkgToIgnore = " + optionalPkgToIgnore); + String[] arrayOptionalPkgsToIgnore = null; + if (optionalPkgToIgnore != null) { + arrayOptionalPkgsToIgnore = optionalPkgToIgnore.split(","); + } + + if (packagesUnderTest != null && packagesUnderTest.length > 0) { + System.out.println("********** BEGIN PACKAGE LEVEL SIGNATURE " + "VALIDATION **********\n\n"); + for (int i = 0; i < packagesUnderTest.length; i++) { + + String packageName = packagesUnderTest[i]; + + System.out.println("********** BEGIN VALIDATE PACKAGE '" + packagesUnderTest[i] + "' **********\n"); + + System.out.println("********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES ****"); + System.out.println("Static mode supports checks of static constants values "); + + String[] args = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, packageName, + classpath, true); + dumpTestArguments(args); + + if (runSignatureTest(packageName, args)) { + System.out.println("********** Package '" + packageName + "' - PASSED (STATIC MODE) **********"); + result.addPassedPkg(packageName + "(static mode)"); + } else { + result.addFailedPkg(packageName + "(static mode)"); + System.out.println("********** Package '" + packageName + "' - FAILED (STATIC MODE) **********"); + } + + System.out.println("\n\n"); + System.out.println("********** VALIDATE IN REFLECTIVE MODE ****"); + System.out.println("Reflective mode supports verification within containers (ie ejb, servlet, etc)"); + + String[] args2 = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, packageName, + classpath, false); + dumpTestArguments(args2); + + if (runSignatureTest(packageName, args2)) { + System.out + .println("********** Package '" + packageName + "' - PASSED (REFLECTION MODE) **********"); + result.addPassedPkg(packageName + "(reflection mode)"); + } else { + result.addFailedPkg(packageName + "(reflection mode)"); + System.out + .println("********** Package '" + packageName + "' - FAILED (REFLECTION MODE) **********"); + } + + System.out.println("********** END VALIDATE PACKAGE '" + packagesUnderTest[i] + "' **********\n"); + + System.out.println("\n"); + System.out.println("\n"); + + } + } + + if (classesUnderTest != null && classesUnderTest.length > 0) { + System.out.println("********** BEGIN CLASS LEVEL SIGNATURE " + "VALIDATION **********\n\n"); + + for (int i = 0; i < classesUnderTest.length; i++) { + + String className = classesUnderTest[i]; + + System.out.println("********** BEGIN VALIDATE CLASS '" + classesUnderTest[i] + "' **********\n"); + + System.out.println("********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES ****"); + System.out.println("Static mode supports checks of static constants values "); + + String[] args = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, className, + classpath, true); + dumpTestArguments(args); + + if (runSignatureTest(className, args)) { + System.out.println("********** Class '" + className + "' - PASSED (STATIC MODE) **********"); + result.addPassedClass(className + "(static mode)"); + } else { + System.out.println("********** Class '" + className + "' - FAILED (STATIC MODE) **********"); + result.addFailedClass(className + "(static mode)"); + } + + System.out.println("\n\n"); + System.out.println("********** VALIDATE IN REFLECTIVE MODE ****"); + System.out.println("Reflective mode supports verification within containers (ie ejb, servlet, etc)"); + + String[] args2 = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, className, + classpath, false); + dumpTestArguments(args2); + + if (runSignatureTest(className, args2)) { + System.out.println("********** Class '" + className + "' - PASSED (REFLECTION MODE) **********"); + result.addPassedClass(className + "(reflection mode)"); + } else { + System.out.println("********** Class '" + className + "' - FAILED (REFLECTION MODE) **********"); + result.addFailedClass(className + "(reflection mode)"); + } + + System.out.println("********** END VALIDATE CLASS '" + classesUnderTest[i] + "' **********\n"); + + System.out.println("\n"); + System.out.println("\n"); + + } + } + + /* + * The following will check if there are Optional Technologies being implemented + * but not explicitly defined thru (ts.jte) javaee.level property. This is a + * problem because if an optional technolgy is defined (either whole or + * partially) than the TCK tests (and sig tests) for those Optional + * Technology(s) MUST be run according to related specs. + */ + if (unaccountedTechPkgs != null) { + for (int ii = 0; ii < unaccountedTechPkgs.size(); ii++) { + // 'unaccountedTechPkgs' are t hose packages which do not beling to + // base technology nor one of the *declared* optionalal technologies. + // 'unaccountedTechPkgs' refers to packages for Optional Technologies + // which were not defined thru (ts.jte) javaee.level property. + // So, make sure there are no whole or partial implementations of + // undeclared optional technologies in the implementation + + String packageName = unaccountedTechPkgs.get(ii); + + // this is a special case exception to our validation of Optional + // Technologies. Normally any partial technology implementations + // would be a compatibility failure. HOWEVER, EE 7 Spec (see section + // EE 6.1.2 of the Platform spec in the footnote on p. 156.) + // requires us to add special handling to avoid testing 'certain' pkgs + // within an optional technology. + if (isIgnorePackageUnderTest(packageName, arrayOptionalPkgsToIgnore)) { + System.out.println("Ignoring special optional technology package: " + packageName); + continue; + } + + System.out.println("\n\n"); + System.out.println("********** CHECK IF OPTIONAL TECHNOLOGIES EXIST IN REFLECTIVE MODE ****"); + System.out.println("Reflective mode supports verification within containers (ie ejb, servlet, etc)"); + + String[] args3 = createTestArguments(packageListFile, mapFile, signatureRepositoryDir, packageName, + classpath, false); + dumpTestArguments(args3); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // - - - - + // NOTE: this is the opposite of above in that *if* we find that an + // undeclared + // optional technology package exists - then we want to raise a red + // flag. + // The user would have to either remove the technology from the impl if + // they do not want to include it in their impl -OR- they must + // explicitly + // set javaee.level (in ts.jte) to include that Optional Technology AND + // after setting this property, they have to pass all related TCK tests. + if (runPackageSearch(packageName, args3)) { + // if this passed we have an issue because it should not exist - thus + // should NOT pass. + System.out.println("********** Package '" + packageName + + "' - WAS FOUND BUT SHOULD NOT BE (REFLECTION MODE) **********"); + String err = "ERROR: An area of concern has been identified. "; + err += "You must run sigtests with (ts.jte) javaee.level set to "; + err += "include all optional technology keywords. Whole and/or "; + err += "partial implementations of Optional Technologies "; + err += "must be implemented according to the specs AND must pass "; + err += "all related TCK tests. To properly pass the "; + err += "signature tests - you must identify all Optional Technology "; + err += "areas (via javaee.level) that you wish to pass signature tests for."; + System.out.println(err); + result.addFailedPkg( + packageName + " (Undeclared Optional Technology package found in reflection mode)"); + } else { + System.out.println("********** Undeclared Optional Technology package '" + packageName + + "' - PASSED (REFLECTION MODE) **********"); + } + } + } + + return result; + + } // END executeSigTest + + // ------------------------------------------------------- Protected Methods + + /** + * Using a common set of information, create arguments that are appropriate to + * be used with the underlying signature test framework. + * + * @param packageListFile - file containing the packages/classes that + * are to be verified + * @param mapFile sig-test.map file + * @param signatureRepositoryDir directory containing the recorded signatures + * @param packageOrClassUnderTest the class or package + * @param classpath The location of the API being verified. + * Normally the checked API will be available in + * the test environment and testClasspath will be + * null. In some rare cases the tested API may + * not be part of the test environment and will + * have to specified using this parameter. + */ + protected abstract String[] createTestArguments(String packageListFile, String mapFile, + String signatureRepositoryDir, String packageOrClassUnderTest, String classpath, boolean bStaticMode) + throws Exception; + + /** + * Invoke the underlying signature test framework for the specified package or + * class. + * + * @param packageOrClassName the package or class to be validated + * @param testArguments the arguments necessary to invoke the signature + * test framework + * + * @return true if the test passed, otherwise false + */ + protected abstract boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception; + + /** + * This checks if a class exists or not within the impl. + * + * @param packageOrClassName the package or class to be validated + * + * @return true if the package was found to exist, otherwise + * false + */ + protected abstract boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception; + + /** + * This method checks whether JTA API jar contains classes from + * javax.transaction.xa package + * + * @param classpath the classpath, pointing JTA API jar + * @param repositoryDir the directory containing an empty signature file + * + * @return true if the package javax.transaction.xa is not found in + * the JTA API jar, otherwise false + */ + protected abstract boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception; + + /** + * Loads the specified file into a Properties object provided the specified file + * exists and is a regular file. The call to new FileInputStream verifies that + * the specfied file is a regular file and exists. + * + * @param mapFile the path and name of the map file to be loaded + * + * @return Properties The Properties object initialized with the contents of the + * specified file + * + * @throws java.io.IOException If the specified map file does not exist or is + * not a regular file, can also be thrown if there + * is an error creating an input stream from the + * specified file. + */ + public Properties loadMapFile(String mapFile) throws IOException, FileNotFoundException { + + FileInputStream in = null; + try { + File map = new File(mapFile); + Properties props = new Properties(); + in = new FileInputStream(map); + props.load(in); + return props; + } finally { + try { + if (in != null) { + in.close(); + } + } catch (Throwable t) { + // do nothing + } + } + + } // END loadMapFile + + /** + * This method will attempt to build a fully-qualified filename in the format of + * respositoryDir + baseName + .sig_ + + * version. + * + * @param baseName the base portion of the signature filename + * @param repositoryDir the directory in which the signatures are stored + * @param version the version of the signature file + * @throws FileNotFoundException if the file cannot be validated as existing and + * is in fact a file + * @return a valid, fully qualified filename, appropriate for the system the + * test is being run on + */ + protected String getSigFileName(String baseName, String repositoryDir, String version) + throws FileNotFoundException { + + String sigFile; + if (repositoryDir.endsWith(File.separator)) { + sigFile = repositoryDir + baseName + SIG_FILE_EXT; + } else { + sigFile = repositoryDir + File.separator + baseName + SIG_FILE_EXT; + } + + File testFile = new File(sigFile); + + if (!testFile.exists() && !testFile.isFile()) { + throw new FileNotFoundException("Signature file \"" + sigFile + "\" does not exist."); + } + + // we are actually requiring this normalizeFileName call to get + // things working on Windows. Without this, if we just return the + // testFile; we will fail on windows. (Solaris works either way) + // IMPORTANT UPDATE!! (4/5/2011) + // in sigtest 2.2: they stopped supporting the normalized version which + // created a string filename = + // "file://com/sun/ts/tests/signaturetest/foo.sig" + // so now use file path and name only. + // return normalizeFileName(testFile); + return testFile.toString(); + + } // END getSigFileName + + protected abstract String normalizeFileName(File f); + + /** + * Returns the name and path to the signature file that contains the specified + * package's signatures. + * + * @param packageName The package under test + * @param mapFile The name of the file that maps package names to versions + * @param repositoryDir The directory that conatisn all signature files + * + * @return String The path and name of the siganture file that contains the + * specified package's signatures + * + * @throws Exception if the determined signature file is not a regular file or + * does not exist + */ + protected SignatureFileInfo getSigFileInfo(String packageName, String mapFile, String repositoryDir) + throws Exception { + + String originalPackage = packageName; + String name = null; + String version = null; + Properties props = loadMapFile(mapFile); + + while (true) { + boolean packageFound = false; + for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { + name = (String) (e.nextElement()); + if (name.equals(packageName)) { + version = props.getProperty(name); + packageFound = true; + break; + } // end if + } // end for + + if (packageFound) { + break; + } + + /* + * If we get here we did not find a package name in the properties file that + * matches the package name under test. So we look for a package name in the + * properties file that could be the parent package for the package under test. + * We do this by removing the specified packages last package name section. So + * jakarta.ejb.spi would become jakarta.ejb + */ + int index = packageName.lastIndexOf("."); + if (index <= 0) { + throw new Exception( + "Package \"" + originalPackage + "\" not specified in mapping file \"" + mapFile + "\"."); + } + packageName = packageName.substring(0, index); + } // end while + + /* Return the expected name of the signature file */ + + return new SignatureFileInfo(getSigFileName(name, repositoryDir, version), version); + + } // END getSigFileInfo + + // --------------------------------------------------------- Private Methods + + /* + * This returns true is the passed in packageName matches one of the packages + * that are listed in the arrayOptionalPkgsToIgnore. arrayOptionalPkgsToIgnore + * is ultimately defined in the ts.jte property + * 'optional.tech.packages.to.ignore' If one of the entries in + * arrayOptionalPkgsToIgnore matches the packageName then that means we return + * TRUE to indicate we should ignore and NOT TEST that particular package. + */ + private static boolean isIgnorePackageUnderTest(String packageName, String[] arrayOptionalPkgsToIgnore) { + + // if anything is null - consider no match + if ((packageName == null) || (arrayOptionalPkgsToIgnore == null)) { + return false; + } + + for (int ii = 0; ii < arrayOptionalPkgsToIgnore.length; ii++) { + if (packageName.equals(arrayOptionalPkgsToIgnore[ii])) { + // we found a match - + return true; + } + } + + return false; + } + + /** + * Prints the specified list of parameters to the message log. Used for + * debugging purposes only. + * + * @param params The list of parameters to dump. + */ + private static void dumpTestArguments(String[] params) { + + if (params != null && params.length > 0) { + System.out.println("----------------- BEGIN SIG PARAM DUMP -----------------"); + for (int i = 0; i < params.length; i++) { + System.out.println(" Param[" + i + "]: " + params[i]); + } + System.out.println("------------------ END SIG PARAM DUMP ------------------"); + } + + } // END dumpTestArguments + + // ----------------------------------------------------------- Inner Classes + + /** + * A simple data structure containing the fully qualified path to the signature + * file as well as the version being tested. + */ + protected static class SignatureFileInfo { + + private String file; - private String version; + private String version; - // -------------------------------------------------------- Constructors + // -------------------------------------------------------- Constructors - public SignatureFileInfo(String file, String version) { + public SignatureFileInfo(String file, String version) { - if (file == null) { - throw new IllegalArgumentException("'file' argument cannot be null"); - } + if (file == null) { + throw new IllegalArgumentException("'file' argument cannot be null"); + } - if (version == null) { - throw new IllegalArgumentException("'version' argument cannot be null"); - } + if (version == null) { + throw new IllegalArgumentException("'version' argument cannot be null"); + } - this.file = file; - this.version = version; + this.file = file; + this.version = version; - } // END SignatureFileInfo + } // END SignatureFileInfo - // ------------------------------------------------------ Public Methods + // ------------------------------------------------------ Public Methods - public String getFile() { + public String getFile() { - return file; + return file; - } // END getFileIncludingPath + } // END getFileIncludingPath - public String getVersion() { + public String getVersion() { - return version; + return version; - } // END getVersion + } // END getVersion - } + } } // END SigTestDriver diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java index 55c47de1..3cbe3464 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java @@ -27,52 +27,52 @@ */ public class SignatureTestDriverFactory { - /** - *

- * Identifier for the driver that uses API Check to perform signature - * validation. - *

- */ - public static final String API_CHECK = "apicheck"; + /** + *

+ * Identifier for the driver that uses API Check to perform signature + * validation. + *

+ */ + public static final String API_CHECK = "apicheck"; - /** - *

- * Identifier for the driver that uses the Signature Test framework for signature - * validation. - *

- */ - public static final String SIG_TEST = "sigtest"; + /** + *

+ * Identifier for the driver that uses the Signature Test framework for + * signature validation. + *

+ */ + public static final String SIG_TEST = "sigtest"; - // ------------------------------------------------------------ Constructors + // ------------------------------------------------------------ Constructors - // Access via factory method - private SignatureTestDriverFactory() { - } // END SignatureTestDriverFactory + // Access via factory method + private SignatureTestDriverFactory() { + } // END SignatureTestDriverFactory - // ---------------------------------------------------------- Public Methods + // ---------------------------------------------------------- Public Methods - /** - *

- * Obtain a {@link SignatureTestDriver} instance based on the type - * argument. - * - * @param type the driver type to create - * @return a {@link SignatureTestDriver} implementation - */ - public static SignatureTestDriver getInstance(String type) { + /** + *

+ * Obtain a {@link SignatureTestDriver} instance based on the type + * argument. + * + * @param type the driver type to create + * @return a {@link SignatureTestDriver} implementation + */ + public static SignatureTestDriver getInstance(String type) { - if (type == null || type.length() == 0) { - throw new IllegalArgumentException("Type was null or empty"); - } + if (type == null || type.length() == 0) { + throw new IllegalArgumentException("Type was null or empty"); + } - if (API_CHECK.equals(type)) { - return new ApiCheckDriver(); - } else if (SIG_TEST.equals(type)) { - return new SigTestDriver(); - } else { - throw new IllegalArgumentException("Unknown Type: '" + type + '\''); - } + if (API_CHECK.equals(type)) { + return new ApiCheckDriver(); + } else if (SIG_TEST.equals(type)) { + return new SigTestDriver(); + } else { + throw new IllegalArgumentException("Unknown Type: '" + type + '\''); + } - } // END getInstance + } // END getInstance } // END SignatureTestDriverFactory diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java index 345d5477..aafeddd8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java @@ -22,43 +22,43 @@ * the Runnable Task to check the context related job. */ public class CallableTask extends RunnableTask implements Callable { - private final T expectedReturnValue; + private final T expectedReturnValue; - @Override - public T call() { - run(); - return expectedReturnValue; - } + @Override + public T call() { + run(); + return expectedReturnValue; + } - /** - * Construct the callable task with expected properties. - * - * @param jndiName the jndi name set for env-entry, ignore jndi test if it is - * null. - * @param jndiValue the jndi value set for jndiName - * @param className class name to be loaded inside the task, ignore class - * loading test if it is null. - * @param returned expected returned object. - * @param blockTime block time(in millisecond) for this task. - */ - public CallableTask(String jndiName, String jndiValue, String className, T returned, long blockTime) { - super(jndiName, jndiValue, className, blockTime); - this.expectedReturnValue = returned; - } + /** + * Construct the callable task with expected properties. + * + * @param jndiName the jndi name set for env-entry, ignore jndi test if it is + * null. + * @param jndiValue the jndi value set for jndiName + * @param className class name to be loaded inside the task, ignore class + * loading test if it is null. + * @param returned expected returned object. + * @param blockTime block time(in millisecond) for this task. + */ + public CallableTask(String jndiName, String jndiValue, String className, T returned, long blockTime) { + super(jndiName, jndiValue, className, blockTime); + this.expectedReturnValue = returned; + } - /** - * Construct the callable task with expected properties. - * - * @param jndiName the jndi name set for env-entry, ignore jndi test if it is - * null. - * @param jndiValue the jndi value set for jndiName - * @param className class name to be loaded inside the task, ignore class - * loading test if it is null. - * @param returned expected returned object. - */ - public CallableTask(String jndiName, String jndiValue, String className, T returned) { - super(jndiName, jndiValue, className); - this.expectedReturnValue = returned; - } + /** + * Construct the callable task with expected properties. + * + * @param jndiName the jndi name set for env-entry, ignore jndi test if it is + * null. + * @param jndiValue the jndi value set for jndiName + * @param className class name to be loaded inside the task, ignore class + * loading test if it is null. + * @param returned expected returned object. + */ + public CallableTask(String jndiName, String jndiValue, String className, T returned) { + super(jndiName, jndiValue, className); + this.expectedReturnValue = returned; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java index 7262269c..798b4594 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java @@ -24,56 +24,56 @@ public class CommonTasks { - public static final String SIMPLE_RETURN_STRING = "ok"; + public static final String SIMPLE_RETURN_STRING = "ok"; - public static class SimpleCallable implements Callable { - private Duration waitTime = Duration.ZERO; + public static class SimpleCallable implements Callable { + private Duration waitTime = Duration.ZERO; - public SimpleCallable() { - } + public SimpleCallable() { + } - public SimpleCallable(Duration waitTime) { - this.waitTime = waitTime; - } + public SimpleCallable(Duration waitTime) { + this.waitTime = waitTime; + } - public String call() { - try { - if (!waitTime.isZero()) { - Wait.sleep(waitTime); - } else { - Wait.sleep(TestConstants.PollInterval); - } - } catch (Exception e) { - throw new RuntimeException(e); - } - return SIMPLE_RETURN_STRING; - } - } + public String call() { + try { + if (!waitTime.isZero()) { + Wait.sleep(waitTime); + } else { + Wait.sleep(TestConstants.PollInterval); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + return SIMPLE_RETURN_STRING; + } + } - public static class SimpleRunnable implements Runnable { - public void run() { - try { - Wait.sleep(TestConstants.PollInterval); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } + public static class SimpleRunnable implements Runnable { + public void run() { + try { + Wait.sleep(TestConstants.PollInterval); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } - public static class SimpleArgCallable implements Callable { - private int value = -1; + public static class SimpleArgCallable implements Callable { + private int value = -1; - public SimpleArgCallable(int arg) { - value = arg; - } + public SimpleArgCallable(int arg) { + value = arg; + } - public Integer call() { - try { - Wait.sleep(TestConstants.PollInterval); - } catch (Exception e) { - throw new RuntimeException(e); - } - return value; - } - } + public Integer call() { + try { + Wait.sleep(TestConstants.PollInterval); + } catch (Exception e) { + throw new RuntimeException(e); + } + return value; + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java index 9f62f4b4..0d94d3ee 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java @@ -25,77 +25,77 @@ public class CommonTriggers { - /** - * A trigger that only run once. - */ - public static class OnceTrigger implements Trigger { - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (lastExecutionInfo != null) { - return null; - } - return new Date(); - } - - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { - return false; - } - } - - /** - * A trigger that will skip. - */ - public static class OnceTriggerDelaySkip implements Trigger { - - private Duration delay; - - public OnceTriggerDelaySkip(Duration delay) { - this.delay = delay; - } - - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (lastExecutionInfo != null) { - return null; - } - return new Date(new Date().getTime() + delay.toMillis()); - } - - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { - return true; - } - } - - /** - * A fixed-rate trigger - */ - public static class TriggerFixedRate implements Trigger { - private Date startTime; - - private long delta; - - private int executionCount = 0; - - private static final int executionCountLimit = TestConstants.PollsPerTimeout * 2; - - public TriggerFixedRate(Date startTime, long delta) { - this.startTime = startTime; - this.delta = delta; - } - - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { - executionCount++; - if (executionCount > executionCountLimit) { - return null; - } - - if (lastExecutionInfo == null) { - return new Date(startTime.getTime() + delta); - } - return new Date(lastExecutionInfo.getScheduledStart().getTime() + delta); - } - - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { - return false; - } - } + /** + * A trigger that only run once. + */ + public static class OnceTrigger implements Trigger { + public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (lastExecutionInfo != null) { + return null; + } + return new Date(); + } + + public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + return false; + } + } + + /** + * A trigger that will skip. + */ + public static class OnceTriggerDelaySkip implements Trigger { + + private Duration delay; + + public OnceTriggerDelaySkip(Duration delay) { + this.delay = delay; + } + + public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (lastExecutionInfo != null) { + return null; + } + return new Date(new Date().getTime() + delay.toMillis()); + } + + public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + return true; + } + } + + /** + * A fixed-rate trigger + */ + public static class TriggerFixedRate implements Trigger { + private Date startTime; + + private long delta; + + private int executionCount = 0; + + private static final int executionCountLimit = TestConstants.PollsPerTimeout * 2; + + public TriggerFixedRate(Date startTime, long delta) { + this.startTime = startTime; + this.delta = delta; + } + + public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + executionCount++; + if (executionCount > executionCountLimit) { + return null; + } + + if (lastExecutionInfo == null) { + return new Date(startTime.getTime() + delta); + } + return new Date(lastExecutionInfo.getScheduledStart().getTime() + delta); + } + + public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + return false; + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java index 499f921c..30837908 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java @@ -29,97 +29,97 @@ */ public class RunnableTask implements Runnable { - private static final TestLogger log = TestLogger.get(RunnableTask.class); - - private final String jndiName; - - private final String expectedJndiValue; - - private final String contexualClassName; - - private final long blockTime; - - private volatile int count = 0; - - @Override - public void run() { - if (blockTime > 0) { - try { - TimeUnit.MILLISECONDS.sleep(blockTime); - } catch (InterruptedException e) { - log.severe("", e); - } - } - boolean jndiPassed = lookupEnvRef(); - boolean loadClassPassed = loadClass(); - if (!(jndiPassed && loadClassPassed)) { - throw new RuntimeException( - "jndi test passed: " + jndiPassed + ", class loading test passed: " + loadClassPassed); - } - count++; - } - - /** - * Construct the runnable task with expected properties. - * - * @param jndiName the jndi name set for env-entry, ignore jndi test if it is - * null. - * @param jndiValue the jndi value set for jndiName - * @param className class name to be loaded inside the task, ignore class - * loading test if it is null. - * @param blockTime block time(in millisecond) for this task. - */ - public RunnableTask(String jndiName, String jndiValue, String className, long blockTime) { - this.contexualClassName = className; - this.jndiName = jndiName; - this.expectedJndiValue = jndiValue; - this.blockTime = blockTime; - } - - /** - * Construct the runnable task with expected properties. - * - * @param jndiName the jndi name set for env-entry, ignore jndi test if it is - * null. - * @param jndiValue the jndi value set for jndiName - * @param className class name to be loaded inside the task, ignore class - * loading test if it is null. - */ - public RunnableTask(String jndiName, String jndiValue, String className) { - this.contexualClassName = className; - this.jndiName = jndiName; - this.expectedJndiValue = jndiValue; - this.blockTime = 0; - } - - protected boolean lookupEnvRef() { - boolean passed = false; - String value = null; - try { - value = InitialContext.doLookup(jndiName); - if (expectedJndiValue.equals(value)) { - passed = true; - } - } catch (NamingException e) { - } - - return passed; - } - + private static final TestLogger log = TestLogger.get(RunnableTask.class); + + private final String jndiName; + + private final String expectedJndiValue; + + private final String contexualClassName; + + private final long blockTime; + + private volatile int count = 0; + + @Override + public void run() { + if (blockTime > 0) { + try { + TimeUnit.MILLISECONDS.sleep(blockTime); + } catch (InterruptedException e) { + log.severe("", e); + } + } + boolean jndiPassed = lookupEnvRef(); + boolean loadClassPassed = loadClass(); + if (!(jndiPassed && loadClassPassed)) { + throw new RuntimeException( + "jndi test passed: " + jndiPassed + ", class loading test passed: " + loadClassPassed); + } + count++; + } + + /** + * Construct the runnable task with expected properties. + * + * @param jndiName the jndi name set for env-entry, ignore jndi test if it is + * null. + * @param jndiValue the jndi value set for jndiName + * @param className class name to be loaded inside the task, ignore class + * loading test if it is null. + * @param blockTime block time(in millisecond) for this task. + */ + public RunnableTask(String jndiName, String jndiValue, String className, long blockTime) { + this.contexualClassName = className; + this.jndiName = jndiName; + this.expectedJndiValue = jndiValue; + this.blockTime = blockTime; + } + + /** + * Construct the runnable task with expected properties. + * + * @param jndiName the jndi name set for env-entry, ignore jndi test if it is + * null. + * @param jndiValue the jndi value set for jndiName + * @param className class name to be loaded inside the task, ignore class + * loading test if it is null. + */ + public RunnableTask(String jndiName, String jndiValue, String className) { + this.contexualClassName = className; + this.jndiName = jndiName; + this.expectedJndiValue = jndiValue; + this.blockTime = 0; + } + + protected boolean lookupEnvRef() { + boolean passed = false; + String value = null; + try { + value = InitialContext.doLookup(jndiName); + if (expectedJndiValue.equals(value)) { + passed = true; + } + } catch (NamingException e) { + } + + return passed; + } + public int getCount() { return count; } - protected boolean loadClass() { - boolean passed = false; - try { - Class loadedClass = Thread.currentThread().getContextClassLoader().loadClass(contexualClassName); - if (contexualClassName == loadedClass.getName()) { - passed = true; - } - } catch (ClassNotFoundException e) { - } - return passed; - } + protected boolean loadClass() { + boolean passed = false; + try { + Class loadedClass = Thread.currentThread().getContextClassLoader().loadClass(contexualClassName); + if (contexualClassName == loadedClass.getName()) { + passed = true; + } + } catch (ClassNotFoundException e) { + } + return passed; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java index 878075ec..0ac85afe 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java @@ -21,21 +21,21 @@ import javax.sql.DataSource; public class Connections { - + private Connections() { - //ignore + // ignore } - + private static DataSource ds; - + public static void setDataSource(DataSource ds) { Connections.ds = ds; } - + public static void unsetDataSource() { Connections.ds = null; } - + public static Connection getConnection(boolean autoCommit) { Connection conn = null; try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java index e1448aa8..42b8832a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java @@ -20,11 +20,13 @@ import java.sql.Statement; public class Counter { - + /** - * Get count of rows in test table to verify if a transaction was committed or rolled back. + * Get count of rows in test table to verify if a transaction was committed or + * rolled back. * - * @return number of rows, or -1 if error occurred while attempting to access table. + * @return number of rows, or -1 if error occurred while attempting to access + * table. */ public static int getCount() { try (Connection conn = Connections.getConnection(true);) { @@ -37,7 +39,7 @@ public static int getCount() { private static int getCount(Connection conn) { final String queryStr = "select count(*) from " + Constants.TABLE_P; - + try (Statement stmt = conn.createStatement()) { ResultSet rs = stmt.executeQuery(queryStr); if (rs.next()) { @@ -46,7 +48,7 @@ private static int getCount(Connection conn) { } catch (Exception e) { e.printStackTrace(); } - + return -1; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java index a56e49cc..082e349f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java @@ -1,13 +1,14 @@ package ee.jakarta.tck.concurrent.framework; /** - * A service provider to pass along EJB JNDI names from test class to servlet, or tasks. - * This is a necessary provider since the same test packaged as an EAR for Full profile, and a - * WAR for Web Profile will have different JNDI names for their EJBs. + * A service provider to pass along EJB JNDI names from test class to servlet, + * or tasks. This is a necessary provider since the same test packaged as an EAR + * for Full profile, and a WAR for Web Profile will have different JNDI names + * for their EJBs. */ public interface EJBJNDIProvider { - /** - * Provides the EJB JNDI name for the test. - */ - public String getEJBJNDIName(); + /** + * Provides the EJB JNDI name for the test. + */ + public String getEJBJNDIName(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java index a9eb1f43..01bf80de 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java @@ -32,151 +32,162 @@ /** * This class is intended to be used in conjunction with TestServlet. - * TestServlets are deployed to the application server and has custom doGet/doPost methods - * that will return a successful or failure message depending on the test outcome. + * TestServlets are deployed to the application server and has custom + * doGet/doPost methods that will return a successful or failure message + * depending on the test outcome. * - * The TestClient class has runTest methods that will create an HTTP connection to - * the TestServlet and provide the TestServlet with the method name it needs to test. - * The TestClient class will then confirm that it recieved a successful outcome from the test. + * The TestClient class has runTest methods that will create an HTTP connection + * to the TestServlet and provide the TestServlet with the method name it needs + * to test. The TestClient class will then confirm that it recieved a successful + * outcome from the test. * */ public abstract class TestClient { - private static final TestLogger log = TestLogger.get(TestClient.class); - - public static final String SUCCESS = TestServlet.SUCCESS; - public static final String FAILURE = TestServlet.FAILURE; - public static final String TEST_METHOD = TestServlet.TEST_METHOD; - - public static final String nl = System.lineSeparator(); - - //###### run test without response ##### - - /** - * Runs test against servlet at baseURL, and will run against a specified testName. - */ - public void runTest(URL baseURL, String testName) { - try { - assertSuccessfulURLResponse(URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testName).build(), null); - } catch (UnsupportedOperationException e) { - throw new RuntimeException("Tried to call runTest method without overwritting getServletPath() method.", e); - } - } - - /** - * Runs test against servlet using a URLBuilder. This is useful for complicated testing situations. - */ - public void runTest(URLBuilder builder) { - assertSuccessfulURLResponse(builder.build(), null); - } - - //###### run test with response ###### - - /** - * Runs test against servlet at baseURL, and will run against a specified testName. - * Provide properties if you want them included in a POST request, otherwise pass in null. - */ - public String runTestWithResponse(URL baseURL, String testName, Properties props) { - try { - return assertSuccessfulURLResponse(URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testName).build(), props); - } catch (UnsupportedOperationException e) { - throw new RuntimeException("Tried to call runTest method without overwritting getServletPath() method.", e); - } - } - - /** - * Runs test against servlet using a URLBuilder. This is useful for complicated testing situations. - * Provide properties if you want them included in a POST request, otherwise pass in null. - */ - public String runTestWithResponse(URLBuilder builder, Properties props) { - return assertSuccessfulURLResponse(builder.build(), props); - } - - //##### test runner ###### - private String assertSuccessfulURLResponse(URL url, Properties props) { - log.enter("assertSuccessfulURLResponse", "Calling application with URL=" + url.toString()); - - boolean withProps = props != null; - boolean pass = false; - - HttpURLConnection con = null; - try { - con = (HttpURLConnection) url.openConnection(); - con.setDoInput(true); - con.setDoOutput(true); - con.setUseCaches(false); - con.setConnectTimeout((int) Duration.ofSeconds(30).toMillis()); - - if(withProps) { - con.setRequestMethod("POST"); - try( DataOutputStream wr = new DataOutputStream( con.getOutputStream())){ - wr.writeBytes( toEncodedString(props) ); - } - - } else { - con.setRequestMethod("GET"); - } - - final BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); - final StringBuilder outputBuilder = new StringBuilder(); - String line; - - while ((line = br.readLine()) != null) { - outputBuilder.append(line).append(nl); - - if (line.contains(SUCCESS)) { - pass = true; - } - } - - log.exit("assertSuccessfulURLResponse", "Response code: " + con.getResponseCode() ,"Response body: " + outputBuilder.toString()); - - assertTrue(con.getResponseCode() < 400, "Connection returned a response code that was greater than 400"); - assertTrue(pass, "Output did not contain successful message: " + SUCCESS); - - return outputBuilder.toString(); - } catch (IOException e) { - throw new RuntimeException("Exception: " + e.getClass().getName() + " requesting URL=" + url.toString(), e); - } finally { - if (con != null) { - con.disconnect(); - } - } - } - - static String toEncodedString(Properties args) throws UnsupportedEncodingException { + private static final TestLogger log = TestLogger.get(TestClient.class); + + public static final String SUCCESS = TestServlet.SUCCESS; + public static final String FAILURE = TestServlet.FAILURE; + public static final String TEST_METHOD = TestServlet.TEST_METHOD; + + public static final String nl = System.lineSeparator(); + + // ###### run test without response ##### + + /** + * Runs test against servlet at baseURL, and will run against a specified + * testName. + */ + public void runTest(URL baseURL, String testName) { + try { + assertSuccessfulURLResponse( + URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testName).build(), + null); + } catch (UnsupportedOperationException e) { + throw new RuntimeException("Tried to call runTest method without overwritting getServletPath() method.", e); + } + } + + /** + * Runs test against servlet using a URLBuilder. This is useful for complicated + * testing situations. + */ + public void runTest(URLBuilder builder) { + assertSuccessfulURLResponse(builder.build(), null); + } + + // ###### run test with response ###### + + /** + * Runs test against servlet at baseURL, and will run against a specified + * testName. Provide properties if you want them included in a POST request, + * otherwise pass in null. + */ + public String runTestWithResponse(URL baseURL, String testName, Properties props) { + try { + return assertSuccessfulURLResponse( + URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testName).build(), + props); + } catch (UnsupportedOperationException e) { + throw new RuntimeException("Tried to call runTest method without overwritting getServletPath() method.", e); + } + } + + /** + * Runs test against servlet using a URLBuilder. This is useful for complicated + * testing situations. Provide properties if you want them included in a POST + * request, otherwise pass in null. + */ + public String runTestWithResponse(URLBuilder builder, Properties props) { + return assertSuccessfulURLResponse(builder.build(), props); + } + + // ##### test runner ###### + private String assertSuccessfulURLResponse(URL url, Properties props) { + log.enter("assertSuccessfulURLResponse", "Calling application with URL=" + url.toString()); + + boolean withProps = props != null; + boolean pass = false; + + HttpURLConnection con = null; + try { + con = (HttpURLConnection) url.openConnection(); + con.setDoInput(true); + con.setDoOutput(true); + con.setUseCaches(false); + con.setConnectTimeout((int) Duration.ofSeconds(30).toMillis()); + + if (withProps) { + con.setRequestMethod("POST"); + try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { + wr.writeBytes(toEncodedString(props)); + } + + } else { + con.setRequestMethod("GET"); + } + + final BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); + final StringBuilder outputBuilder = new StringBuilder(); + String line; + + while ((line = br.readLine()) != null) { + outputBuilder.append(line).append(nl); + + if (line.contains(SUCCESS)) { + pass = true; + } + } + + log.exit("assertSuccessfulURLResponse", "Response code: " + con.getResponseCode(), + "Response body: " + outputBuilder.toString()); + + assertTrue(con.getResponseCode() < 400, "Connection returned a response code that was greater than 400"); + assertTrue(pass, "Output did not contain successful message: " + SUCCESS); + + return outputBuilder.toString(); + } catch (IOException e) { + throw new RuntimeException("Exception: " + e.getClass().getName() + " requesting URL=" + url.toString(), e); + } finally { + if (con != null) { + con.disconnect(); + } + } + } + + static String toEncodedString(Properties args) throws UnsupportedEncodingException { StringBuffer buf = new StringBuffer(); Enumeration names = args.propertyNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); String value = args.getProperty(name); - - buf.append(URLEncoder.encode(name, StandardCharsets.UTF_8.name())) - .append("=") - .append(URLEncoder.encode(value, StandardCharsets.UTF_8.name())); - + + buf.append(URLEncoder.encode(name, StandardCharsets.UTF_8.name())).append("=") + .append(URLEncoder.encode(value, StandardCharsets.UTF_8.name())); + if (names.hasMoreElements()) buf.append("&"); } return buf.toString(); } - - /** - * Override this method to return the servlet path for the suite of tests. - * Used for the runTest() methods. - */ - protected String getServletPath() { - throw new UnsupportedOperationException("Subclass did not override the getServletPath method"); - } - - /** - * Asserts that the response from a runTestWithResponse method contains a specific string. - * - * @param message - message to display if test fails - * @param expected - the expected string to find in the response - * @param resp - the response you received from the servlet - */ - protected void assertStringInResponse(String message, String expected, String resp) { - assertTrue(resp.toLowerCase().contains(expected.toLowerCase()), message); - } + + /** + * Override this method to return the servlet path for the suite of tests. Used + * for the runTest() methods. + */ + protected String getServletPath() { + throw new UnsupportedOperationException("Subclass did not override the getServletPath method"); + } + + /** + * Asserts that the response from a runTestWithResponse method contains a + * specific string. + * + * @param message - message to display if test fails + * @param expected - the expected string to find in the response + * @param resp - the response you received from the servlet + */ + protected void assertStringInResponse(String message, String expected, String resp) { + assertTrue(resp.toLowerCase().contains(expected.toLowerCase()), message); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java index e9cb9ca4..f1875f7e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java @@ -18,29 +18,29 @@ import java.time.Duration; /** - * Constants that are used within the TCK to ensure consistency in test infrastructure. + * Constants that are used within the TCK to ensure consistency in test + * infrastructure. */ public final class TestConstants { - - //JNDI Names - public static final String DefaultContextService = "java:comp/DefaultContextService"; - public static final String DefaultManagedScheduledExecutorService = "java:comp/DefaultManagedScheduledExecutorService"; - public static final String DefaultManagedExecutorService = "java:comp/DefaultManagedExecutorService"; - public static final String DefaultManagedThreadFactory = "java:comp/DefaultManagedThreadFactory"; - public static final String UserTransaction = "java:comp/UserTransaction"; - - //Durations - /** 1 second */ - public static final Duration PollInterval = Duration.ofSeconds(1); - - /** 15 seconds */ - public static final Duration WaitTimeout = Duration.ofSeconds(15); - - /** Approximate number of polls performed before timeout */ - public static final int PollsPerTimeout = (int) (WaitTimeout.getSeconds() / PollInterval.getSeconds()); - - //Return values - public static final String SimpleReturnValue = "ok"; - public static final String ComplexReturnValue = "ConcurrentResultOkay"; + // JNDI Names + public static final String DefaultContextService = "java:comp/DefaultContextService"; + public static final String DefaultManagedScheduledExecutorService = "java:comp/DefaultManagedScheduledExecutorService"; + public static final String DefaultManagedExecutorService = "java:comp/DefaultManagedExecutorService"; + public static final String DefaultManagedThreadFactory = "java:comp/DefaultManagedThreadFactory"; + public static final String UserTransaction = "java:comp/UserTransaction"; + + // Durations + /** 1 second */ + public static final Duration PollInterval = Duration.ofSeconds(1); + + /** 15 seconds */ + public static final Duration WaitTimeout = Duration.ofSeconds(15); + + /** Approximate number of polls performed before timeout */ + public static final int PollsPerTimeout = (int) (WaitTimeout.getSeconds() / PollInterval.getSeconds()); + + // Return values + public static final String SimpleReturnValue = "ok"; + public static final String ComplexReturnValue = "ConcurrentResultOkay"; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java index 803dcfd4..13153bef 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java @@ -23,140 +23,141 @@ import java.util.logging.Logger; /** - * Abstract out the logging framework so that in the future it can be replaced if needed. + * Abstract out the logging framework so that in the future it can be replaced + * if needed. */ public final class TestLogger { - private static final String nl = System.lineSeparator(); - - private Logger log; - - /* - * Private constructor since there should only be one TestLogger per class - */ - private TestLogger(Class clazz) { - log = Logger.getLogger(clazz.getCanonicalName()); - } - - private TestLogger(String clazz) { - log = Logger.getLogger(clazz); - } - - public static TestLogger get(Class clazz) { - return new TestLogger(clazz); - } - - public static TestLogger get(String clazz) { - return new TestLogger(clazz); - } - - public void severe(String s) { - log.severe(s); - } - - public void severe(String s, Throwable t) { - log.severe(messageWithThrowable(s, t)); - } - - public void warning(String s) { - log.warning(s); - } - - public void warning(String s, Throwable t) { - log.warning(messageWithThrowable(s, t)); - } - - public void info(String s) { - log.info(s); - } - - public void info(String s, Throwable t) { - log.info(messageWithThrowable(s, t)); - } - - public void info(String s, Object... objs) { - log.log(Level.INFO, s + getObjectSuffix(objs), removeNewLines(objs)); - } - - public void config(String s) { - log.config(s); - } - - public void config(String s, Throwable t) { - log.config(messageWithThrowable(s, t)); - } - - public void fine(String s) { - log.fine(s); - } - - public void fine(String s, Throwable t) { - log.fine(messageWithThrowable(s, t)); - } - - public void finer(String s) { - log.fine(s); - } - - public void finer(String s, Throwable t) { - log.finer(messageWithThrowable(s, t)); - } - - public void finest(String s) { - log.fine(s); - } - - public void finest(String s, Throwable t) { - log.finest(messageWithThrowable(s, t)); - } - - public void enter(Method method, Object... objs) { - log.log(Level.INFO, "--> " + method.getName() + getObjectSuffix(objs), removeNewLines(objs)); - } - - public void enter(String method, Object... objs) { - log.log(Level.INFO, "--> " + method + getObjectSuffix(objs), removeNewLines(objs)); - } - - public void exit(Method method, Object... objs) { - log.log(Level.INFO, "<-- " + method.getName() + getObjectSuffix(objs), removeNewLines(objs)); - } - - public void exit(String method, Object... objs) { - log.log(Level.INFO, "<-- " + method + getObjectSuffix(objs), removeNewLines(objs)); - } - - private String messageWithThrowable(String s, Throwable t) { - Writer buffer = new StringWriter(); - PrintWriter pw = new PrintWriter(buffer); - t.printStackTrace(pw); - return s + nl + buffer.toString(); - } - - private String getObjectSuffix(Object[] objs) { - if (objs == null || objs.length == 0) - return ""; - - String suffix = nl + "[ "; + private static final String nl = System.lineSeparator(); + + private Logger log; + + /* + * Private constructor since there should only be one TestLogger per class + */ + private TestLogger(Class clazz) { + log = Logger.getLogger(clazz.getCanonicalName()); + } + + private TestLogger(String clazz) { + log = Logger.getLogger(clazz); + } + + public static TestLogger get(Class clazz) { + return new TestLogger(clazz); + } + + public static TestLogger get(String clazz) { + return new TestLogger(clazz); + } + + public void severe(String s) { + log.severe(s); + } + + public void severe(String s, Throwable t) { + log.severe(messageWithThrowable(s, t)); + } + + public void warning(String s) { + log.warning(s); + } + + public void warning(String s, Throwable t) { + log.warning(messageWithThrowable(s, t)); + } + + public void info(String s) { + log.info(s); + } + + public void info(String s, Throwable t) { + log.info(messageWithThrowable(s, t)); + } + + public void info(String s, Object... objs) { + log.log(Level.INFO, s + getObjectSuffix(objs), removeNewLines(objs)); + } + + public void config(String s) { + log.config(s); + } + + public void config(String s, Throwable t) { + log.config(messageWithThrowable(s, t)); + } + + public void fine(String s) { + log.fine(s); + } + + public void fine(String s, Throwable t) { + log.fine(messageWithThrowable(s, t)); + } + + public void finer(String s) { + log.fine(s); + } + + public void finer(String s, Throwable t) { + log.finer(messageWithThrowable(s, t)); + } + + public void finest(String s) { + log.fine(s); + } + + public void finest(String s, Throwable t) { + log.finest(messageWithThrowable(s, t)); + } + + public void enter(Method method, Object... objs) { + log.log(Level.INFO, "--> " + method.getName() + getObjectSuffix(objs), removeNewLines(objs)); + } + + public void enter(String method, Object... objs) { + log.log(Level.INFO, "--> " + method + getObjectSuffix(objs), removeNewLines(objs)); + } + + public void exit(Method method, Object... objs) { + log.log(Level.INFO, "<-- " + method.getName() + getObjectSuffix(objs), removeNewLines(objs)); + } + + public void exit(String method, Object... objs) { + log.log(Level.INFO, "<-- " + method + getObjectSuffix(objs), removeNewLines(objs)); + } + + private String messageWithThrowable(String s, Throwable t) { + Writer buffer = new StringWriter(); + PrintWriter pw = new PrintWriter(buffer); + t.printStackTrace(pw); + return s + nl + buffer.toString(); + } + + private String getObjectSuffix(Object[] objs) { + if (objs == null || objs.length == 0) + return ""; + + String suffix = nl + "[ "; + for (int i = 0; i < objs.length; i++) { + suffix = suffix + "{" + i + "}, "; + } + return suffix.substring(0, suffix.length() - 2) + " ]"; + } + + private String[] removeNewLines(Object[] objs) { + if (objs == null || objs.length == 0) + return new String[] {}; + + String[] result = new String[objs.length]; + for (int i = 0; i < objs.length; i++) { - suffix = suffix + "{" + i + "}, "; + if (objs[i] instanceof String) { + result[i] = ((String) objs[i]).replace(nl, ""); + } else { + result[i] = String.valueOf(objs[i]).replace(nl, ""); + } } - return suffix.substring(0, suffix.length() -2) + " ]"; - } - - private String[] removeNewLines(Object[] objs) { - if (objs == null || objs.length == 0) - return new String[] {}; - - String[] result = new String[objs.length]; - - for (int i = 0; i < objs.length; i++) { - if(objs[i] instanceof String) { - result[i] = ((String) objs[i]).replace(nl, ""); - } else { - result[i] = String.valueOf(objs[i]).replace(nl, ""); - } - } return result; - } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java index 8ad4b5d8..c1bc7291 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java @@ -32,137 +32,139 @@ import jakarta.servlet.http.HttpServletResponse; /** - * Standard superclass for test servlets that accepts a `testMethod` parameter - * to the doGet / doPost methods that will attempt to run that method on the subclass. + * Standard superclass for test servlets that accepts a `testMethod` parameter + * to the doGet / doPost methods that will attempt to run that method on the + * subclass. * - * The doGet / doPost methods will append `SUCCESS` to the response if the test is successfully. - * Otherwise, SUCCESS will not be appended to the response. + * The doGet / doPost methods will append `SUCCESS` to the response if the test + * is successfully. Otherwise, SUCCESS will not be appended to the response. */ public class TestServlet extends HttpServlet { - private static final long serialVersionUID = 1L; - - private static final TestLogger log = TestLogger.get(TestServlet.class); - - public static final String nl = System.lineSeparator(); - - private boolean runBeforeClass = true; - - public static final String SUCCESS = "SUCCESS"; - public static final String FAILURE = "FAILURE"; - public static final String TEST_METHOD = "testMethod"; - - @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - doGet(request, response); - } - - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { - String method = request.getParameter(TEST_METHOD); - - log.enter(method, "Request URL: " + request.getRequestURL() + '?' + request.getQueryString()); - - if(runBeforeClass) { - try { - beforeClass(); - runBeforeClass = false; - } catch (Exception e) { - throw new RuntimeException("Caught exception trying to run beforeClass method.", e); - } - } - - PrintWriter writer = response.getWriter(); - if (method != null && method.length() > 0) { - try { - before(); - - // Use reflection to try invoking various test method signatures: - // 1) method(HttpServletRequest request, HttpServletResponse response) - // 2) method() - // 3) use custom method invocation by calling invokeTest(method, request, - // response) - try { - Method mthd = getClass().getMethod(method, HttpServletRequest.class, HttpServletResponse.class); - mthd.invoke(this, request, response); - } catch (NoSuchMethodException nsme) { - try { - Method mthd = getClass().getMethod(method, (Class[]) null); - mthd.invoke(this); - } catch (NoSuchMethodException nsme1) { - log.config("Delegating to invokeTest method"); - invokeTest(method, request, response); - } - } finally { - after(); - } - - writer.println(SUCCESS); - } catch (Throwable t) { - if (t instanceof InvocationTargetException) { - t = t.getCause(); - } - writer.println(FAILURE); - String message = "Caught exception attempting to call test method " + method + " on servlet " - + getClass().getName(); - log.warning(message, t); - writer.println(message); - t.printStackTrace(writer); - } - } else { - log.warning("ERROR: expected testMethod parameter"); - writer.println("ERROR: expected testMethod parameter"); - } - - writer.flush(); - writer.close(); - - log.exit(method); - } - - /** - * Override to mimic JUnit's {@code @BeforeClass} annotation. - */ - protected void beforeClass() throws Exception { - } - - /** - * Override to mimic JUnit's {@code @Before} annotation. - */ - protected void before() throws Exception { - } - - /** - * Override to mimic JUnit's {@code @After} annotation. - */ - protected void after() throws Exception { - } - - /** - * Implement this method for custom test invocation, such as specific test - * method signatures - */ - protected void invokeTest(String method, HttpServletRequest request, HttpServletResponse response) - throws Exception { - throw new NoSuchMethodException("No such method '" + method + "' found on class " + getClass() - + " with any of the following signatures: " + method + "(HttpServletRequest, HttpServletResponse) " - + method + "()"); - } - - /** - * HTTP convenience method for servlets to get a response from another servlet. - * Test clients should extend the {@link TestClient} class that has its own HTTP methods. + private static final long serialVersionUID = 1L; + + private static final TestLogger log = TestLogger.get(TestServlet.class); + + public static final String nl = System.lineSeparator(); + + private boolean runBeforeClass = true; + + public static final String SUCCESS = "SUCCESS"; + public static final String FAILURE = "FAILURE"; + public static final String TEST_METHOD = "testMethod"; + + @Override + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doGet(request, response); + } + + @Override + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + String method = request.getParameter(TEST_METHOD); + + log.enter(method, "Request URL: " + request.getRequestURL() + '?' + request.getQueryString()); + + if (runBeforeClass) { + try { + beforeClass(); + runBeforeClass = false; + } catch (Exception e) { + throw new RuntimeException("Caught exception trying to run beforeClass method.", e); + } + } + + PrintWriter writer = response.getWriter(); + if (method != null && method.length() > 0) { + try { + before(); + + // Use reflection to try invoking various test method signatures: + // 1) method(HttpServletRequest request, HttpServletResponse response) + // 2) method() + // 3) use custom method invocation by calling invokeTest(method, request, + // response) + try { + Method mthd = getClass().getMethod(method, HttpServletRequest.class, HttpServletResponse.class); + mthd.invoke(this, request, response); + } catch (NoSuchMethodException nsme) { + try { + Method mthd = getClass().getMethod(method, (Class[]) null); + mthd.invoke(this); + } catch (NoSuchMethodException nsme1) { + log.config("Delegating to invokeTest method"); + invokeTest(method, request, response); + } + } finally { + after(); + } + + writer.println(SUCCESS); + } catch (Throwable t) { + if (t instanceof InvocationTargetException) { + t = t.getCause(); + } + writer.println(FAILURE); + String message = "Caught exception attempting to call test method " + method + " on servlet " + + getClass().getName(); + log.warning(message, t); + writer.println(message); + t.printStackTrace(writer); + } + } else { + log.warning("ERROR: expected testMethod parameter"); + writer.println("ERROR: expected testMethod parameter"); + } + + writer.flush(); + writer.close(); + + log.exit(method); + } + + /** + * Override to mimic JUnit's {@code @BeforeClass} annotation. + */ + protected void beforeClass() throws Exception { + } + + /** + * Override to mimic JUnit's {@code @Before} annotation. + */ + protected void before() throws Exception { + } + + /** + * Override to mimic JUnit's {@code @After} annotation. + */ + protected void after() throws Exception { + } + + /** + * Implement this method for custom test invocation, such as specific test + * method signatures + */ + protected void invokeTest(String method, HttpServletRequest request, HttpServletResponse response) + throws Exception { + throw new NoSuchMethodException("No such method '" + method + "' found on class " + getClass() + + " with any of the following signatures: " + method + "(HttpServletRequest, HttpServletResponse) " + + method + "()"); + } + + /** + * HTTP convenience method for servlets to get a response from another servlet. + * Test clients should extend the {@link TestClient} class that has its own HTTP + * methods. * * @param con - the URLConnection * @return String - response body * @throws IOException */ - public static String getResponse(URLConnection con) throws IOException { + public static String getResponse(URLConnection con) throws IOException { try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()))) { - + StringBuffer response = new StringBuffer(); - + String line; while ((line = br.readLine()) != null) { response.append(line).append(nl); @@ -173,12 +175,13 @@ public static String getResponse(URLConnection con) throws IOException { } /** - * HTTP convenience method for servlets to create a URLConnection and post properties - * to that connection. + * HTTP convenience method for servlets to create a URLConnection and post + * properties to that connection. * - * Test clients should extend the {@link TestClient} class that has its own HTTP methods. + * Test clients should extend the {@link TestClient} class that has its own HTTP + * methods. * - * @param url - the URL to open a connection to + * @param url - the URL to open a connection to * @param props - the properties to put into the connection input stream * * @return the connection for further testing diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java index efeee084..6a7b5755 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java @@ -22,163 +22,158 @@ import java.util.List; /** - * Utility method to ensure all classes use a common URL manipulation tool. - * baseURL will be provided by Arquillian using the ArquillianResource - * annotation to get the URL of the servlet. + * Utility method to ensure all classes use a common URL manipulation tool. + * baseURL will be provided by Arquillian using the + * ArquillianResource annotation to get the URL of the servlet. */ public class URLBuilder { - private static final TestLogger log = TestLogger.get(URLBuilder.class); - - public static final String TEST_METHOD = "testMethod"; - - private URL baseURL; - private ArrayList queries; - private ArrayList paths; - private boolean testNameSet = false; - - private URLBuilder() { - // Make constructor private so no instances can be created - } - - /** - * Get the builder - */ - public static URLBuilder get() { - return new URLBuilder(); - } - - /** - * Base URL obtained from ArquillianResource - */ - public URLBuilder withBaseURL(URL baseURL) { - this.baseURL = baseURL; - return this; - } - - /** - * Additional queries to tack onto the end of the URL. - * Example: - * baseURL = http://localhost:80/servlet/ - * query = count=5 - * result = http://localhost:80/servlet/?count=5 - */ - public URLBuilder withQueries(String... queries) { - if (this.queries == null) { - this.queries = new ArrayList<>(Arrays.asList(queries)); - } else { - this.queries.addAll(Arrays.asList(queries)); - } - return this; - } - - /** - * Additional paths to tack onto the end of the URL. - * Example: - * baseURL = http://localhost:80/servlet/ - * path = app, inventory - * result = http://localhost:80/servlet/app/inventory - */ - public URLBuilder withPaths(String... paths) { - if (this.paths == null) { - this.paths = new ArrayList<>(Arrays.asList(paths)); - } else { - this.paths.addAll(Arrays.asList(paths)); - } - return this; - } - - /** - * Additional testName query to tack onto the end of the URL. - * Example: - * baseURL = http://localhost:80/servlet/ - * testName = transactionTest - * result = http://localhost:80/servlet/?testMethod=transactionTest - */ - public URLBuilder withTestName(String testName) { - if(testNameSet) { - throw new UnsupportedOperationException("Cannot call withTestName more than once."); - } - - String query = TEST_METHOD + "=" + testName; - - if (this.queries == null) { - this.queries = new ArrayList<>(Arrays.asList(query)); - } else { - this.queries.add(query); - } - - testNameSet = true; - return this; - } - - /** - * This will build the URL tacking on the additional queries, paths, and testName. - */ - public URL build() { - if (baseURL == null) { - throw new RuntimeException("Cannot build URL without a baseURL"); - } - - log.enter("build", baseURL, queries, paths); - - URL extendedURL = baseURL; - - extendedURL = extendQuery(extendedURL, queries); - extendedURL = extendPath(extendedURL, paths); - - log.exit("build", extendedURL); - - return extendedURL; - } - - public static URL extendQuery(URL baseURL, List queries) { - if (queries == null) - return baseURL; - - //Get existing query part - boolean existingQuery = baseURL.getQuery() != null; - String extendedQuery = existingQuery ? "?" + baseURL.getQuery() : "?"; - - //Append additional query parts - for (String queryPart : queries) { - extendedQuery += queryPart + "&"; - } - - //Cleanup trailing symbol(s) - extendedQuery = extendedQuery.substring(0, extendedQuery.length() - 1); - - //Generate and return new URL - try { - return new URL(baseURL.getProtocol(), baseURL.getHost(), baseURL.getPort(), - baseURL.getPath() + extendedQuery, null); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } - - public static URL extendPath(URL baseURL, List paths) { - if (paths == null) - return baseURL; - - //Get existing path part - boolean existingPath = baseURL.getPath() != null; - String extendedPath = existingPath ? baseURL.getPath() : ""; - - //Append additional path parts - for (String pathPart : paths) { - pathPart = pathPart.replace("/", ""); //Remove existing / - extendedPath += pathPart + "/"; - } - - //cleanup trailing symbol(s) - extendedPath = extendedPath.substring(0, extendedPath.length() - 1); - - //Generate and return new URL - try { - return new URL(baseURL.getProtocol(), baseURL.getHost(), baseURL.getPort(), - extendedPath + (baseURL.getQuery() == null ? "" : "?" + baseURL.getQuery()), null); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - } + private static final TestLogger log = TestLogger.get(URLBuilder.class); + + public static final String TEST_METHOD = "testMethod"; + + private URL baseURL; + private ArrayList queries; + private ArrayList paths; + private boolean testNameSet = false; + + private URLBuilder() { + // Make constructor private so no instances can be created + } + + /** + * Get the builder + */ + public static URLBuilder get() { + return new URLBuilder(); + } + + /** + * Base URL obtained from ArquillianResource + */ + public URLBuilder withBaseURL(URL baseURL) { + this.baseURL = baseURL; + return this; + } + + /** + * Additional queries to tack onto the end of the URL. Example: baseURL = + * http://localhost:80/servlet/ query = count=5 result = + * http://localhost:80/servlet/?count=5 + */ + public URLBuilder withQueries(String... queries) { + if (this.queries == null) { + this.queries = new ArrayList<>(Arrays.asList(queries)); + } else { + this.queries.addAll(Arrays.asList(queries)); + } + return this; + } + + /** + * Additional paths to tack onto the end of the URL. Example: baseURL = + * http://localhost:80/servlet/ path = app, inventory result = + * http://localhost:80/servlet/app/inventory + */ + public URLBuilder withPaths(String... paths) { + if (this.paths == null) { + this.paths = new ArrayList<>(Arrays.asList(paths)); + } else { + this.paths.addAll(Arrays.asList(paths)); + } + return this; + } + + /** + * Additional testName query to tack onto the end of the URL. Example: baseURL = + * http://localhost:80/servlet/ testName = transactionTest result = + * http://localhost:80/servlet/?testMethod=transactionTest + */ + public URLBuilder withTestName(String testName) { + if (testNameSet) { + throw new UnsupportedOperationException("Cannot call withTestName more than once."); + } + + String query = TEST_METHOD + "=" + testName; + + if (this.queries == null) { + this.queries = new ArrayList<>(Arrays.asList(query)); + } else { + this.queries.add(query); + } + + testNameSet = true; + return this; + } + + /** + * This will build the URL tacking on the additional queries, paths, and + * testName. + */ + public URL build() { + if (baseURL == null) { + throw new RuntimeException("Cannot build URL without a baseURL"); + } + + log.enter("build", baseURL, queries, paths); + + URL extendedURL = baseURL; + + extendedURL = extendQuery(extendedURL, queries); + extendedURL = extendPath(extendedURL, paths); + + log.exit("build", extendedURL); + + return extendedURL; + } + + public static URL extendQuery(URL baseURL, List queries) { + if (queries == null) + return baseURL; + + // Get existing query part + boolean existingQuery = baseURL.getQuery() != null; + String extendedQuery = existingQuery ? "?" + baseURL.getQuery() : "?"; + + // Append additional query parts + for (String queryPart : queries) { + extendedQuery += queryPart + "&"; + } + + // Cleanup trailing symbol(s) + extendedQuery = extendedQuery.substring(0, extendedQuery.length() - 1); + + // Generate and return new URL + try { + return new URL(baseURL.getProtocol(), baseURL.getHost(), baseURL.getPort(), + baseURL.getPath() + extendedQuery, null); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } + + public static URL extendPath(URL baseURL, List paths) { + if (paths == null) + return baseURL; + + // Get existing path part + boolean existingPath = baseURL.getPath() != null; + String extendedPath = existingPath ? baseURL.getPath() : ""; + + // Append additional path parts + for (String pathPart : paths) { + pathPart = pathPart.replace("/", ""); // Remove existing / + extendedPath += pathPart + "/"; + } + + // cleanup trailing symbol(s) + extendedPath = extendedPath.substring(0, extendedPath.length() - 1); + + // Generate and return new URL + try { + return new URL(baseURL.getProtocol(), baseURL.getHost(), baseURL.getPort(), + extendedPath + (baseURL.getQuery() == null ? "" : "?" + baseURL.getQuery()), null); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java index 65ff15d7..8e8af8cc 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java @@ -31,35 +31,34 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Common; /** - * This extension will intercept archives before they are deployed to the container and append - * the packages from the @Common annotation. + * This extension will intercept archives before they are deployed to the + * container and append the packages from the @Common annotation. */ public class TCKArchiveProcessor implements ApplicationArchiveProcessor { private static final Logger log = Logger.getLogger(TCKArchiveProcessor.class.getCanonicalName()); - + @Override public void process(Archive applicationArchive, TestClass testClass) { - String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() : applicationArchive.getName(); - - if( ! testClass.isAnnotationPresent(Common.class) ) { + String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() + : applicationArchive.getName(); + + if (!testClass.isAnnotationPresent(Common.class)) { return; } - + List packages = Stream.of(testClass.getAnnotation(Common.class).value()) - .map(pkg -> pkg.getPackageName()) - .collect(Collectors.toList()); - - //TODO research to see if there is a way around this - if(applicationArchive instanceof EnterpriseArchive && !packages.isEmpty()) { + .map(pkg -> pkg.getPackageName()).collect(Collectors.toList()); + + // TODO research to see if there is a way around this + if (applicationArchive instanceof EnterpriseArchive && !packages.isEmpty()) { throw new RuntimeException("Cannot append packages to Enterprise Archives since modules are immutable"); } - + if (applicationArchive instanceof WebArchive || applicationArchive instanceof JavaArchive) { log.info("Application Archive [" + applicationName + "] is being appended with packages " + packages); - packages.stream().forEach(pkg -> ((ClassContainer) applicationArchive).addPackage(pkg) ); - + packages.stream().forEach(pkg -> ((ClassContainer) applicationArchive).addPackage(pkg)); + } - - + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java index 15211715..df24e20e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java @@ -27,34 +27,34 @@ import ee.jakarta.tck.concurrent.framework.junit.extensions.AssertionExtension; /** - * This extension will intercept all archives before they are deployed to the container and append - * a library with the following: + * This extension will intercept all archives before they are deployed to the + * container and append a library with the following: * - * Package - ee.jakarta.tck.concurrent.framework - * Package - ee.jakarta.tck.concurrent.framework.arquillian.extensions - * Package - ee.jakarta.tck.concurrent.framework.junit.extensions + * Package - ee.jakarta.tck.concurrent.framework Package - + * ee.jakarta.tck.concurrent.framework.arquillian.extensions Package - + * ee.jakarta.tck.concurrent.framework.junit.extensions * */ public class TCKFrameworkAppender implements AuxiliaryArchiveAppender { - + private static final Logger log = Logger.getLogger(TCKFrameworkAppender.class.getCanonicalName()); - + private static final Package utilPackage = TestServlet.class.getPackage(); private static final Package annoPackage = Common.class.getPackage(); private static final Package extePackage = AssertionExtension.class.getPackage(); - + private static final String archiveName = "jakarta-concurrent-framework.jar"; - + private static JavaArchive framework = null; @Override public Archive createAuxiliaryArchive() { - if(framework != null) { + if (framework != null) { return framework; } - + log.info("Creating auxiliary archive: " + archiveName); - + framework = ShrinkWrap.create(JavaArchive.class, archiveName); framework.addPackages(false, utilPackage, annoPackage, extePackage); return framework; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java index 64263f6e..0fbe89e7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java @@ -29,41 +29,44 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Signature; /** - * This extension will intercept archives before they are deployed to the container and append - * the signature files. + * This extension will intercept archives before they are deployed to the + * container and append the signature files. */ public class TCKSignatureProcessor implements ApplicationArchiveProcessor { private static final Logger log = Logger.getLogger(TCKSignatureProcessor.class.getCanonicalName()); - + private static final Package signaturePackage = ConcurrencySignatureTestRunner.class.getPackage(); - + @Override public void process(Archive applicationArchive, TestClass testClass) { - String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() : applicationArchive.getName(); - - if( ! testClass.isAnnotationPresent(Signature.class) ) { + String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() + : applicationArchive.getName(); + + if (!testClass.isAnnotationPresent(Signature.class)) { return; } - - if( testClass.isAnnotationPresent(Full.class) ) { + + if (testClass.isAnnotationPresent(Full.class)) { throw new RuntimeException("Signature tests must be run using the @Web annotation"); } - + boolean isJava21orAbove = Integer.parseInt(System.getProperty("java.specification.version")) >= 21; - + if (applicationArchive instanceof ClassContainer) { - log.info("Application Archive [" + applicationName + "] is being appended with packages [" + signaturePackage +"]"); - log.info("Application Archive [" + applicationName + "] is being appended with resources " + Arrays.asList(ConcurrencySignatureTestRunner.SIG_RESOURCES)); + log.info("Application Archive [" + applicationName + "] is being appended with packages [" + + signaturePackage + "]"); + log.info("Application Archive [" + applicationName + "] is being appended with resources " + + Arrays.asList(ConcurrencySignatureTestRunner.SIG_RESOURCES)); ((ClassContainer) applicationArchive).addPackage(signaturePackage); ((ResourceContainer) applicationArchive).addAsResources(signaturePackage, - ConcurrencySignatureTestRunner.SIG_MAP_NAME, - ConcurrencySignatureTestRunner.SIG_PKG_NAME); + ConcurrencySignatureTestRunner.SIG_MAP_NAME, ConcurrencySignatureTestRunner.SIG_PKG_NAME); ((ResourceContainer) applicationArchive).addAsResource(signaturePackage, - //Get local resource based on JDK level - isJava21orAbove ? ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_21" : ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_17", - //Target same package as test + // Get local resource based on JDK level + isJava21orAbove ? ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_21" + : ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_17", + // Target same package as test signaturePackage.getName().replace(".", "/") + "/" + ConcurrencySignatureTestRunner.SIG_FILE_NAME); } - + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Common.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Common.java index 16a02da4..7faebfb1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Common.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Common.java @@ -8,23 +8,16 @@ @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) public @interface Common { - + public enum PACKAGE { - CONTEXT, - CONTEXT_PROVIDERS, - COUNTER, - FIXED_COUNTER, - MANAGED_TASK_LISTENER, - TASKS, - TRANSACTION, - SIGNATURE; - + CONTEXT, CONTEXT_PROVIDERS, COUNTER, FIXED_COUNTER, MANAGED_TASK_LISTENER, TASKS, TRANSACTION, SIGNATURE; + private static final String prefix = "ee/jakarta/tck/concurrent/common/"; - + public String getPackageName() { return prefix + this.name().toLowerCase().replace("_", "/"); } } - + PACKAGE[] value(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java index b6acdcc4..fca18ee2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java @@ -27,12 +27,16 @@ import ee.jakarta.tck.concurrent.framework.junit.extensions.AssertionExtension; /** - *

These are test classes that REQUIRE full profile to be executed. For these + *

+ * These are test classes that REQUIRE full 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.

+ * Arquillian {@code @Deployment} annotation. + *

* - *

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

+ *

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

*/ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Signature.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Signature.java index 82b40883..932707b1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Signature.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Signature.java @@ -23,8 +23,10 @@ import org.junit.jupiter.api.Tag; /** - *

This annotation will allow vendors to run signature tests - * separately from all other tests, if desired.

+ *

+ * This annotation will allow vendors to run signature tests separately from all + * other tests, if desired. + *

*/ @Target({ ElementType.TYPE }) @Retention(RetentionPolicy.RUNTIME) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java index 76cd0795..8b9bafbc 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java @@ -27,12 +27,16 @@ import ee.jakarta.tck.concurrent.framework.junit.extensions.AssertionExtension; /** - *

These are test classes that REQUIRE web profile to be executed. For these + *

+ * These are test classes that REQUIRE web 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.

+ * Arquillian {@code @Deployment} annotation. + *

* - *

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

+ *

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

*/ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) 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 0d5077c4..582a98bb 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 @@ -25,12 +25,13 @@ 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. + * 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 BeforeTestExecutionCallback, AfterTestExecutionCallback { + private static final Logger log = Logger.getLogger(AssertionExtension.class.getCanonicalName()); - + @Override public void beforeTestExecution(ExtensionContext context) throws Exception { log.info(">>> Begin test: " + context.getDisplayName()); @@ -42,21 +43,22 @@ public void afterTestExecution(ExtensionContext context) throws Exception { log.info("<<< End test: " + context.getDisplayName()); injectTestName(context, null); } - - //TODO could consider using getFields to allow for injection into superclass, but will affect performance. - private void injectTestName(ExtensionContext context, String testname) { + + // TODO could consider using getFields to allow for injection into superclass, + // but will affect performance. + private void injectTestName(ExtensionContext context, String testname) { Class testClass = context.getRequiredTestClass(); - - Stream.of(testClass.getDeclaredFields()) - .filter(field -> field.isAnnotationPresent(TestName.class)) - .forEach(field -> { - field.setAccessible(true); - try { - field.set(context.getRequiredTestInstance(), testname); - } catch (Exception e) { - log.warning("Unable to set TestName field on test class: " + testClass.getCanonicalName() + " Error:" + e.getLocalizedMessage()); - } - }); + + Stream.of(testClass.getDeclaredFields()).filter(field -> field.isAnnotationPresent(TestName.class)) + .forEach(field -> { + field.setAccessible(true); + try { + field.set(context.getRequiredTestInstance(), testname); + } catch (Exception e) { + log.warning("Unable to set TestName field on test class: " + testClass.getCanonicalName() + + " Error:" + e.getLocalizedMessage()); + } + }); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java index 5e661c49..d96cc334 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java @@ -6,46 +6,48 @@ * Helper class for custom assertions not supported by JUnit 5 */ public class Assertions { - + private Assertions() { - //helper method + // helper method } - + /** - * Asserts expected integer is within the range ( lowerBound, upperBound ) (exclusive). + * Asserts expected integer is within the range ( lowerBound, upperBound ) + * (exclusive). */ public static void assertWithin(int expected, int lowerBound, int upperBound) { - if( lowerBound < expected && upperBound > expected ) { - return; //pass + if (lowerBound < expected && upperBound > expected) { + return; // pass } - + String message = "Expected " + expected + " to be within the range ( " + lowerBound + ", " + upperBound + " )"; throw new AssertionError(message); } - + /** - * Asserts expected integer is within the range [ lowerBound, upperBound ] [inclusive]. + * Asserts expected integer is within the range [ lowerBound, upperBound ] + * [inclusive]. */ public static void assertBetween(int expected, int lowerBound, int upperBound) { - if( lowerBound <= expected && upperBound >= expected ) { - return; //pass + if (lowerBound <= expected && upperBound >= expected) { + return; // pass } - + String message = "Expected " + expected + " to be within the range [ " + lowerBound + ", " + upperBound + " ]"; throw new AssertionError(message); } - + /** * Asserts expected object is within a range represented by an Iterable */ public static void assertRangeContains(Object expected, Iterable range) { Iterator it = range.iterator(); - while(it.hasNext()) { - if(it.equals(expected)) { - return; //pass + while (it.hasNext()) { + if (it.equals(expected)) { + return; // pass } } - + String message = "Expected " + expected + " to be within the range " + range.toString(); throw new AssertionError(message); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java index 5a7eb74d..a1a9b3f1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java @@ -18,15 +18,16 @@ * Prioritize polling for results, and discourages sleeping */ public class Wait { - + static TestLogger log = TestLogger.get(Wait.class); - + private Wait() { - //Utility class no constructor + // Utility class no constructor } - + /** - * Waits for task to complete, but will timeout after {@link TestConstants#WaitTimeout} + * Waits for task to complete, but will timeout after + * {@link TestConstants#WaitTimeout} * * @param future to wait for * @return result @@ -34,20 +35,22 @@ private Wait() { public static T waitForTaskComplete(final Future future) { return waitForTaskComplete(future, TestConstants.WaitTimeout); } - + /** * Waits for task to complete, but will timeout after specified timeout - * @param future - the future to wait for + * + * @param future - the future to wait for * @param timeout - the duration of timeout * @return result - result returned from future, or null if timeout was exceeded */ public static T waitForTaskComplete(final Future future, final Duration timeout) { return assertTimeoutPreemptively(timeout, () -> future.get()); } - + /** - * Wait for listener to complete, but will timeout after {@link TestConstants#WaitTimeout}, - * and will be polled ever {@link TestConstants#PollInterval} + * Wait for listener to complete, but will timeout after + * {@link TestConstants#WaitTimeout}, and will be polled ever + * {@link TestConstants#PollInterval} * * @param managedTaskListener - the listener to be polled */ @@ -56,22 +59,25 @@ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskLi } /** - * Wait for listener to complete, but will timeout after a specified timeout, + * Wait for listener to complete, but will timeout after a specified timeout, * and will be polled ever specified interval * * @param managedTaskListener - the listener to be polled - * @param maxWaitTimeMillis - timeout - * @param pollIntervalMillis - poll interval + * @param maxWaitTimeMillis - timeout + * @param pollIntervalMillis - poll interval */ - public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener, Duration timeout, Duration pollInterval) { + public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener, Duration timeout, + Duration pollInterval) { assertTimeoutPreemptively(timeout, () -> { - for(; ! managedTaskListener.eventCalled(ListenerEvent.DONE); sleep(TestConstants.PollInterval)); - }); + for (; !managedTaskListener.eventCalled(ListenerEvent.DONE); sleep(TestConstants.PollInterval)) + ; + }); } /** - * Waits for future to complete, but will timeout after {@link TestConstants#WaitTimeout}, - * and will be polled every {@link TestConstants#PollInterval} + * Waits for future to complete, but will timeout after + * {@link TestConstants#WaitTimeout}, and will be polled every + * {@link TestConstants#PollInterval} * * The difference between this method and waitForTaskComplete is that some * scheduled task will return values for multiple times, in this situation @@ -81,53 +87,60 @@ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskLi */ public static void waitTillFutureIsDone(final Future future) { assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for(; ! future.isDone(); sleep(TestConstants.PollInterval)); + for (; !future.isDone(); sleep(TestConstants.PollInterval)) + ; }); } - + /** - * Waits for future to throw an error, but will timeout after {@link TestConstants#WaitTimeout}, - * and will be polled every {@link TestConstants#PollInterval} + * Waits for future to throw an error, but will timeout after + * {@link TestConstants#WaitTimeout}, and will be polled every + * {@link TestConstants#PollInterval} * * @param future - the future to wait for */ - public static void waitTillFutureThrowsException(final Future future, final Class expected) { + public static void waitTillFutureThrowsException(final Future future, + final Class expected) { assertThrows(expected, () -> { assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for(; ; sleep(TestConstants.PollInterval)) { + for (;; sleep(TestConstants.PollInterval)) { future.get(); } }); }); } - + public static void waitCancelFuture(final Future future) { assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for(future.cancel(true); !future.isDone(); sleep(TestConstants.PollInterval)); - }); + for (future.cancel(true); !future.isDone(); sleep(TestConstants.PollInterval)) + ; + }); } - + /** - * Waits until thread is finished, but will timeout after {@link TestConstants#WaitTimeout}, - * and will be polled every {@link TestConstants#PollInterval} + * Waits until thread is finished, but will timeout after + * {@link TestConstants#WaitTimeout}, and will be polled every + * {@link TestConstants#PollInterval} * * @param thread - the thread to wait for */ public static void waitTillThreadFinish(final Thread thread) { assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for(; thread.isAlive(); sleep(TestConstants.PollInterval)); + for (; thread.isAlive(); sleep(TestConstants.PollInterval)) + ; }); } - + public static void waitForTransactionBegan(CancelledTransactedTask task) { assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for(; ! task.beginTransaction.get(); sleep(TestConstants.PollInterval)); + for (; !task.beginTransaction.get(); sleep(TestConstants.PollInterval)) + ; }); } - + public static void sleep(Duration time) { try { - Thread.sleep(time.toMillis()); + Thread.sleep(time.toMillis()); } catch (InterruptedException e) { throw new AssertionError("Interrupted while sleeping", e); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/BaseTestRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/BaseTestRunnableWork.java index f7d32762..dcd915b7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/BaseTestRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/BaseTestRunnableWork.java @@ -21,21 +21,21 @@ public abstract class BaseTestRunnableWork implements Serializable, Runnable, TestWorkInterface { private static final long serialVersionUID = 1L; - + private String message; - public void run() { - message = work(); - } + public void run() { + message = work(); + } - public String doSomeWork() { - message = work(); - return message; - } + public String doSomeWork() { + message = work(); + return message; + } - public String getResult() { - return message; - } + public String getResult() { + return message; + } - protected abstract String work(); + protected abstract String work(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java index 876840e4..9f3c9e0b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java @@ -31,15 +31,17 @@ @WebServlet("/ClassloaderServlet") public class ClassloaderServlet extends TestServlet { - @EJB - private ContextPropagateInterface intf; - + @EJB + private ContextPropagateInterface intf; + @Resource(lookup = TestConstants.DefaultContextService) public ContextService context; - public void testClassloaderAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { - String result = intf.executeWorker((TestWorkInterface) context.createContextualProxy( - new TestClassloaderRunnableWork(), Runnable.class, TestWorkInterface.class, Serializable.class)); - resp.getWriter().println(result); - } + public void testClassloaderAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) + throws Exception { + String result = intf + .executeWorker((TestWorkInterface) context.createContextualProxy(new TestClassloaderRunnableWork(), + Runnable.class, TestWorkInterface.class, Serializable.class)); + resp.getWriter().println(result); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java index 4260df17..bed7062f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java @@ -6,20 +6,24 @@ * Need to provide different JNDI names depending application deployment */ public class ContextEJBProvider { - - public static class FullProvider implements EJBJNDIProvider { - public FullProvider() {} - @Override - public String getEJBJNDIName() { - return "java:app/ContextPropagationTests_ejb/LimitedBean"; - } - } - - public static class WebProvider implements EJBJNDIProvider { - public WebProvider() {} - @Override - public String getEJBJNDIName() { - return "java:app/ContextPropagationTests_web/LimitedBean"; - } - } + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:app/ContextPropagationTests_ejb/LimitedBean"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:app/ContextPropagationTests_web/LimitedBean"; + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java index 9a184840..01f1a222 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java @@ -29,30 +29,30 @@ public class ContextPropagateBean implements ContextPropagateInterface { @Resource(lookup = TestConstants.DefaultManagedThreadFactory) public ManagedThreadFactory threadFactory; - + @Resource(lookup = TestConstants.DefaultContextService) public ContextService context; - @Override - public TestWorkInterface createWorker(String classname) { - try { - return (TestWorkInterface) context.createContextualProxy( - Class.forName(classname).getConstructor().newInstance(), Runnable.class, TestWorkInterface.class); - } catch (Exception en) { - throw new RuntimeException(en); - } - } - - @Override - public String executeWorker(TestWorkInterface worker) { - Thread workThread = threadFactory.newThread(worker); - workThread.start(); - try { - workThread.join(); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - return worker.getResult(); - } + @Override + public TestWorkInterface createWorker(String classname) { + try { + return (TestWorkInterface) context.createContextualProxy( + Class.forName(classname).getConstructor().newInstance(), Runnable.class, TestWorkInterface.class); + } catch (Exception en) { + throw new RuntimeException(en); + } + } + + @Override + public String executeWorker(TestWorkInterface worker) { + Thread workThread = threadFactory.newThread(worker); + workThread.start(); + try { + workThread.join(); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + return worker.getResult(); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateInterface.java index d30208b3..c36198a7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateInterface.java @@ -17,7 +17,7 @@ package ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate; public interface ContextPropagateInterface { - public TestWorkInterface createWorker(String classname); + public TestWorkInterface createWorker(String classname); - public String executeWorker(TestWorkInterface worker); + public String executeWorker(TestWorkInterface worker); } 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 d133acde..574410b5 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 @@ -39,264 +39,275 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import jakarta.enterprise.concurrent.spi.ThreadContextProvider; -@Full @RunAsClient //Requires client testing due to multiple servlets and annotation configuration +@Full +@RunAsClient // Requires client testing due to multiple servlets and annotation configuration public class ContextPropagationFullTests extends TestClient { - - @Deployment(name="ContextPropagationTests") - public static EnterpriseArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ContextPropagationTests_web.war") - .addPackages(true, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) - .addClasses( - ContextServiceDefinitionServlet.class, - ClassloaderServlet.class, - JNDIServlet.class, - SecurityServlet.class, - JSPSecurityServlet.class, - ContextServiceDefinitionFromEJBServlet.class) - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()) - .addAsWebInfResource(ContextPropagationFullTests.class.getPackage(), "web.xml", "web.xml") - .addAsWebResource(ContextPropagationFullTests.class.getPackage(), "jspTests.jsp", "jspTests.jsp"); - - JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ContextPropagationTests_ejb.jar") - .addPackages(true, ContextPropagationFullTests.class.getPackage()) - .deleteClasses( - ContextServiceDefinitionServlet.class, - ClassloaderServlet.class, - JNDIServlet.class, - SecurityServlet.class, - JSPSecurityServlet.class, - ContextServiceDefinitionFromEJBServlet.class, - ContextServiceDefinitionWebBean.class) - .addAsServiceProvider(EJBJNDIProvider.class, ContextEJBProvider.FullProvider.class) - .addAsManifestResource(ContextPropagationFullTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ContextPropagationTests.ear").addAsModules(war, jar); - - return ear; - } - - @TestName - String testname; - - @ArquillianResource(JNDIServlet.class) - URL jndiURL; - - @ArquillianResource(JSPSecurityServlet.class) - URL jspURL; - - @ArquillianResource(ClassloaderServlet.class) - URL classloaderURL; - - @ArquillianResource(SecurityServlet.class) - URL securityURL; - - @ArquillianResource(ContextServiceDefinitionServlet.class) - URL contextURL; - - @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) - URL ejbContextURL; - - // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed - @Disabled - 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 - public void testSecurityUnchangedContext() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); - runTest(requestURL); - } - - @Test - 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 - 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 - 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 - public void testClassloaderAndCreateProxyInServlet() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet").withTestName(testname); - String resp = runTestWithResponse(requestURL, null); - 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 - public void testSecurityAndCreateProxyInServlet() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet").withTestName(testname); - String resp = runTestWithResponse(requestURL, null); - this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.ComplexReturnValue, resp); - } - + + @Deployment(name = "ContextPropagationTests") + public static EnterpriseArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ContextPropagationTests_web.war") + .addPackages(true, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) + .addClasses(ContextServiceDefinitionServlet.class, ClassloaderServlet.class, JNDIServlet.class, + SecurityServlet.class, JSPSecurityServlet.class, ContextServiceDefinitionFromEJBServlet.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()) + .addAsWebInfResource(ContextPropagationFullTests.class.getPackage(), "web.xml", "web.xml") + .addAsWebResource(ContextPropagationFullTests.class.getPackage(), "jspTests.jsp", "jspTests.jsp"); + + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ContextPropagationTests_ejb.jar") + .addPackages(true, ContextPropagationFullTests.class.getPackage()) + .deleteClasses(ContextServiceDefinitionServlet.class, ClassloaderServlet.class, JNDIServlet.class, + SecurityServlet.class, JSPSecurityServlet.class, ContextServiceDefinitionFromEJBServlet.class, + ContextServiceDefinitionWebBean.class) + .addAsServiceProvider(EJBJNDIProvider.class, ContextEJBProvider.FullProvider.class) + .addAsManifestResource(ContextPropagationFullTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ContextPropagationTests.ear") + .addAsModules(war, jar); + + return ear; + } + + @TestName + String testname; + + @ArquillianResource(JNDIServlet.class) + URL jndiURL; + + @ArquillianResource(JSPSecurityServlet.class) + URL jspURL; + + @ArquillianResource(ClassloaderServlet.class) + URL classloaderURL; + + @ArquillianResource(SecurityServlet.class) + URL securityURL; + + @ArquillianResource(ContextServiceDefinitionServlet.class) + URL contextURL; + + @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) + URL ejbContextURL; + + // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from + // another thread or the current user is changed + @Disabled + 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 + public void testSecurityUnchangedContext() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); + runTest(requestURL); + } + + @Test + 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 + 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 + 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 + public void testClassloaderAndCreateProxyInServlet() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet") + .withTestName(testname); + String resp = runTestWithResponse(requestURL, null); + 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 + public void testSecurityAndCreateProxyInServlet() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet") + .withTestName(testname); + String resp = runTestWithResponse(requestURL, null); + 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. + * 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 + @Test public void testContextServiceDefinitionAllAttributes() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * 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 + @Test public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); - runTest(requestURL); + 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. + * A ContextServiceDefinition with minimal attributes configured clears + * transaction context and propagates other types. */ - @Test + @Test public void testContextServiceDefinitionDefaults() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * A ContextServiceDefinition defined in an EJB with minimal attributes + * configured clears transaction context and propagates other types. */ - @Test + @Test public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); - runTest(requestURL); + 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). + * 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 + @Test public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * 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 + @Test public void testContextualConsumer() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") + .withTestName(testname); + runTest(requestURL); } /** - * 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. + * 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 + * 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 */ - @Disabled + @Disabled public void testContextualFunction() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * 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 + @Test public void testContextualSupplier() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); - requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") + .withTestName(testname); + runTest(requestURL); + requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet") + .withTestName(testname); runTest(requestURL); } /** - * ContextService can create a contextualized copy of an unmanaged CompletableFuture. + * ContextService can create a contextualized copy of an unmanaged + * CompletableFuture. */ - @Test + @Test public void testCopyWithContextCapture() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") + .withTestName(testname); + runTest(requestURL); } } 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 d4f51932..b4e4882f 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 @@ -38,245 +38,266 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Web; import jakarta.enterprise.concurrent.spi.ThreadContextProvider; -@Web @RunAsClient //Requires client testing due to multiple servlets and annotation configuration -@Common({PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS}) +@Web +@RunAsClient // Requires client testing due to multiple servlets and annotation configuration +@Common({ PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS }) public class ContextPropagationWebTests extends TestClient { - - @Deployment(name="ContextPropagationTests") - public static WebArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ContextPropagationTests_web.war") - .addPackages(true, ContextPropagationWebTests.class.getPackage()) - .deleteClasses(ContextServiceDefinitionBean.class) - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()) - .addAsServiceProvider(EJBJNDIProvider.class, ContextEJBProvider.WebProvider.class) - .addAsWebInfResource(ContextPropagationWebTests.class.getPackage(), "web.xml", "web.xml") - .addAsWebResource(ContextPropagationWebTests.class.getPackage(), "jspTests.jsp", "jspTests.jsp"); - - return war; - } - - @TestName + + @Deployment(name = "ContextPropagationTests") + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ContextPropagationTests_web.war") + .addPackages(true, ContextPropagationWebTests.class.getPackage()) + .deleteClasses(ContextServiceDefinitionBean.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()) + .addAsServiceProvider(EJBJNDIProvider.class, ContextEJBProvider.WebProvider.class) + .addAsWebInfResource(ContextPropagationWebTests.class.getPackage(), "web.xml", "web.xml") + .addAsWebResource(ContextPropagationWebTests.class.getPackage(), "jspTests.jsp", "jspTests.jsp"); + + return war; + } + + @TestName String testname; - - @ArquillianResource(JNDIServlet.class) - URL jndiURL; - - @ArquillianResource(JSPSecurityServlet.class) - URL jspURL; - - @ArquillianResource(ClassloaderServlet.class) - URL classloaderURL; - - @ArquillianResource(SecurityServlet.class) - URL securityURL; - - @ArquillianResource(ContextServiceDefinitionServlet.class) - URL contextURL; - - @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) - URL ejbContextURL; - // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed - @Disabled - public void testSecurityClearedContext() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); - runTest(requestURL); - } + @ArquillianResource(JNDIServlet.class) + URL jndiURL; + + @ArquillianResource(JSPSecurityServlet.class) + URL jspURL; + + @ArquillianResource(ClassloaderServlet.class) + URL classloaderURL; - // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed - @Disabled - public void testSecurityUnchangedContext() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); - runTest(requestURL); - } - - @Test - public void testSecurityPropagatedContext() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); - runTest(requestURL); - } + @ArquillianResource(SecurityServlet.class) + URL securityURL; - /* - * @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 - 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); - } + @ArquillianResource(ContextServiceDefinitionServlet.class) + URL contextURL; + + @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) + URL ejbContextURL; + + // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from + // another thread or the current user is changed + @Disabled + 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 + public void testSecurityUnchangedContext() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testname); + runTest(requestURL); + } + + @Test + 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 + 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 + 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: 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 - 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 + public void testClassloaderAndCreateProxyInServlet() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet") + .withTestName(testname); + String resp = runTestWithResponse(requestURL, null); + this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.ComplexReturnValue, 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 - public void testClassloaderAndCreateProxyInServlet() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet").withTestName(testname); - String resp = runTestWithResponse(requestURL, null); - 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 + public void testSecurityAndCreateProxyInServlet() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet") + .withTestName(testname); + String resp = runTestWithResponse(requestURL, null); + 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 - public void testSecurityAndCreateProxyInServlet() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet").withTestName(testname); - String resp = runTestWithResponse(requestURL, null); - 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. + * 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 + @Test public void testContextServiceDefinitionAllAttributes() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * 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 + @Test public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); - runTest(requestURL); + 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. + * A ContextServiceDefinition with minimal attributes configured clears + * transaction context and propagates other types. */ - @Test + @Test public void testContextServiceDefinitionDefaults() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * A ContextServiceDefinition defined in an EJB with minimal attributes + * configured clears transaction context and propagates other types. */ - @Test + @Test public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); - runTest(requestURL); + 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). + * 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 + @Test public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * 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 + @Test public void testContextualConsumer() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") + .withTestName(testname); + runTest(requestURL); } /** - * 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. + * 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 + * 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 */ - @Disabled + @Disabled public void testContextualFunction() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + 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. + * 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 + @Test public void testContextualSupplier() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); - requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testname); + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") + .withTestName(testname); + runTest(requestURL); + requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet") + .withTestName(testname); runTest(requestURL); } /** - * ContextService can create a contextualized copy of an unmanaged CompletableFuture. + * ContextService can create a contextualized copy of an unmanaged + * CompletableFuture. */ - @Test + @Test public void testCopyWithContextCapture() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet") + .withTestName(testname); + runTest(requestURL); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionBean.java index 86f0d6ee..0f38fcdb 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionBean.java @@ -28,33 +28,29 @@ import jakarta.enterprise.concurrent.ContextService; import jakarta.enterprise.concurrent.ContextServiceDefinition; -@ContextServiceDefinition(name = "java:app/concurrent/EJBContextA", - propagated = { APPLICATION, IntContext.NAME }, - cleared = StringContext.NAME, - unchanged = TRANSACTION) +@ContextServiceDefinition(name = "java:app/concurrent/EJBContextA", propagated = { APPLICATION, + IntContext.NAME }, cleared = StringContext.NAME, unchanged = TRANSACTION) // Reuse the same name as defined in ContextServiceDefinitionServlet. -@ContextServiceDefinition(name = "java:module/concurrent/ContextB", - propagated = { APPLICATION, StringContext.NAME }, - cleared = IntContext.NAME, - unchanged = TRANSACTION) +@ContextServiceDefinition(name = "java:module/concurrent/ContextB", propagated = { APPLICATION, + StringContext.NAME }, cleared = IntContext.NAME, unchanged = TRANSACTION) @ContextServiceDefinition(name = "java:comp/concurrent/EJBContextC") @Local(ContextServiceDefinitionInterface.class) @Stateless public class ContextServiceDefinitionBean implements ContextServiceDefinitionInterface { - /** - * Get java:comp/concurrent/EJBContextC from the bean. - */ - @Override - public ContextService getContextC() throws NamingException { - return InitialContext.doLookup("java:comp/concurrent/EJBContextC"); - } - - /** - * Get java:comp/concurrent/ContextB from the bean. - */ - @Override - public ContextService getContextB() throws NamingException { - return InitialContext.doLookup("java:module/concurrent/ContextB"); - } + /** + * Get java:comp/concurrent/EJBContextC from the bean. + */ + @Override + public ContextService getContextC() throws NamingException { + return InitialContext.doLookup("java:comp/concurrent/EJBContextC"); + } + + /** + * Get java:comp/concurrent/ContextB from the bean. + */ + @Override + public ContextService getContextB() throws NamingException { + return InitialContext.doLookup("java:module/concurrent/ContextB"); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java index 47437f51..e53450a6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java @@ -57,7 +57,7 @@ public class ContextServiceDefinitionFromEJBServlet extends TestServlet { @Resource UserTransaction tx; - + @EJB private ContextServiceDefinitionInterface contextServiceDefinitionBean; @@ -70,12 +70,12 @@ public void destroy() { public void before() throws ServletException { unmanagedThreads = Executors.newFixedThreadPool(10); } - + /** * 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. + * propagates/clears/ignores context types as configured. ContextA, which is + * tested here, propagates Application context and IntContext, clears + * StringContext, and leaves Transaction context unchanged. */ public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable { ContextService contextServiceA = InitialContext.doLookup("java:app/concurrent/EJBContextA"); @@ -104,8 +104,7 @@ public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable BiFunction contextualFunction = contextServiceA.contextualFunction(fn); future = CompletableFuture.completedFuture(new Object[4]).thenCombineAsync( - CompletableFuture.completedFuture("java:app/concurrent/EJBContextA"), - contextualFunction, + CompletableFuture.completedFuture("java:app/concurrent/EJBContextA"), contextualFunction, unmanagedThreads); // change context of the current thread @@ -116,31 +115,32 @@ public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable // run inline Object[] results = contextualFunction.apply(new Object[4], "java:app/concurrent/EJBContextA"); if (results[0] instanceof Throwable) - throw new AssertionError("Application context must be propagated to inline contextual BiFunction " + - "to perform lookup of java:app/concurrent/EJBContextA").initCause((Throwable) results[0]); + throw new AssertionError("Application context must be propagated to inline contextual BiFunction " + + "to perform lookup of java:app/concurrent/EJBContextA").initCause((Throwable) results[0]); assertTrue(results[0] instanceof ContextService, - "Application context must be propagated to inline contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); - assertEquals(results[1], Integer.valueOf(101), - "Third-party context type IntContext must be propagated to inline contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); - assertEquals(results[2], "", - "Third-party context type StringContext must be cleared from inline contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); - assertEquals(results[3], Integer.valueOf(Status.STATUS_ACTIVE), - "Transaction context must be left unchanged on inline contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); - - // context from before the inline contextual BiFunction must be restored to thread + "Application context must be propagated to inline contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); + assertEquals(results[1], Integer.valueOf(101), + "Third-party context type IntContext must be propagated to inline contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); + assertEquals(results[2], "", + "Third-party context type StringContext must be cleared from inline contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); + assertEquals(results[3], Integer.valueOf(Status.STATUS_ACTIVE), + "Transaction context must be left unchanged on inline contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); + + // context from before the inline contextual BiFunction must be restored to + // thread assertNotNull(InitialContext.doLookup("java:app/concurrent/EJBContextA"), "Previous Application context must be present after inline contextual BiFunction."); - assertEquals(IntContext.get(), 102, + assertEquals(IntContext.get(), 102, "Third-party context type IntContext must be restored after inline contextual BiFunction."); - assertEquals(StringContext.get(), "testContextServiceDefinitionFromEJBAllAttributes-2", + assertEquals(StringContext.get(), "testContextServiceDefinitionFromEJBAllAttributes-2", "Third-party context type StringContext must be restored after inline contextual BiFunction."); - assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, - "Transaction context must remain on thread after inline contextual BiFunction " + - "because it is to be left unchanged per java:app/concurrent/EJBContextA configuration."); + assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, + "Transaction context must remain on thread after inline contextual BiFunction " + + "because it is to be left unchanged per java:app/concurrent/EJBContextA configuration."); } finally { StringContext.set(""); IntContext.set(0); @@ -151,25 +151,25 @@ public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable Object[] results = future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); if (results[0] instanceof Throwable) - throw new AssertionError("Application context must be propagated to async contextual BiFunction " + - "to perform lookup of java:app/concurrent/EJBContextA").initCause((Throwable) results[0]); + throw new AssertionError("Application context must be propagated to async contextual BiFunction " + + "to perform lookup of java:app/concurrent/EJBContextA").initCause((Throwable) results[0]); assertTrue(results[0] instanceof ContextService, - "Application context must be propagated to async contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); - assertEquals(results[1], Integer.valueOf(101), - "Third-party context type IntContext must be propagated to async contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); - assertEquals(results[2], "", - "Third-party context type StringContext must be cleared from async contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); - assertEquals(results[3], Integer.valueOf(Status.STATUS_NO_TRANSACTION), - "Transaction context must be left unchanged on async contextual BiFunction " + - "per java:app/concurrent/EJBContextA configuration."); + "Application context must be propagated to async contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); + assertEquals(results[1], Integer.valueOf(101), + "Third-party context type IntContext must be propagated to async contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); + assertEquals(results[2], "", + "Third-party context type StringContext must be cleared from async contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); + assertEquals(results[3], Integer.valueOf(Status.STATUS_NO_TRANSACTION), + "Transaction context must be left unchanged on async contextual BiFunction " + + "per java:app/concurrent/EJBContextA configuration."); } /** - * A ContextServiceDefinition defined in an EJB with minimal attributes configured - * clears transaction context and propagates other types. + * A ContextServiceDefinition defined in an EJB with minimal attributes + * configured clears transaction context and propagates other types. */ public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { ContextService contextService = contextServiceDefinitionBean.getContextC(); @@ -204,10 +204,10 @@ public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { StringContext.set("testContextServiceDefinitionFromeEJBDefaults-2"); - assertEquals(callable.call(), "testContextServiceDefinitionFromeEJBDefaults-1", + assertEquals(callable.call(), "testContextServiceDefinitionFromeEJBDefaults-1", "Third-party context type StringContext must be propagated to contextual Callable."); - assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, + assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, "Transaction must be restored on thread after contextual proxy completes."); } finally { StringContext.set(null); @@ -217,23 +217,23 @@ public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { Object result; assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "Contextual runnable did not start on thread."); - assertEquals(result, Integer.valueOf(13), + assertEquals(result, Integer.valueOf(13), "Third-party context type IntContext must be propagated to contextual Runnable."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "Contextual runnable did not complete on thread."); if (result instanceof Throwable) throw new AssertionError("Unable to look up java:comp name from contextual Runnable.") - .initCause((Throwable) result); + .initCause((Throwable) result); assertTrue(result instanceof ContextService, - "Application context must be propagated to contextual Runnable, but instead lookup found: " + - result); + "Application context must be propagated to contextual Runnable, but instead lookup found: " + result); } - + /** - * 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. + * 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 { try { @@ -241,21 +241,21 @@ public void testContextualSupplier() throws Throwable { IntContext.set(61); ContextService contextServiceB = contextServiceDefinitionBean.getContextB(); - Supplier> supplierB = contextServiceB.contextualSupplier(() -> - new SimpleEntry(IntContext.get(), StringContext.get())); - CompletableFuture> futureB = - CompletableFuture.supplyAsync(supplierB, unmanagedThreads); + Supplier> supplierB = contextServiceB + .contextualSupplier(() -> new SimpleEntry(IntContext.get(), StringContext.get())); + CompletableFuture> futureB = CompletableFuture.supplyAsync(supplierB, + unmanagedThreads); StringContext.set("testContextualSupplier-2"); IntContext.set(62); Map.Entry results = futureB.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(results.getKey(), Integer.valueOf(0), - "Third-party context type IntContext must be cleared from async contextual Supplier " + - "per java:module/concurrent/ContextB configuration."); + assertEquals(results.getKey(), Integer.valueOf(0), + "Third-party context type IntContext must be cleared from async contextual Supplier " + + "per java:module/concurrent/ContextB configuration."); assertEquals(results.getValue(), "testContextualSupplier-1", - "Third-party context type StringContext must be propagated to async contextual Supplier " + - "per java:module/concurrent/ContextB configuration."); + "Third-party context type StringContext must be propagated to async contextual Supplier " + + "per java:module/concurrent/ContextB configuration."); } finally { StringContext.set(null); IntContext.set(0); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionInterface.java index 4f2e75f1..020fdcf4 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionInterface.java @@ -21,13 +21,13 @@ public interface ContextServiceDefinitionInterface { - /** - * Get java:comp/concurrent/EJBContextC from the bean. - */ - public ContextService getContextC() throws NamingException; + /** + * Get java:comp/concurrent/EJBContextC from the bean. + */ + public ContextService getContextC() throws NamingException; - /** - * Get java:comp/concurrent/ContextB from the bean. - */ - ContextService getContextB() throws NamingException; + /** + * Get java:comp/concurrent/ContextB from the bean. + */ + ContextService getContextB() throws NamingException; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java index c791363d..582cd83a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java @@ -55,14 +55,10 @@ import jakarta.transaction.SystemException; import jakarta.transaction.UserTransaction; -@ContextServiceDefinition(name = "java:app/concurrent/ContextA", - propagated = { APPLICATION, IntContext.NAME }, - cleared = StringContext.NAME, - unchanged = TRANSACTION) -@ContextServiceDefinition(name = "java:module/concurrent/ContextB", - cleared = TRANSACTION, - unchanged = { APPLICATION, IntContext.NAME }, - propagated = ALL_REMAINING) +@ContextServiceDefinition(name = "java:app/concurrent/ContextA", propagated = { APPLICATION, + IntContext.NAME }, cleared = StringContext.NAME, unchanged = TRANSACTION) +@ContextServiceDefinition(name = "java:module/concurrent/ContextB", cleared = TRANSACTION, unchanged = { APPLICATION, + IntContext.NAME }, propagated = ALL_REMAINING) @ContextServiceDefinition(name = "java:comp/concurrent/ContextC") @WebServlet("/ContextServiceDefinitionServlet") public class ContextServiceDefinitionServlet extends TestServlet { @@ -89,9 +85,9 @@ public void before() throws ServletException { /** * 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. + * propagates/clears/ignores context types as configured. ContextA, which is + * tested here, propagates Application context and IntContext, clears + * StringContext, and leaves Transaction context unchanged. */ public void testContextServiceDefinitionAllAttributes() throws Throwable { ContextService contextServiceA = InitialContext.doLookup("java:app/concurrent/ContextA"); @@ -120,8 +116,7 @@ public void testContextServiceDefinitionAllAttributes() throws Throwable { BiFunction contextualFunction = contextServiceA.contextualFunction(fn); future = CompletableFuture.completedFuture(new Object[4]).thenCombineAsync( - CompletableFuture.completedFuture("java:app/concurrent/ContextA"), - contextualFunction, + CompletableFuture.completedFuture("java:app/concurrent/ContextA"), contextualFunction, unmanagedThreads); // change context of the current thread @@ -132,31 +127,32 @@ public void testContextServiceDefinitionAllAttributes() throws Throwable { // run inline Object[] results = contextualFunction.apply(new Object[4], "java:app/concurrent/ContextA"); if (results[0] instanceof Throwable) - throw new AssertionError("Application context must be propagated to inline contextual BiFunction " + - "to perform lookup of java:app/concurrent/ContextA").initCause((Throwable) results[0]); + throw new AssertionError("Application context must be propagated to inline contextual BiFunction " + + "to perform lookup of java:app/concurrent/ContextA").initCause((Throwable) results[0]); assertTrue(results[0] instanceof ContextService, - "Application context must be propagated to inline contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results[1], Integer.valueOf(101), - "Third-party context type IntContext must be propagated to inline contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results[2], "", - "Third-party context type StringContext must be cleared from inline contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results[3], Integer.valueOf(Status.STATUS_ACTIVE), - "Transaction context must be left unchanged on inline contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); - - // context from before the inline contextual BiFunction must be restored to thread + "Application context must be propagated to inline contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results[1], Integer.valueOf(101), + "Third-party context type IntContext must be propagated to inline contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results[2], "", + "Third-party context type StringContext must be cleared from inline contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results[3], Integer.valueOf(Status.STATUS_ACTIVE), + "Transaction context must be left unchanged on inline contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); + + // context from before the inline contextual BiFunction must be restored to + // thread assertNotNull(InitialContext.doLookup("java:app/concurrent/ContextA"), "Previous Application context must be present after inline contextual BiFunction."); - assertEquals(IntContext.get(), 102, + assertEquals(IntContext.get(), 102, "Third-party context type IntContext must be restored after inline contextual BiFunction."); - assertEquals(StringContext.get(), "testContextServiceDefinitionAllAttributes-2", + assertEquals(StringContext.get(), "testContextServiceDefinitionAllAttributes-2", "Third-party context type StringContext must be restored after inline contextual BiFunction."); - assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, - "Transaction context must remain on thread after inline contextual BiFunction " + - "because it is to be left unchanged per java:app/concurrent/ContextA configuration."); + assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, + "Transaction context must remain on thread after inline contextual BiFunction " + + "because it is to be left unchanged per java:app/concurrent/ContextA configuration."); } finally { StringContext.set(""); IntContext.set(0); @@ -167,25 +163,25 @@ public void testContextServiceDefinitionAllAttributes() throws Throwable { Object[] results = future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); if (results[0] instanceof Throwable) - throw new AssertionError("Application context must be propagated to async contextual BiFunction " + - "to perform lookup of java:app/concurrent/ContextA").initCause((Throwable) results[0]); + throw new AssertionError("Application context must be propagated to async contextual BiFunction " + + "to perform lookup of java:app/concurrent/ContextA").initCause((Throwable) results[0]); assertTrue(results[0] instanceof ContextService, - "Application context must be propagated to async contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results[1], Integer.valueOf(101), - "Third-party context type IntContext must be propagated to async contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results[2], "", - "Third-party context type StringContext must be cleared from async contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results[3], Integer.valueOf(Status.STATUS_NO_TRANSACTION), - "Transaction context must be left unchanged on async contextual BiFunction " + - "per java:app/concurrent/ContextA configuration."); + "Application context must be propagated to async contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results[1], Integer.valueOf(101), + "Third-party context type IntContext must be propagated to async contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results[2], "", + "Third-party context type StringContext must be cleared from async contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results[3], Integer.valueOf(Status.STATUS_NO_TRANSACTION), + "Transaction context must be left unchanged on async contextual BiFunction " + + "per java:app/concurrent/ContextA configuration."); } - + /** - * A ContextServiceDefinition with minimal attributes configured - * clears transaction context and propagates other types. + * A ContextServiceDefinition with minimal attributes configured clears + * transaction context and propagates other types. */ public void testContextServiceDefinitionDefaults() throws Throwable { ContextService contextService = InitialContext.doLookup("java:comp/concurrent/ContextC"); @@ -220,10 +216,10 @@ public void testContextServiceDefinitionDefaults() throws Throwable { StringContext.set("testContextServiceDefinitionDefaults-2"); - assertEquals(callable.call(), "testContextServiceDefinitionDefaults-1", + assertEquals(callable.call(), "testContextServiceDefinitionDefaults-1", "Third-party context type StringContext must be propagated to contextual Callable."); - assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, + assertEquals(tx.getStatus(), Status.STATUS_ACTIVE, "Transaction must be restored on thread after contextual proxy completes."); } finally { StringContext.set(null); @@ -233,24 +229,23 @@ public void testContextServiceDefinitionDefaults() throws Throwable { Object result; assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "Contextual runnable did not start on thread."); - assertEquals(result, Integer.valueOf(13), + assertEquals(result, Integer.valueOf(13), "Third-party context type IntContext must be propagated to contextual Runnable."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "Contextual runnable did not complete on thread."); if (result instanceof Throwable) throw new AssertionError("Unable to look up java:comp name from contextual Runnable.") - .initCause((Throwable) result); + .initCause((Throwable) result); assertTrue(result instanceof ContextService, - "Application context must be propagated to contextual Runnable, but instead lookup found: " + - result); + "Application context must be propagated to contextual Runnable, but instead lookup found: " + result); } /** - * 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). + * 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). */ public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable { try { @@ -258,21 +253,19 @@ public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable IntContext.set(31); ContextService contextServiceA = InitialContext.doLookup("java:app/concurrent/ContextA"); - BiConsumer, Queue> consumerA = - contextServiceA.contextualConsumer((intQ, strQ) -> { - intQ.add(IntContext.get()); - strQ.add(StringContext.get()); - }); + BiConsumer, Queue> consumerA = contextServiceA.contextualConsumer((intQ, strQ) -> { + intQ.add(IntContext.get()); + strQ.add(StringContext.get()); + }); BlockingQueue queueA = new LinkedBlockingQueue(); CompletableFuture> qFutureA = CompletableFuture.completedFuture(queueA); qFutureA.thenAcceptBothAsync(qFutureA, consumerA, unmanagedThreads); ContextService contextServiceB = InitialContext.doLookup("java:module/concurrent/ContextB"); - BiConsumer, Queue> consumerB = - contextServiceB.contextualConsumer((intQ, strQ) -> { - intQ.add(IntContext.get()); - strQ.add(StringContext.get()); - }); + BiConsumer, Queue> consumerB = contextServiceB.contextualConsumer((intQ, strQ) -> { + intQ.add(IntContext.get()); + strQ.add(StringContext.get()); + }); BlockingQueue queueB = new LinkedBlockingQueue(); CompletableFuture> qFutureB = CompletableFuture.completedFuture(queueB); qFutureB.thenAcceptBothAsync(qFutureB, consumerB); @@ -284,34 +277,34 @@ public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable Queue results = new LinkedList(); consumerA.accept(results, results); assertEquals(results.poll(), Integer.valueOf(31), - "Third-party context type IntContext must be propagated to inline contextual BiConsumer " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results.poll(), "", - "Third-party context type StringContext must be cleared from inline contextual BiConsumer " + - "per java:app/concurrent/ContextA configuration."); + "Third-party context type IntContext must be propagated to inline contextual BiConsumer " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results.poll(), "", + "Third-party context type StringContext must be cleared from inline contextual BiConsumer " + + "per java:app/concurrent/ContextA configuration."); consumerB.accept(results, results); - assertEquals(results.poll(), Integer.valueOf(32), - "Third-party context type IntContext must be left unchanged on inline contextual BiConsumer " + - "per java:module/concurrent/ContextB configuration."); - assertEquals(results.poll(), "testCSDWithThirdPartyContext-1", - "Third-party context type StringContext must be propagated to inline contextual BiConsumer " + - "per java:module/concurrent/ContextB configuration."); + assertEquals(results.poll(), Integer.valueOf(32), + "Third-party context type IntContext must be left unchanged on inline contextual BiConsumer " + + "per java:module/concurrent/ContextB configuration."); + assertEquals(results.poll(), "testCSDWithThirdPartyContext-1", + "Third-party context type StringContext must be propagated to inline contextual BiConsumer " + + "per java:module/concurrent/ContextB configuration."); // Check the thread context of async consumers - assertEquals(queueA.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(31), - "Third-party context type IntContext must be propagated to async contextual BiConsumer " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(queueA.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "", - "Third-party context type StringContext must be cleared from async contextual BiConsumer " + - "per java:app/concurrent/ContextA configuration."); - - assertEquals(queueB.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(0), - "Third-party context type IntContext must be left unchanged on async contextual BiConsumer " + - "per java:module/concurrent/ContextB configuration."); - assertEquals(queueB.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testCSDWithThirdPartyContext-1", - "Third-party context type StringContext must be propagated to async contextual BiConsumer " + - "per java:module/concurrent/ContextB configuration."); + assertEquals(queueA.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(31), + "Third-party context type IntContext must be propagated to async contextual BiConsumer " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(queueA.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "", + "Third-party context type StringContext must be cleared from async contextual BiConsumer " + + "per java:app/concurrent/ContextA configuration."); + + assertEquals(queueB.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(0), + "Third-party context type IntContext must be left unchanged on async contextual BiConsumer " + + "per java:module/concurrent/ContextB configuration."); + assertEquals(queueB.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testCSDWithThirdPartyContext-1", + "Third-party context type StringContext must be propagated to async contextual BiConsumer " + + "per java:module/concurrent/ContextB configuration."); } finally { StringContext.set(null); IntContext.set(0); @@ -319,9 +312,10 @@ public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable } /** - * 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. + * 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. */ public void testContextualConsumer() throws Throwable { ContextService contextService = InitialContext.doLookup("java:app/concurrent/ContextA"); @@ -350,27 +344,26 @@ public void testContextualConsumer() throws Throwable { assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "Contextual Consumer did not start running."); assertEquals(result, Integer.valueOf(121), - "Third-party context type IntContext must be propagated to contextual Consumer " + - "per java:app/concurrent/ContextA configuration."); + "Third-party context type IntContext must be propagated to contextual Consumer " + + "per java:app/concurrent/ContextA configuration."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "Contextual Consumer did not continue running."); - assertEquals(result, "", - "Third-party context type StringContext must be cleared on contextual Consumer " + - "per java:app/concurrent/ContextA configuration."); + assertEquals(result, "", "Third-party context type StringContext must be cleared on contextual Consumer " + + "per java:app/concurrent/ContextA configuration."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "Contextual Consumer did not complete."); if (result instanceof Throwable) throw new AssertionError("Application context must be propagated to contextual Consumer") - .initCause((Throwable) result); - assertTrue(result instanceof ContextService, - "Application context must be propagated to contextual Consumer " + - "per java:app/concurrent/ContextA configuration."); + .initCause((Throwable) result); + assertTrue(result instanceof ContextService, "Application context must be propagated to contextual Consumer " + + "per java:app/concurrent/ContextA configuration."); } /** - * 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. + * 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 { ContextService contextService = InitialContext.doLookup("java:module/concurrent/ContextB"); @@ -398,7 +391,7 @@ public void testContextualFunction() throws Throwable { }); future = CompletableFuture.completedFuture("java:module/concurrent/ContextB") - .thenApplyAsync(contextualFunction); + .thenApplyAsync(contextualFunction); } finally { StringContext.set(null); IntContext.set(0); @@ -407,23 +400,24 @@ public void testContextualFunction() throws Throwable { Object[] results = future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); assertTrue(results[0] instanceof NamingException, - "Application context must remain unchanged on contextual Function " + - "per java:module/concurrent/ContextB configuration. Result: " + results[0]); - assertEquals(results[1], Integer.valueOf(0), - "Third-party context type IntContext must remain unchanged on contextual Function " + - "per java:module/concurrent/ContextB configuration."); + "Application context must remain unchanged on contextual Function " + + "per java:module/concurrent/ContextB configuration. Result: " + results[0]); + assertEquals(results[1], Integer.valueOf(0), + "Third-party context type IntContext must remain unchanged on contextual Function " + + "per java:module/concurrent/ContextB configuration."); assertEquals(results[2], "testContextualFunction-1", - "Third-party context type StringContext must be propagated to contextual Function " + - "per java:module/concurrent/ContextB configuration."); - assertEquals(results[3], Integer.valueOf(Status.STATUS_NO_TRANSACTION), - "Transaction context must be cleared from contextual Function " + - "per java:module/concurrent/ContextB configuration."); + "Third-party context type StringContext must be propagated to contextual Function " + + "per java:module/concurrent/ContextB configuration."); + assertEquals(results[3], Integer.valueOf(Status.STATUS_NO_TRANSACTION), + "Transaction context must be cleared from contextual Function " + + "per java:module/concurrent/ContextB configuration."); } /** - * 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. + * 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 { try { @@ -431,21 +425,21 @@ public void testContextualSupplier() throws Throwable { IntContext.set(61); ContextService contextServiceA = InitialContext.doLookup("java:app/concurrent/ContextA"); - Supplier> supplierA = contextServiceA.contextualSupplier(() -> - new SimpleEntry(IntContext.get(), StringContext.get())); - CompletableFuture> futureA = - CompletableFuture.supplyAsync(supplierA, unmanagedThreads); + Supplier> supplierA = contextServiceA + .contextualSupplier(() -> new SimpleEntry(IntContext.get(), StringContext.get())); + CompletableFuture> futureA = CompletableFuture.supplyAsync(supplierA, + unmanagedThreads); StringContext.set("testContextualSupplier-2"); IntContext.set(62); Map.Entry results = futureA.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(results.getKey(), Integer.valueOf(61), - "Third-party context type IntContext must be propagated to async contextual Supplier " + - "per java:app/concurrent/ContextA configuration."); - assertEquals(results.getValue(), "", - "Third-party context type StringContext must be cleared from async contextual Supplier " + - "per java:app/concurrent/ContextA configuration."); + assertEquals(results.getKey(), Integer.valueOf(61), + "Third-party context type IntContext must be propagated to async contextual Supplier " + + "per java:app/concurrent/ContextA configuration."); + assertEquals(results.getValue(), "", + "Third-party context type StringContext must be cleared from async contextual Supplier " + + "per java:app/concurrent/ContextA configuration."); } finally { StringContext.set(null); IntContext.set(0); @@ -453,7 +447,8 @@ public void testContextualSupplier() throws Throwable { } /** - * ContextService can create a contextualized copy of an unmanaged CompletableFuture. + * ContextService can create a contextualized copy of an unmanaged + * CompletableFuture. */ public void testCopyWithContextCapture() throws Throwable { ContextService contextService = InitialContext.doLookup("java:app/concurrent/ContextA"); @@ -467,33 +462,33 @@ public void testCopyWithContextCapture() throws Throwable { IntContext.set(172); CompletableFuture stage2 = stage1copy.exceptionally(failure -> { - assertEquals(IntContext.get(), 172, - "Third-party context type IntContext must be propagated to the .exceptionally Function " + - "per java:app/concurrent/ContextA configuration."); + assertEquals(IntContext.get(), 172, + "Third-party context type IntContext must be propagated to the .exceptionally Function " + + "per java:app/concurrent/ContextA configuration."); return "java:app/concurrent/ContextA"; }); IntContext.set(173); CompletableFuture stage3 = stage2.thenAcceptAsync(jndiName -> { - assertEquals(StringContext.get(), "", - "Third-party context type StringContext must be cleared from async contextual Consumer " + - "per java:app/concurrent/ContextA configuration."); + assertEquals(StringContext.get(), "", + "Third-party context type StringContext must be cleared from async contextual Consumer " + + "per java:app/concurrent/ContextA configuration."); try { assertNotNull(InitialContext.doLookup("java:app/concurrent/ContextA"), - "Application context must be propagated to async contextual Consumer " + - "per java:app/concurrent/ContextA configuration."); + "Application context must be propagated to async contextual Consumer " + + "per java:app/concurrent/ContextA configuration."); } catch (NamingException x) { throw new CompletionException(x); } }); - stage1unmanaged.completeExceptionally(new UnsupportedOperationException( - "Intentionally raised to force the .exceptionally code path")); + stage1unmanaged.completeExceptionally( + new UnsupportedOperationException("Intentionally raised to force the .exceptionally code path")); - assertEquals(stage3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), null, - "Dependent stages should complete in response to the completion of the stage " + - "from which the first stage was copied."); + assertEquals(stage3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), null, + "Dependent stages should complete in response to the completion of the stage " + + "from which the first stage was copied."); assertTrue(stage1copy.isCompletedExceptionally(), "Copied stage must complete the same way as the stage from which it is copied."); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java index e98fa72e..d96fe410 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java @@ -28,28 +28,26 @@ import jakarta.enterprise.concurrent.ContextService; import jakarta.enterprise.concurrent.ContextServiceDefinition; -@ContextServiceDefinition(name = "java:app/concurrent/EJBContextA", - propagated = { APPLICATION, IntContext.NAME }, - cleared = StringContext.NAME, - unchanged = TRANSACTION) +@ContextServiceDefinition(name = "java:app/concurrent/EJBContextA", propagated = { APPLICATION, + IntContext.NAME }, cleared = StringContext.NAME, unchanged = TRANSACTION) @ContextServiceDefinition(name = "java:comp/concurrent/EJBContextC") @Local(ContextServiceDefinitionInterface.class) @Stateless public class ContextServiceDefinitionWebBean implements ContextServiceDefinitionInterface { - /** - * Get java:comp/concurrent/EJBContextC from the bean. - */ - @Override - public ContextService getContextC() throws NamingException { - return InitialContext.doLookup("java:comp/concurrent/EJBContextC"); - } - - /** - * Get java:comp/concurrent/ContextB from the bean. - */ - @Override - public ContextService getContextB() throws NamingException { - return InitialContext.doLookup("java:module/concurrent/ContextB"); - } + /** + * Get java:comp/concurrent/EJBContextC from the bean. + */ + @Override + public ContextService getContextC() throws NamingException { + return InitialContext.doLookup("java:comp/concurrent/EJBContextC"); + } + + /** + * Get java:comp/concurrent/ContextB from the bean. + */ + @Override + public ContextService getContextB() throws NamingException { + return InitialContext.doLookup("java:module/concurrent/ContextB"); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java index e8a76f82..9f9dc2fb 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java @@ -31,24 +31,22 @@ @WebServlet("/JNDIServlet") public class JNDIServlet extends TestServlet { - @EJB - private ContextPropagateInterface intf; - + @EJB + private ContextPropagateInterface intf; + @Resource(lookup = TestConstants.DefaultContextService) public ContextService context; - - public void testJNDIContextAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { - String result = intf.executeWorker((TestWorkInterface) context - .createContextualProxy(new TestJNDIRunnableWork(), Runnable.class, TestWorkInterface.class, - Serializable.class)); - resp.getWriter().println(result); + public void testJNDIContextAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) + throws Exception { + String result = intf.executeWorker((TestWorkInterface) context.createContextualProxy(new TestJNDIRunnableWork(), + Runnable.class, TestWorkInterface.class, Serializable.class)); + resp.getWriter().println(result); - } + } - public void testJNDIContextAndCreateProxyInEJB(HttpServletRequest req, HttpServletResponse resp) throws Exception { - String result = intf.createWorker( TestJNDIRunnableWork.class.getCanonicalName()) - .doSomeWork(); - resp.getWriter().println(result); - } + public void testJNDIContextAndCreateProxyInEJB(HttpServletRequest req, HttpServletResponse resp) throws Exception { + String result = intf.createWorker(TestJNDIRunnableWork.class.getCanonicalName()).doSomeWork(); + resp.getWriter().println(result); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JSPSecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JSPSecurityServlet.java index 9442636d..4be98b13 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JSPSecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JSPSecurityServlet.java @@ -8,13 +8,10 @@ import jakarta.servlet.annotation.WebServlet; @SuppressWarnings("serial") -@ContextServiceDefinition(name = "java:app/concurrent/securityClearedContextSvc", - cleared = SECURITY) -@ContextServiceDefinition(name = "java:app/concurrent/securityUnchangedContextSvc", - unchanged = SECURITY) +@ContextServiceDefinition(name = "java:app/concurrent/securityClearedContextSvc", cleared = SECURITY) +@ContextServiceDefinition(name = "java:app/concurrent/securityUnchangedContextSvc", unchanged = SECURITY) @ManagedExecutorDefinition(name = "java:app/concurrent/executor1") -@ManagedExecutorDefinition(name = "java:app/concurrent/executor2", - context = "java:app/concurrent/securityUnchangedContextSvc") +@ManagedExecutorDefinition(name = "java:app/concurrent/executor2", context = "java:app/concurrent/securityUnchangedContextSvc") @WebServlet("/JSPSecurityServlet") public class JSPSecurityServlet extends TestServlet { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java index 1ee6aa87..b63ac2e3 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java @@ -25,8 +25,8 @@ @Stateless public class LimitedBean implements LimitedInterface { - @RolesAllowed("Manager") - public String doSomething() { - return TestConstants.ComplexReturnValue; - } + @RolesAllowed("Manager") + public String doSomething() { + return TestConstants.ComplexReturnValue; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedInterface.java index 6cbf58e2..a95b5224 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedInterface.java @@ -17,5 +17,5 @@ package ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate; public interface LimitedInterface { - public String doSomething(); + public String doSomething(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java index 50116faf..1c2155ef 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java @@ -31,18 +31,19 @@ @WebServlet("/SecurityServlet") public class SecurityServlet extends TestServlet { - @EJB - private ContextPropagateInterface intf; - + @EJB + private ContextPropagateInterface intf; + @Resource(lookup = TestConstants.DefaultContextService) public ContextService context; - - public void testSecurityAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { - req.login("javajoe", "javajoe"); - String result = intf.executeWorker((TestWorkInterface) context.createContextualProxy( - new TestSecurityRunnableWork(), Runnable.class, TestWorkInterface.class, Serializable.class)); + public void testSecurityAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { + req.login("javajoe", "javajoe"); + + String result = intf + .executeWorker((TestWorkInterface) context.createContextualProxy(new TestSecurityRunnableWork(), + Runnable.class, TestWorkInterface.class, Serializable.class)); - resp.getWriter().println(result); - } + resp.getWriter().println(result); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java index 6a2cabf1..8dc97461 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java @@ -21,14 +21,14 @@ @SuppressWarnings("serial") public class TestClassloaderRunnableWork extends BaseTestRunnableWork { - @Override - protected String work() { - try { - Thread.currentThread().getContextClassLoader().loadClass( - "ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ClassloaderServlet"); - } catch (ClassNotFoundException e) { - return "can not load class in web module from ejb module."; - } - return TestConstants.ComplexReturnValue; - } + @Override + protected String work() { + try { + Thread.currentThread().getContextClassLoader() + .loadClass("ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ClassloaderServlet"); + } catch (ClassNotFoundException e) { + return "can not load class in web module from ejb module."; + } + return TestConstants.ComplexReturnValue; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestJNDIRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestJNDIRunnableWork.java index e02de75c..a526ef40 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestJNDIRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestJNDIRunnableWork.java @@ -22,12 +22,12 @@ @SuppressWarnings("serial") public class TestJNDIRunnableWork extends BaseTestRunnableWork { - @Override - protected String work() { - try { + @Override + protected String work() { + try { return InitialContext.doLookup("java:comp/env/myMessage"); } catch (NamingException e) { throw new RuntimeException(e); } - } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java index 72496fb5..a93ff66b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java @@ -26,15 +26,15 @@ @SuppressWarnings("serial") public class TestSecurityRunnableWork extends BaseTestRunnableWork { - @Override - protected String work() { - EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); - LimitedInterface limited; + @Override + protected String work() { + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + LimitedInterface limited; try { limited = InitialContext.doLookup(nameProvider.getEJBJNDIName()); } catch (NamingException e) { throw new RuntimeException(e); } - return limited.doSomething(); - } + return limited.doSomething(); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestWorkInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestWorkInterface.java index c2737f2f..2d4b3262 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestWorkInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestWorkInterface.java @@ -19,7 +19,7 @@ import java.io.Serializable; public interface TestWorkInterface extends Runnable, Serializable { - public String doSomeWork(); + public String doSomeWork(); - public String getResult(); + public String getResult(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/BaseTestRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/BaseTestRunnableWork.java index 9f55e53b..1ca4252f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/BaseTestRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/BaseTestRunnableWork.java @@ -19,23 +19,23 @@ import java.io.Serializable; public abstract class BaseTestRunnableWork implements Serializable, Runnable, TestWorkInterface { - + private static final long serialVersionUID = 1L; - + private String message; - public void run() { - message = work(); - } + public void run() { + message = work(); + } - public String doSomeWork() { - message = work(); - return message; - } + public String doSomeWork() { + message = work(); + return message; + } - public String getResult() { - return message; - } + public String getResult() { + return message; + } - protected abstract String work(); + protected abstract String work(); } 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 4c2fd650..05b9aa2c 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 @@ -35,100 +35,104 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to POST requests +@Web +@RunAsClient // Requires client testing due to POST requests public class ContextPropagationServletTests extends TestClient { - - private static final String APP_NAME_PROXY = "ContextPropagationServletTests.Proxy"; - private static final String APP_NAME_WORK = "ContextPropagationServletTests.Work"; - private static final String APP_NAME_DESERIALIZE = "ContextPropagationServletTests.Deserialize"; - - @Deployment(name = APP_NAME_PROXY) - public static WebArchive createDeployment1() { - return ShrinkWrap.create(WebArchive.class, APP_NAME_PROXY + ".war") - .addPackages(true, ContextPropagationServletTests.class.getPackage()) - .deleteClass(WorkInterfaceServlet.class) - .addAsWebInfResource(ContextPropagationServletTests.class.getPackage(), "web.xml", "web.xml"); - } - - @Deployment(name = APP_NAME_WORK) - public static WebArchive createDeployment2() { - return ShrinkWrap.create(WebArchive.class, APP_NAME_WORK + ".war") - .addPackages(true, ContextPropagationServletTests.class.getPackage()) - .deleteClass(ProxyCreatorServlet.class); - } - - @Deployment(name = APP_NAME_DESERIALIZE) - public static WebArchive createDeployment3() { - return ShrinkWrap.create(WebArchive.class, APP_NAME_DESERIALIZE + ".war") - .addPackages(true, ContextPropagationServletTests.class.getPackage()) - .deleteClasses(ProxyCreatorServlet.class, WorkInterfaceServlet.class); - } - - @TestName - String testname; - - @ArquillianResource - @OperateOnDeployment(APP_NAME_PROXY) - URL baseURL; - - @ArquillianResource - @OperateOnDeployment(APP_NAME_WORK) - URL workInterfaceURL; - - @Override - 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 - public void testJNDIContextInServlet() { - URL proxyURL = URLBuilder.get().withBaseURL(workInterfaceURL).withPaths("WorkInterfaceServlet").build(); - URLBuilder requestURL = URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testname); - - Properties props = new Properties(); - props.put("proxyURL", proxyURL.toString()); - props.put(TEST_METHOD, testname); - - String resp = runTestWithResponse(requestURL, props); - assertNotNull("Response should not be null", resp); - 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 - public void testClassloaderInServlet() { - URL proxyURL = URLBuilder.get().withBaseURL(workInterfaceURL).withPaths("WorkInterfaceServlet").build(); - URLBuilder requestURL = URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testname); - - Properties props = new Properties(); - props.put("proxyURL", proxyURL.toString()); - props.put(TEST_METHOD, testname); - - String resp = runTestWithResponse(requestURL, props); - assertNotNull("Response should not be null", resp); - assertStringInResponse(testname + " failed to get correct result.", TestConstants.ComplexReturnValue, resp.trim()); - } + + private static final String APP_NAME_PROXY = "ContextPropagationServletTests.Proxy"; + private static final String APP_NAME_WORK = "ContextPropagationServletTests.Work"; + private static final String APP_NAME_DESERIALIZE = "ContextPropagationServletTests.Deserialize"; + + @Deployment(name = APP_NAME_PROXY) + public static WebArchive createDeployment1() { + return ShrinkWrap.create(WebArchive.class, APP_NAME_PROXY + ".war") + .addPackages(true, ContextPropagationServletTests.class.getPackage()) + .deleteClass(WorkInterfaceServlet.class) + .addAsWebInfResource(ContextPropagationServletTests.class.getPackage(), "web.xml", "web.xml"); + } + + @Deployment(name = APP_NAME_WORK) + public static WebArchive createDeployment2() { + return ShrinkWrap.create(WebArchive.class, APP_NAME_WORK + ".war") + .addPackages(true, ContextPropagationServletTests.class.getPackage()) + .deleteClass(ProxyCreatorServlet.class); + } + + @Deployment(name = APP_NAME_DESERIALIZE) + public static WebArchive createDeployment3() { + return ShrinkWrap.create(WebArchive.class, APP_NAME_DESERIALIZE + ".war") + .addPackages(true, ContextPropagationServletTests.class.getPackage()) + .deleteClasses(ProxyCreatorServlet.class, WorkInterfaceServlet.class); + } + + @TestName + String testname; + + @ArquillianResource + @OperateOnDeployment(APP_NAME_PROXY) + URL baseURL; + + @ArquillianResource + @OperateOnDeployment(APP_NAME_WORK) + URL workInterfaceURL; + + @Override + 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 + public void testJNDIContextInServlet() { + URL proxyURL = URLBuilder.get().withBaseURL(workInterfaceURL).withPaths("WorkInterfaceServlet").build(); + URLBuilder requestURL = URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()) + .withTestName(testname); + + Properties props = new Properties(); + props.put("proxyURL", proxyURL.toString()); + props.put(TEST_METHOD, testname); + + String resp = runTestWithResponse(requestURL, props); + assertNotNull("Response should not be null", resp); + 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 + public void testClassloaderInServlet() { + URL proxyURL = URLBuilder.get().withBaseURL(workInterfaceURL).withPaths("WorkInterfaceServlet").build(); + URLBuilder requestURL = URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()) + .withTestName(testname); + + Properties props = new Properties(); + props.put("proxyURL", proxyURL.toString()); + props.put(TEST_METHOD, testname); + + String resp = runTestWithResponse(requestURL, props); + assertNotNull("Response should not be null", resp); + assertStringInResponse(testname + " failed to get correct result.", TestConstants.ComplexReturnValue, + resp.trim()); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java index 726db6ff..dec165ea 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java @@ -35,25 +35,25 @@ @SuppressWarnings("serial") @WebServlet("/DeserializeServlet") public class DeserializeServlet extends HttpServlet { - + @Resource(lookup = TestConstants.DefaultContextService) public ContextService context; - @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - try { - Object proxy = context.createContextualProxy(new TestJNDIRunnableWork(), - Runnable.class, TestWorkInterface.class, Serializable.class); - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(bout); - out.writeObject(proxy); - out.close(); - byte[] bytes = bout.toByteArray(); - ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes)); - proxy = in.readObject(); - resp.getWriter().println(proxy.toString()); - } catch (Exception e) { - throw new ServletException(e); - } - } + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + try { + Object proxy = context.createContextualProxy(new TestJNDIRunnableWork(), Runnable.class, + TestWorkInterface.class, Serializable.class); + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(bout); + out.writeObject(proxy); + out.close(); + byte[] bytes = bout.toByteArray(); + ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes)); + proxy = in.readObject(); + resp.getWriter().println(proxy.toString()); + } catch (Exception e) { + throw new ServletException(e); + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java index 6daee3f8..bc18acc1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java @@ -36,55 +36,55 @@ @SuppressWarnings("serial") @WebServlet("/ProxyCreatorServlet") public class ProxyCreatorServlet extends TestServlet { - - private static final TestLogger log = TestLogger.get(ProxyCreatorServlet.class); - + + private static final TestLogger log = TestLogger.get(ProxyCreatorServlet.class); + @Resource(lookup = TestConstants.DefaultContextService) public ContextService context; - public void testJNDIContextInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { - Object proxy = true; - String result = null; - String proxyURLString = req.getParameter("proxyURL"); - - log.info("Proxy URL from parameter", proxyURLString); - - URL url = new URL(proxyURLString); - - proxy = context.createContextualProxy(new TestJNDIRunnableWork(), - Runnable.class, TestWorkInterface.class, Serializable.class); - - Properties p = new Properties(); - p.setProperty("proxy", proxyToString(proxy)); - - result = getResponse(sendPostData(url, p)); - resp.getWriter().println(result); - } - - public void testClassloaderInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { - Object proxy = true; - String result = null; - String proxyURLString = req.getParameter("proxyURL"); - - log.info("Proxy URL from parameter", proxyURLString); - - URL url = new URL(proxyURLString); - - proxy = context.createContextualProxy(new TestClassloaderRunnableWork(), - Runnable.class, TestWorkInterface.class, Serializable.class); - - Properties p = new Properties(); - p.setProperty("proxy", proxyToString(proxy)); - - result = getResponse(sendPostData(url, p)); - resp.getWriter().println(result); - } - - private String proxyToString(Object proxy) throws IOException { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(bout); - out.writeObject(proxy); - out.close(); - return Base64.getEncoder().encodeToString(bout.toByteArray()); - } + public void testJNDIContextInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { + Object proxy = true; + String result = null; + String proxyURLString = req.getParameter("proxyURL"); + + log.info("Proxy URL from parameter", proxyURLString); + + URL url = new URL(proxyURLString); + + proxy = context.createContextualProxy(new TestJNDIRunnableWork(), Runnable.class, TestWorkInterface.class, + Serializable.class); + + Properties p = new Properties(); + p.setProperty("proxy", proxyToString(proxy)); + + result = getResponse(sendPostData(url, p)); + resp.getWriter().println(result); + } + + public void testClassloaderInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { + Object proxy = true; + String result = null; + String proxyURLString = req.getParameter("proxyURL"); + + log.info("Proxy URL from parameter", proxyURLString); + + URL url = new URL(proxyURLString); + + proxy = context.createContextualProxy(new TestClassloaderRunnableWork(), Runnable.class, + TestWorkInterface.class, Serializable.class); + + Properties p = new Properties(); + p.setProperty("proxy", proxyToString(proxy)); + + result = getResponse(sendPostData(url, p)); + resp.getWriter().println(result); + } + + private String proxyToString(Object proxy) throws IOException { + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ObjectOutputStream out = new ObjectOutputStream(bout); + out.writeObject(proxy); + out.close(); + return Base64.getEncoder().encodeToString(bout.toByteArray()); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java index c20135d0..db3fecf2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java @@ -21,14 +21,14 @@ @SuppressWarnings("serial") public class TestClassloaderRunnableWork extends BaseTestRunnableWork { - @Override - protected String work() { - try { - Thread.currentThread().getContextClassLoader().loadClass( - "ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.servlet.ProxyCreatorServlet"); - } catch (ClassNotFoundException e) { - throw new RuntimeException(e); - } - return TestConstants.ComplexReturnValue; - } + @Override + protected String work() { + try { + Thread.currentThread().getContextClassLoader().loadClass( + "ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.servlet.ProxyCreatorServlet"); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + return TestConstants.ComplexReturnValue; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestJNDIRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestJNDIRunnableWork.java index 08a0e233..6478eb60 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestJNDIRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestJNDIRunnableWork.java @@ -22,12 +22,12 @@ @SuppressWarnings("serial") public class TestJNDIRunnableWork extends BaseTestRunnableWork { - @Override - protected String work() { - try { + @Override + protected String work() { + try { return InitialContext.doLookup("java:comp/env/myMessage"); } catch (NamingException e) { throw new RuntimeException(e); } - } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestWorkInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestWorkInterface.java index f917e39f..63f108dd 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestWorkInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestWorkInterface.java @@ -19,7 +19,7 @@ import java.io.Serializable; public interface TestWorkInterface extends Runnable, Serializable { - public String doSomeWork(); + public String doSomeWork(); - public String getResult(); + public String getResult(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java index e13f30df..a7c1189c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java @@ -31,15 +31,15 @@ @WebServlet("/WorkInterfaceServlet") public class WorkInterfaceServlet extends HttpServlet { - @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - byte[] proxyAsBytes = Base64.getDecoder().decode(req.getParameter("proxy")); - ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(proxyAsBytes)); - try { - Object proxy = in.readObject(); - resp.getWriter().println(((TestWorkInterface) proxy).doSomeWork()); - } catch (Exception e) { - throw new ServletException(e); - } - } + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + byte[] proxyAsBytes = Base64.getDecoder().decode(req.getParameter("proxy")); + ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(proxyAsBytes)); + try { + Object proxy = in.readObject(); + resp.getWriter().println(((TestWorkInterface) proxy).doSomeWork()); + } catch (Exception e) { + throw new ServletException(e); + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java index e36cb9b8..b31783aa 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java @@ -42,219 +42,218 @@ import jakarta.servlet.annotation.WebServlet; import jakarta.transaction.UserTransaction; -@SuppressWarnings({"serial", "unused"}) +@SuppressWarnings({ "serial", "unused" }) @WebServlet(Constants.CONTEXT_PATH) -@DataSourceDefinition( - name = "java:comp/env/jdbc/ContextServiceDB", - className = "org.apache.derby.jdbc.EmbeddedDataSource", - databaseName = "memory:ContextServiceDB", - properties = { - "createDatabase=create" - } -) +@DataSourceDefinition(name = "java:comp/env/jdbc/ContextServiceDB", className = "org.apache.derby.jdbc.EmbeddedDataSource", databaseName = "memory:ContextServiceDB", properties = { + "createDatabase=create" }) public class TransactionServlet extends TestServlet { - private static final TestLogger log = TestLogger.get(TransactionServlet.class); - - @Resource(lookup = "java:comp/env/jdbc/ContextServiceDB") - private DataSource ds; - - @Resource(lookup = TestConstants.DefaultContextService) - private ContextService cx; - - @Resource(lookup = TestConstants.UserTransaction) - private UserTransaction ut; - - @Override - protected void before() throws RemoteException { - log.enter("before"); - - Connections.setDataSource(ds); - - try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { - try { - stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); - } catch (SQLException e) { - log.finest("Could not drop table, assume table did not exist."); - } - stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); - log.exit("before"); - } catch (Exception e) { - throw new RemoteException(e.getMessage()); - } - } - - public String testTransactionOfExecuteThreadAndCommit() throws ServletException { - + private static final TestLogger log = TestLogger.get(TransactionServlet.class); + + @Resource(lookup = "java:comp/env/jdbc/ContextServiceDB") + private DataSource ds; + + @Resource(lookup = TestConstants.DefaultContextService) + private ContextService cx; + + @Resource(lookup = TestConstants.UserTransaction) + private UserTransaction ut; + + @Override + protected void before() throws RemoteException { + log.enter("before"); + + Connections.setDataSource(ds); + + try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { + try { + stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); + } catch (SQLException e) { + log.finest("Could not drop table, assume table did not exist."); + } + stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); + log.exit("before"); + } catch (Exception e) { + throw new RemoteException(e.getMessage()); + } + } + + public String testTransactionOfExecuteThreadAndCommit() throws ServletException { + + int originCount = Counter.getCount(); + + try { + ut.begin(); + try (Connection conn = Connections.getConnection(false); + PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { + pStmt.setInt(1, 99); + pStmt.setString(2, "Type-99"); + pStmt.addBatch(); + pStmt.setInt(1, 100); + pStmt.setString(2, "Type-100"); + pStmt.addBatch(); + pStmt.executeBatch(); + + WorkInterface work = new TransactedTask(false, false, Constants.SQL_TEMPLATE_INSERT); + + Map m = new HashMap<>(); + m.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD); + + WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); + proxy.doWork(); + + ut.commit(); + + int afterTransacted = Counter.getCount(); + + return String.valueOf(afterTransacted - originCount); + } + } catch (Exception e) { + throw new ServletException(e); + } + } + + public String testTransactionOfExecuteThreadAndRollback() throws ServletException { + + int originCount = Counter.getCount(); + + try { + ut.begin(); + try (Connection conn = Connections.getConnection(false); + PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { + pStmt.setInt(1, 99); + pStmt.setString(2, "Type-99"); + pStmt.addBatch(); + pStmt.setInt(1, 100); + pStmt.setString(2, "Type-100"); + pStmt.addBatch(); + pStmt.executeBatch(); + + WorkInterface work = new TransactedTask(false, false, Constants.SQL_TEMPLATE_INSERT); + + Map m = new HashMap<>(); + m.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD); + + WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); + proxy.doWork(); + + ut.rollback(); + + int afterTransacted = Counter.getCount(); + + return String.valueOf(afterTransacted - originCount); + } + } catch (Exception e) { + throw new ServletException(e); + } + } + + public String testSuspendAndCommit() throws ServletException { + int originCount = Counter.getCount(); try { ut.begin(); - try (Connection conn = Connections.getConnection(false); PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { - pStmt.setInt(1, 99); - pStmt.setString(2, "Type-99"); - pStmt.addBatch(); - pStmt.setInt(1, 100); - pStmt.setString(2, "Type-100"); - pStmt.addBatch(); - pStmt.executeBatch(); - - WorkInterface work = new TransactedTask(false, false, Constants.SQL_TEMPLATE_INSERT); - - Map m = new HashMap<>(); - m.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD); - - WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); - proxy.doWork(); - - ut.commit(); - - int afterTransacted = Counter.getCount(); - - return String.valueOf(afterTransacted - originCount); - } - } catch (Exception e) { - throw new ServletException(e); - } - } - - public String testTransactionOfExecuteThreadAndRollback() throws ServletException { - - int originCount = Counter.getCount(); - - try { - ut.begin(); - try ( Connection conn = Connections.getConnection(false); PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { - pStmt.setInt(1, 99); - pStmt.setString(2, "Type-99"); - pStmt.addBatch(); - pStmt.setInt(1, 100); - pStmt.setString(2, "Type-100"); - pStmt.addBatch(); - pStmt.executeBatch(); - - WorkInterface work = new TransactedTask(false, false, Constants.SQL_TEMPLATE_INSERT); - - Map m = new HashMap<>(); - m.put(ManagedTask.TRANSACTION, ManagedTask.USE_TRANSACTION_OF_EXECUTION_THREAD); - - WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); - proxy.doWork(); - - ut.rollback(); - - int afterTransacted = Counter.getCount(); - - return String.valueOf(afterTransacted - originCount); - } + try (Connection conn = Connections.getConnection(false); + PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { + + pStmt.setInt(1, 99); + pStmt.setString(2, "Type-99"); + pStmt.addBatch(); + pStmt.setInt(1, 100); + pStmt.setString(2, "Type-100"); + pStmt.addBatch(); + pStmt.executeBatch(); + + WorkInterface work = new TransactedTask(true, true, Constants.SQL_TEMPLATE_INSERT); + + Map m = new HashMap<>(); + m.put(ManagedTask.TRANSACTION, ManagedTask.SUSPEND); + + WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); + proxy.doWork(); + + ut.rollback(); + + int afterTransacted = Counter.getCount(); + + return String.valueOf(afterTransacted - originCount); + } } catch (Exception e) { throw new ServletException(e); } - } - - public String testSuspendAndCommit() throws ServletException { - - int originCount = Counter.getCount(); - - try { - ut.begin(); - try (Connection conn = Connections.getConnection(false); PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { - - pStmt.setInt(1, 99); - pStmt.setString(2, "Type-99"); - pStmt.addBatch(); - pStmt.setInt(1, 100); - pStmt.setString(2, "Type-100"); - pStmt.addBatch(); - pStmt.executeBatch(); - - WorkInterface work = new TransactedTask(true, true, Constants.SQL_TEMPLATE_INSERT); - - Map m = new HashMap<>(); - m.put(ManagedTask.TRANSACTION, ManagedTask.SUSPEND); - - WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); - proxy.doWork(); - - ut.rollback(); - - int afterTransacted = Counter.getCount(); - - return String.valueOf(afterTransacted - originCount); - } + + } + + public String testSuspendAndRollback() throws ServletException { + + int originCount = Counter.getCount(); + + try { + ut.begin(); + + try (Connection conn = Connections.getConnection(false); + PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { + pStmt.setInt(1, 99); + pStmt.setString(2, "Type-99"); + pStmt.addBatch(); + pStmt.setInt(1, 100); + pStmt.setString(2, "Type-100"); + pStmt.addBatch(); + pStmt.executeBatch(); + + WorkInterface work = new TransactedTask(false, true, Constants.SQL_TEMPLATE_INSERT); + + Map m = new HashMap<>(); + m.put(ManagedTask.TRANSACTION, ManagedTask.SUSPEND); + + WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); + proxy.doWork(); + + ut.commit(); + + int afterTransacted = Counter.getCount(); + + return String.valueOf(afterTransacted - originCount); + } } catch (Exception e) { throw new ServletException(e); } - - } - - public String testSuspendAndRollback() throws ServletException { - - int originCount = Counter.getCount(); - - try { - ut.begin(); - - try (Connection conn = Connections.getConnection(false); PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { - pStmt.setInt(1, 99); - pStmt.setString(2, "Type-99"); - pStmt.addBatch(); - pStmt.setInt(1, 100); - pStmt.setString(2, "Type-100"); - pStmt.addBatch(); - pStmt.executeBatch(); - - WorkInterface work = new TransactedTask(false, true, Constants.SQL_TEMPLATE_INSERT); - - Map m = new HashMap<>(); - m.put(ManagedTask.TRANSACTION, ManagedTask.SUSPEND); - - WorkInterface proxy = cx.createContextualProxy(work, m, WorkInterface.class); - proxy.doWork(); - - ut.commit(); - - int afterTransacted = Counter.getCount(); - - return String.valueOf(afterTransacted - originCount); - } + + } + + public String testDefaultAndCommit() throws ServletException { + + int originCount = Counter.getCount(); + + try { + ut.begin(); + + try (Connection conn = Connections.getConnection(false); + PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { + + pStmt.setInt(1, 99); + pStmt.setString(2, "Type-99"); + pStmt.addBatch(); + pStmt.setInt(1, 100); + pStmt.setString(2, "Type-100"); + pStmt.addBatch(); + pStmt.executeBatch(); + + WorkInterface work = new TransactedTask(true, true, Constants.SQL_TEMPLATE_INSERT); + + WorkInterface proxy = cx.createContextualProxy(work, WorkInterface.class); + proxy.doWork(); + + ut.rollback(); + + int afterTransacted = Counter.getCount(); + + return String.valueOf(afterTransacted - originCount); + } } catch (Exception e) { throw new ServletException(e); } - - } - - public String testDefaultAndCommit() throws ServletException { - - int originCount = Counter.getCount(); - - try { - ut.begin(); - - try (Connection conn = Connections.getConnection(false); PreparedStatement pStmt = conn.prepareStatement(Constants.SQL_TEMPLATE_INSERT);) { - - pStmt.setInt(1, 99); - pStmt.setString(2, "Type-99"); - pStmt.addBatch(); - pStmt.setInt(1, 100); - pStmt.setString(2, "Type-100"); - pStmt.addBatch(); - pStmt.executeBatch(); - - WorkInterface work = new TransactedTask(true, true, Constants.SQL_TEMPLATE_INSERT); - - WorkInterface proxy = cx.createContextualProxy(work, WorkInterface.class); - proxy.doWork(); - - ut.rollback(); - - int afterTransacted = Counter.getCount(); - - return String.valueOf(afterTransacted - originCount); - } - } catch (Exception e) { - throw new ServletException(e); - } - - } + + } } 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 acfb4a8b..ec1893ff 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 @@ -31,7 +31,8 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to annotation configuration +@Web +@RunAsClient // Requires client testing due to annotation configuration @Common({ PACKAGE.TRANSACTION }) public class TransactionTests extends TestClient { @@ -40,8 +41,7 @@ public class TransactionTests extends TestClient { @Deployment(name = "TransactionTests") public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, TransactionTests.class.getPackage()); + return ShrinkWrap.create(WebArchive.class).addPackages(true, TransactionTests.class.getPackage()); } @Override 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 db08a6a9..63fcfe22 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 @@ -53,7 +53,7 @@ public class InheritedAPITests { public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class); } - + @Resource(lookup = TestConstants.DefaultManagedExecutorService) public ManagedExecutorService executor; @@ -78,7 +78,7 @@ public static WebArchive createDeployment() { public void testExecute() { try { executor.execute(new CounterRunnableTask()); - StaticCounter.waitTill(1); + StaticCounter.waitTill(1); } finally { StaticCounter.reset(); } @@ -114,7 +114,7 @@ public void testInvokeAny() { } catch (Exception e) { throw new RuntimeException(e); } - + assertThrows(TimeoutException.class, () -> { List> taskList = new ArrayList<>(); taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); @@ -153,7 +153,8 @@ public void testInvokeAll() { List> taskList = new ArrayList<>(); taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - List> resultList = executor.invokeAll(taskList, TestConstants.PollInterval.getSeconds(),TimeUnit.SECONDS); + List> resultList = executor.invokeAll(taskList, TestConstants.PollInterval.getSeconds(), + TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureThrowsException(each, CancellationException.class); } 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 4e7ca329..02aab1ef 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 @@ -26,79 +26,78 @@ @Web public class ForbiddenAPIEJBTests { - - @Deployment(name="ForbiddenAPITests") - public static JavaArchive createDeployment() { - return ShrinkWrap.create(JavaArchive.class) - .addPackages(true, ForbiddenAPIEJBTests.class.getPackage()); - } - @EJB - private TestEjbInterface testEjb; + @Deployment(name = "ForbiddenAPITests") + public static JavaArchive createDeployment() { + return ShrinkWrap.create(JavaArchive.class).addPackages(true, ForbiddenAPIEJBTests.class.getPackage()); + } - /* - * @testName: testAwaitTermination - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.1; - * - * @test_Strategy: - */ - @Test - public void testAwaitTermination() { - testEjb.testAwaitTermination(); - } + @EJB + private TestEjbInterface testEjb; - /* - * @testName: testIsShutdown - * - * @assertion_ids: - * - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.2; - * - * @test_Strategy: - */ - @Test - public void testIsShutdown() { - testEjb.testIsShutdown(); - } + /* + * @testName: testAwaitTermination + * + * @assertion_ids: + * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.1; + * + * @test_Strategy: + */ + @Test + public void testAwaitTermination() { + testEjb.testAwaitTermination(); + } - /* - * @testName: testIsTerminated - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.3; - * - * @test_Strategy: - */ - @Test - public void testIsTerminated() { - testEjb.testIsTerminated(); - } + /* + * @testName: testIsShutdown + * + * @assertion_ids: + * + * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.2; + * + * @test_Strategy: + */ + @Test + public void testIsShutdown() { + testEjb.testIsShutdown(); + } - /* - * @testName: testShutdown - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.4; - * - * @test_Strategy: - */ - @Test - public void testShutdown() { - testEjb.testShutdown(); - } + /* + * @testName: testIsTerminated + * + * @assertion_ids: + * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.3; + * + * @test_Strategy: + */ + @Test + public void testIsTerminated() { + testEjb.testIsTerminated(); + } - /* - * @testName: testShutdownNow - * - * @assertion_ids: - * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.5; - * - * @test_Strategy: - */ - @Test - public void testShutdownNow() { - testEjb.testShutdownNow(); - } + /* + * @testName: testShutdown + * + * @assertion_ids: + * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.4; + * + * @test_Strategy: + */ + @Test + public void testShutdown() { + testEjb.testShutdown(); + } + + /* + * @testName: testShutdownNow + * + * @assertion_ids: + * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.5; + * + * @test_Strategy: + */ + @Test + public void testShutdownNow() { + testEjb.testShutdownNow(); + } } 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 156fad61..a8ce8d1b 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 @@ -27,62 +27,62 @@ @Stateless public class TestEjb implements TestEjbInterface { - - private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - + + private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; + @Resource(lookup = TestConstants.DefaultManagedExecutorService) public ManagedExecutorService executor; - public void testAwaitTermination() { - try { - executor.awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - fail(e.toString()); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } - - public void testIsShutdown() { - try { - executor.isShutdown(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } - - public void testIsTerminated() { - try { - executor.isTerminated(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } - - public void testShutdown() { - try { - executor.shutdown(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } - - public void testShutdownNow() { - try { - executor.shutdownNow(); - } catch (IllegalStateException e) { - return; - } - - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } + public void testAwaitTermination() { + try { + executor.awaitTermination(10, TimeUnit.SECONDS); + } catch (InterruptedException e) { + fail(e.toString()); + } catch (IllegalStateException e) { + return; + } + + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } + + public void testIsShutdown() { + try { + executor.isShutdown(); + } catch (IllegalStateException e) { + return; + } + + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } + + public void testIsTerminated() { + try { + executor.isTerminated(); + } catch (IllegalStateException e) { + return; + } + + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } + + public void testShutdown() { + try { + executor.shutdown(); + } catch (IllegalStateException e) { + return; + } + + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } + + public void testShutdownNow() { + try { + executor.shutdownNow(); + } catch (IllegalStateException e) { + return; + } + + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjbInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjbInterface.java index 2b027911..3be817ae 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjbInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/managed/forbiddenapi/TestEjbInterface.java @@ -18,13 +18,13 @@ public interface TestEjbInterface { - public void testAwaitTermination(); + public void testAwaitTermination(); - public void testIsShutdown(); + public void testIsShutdown(); - public void testIsTerminated(); + public void testIsTerminated(); - public void testShutdown(); + public void testShutdown(); - public void testShutdownNow(); + public void testShutdownNow(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java index 84ce7cfb..afa6ae47 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java @@ -61,8 +61,8 @@ public CompletableFuture waitAndGetIntContext(Semaphore started, CountD CompletableFuture future = Asynchronous.Result.getFuture(); try { while (!future.isDone() && !blocker.await(300, TimeUnit.MILLISECONDS)) - System.out.println(Thread.currentThread().getName() + - ": waitAndGetIntContext awaiting signal from caller"); + System.out.println( + Thread.currentThread().getName() + ": waitAndGetIntContext awaiting signal from caller"); future.complete(IntContext.get()); } catch (Exception x) { future.completeExceptionally(x); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java index 5cd79b02..796a585a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java @@ -26,21 +26,16 @@ * ContextServiceDefinitions are defined under * {@link ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionBean} */ -@ManagedExecutorDefinition(name = "java:app/concurrent/EJBExecutorA", - context = "java:app/concurrent/EJBContextA", - maxAsync = 2, - hungTaskThreshold = 300000) +@ManagedExecutorDefinition(name = "java:app/concurrent/EJBExecutorA", context = "java:app/concurrent/EJBContextA", maxAsync = 2, hungTaskThreshold = 300000) // Reuse the same names as defined in the web module. -@ManagedExecutorDefinition(name = "java:module/concurrent/ExecutorB", - context = "java:module/concurrent/ContextB", - maxAsync = 1) +@ManagedExecutorDefinition(name = "java:module/concurrent/ExecutorB", context = "java:module/concurrent/ContextB", maxAsync = 1) @ManagedExecutorDefinition(name = "java:comp/concurrent/EJBExecutorC") @Local(ManagedExecutorDefinitionInterface.class) @Stateless public class ManagedExecutorDefinitionBean implements ManagedExecutorDefinitionInterface { - - @Override - public Object doLookup(String name) throws NamingException { - return InitialContext.doLookup(name); - } + + @Override + public Object doLookup(String name) throws NamingException { + return InitialContext.doLookup(name); + } } 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 adba6e90..385743e5 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 @@ -39,109 +39,107 @@ import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionServlet; import jakarta.enterprise.concurrent.spi.ThreadContextProvider; -@Full @RunAsClient //Requires client testing due to multiple servlets and annotation configuration -public class ManagedExecutorDefinitionFullTests extends TestClient{ - - @ArquillianResource(ManagedExecutorDefinitionServlet.class) - URL baseURL; - - @ArquillianResource(ManagedExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; - - @Deployment(name="ManagedExecutorDefinitionTests") - public static EnterpriseArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedExecutorDefinitionTests_web.war") - .addPackages(true, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) - .addClasses( - AppBean.class, - ManagedExecutorDefinitionServlet.class, - ManagedExecutorDefinitionOnEJBServlet.class, - ContextServiceDefinitionServlet.class) - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); - - JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ManagedExecutorDefinitionTests_ejb.jar") - .addPackages(false, ManagedExecutorDefinitionFullTests.class.getPackage()) - .deleteClasses( - AppBean.class, - ManagedExecutorDefinitionWebBean.class, - ManagedExecutorDefinitionServlet.class, - ManagedExecutorDefinitionOnEJBServlet.class, - ContextServiceDefinitionServlet.class) - .addClasses( - ContextServiceDefinitionInterface.class, - ContextServiceDefinitionBean.class); - //TODO document how users can dynamically inject vendor specific deployment descriptors into this archive - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ManagedExecutorDefinitionTests.ear").addAsModules(war, jar); - - return ear; - } - +@Full +@RunAsClient // Requires client testing due to multiple servlets and annotation configuration +public class ManagedExecutorDefinitionFullTests extends TestClient { + + @ArquillianResource(ManagedExecutorDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedExecutorDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name = "ManagedExecutorDefinitionTests") + public static EnterpriseArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedExecutorDefinitionTests_web.war") + .addPackages(true, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) + .addClasses(AppBean.class, ManagedExecutorDefinitionServlet.class, + ManagedExecutorDefinitionOnEJBServlet.class, ContextServiceDefinitionServlet.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()); + + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ManagedExecutorDefinitionTests_ejb.jar") + .addPackages(false, ManagedExecutorDefinitionFullTests.class.getPackage()) + .deleteClasses(AppBean.class, ManagedExecutorDefinitionWebBean.class, + ManagedExecutorDefinitionServlet.class, ManagedExecutorDefinitionOnEJBServlet.class, + ContextServiceDefinitionServlet.class) + .addClasses(ContextServiceDefinitionInterface.class, ContextServiceDefinitionBean.class); + // TODO document how users can dynamically inject vendor specific deployment + // descriptors into this archive + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ManagedExecutorDefinitionTests.ear") + .addAsModules(war, jar); + + return ear; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "ManagedExecutorDefinitionServlet"; - } - - @Test + + @Override + protected String getServletPath() { + return "ManagedExecutorDefinitionServlet"; + } + + @Test public void testAsyncCompletionStage() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodReturnsCompletableFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodReturnsCompletionStage() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodVoidReturnType() { - runTest(baseURL, testname); + runTest(baseURL, testname); } // TCK Accepted Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + @Disabled public void testCompletedFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testCopyCompletableFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testCopyCompletableFutureEJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testIncompleteFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testIncompleteFutureEJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedExecutorDefinitionAllAttributes() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testManagedExecutorDefinitionDefaults() { - runTest(baseURL, testname); + runTest(baseURL, testname); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionInterface.java index 516e88bc..aff4ed68 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionInterface.java @@ -19,6 +19,6 @@ public interface ManagedExecutorDefinitionInterface { - Object doLookup(String name) throws NamingException; + Object doLookup(String name) throws NamingException; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java index efe363d4..85007187 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java @@ -38,115 +38,120 @@ @WebServlet("/ManagedExecutorDefinitionOnEJBServlet") public class ManagedExecutorDefinitionOnEJBServlet extends TestServlet { - private static final long serialVersionUID = 1L; - private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); - - @Inject AppBean appBean; - - @Resource - UserTransaction tx; - - @EJB - private ManagedExecutorDefinitionInterface managedExecutorDefinitionBean; - - //Needed to initialize the ContextServiceDefinitions - @EJB - private ContextServiceDefinitionInterface contextServiceDefinitionBean; - - /** - * 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 testIncompleteFutureEJB() throws Throwable { - ManagedExecutorService executor = InitialContext.doLookup("java:app/concurrent/EJBExecutorA"); - - try { - IntContext.set(181); - StringContext.set("testIncompleteFutureEJB-1"); - - CompletableFuture stage1 = executor.newIncompleteFuture(); - - IntContext.set(182); - - CompletableFuture stage2a = stage1.thenApplyAsync(sep -> { - int i = IntContext.get(); - return "IntContext " + (i == 182 ? "propagated" : "incorrect:" + i) + sep; - }); - - CompletableFuture stage2b = stage1.thenApply(sep -> { - String s = StringContext.get(); - return "StringContext " + ("".equals(s) ? "cleared" : "incorrect:" + s) + sep; - }); - - IntContext.set(183); - - CompletableFuture stage3 = stage2a.thenCombineAsync(stage2b, (status1, status2) -> { - try { - ManagedExecutorService mes = InitialContext.doLookup("java:app/concurrent/EJBExecutorA"); - return status1 + status2 + "Application context " + (mes == null ? "incorrect" : "propagated"); - } catch (NamingException x) { - throw new CompletionException(x); - } - }); - - stage1.complete(";"); - - String result = stage3.join(); - assertEquals(result, "IntContext propagated;StringContext cleared;Application context propagated", - "Application context and IntContext must be propagated and StringContext must be cleared " + - "per ManagedExecutorDefinition and ContextServiceDefinition config."); - } finally { - IntContext.set(0); - StringContext.set(null); - } - } - - /** - * ManagedExecutorService can create a contextualized copy of an unmanaged CompletableFuture. - */ - public void testCopyCompletableFutureEJB() throws Throwable { - ManagedExecutorService executor = (ManagedExecutorService) managedExecutorDefinitionBean.doLookup("java:module/concurrent/ExecutorB"); - - IntContext.set(271); - StringContext.set("testCopyCompletableFutureEJB-1"); - - try { - CompletableFuture stage1unmanaged = new CompletableFuture(); - CompletableFuture stage1copy = executor.copy(stage1unmanaged); - CompletableFuture permanentlyIncompleteStage = new CompletableFuture(); - - StringContext.set("testCopyCompletableFutureEJB-2"); - - CompletableFuture stage2 = stage1copy.applyToEitherAsync(permanentlyIncompleteStage, sep -> { - String s = StringContext.get(); - return "StringContext " + ("testCopyCompletableFutureEJB-2".equals(s) ? "propagated" : "incorrect:" + s) - + sep; - }); - - StringContext.set("testCopyCompletableFutureEJB-3"); - - CompletableFuture stage3 = stage2.handleAsync((result, failure) -> { - if (failure == null) { - int i = IntContext.get(); - return result + "IntContext " + (i == 0 ? "unchanged" : "incorrect:" + i); - } else { - throw (AssertionError) new AssertionError().initCause(failure); - } - }); - - assertTrue(stage1unmanaged.complete(';'), - "Completation stage that is supplied to copy must not be modified by the " + - "ManagedExecutorService."); - - String result = stage3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(result, "StringContext propagated;IntContext unchanged", - "StringContext must be propagated and Application context and IntContext must be left " + - "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); - } finally { - IntContext.set(0);; - StringContext.set(null); - } - } + private static final long serialVersionUID = 1L; + private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); + + @Inject + AppBean appBean; + + @Resource + UserTransaction tx; + + @EJB + private ManagedExecutorDefinitionInterface managedExecutorDefinitionBean; + + // Needed to initialize the ContextServiceDefinitions + @EJB + private ContextServiceDefinitionInterface contextServiceDefinitionBean; + + /** + * 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 testIncompleteFutureEJB() throws Throwable { + ManagedExecutorService executor = InitialContext.doLookup("java:app/concurrent/EJBExecutorA"); + + try { + IntContext.set(181); + StringContext.set("testIncompleteFutureEJB-1"); + + CompletableFuture stage1 = executor.newIncompleteFuture(); + + IntContext.set(182); + + CompletableFuture stage2a = stage1.thenApplyAsync(sep -> { + int i = IntContext.get(); + return "IntContext " + (i == 182 ? "propagated" : "incorrect:" + i) + sep; + }); + + CompletableFuture stage2b = stage1.thenApply(sep -> { + String s = StringContext.get(); + return "StringContext " + ("".equals(s) ? "cleared" : "incorrect:" + s) + sep; + }); + + IntContext.set(183); + + CompletableFuture stage3 = stage2a.thenCombineAsync(stage2b, (status1, status2) -> { + try { + ManagedExecutorService mes = InitialContext.doLookup("java:app/concurrent/EJBExecutorA"); + return status1 + status2 + "Application context " + (mes == null ? "incorrect" : "propagated"); + } catch (NamingException x) { + throw new CompletionException(x); + } + }); + + stage1.complete(";"); + + String result = stage3.join(); + assertEquals(result, "IntContext propagated;StringContext cleared;Application context propagated", + "Application context and IntContext must be propagated and StringContext must be cleared " + + "per ManagedExecutorDefinition and ContextServiceDefinition config."); + } finally { + IntContext.set(0); + StringContext.set(null); + } + } + + /** + * ManagedExecutorService can create a contextualized copy of an unmanaged + * CompletableFuture. + */ + public void testCopyCompletableFutureEJB() throws Throwable { + ManagedExecutorService executor = (ManagedExecutorService) managedExecutorDefinitionBean + .doLookup("java:module/concurrent/ExecutorB"); + + IntContext.set(271); + StringContext.set("testCopyCompletableFutureEJB-1"); + + try { + CompletableFuture stage1unmanaged = new CompletableFuture(); + CompletableFuture stage1copy = executor.copy(stage1unmanaged); + CompletableFuture permanentlyIncompleteStage = new CompletableFuture(); + + StringContext.set("testCopyCompletableFutureEJB-2"); + + CompletableFuture stage2 = stage1copy.applyToEitherAsync(permanentlyIncompleteStage, sep -> { + String s = StringContext.get(); + return "StringContext " + ("testCopyCompletableFutureEJB-2".equals(s) ? "propagated" : "incorrect:" + s) + + sep; + }); + + StringContext.set("testCopyCompletableFutureEJB-3"); + + CompletableFuture stage3 = stage2.handleAsync((result, failure) -> { + if (failure == null) { + int i = IntContext.get(); + return result + "IntContext " + (i == 0 ? "unchanged" : "incorrect:" + i); + } else { + throw (AssertionError) new AssertionError().initCause(failure); + } + }); + + assertTrue(stage1unmanaged.complete(';'), + "Completation stage that is supplied to copy must not be modified by the " + + "ManagedExecutorService."); + + String result = stage3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertEquals(result, "StringContext propagated;IntContext unchanged", + "StringContext must be propagated and Application context and IntContext must be left " + + "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); + } finally { + IntContext.set(0); + ; + StringContext.set(null); + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java index 00770377..33448a9a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java @@ -47,35 +47,31 @@ import jakarta.transaction.UserTransaction; /** - * @ContextServiceDefinitions are defined under {@link ContextServiceDefinitionServlet} + * @ContextServiceDefinitions are defined under + * {@link ContextServiceDefinitionServlet} */ -@ManagedExecutorDefinition(name = "java:app/concurrent/ExecutorA", - context = "java:app/concurrent/ContextA", - maxAsync = 2, - hungTaskThreshold = 300000) -@ManagedExecutorDefinition(name = "java:module/concurrent/ExecutorB", - context = "java:module/concurrent/ContextB", - maxAsync = 1) +@ManagedExecutorDefinition(name = "java:app/concurrent/ExecutorA", context = "java:app/concurrent/ContextA", maxAsync = 2, hungTaskThreshold = 300000) +@ManagedExecutorDefinition(name = "java:module/concurrent/ExecutorB", context = "java:module/concurrent/ContextB", maxAsync = 1) @ManagedExecutorDefinition(name = "java:comp/concurrent/ExecutorC") @WebServlet("/ManagedExecutorDefinitionServlet") public class ManagedExecutorDefinitionServlet extends TestServlet { private static final long serialVersionUID = 1L; private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); - @Inject AppBean appBean; + @Inject + AppBean appBean; @Resource UserTransaction tx; - /** - * 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. + * 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() throws Throwable { - + ManagedExecutorService executor = InitialContext.doLookup("java:app/concurrent/ExecutorA"); try { @@ -91,7 +87,7 @@ public void testAsyncCompletionStage() throws Throwable { } }).thenApplyAsync(status -> { int i = IntContext.get(); - return status + ";IntContext " + (i == 10 ? "propagated" : "incorrect:" + i); + return status + ";IntContext " + (i == 10 ? "propagated" : "incorrect:" + i); }).thenCombine(CompletableFuture.completedFuture(";"), (status, sep) -> { String s = StringContext.get(); return status + sep + "StringContext " + ("".equals(s) ? "cleared" : "incorrect:" + s); @@ -100,18 +96,20 @@ public void testAsyncCompletionStage() throws Throwable { IntContext.set(25); String result = future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(result, "Application context propagated;IntContext propagated;StringContext cleared", - "Application context and IntContext must be propagated and StringContext must be cleared " + - "per ManagedExecutorDefinition and ContextServiceDefinition config."); + assertEquals(result, "Application context propagated;IntContext propagated;StringContext cleared", + "Application context and IntContext must be propagated and StringContext must be cleared " + + "per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { - IntContext.set(0);; + IntContext.set(0); + ; StringContext.set(null); } } /** - * Asynchronous method that returns CompletableFuture runs asynchronously and can run successfully to completion - * or be signaled to end prematurely (if so implemented) by completing its CompletableFuture. + * Asynchronous method that returns CompletableFuture runs asynchronously and + * can run successfully to completion or be signaled to end prematurely (if so + * implemented) by completing its CompletableFuture. */ public void testAsynchronousMethodReturnsCompletableFuture() throws Exception { CountDownLatch blocker = new CountDownLatch(1); @@ -128,55 +126,57 @@ public void testAsynchronousMethodReturnsCompletableFuture() throws Exception { future3 = appBean.waitAndGetIntContext(invocationsStarted, blocker); future4 = appBean.waitAndGetIntContext(invocationsStarted, blocker); - assertEquals(invocationsStarted.tryAcquire(2, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, - "Must be able to run 2 asynchronous methods in parallel."); + assertEquals(invocationsStarted.tryAcquire(2, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, + "Must be able to run 2 asynchronous methods in parallel."); - assertEquals(future1.complete(1000), true, - "Must be able to complete the CompletableFuture of an asynchronous method."); + assertEquals(future1.complete(1000), true, + "Must be able to complete the CompletableFuture of an asynchronous method."); - assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, - "Must be able to run another asynchronous method in parallel after forcibly " + - "completing the first."); + assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, + "Must be able to run another asynchronous method in parallel after forcibly " + + "completing the first."); - assertEquals(future2.completeExceptionally(new CloneNotSupportedException( - "Not a real error. This is only testing exceptional completion.")), true, - "Must be able to complete the CompletableFuture of an asynchronous method exceptionally."); + assertEquals( + future2.completeExceptionally(new CloneNotSupportedException( + "Not a real error. This is only testing exceptional completion.")), + true, "Must be able to complete the CompletableFuture of an asynchronous method exceptionally."); - assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, - "Must be able to run another asynchronous method in parallel after forcibly " + - "completing the second exceptionally."); + assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, + "Must be able to run another asynchronous method in parallel after forcibly " + + "completing the second exceptionally."); - assertEquals(invocationsStarted.tryAcquire(1, 1, TimeUnit.SECONDS), false, - "Must not be able to run another asynchronous method in parallel."); + assertEquals(invocationsStarted.tryAcquire(1, 1, TimeUnit.SECONDS), false, + "Must not be able to run another asynchronous method in parallel."); } finally { IntContext.set(0); blocker.countDown(); } - assertEquals(future1.getNow(1234), Integer.valueOf(1000), - "Asynchronous method's CompletableFuture must report the value with which it was " + - "forcibly completed."); + assertEquals(future1.getNow(1234), Integer.valueOf(1000), + "Asynchronous method's CompletableFuture must report the value with which it was " + + "forcibly completed."); try { Integer result = future2.join(); - throw new AssertionError("Asynchronous method's CompletableFuture must not return result " + result + - "after being forcibly completed with an exception."); + throw new AssertionError("Asynchronous method's CompletableFuture must not return result " + result + + "after being forcibly completed with an exception."); } catch (CompletionException x) { if (!(x.getCause() instanceof CloneNotSupportedException)) // expected due to forced exceptional completion throw x; } - assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(1215), - "Third-party context type IntContext must be propagated to asynchronous method " + - "per ManagedExecutorDefinition and ContextServiceDefinition."); + assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(1215), + "Third-party context type IntContext must be propagated to asynchronous method " + + "per ManagedExecutorDefinition and ContextServiceDefinition."); - assertEquals(future4.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(1215), - "Third-party context type IntContext must be propagated to asynchronous method " + - "per ManagedExecutorDefinition and ContextServiceDefinition."); + assertEquals(future4.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(1215), + "Third-party context type IntContext must be propagated to asynchronous method " + + "per ManagedExecutorDefinition and ContextServiceDefinition."); } /** - * Asynchronous method that returns a CompletionStage runs asynchronously on the specified executor. + * Asynchronous method that returns a CompletionStage runs asynchronously on the + * specified executor. */ public void testAsynchronousMethodReturnsCompletionStage() throws Exception { CountDownLatch blocker = new CountDownLatch(1); @@ -193,30 +193,30 @@ public void testAsynchronousMethodReturnsCompletionStage() throws Exception { StringContext.set("testAsynchronousMethodReturnsCompletionStage-2"); assertEquals(queue.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "testAsynchronousMethodReturnsCompletionStage-1", - "One of the asynchronous method invocations should run per maxAsync=1."); + "testAsynchronousMethodReturnsCompletionStage-1", + "One of the asynchronous method invocations should run per maxAsync=1."); - assertEquals(queue.poll(1, TimeUnit.SECONDS), null, - "Two asynchronous method invocations should not run at same time per maxAsync=1."); + assertEquals(queue.poll(1, TimeUnit.SECONDS), null, + "Two asynchronous method invocations should not run at same time per maxAsync=1."); stage1.thenAcceptBoth(stage2, (result1, result2) -> { if (result1.equals(result2)) queue.add(StringContext.get()); else - queue.add("Both asynchronous method invocations must have same result. Instead: " + - result1 + " and " + result2); + queue.add("Both asynchronous method invocations must have same result. Instead: " + result1 + + " and " + result2); }); } finally { StringContext.set(null); blocker.countDown(); } - assertEquals(queue.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testAsynchronousMethodReturnsCompletionStage-1", - "The other asynchronous method invocation should run after the first is no longer running."); + assertEquals(queue.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testAsynchronousMethodReturnsCompletionStage-1", + "The other asynchronous method invocation should run after the first is no longer running."); - assertEquals(queue.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testAsynchronousMethodReturnsCompletionStage-2", - "Completion stage that is created from an asynchronous method completion stage must run " + - "with the same executor and therefore propagate the same third-party context type StringContext."); + assertEquals(queue.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testAsynchronousMethodReturnsCompletionStage-2", + "Completion stage that is created from an asynchronous method completion stage must run " + + "with the same executor and therefore propagate the same third-party context type StringContext."); } /** @@ -228,14 +228,14 @@ public void testAsynchronousMethodVoidReturnType() throws Exception { String status = exchanger.exchange("WAITING", MAX_WAIT_SECONDS, TimeUnit.SECONDS); assertEquals(status, "RUNNING", - "Asynchronous method with void return type must be able to run asynchronously. " + status); + "Asynchronous method with void return type must be able to run asynchronously. " + status); } /** - * 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. + * 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() throws Throwable { ManagedExecutorService executor = InitialContext.doLookup("java:module/concurrent/ExecutorB"); @@ -250,8 +250,8 @@ public void testCompletedFuture() throws Throwable { CompletableFuture stage2 = stage1.thenAcceptAsync(jndiName -> { try { InitialContext.doLookup(jndiName); - throw new AssertionError("Application context must be left unchanged per " + - "ManagedExecutorDefinition and ContextServiceDefinition config."); + throw new AssertionError("Application context must be left unchanged per " + + "ManagedExecutorDefinition and ContextServiceDefinition config."); } catch (NamingException x) { throw new CompletionException(x); // expected because Application context is unchanged } @@ -263,11 +263,12 @@ public void testCompletedFuture() throws Throwable { int i = IntContext.get(); String s = StringContext.get(); - // CompletionException with chained NamingException is expected due to Application context + // CompletionException with chained NamingException is expected due to + // Application context // remaining unchanged (absent) on the async completion stage action if (failure instanceof CompletionException && failure.getCause() instanceof NamingException) - return "StringContext " + ("testCompletedFuture-3".equals(s) ? "propagated" : "incorrect:" + s) + - ";IntContext " + (i == 0 ? "unchanged" : "incorrect:" + i); + return "StringContext " + ("testCompletedFuture-3".equals(s) ? "propagated" : "incorrect:" + s) + + ";IntContext " + (i == 0 ? "unchanged" : "incorrect:" + i); else if (failure == null) throw new AssertionError("Missing Throwable argument to handleAsync"); else @@ -277,17 +278,19 @@ else if (failure == null) StringContext.set("testCompletedFuture-4"); String result = stage3.join(); - assertEquals(result, "StringContext propagated;IntContext unchanged", - "StringContext must be propagated and Application context and IntContext must be left " + - "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); + assertEquals(result, "StringContext propagated;IntContext unchanged", + "StringContext must be propagated and Application context and IntContext must be left " + + "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { - IntContext.set(0);; + IntContext.set(0); + ; StringContext.set(null); } } /** - * ManagedExecutorService can create a contextualized copy of an unmanaged CompletableFuture. + * ManagedExecutorService can create a contextualized copy of an unmanaged + * CompletableFuture. */ public void testCopyCompletableFuture() throws Throwable { ManagedExecutorService executor = InitialContext.doLookup("java:module/concurrent/ExecutorB"); @@ -304,7 +307,7 @@ public void testCopyCompletableFuture() throws Throwable { CompletableFuture stage2 = stage1copy.applyToEitherAsync(permanentlyIncompleteStage, sep -> { String s = StringContext.get(); return "StringContext " + ("testCopyCompletableFuture-2".equals(s) ? "propagated" : "incorrect:" + s) - + sep; + + sep; }); StringContext.set("testCopyCompletableFuture-3"); @@ -319,24 +322,26 @@ public void testCopyCompletableFuture() throws Throwable { }); assertTrue(stage1unmanaged.complete(';'), - "Completation stage that is supplied to copy must not be modified by the " + - "ManagedExecutorService."); + "Completation stage that is supplied to copy must not be modified by the " + + "ManagedExecutorService."); String result = stage3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(result, "StringContext propagated;IntContext unchanged", - "StringContext must be propagated and Application context and IntContext must be left " + - "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); + assertEquals(result, "StringContext propagated;IntContext unchanged", + "StringContext must be propagated and Application context and IntContext must be left " + + "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { - IntContext.set(0);; + IntContext.set(0); + ; StringContext.set(null); } } /** - * 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. + * 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() throws Throwable { ManagedExecutorService executor = InitialContext.doLookup("java:app/concurrent/ExecutorA"); @@ -367,15 +372,15 @@ public void testIncompleteFuture() throws Throwable { return status1 + status2 + "Application context " + (mes == null ? "incorrect" : "propagated"); } catch (NamingException x) { throw new CompletionException(x); - } + } }); stage1.complete(";"); String result = stage3.join(); - assertEquals(result, "IntContext propagated;StringContext cleared;Application context propagated", - "Application context and IntContext must be propagated and StringContext must be cleared " + - "per ManagedExecutorDefinition and ContextServiceDefinition config."); + assertEquals(result, "IntContext propagated;StringContext cleared;Application context propagated", + "Application context and IntContext must be propagated and StringContext must be cleared " + + "per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); StringContext.set(null); @@ -383,7 +388,8 @@ public void testIncompleteFuture() throws Throwable { } /** - * A ManagedExecutorDefinition with all attributes configured enforces maxAsync and propagates context. + * A ManagedExecutorDefinition with all attributes configured enforces maxAsync + * and propagates context. */ public void testManagedExecutorDefinitionAllAttributes() throws Throwable { ManagedExecutorService executor = InitialContext.doLookup("java:app/concurrent/ExecutorA"); @@ -407,26 +413,27 @@ public void testManagedExecutorDefinitionAllAttributes() throws Throwable { executor.submit(task); executor.execute(task); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(22), - "ManagedExecutorService with maxAsync=2 must be able to run an async task."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(22), + "ManagedExecutorService with maxAsync=2 must be able to run an async task."); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(22), - "ManagedExecutorService with maxAsync=2 must be able to run 2 async tasks concurrently."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(22), + "ManagedExecutorService with maxAsync=2 must be able to run 2 async tasks concurrently."); - assertEquals(results.poll(1, TimeUnit.SECONDS), null, - "ManagedExecutorService with maxAsync=2 must not run 3 async tasks concurrently."); + assertEquals(results.poll(1, TimeUnit.SECONDS), null, + "ManagedExecutorService with maxAsync=2 must not run 3 async tasks concurrently."); } finally { IntContext.set(0); blocker.countDown(); } - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(22), - "ManagedExecutorService with maxAsync=2 must be able to run 3rd task after 1st completes."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(22), + "ManagedExecutorService with maxAsync=2 must be able to run 3rd task after 1st completes."); } /** - * A ManagedExecutorDefinition with minimal attributes can run multiple async tasks concurrently - * and uses java:comp/DefaultContextService to determine context propagation and clearing. + * A ManagedExecutorDefinition with minimal attributes can run multiple async + * tasks concurrently and uses java:comp/DefaultContextService to determine + * context propagation and clearing. */ public void testManagedExecutorDefinitionDefaults() throws Throwable { ManagedExecutorService executor = InitialContext.doLookup("java:comp/concurrent/ExecutorC"); @@ -461,28 +468,28 @@ public void testManagedExecutorDefinitionDefaults() throws Throwable { Future txFuture = executor.submit(txCallable); CompletableFuture lookupFuture1 = executor.completedFuture("java:comp/concurrent/ExecutorC") - .thenApplyAsync(lookupFunction); + .thenApplyAsync(lookupFunction); CompletableFuture lookupFuture2 = executor.completedFuture("java:module/concurrent/ExecutorB") - .thenApplyAsync(lookupFunction); + .thenApplyAsync(lookupFunction); assertTrue(allTasksRunning.await(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "ManagedExecutorService without maxAsync must be able to run async tasks concurrently."); + "ManagedExecutorService without maxAsync must be able to run async tasks concurrently."); blocker.countDown(); int status = txFuture.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from async Callable task " + - "per java:comp/concurrent/ExecutorC configuration."); + assertEquals(status, Status.STATUS_NO_TRANSACTION, + "Transaction context must be cleared from async Callable task " + + "per java:comp/concurrent/ExecutorC configuration."); assertTrue(lookupFuture1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedExecutorService, - "Application context must be propagated to first async Function " + - "per java:comp/concurrent/ExecutorC configuration."); + "Application context must be propagated to first async Function " + + "per java:comp/concurrent/ExecutorC configuration."); assertTrue(lookupFuture2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedExecutorService, - "Application context must be propagated to second async Function " + - "per java:comp/concurrent/ExecutorC configuration."); + "Application context must be propagated to second async Function " + + "per java:comp/concurrent/ExecutorC configuration."); } finally { IntContext.set(0); blocker.countDown(); @@ -492,9 +499,9 @@ public void testManagedExecutorDefinitionDefaults() throws Throwable { try { // run inline to verify that transaction context is cleared int status = executor.getContextService().contextualCallable(txCallable).call(); - assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from inline contextual Callable " + - "per java:comp/concurrent/ExecutorC configuration."); + assertEquals(status, Status.STATUS_NO_TRANSACTION, + "Transaction context must be cleared from inline contextual Callable " + + "per java:comp/concurrent/ExecutorC configuration."); } finally { tx.rollback(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java index 8447a30e..c3f70585 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java @@ -26,17 +26,14 @@ * ContextServiceDefinitions are defined under * {@link ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionBean} */ -@ManagedExecutorDefinition(name = "java:app/concurrent/EJBExecutorA", - context = "java:app/concurrent/EJBContextA", - maxAsync = 2, - hungTaskThreshold = 300000) +@ManagedExecutorDefinition(name = "java:app/concurrent/EJBExecutorA", context = "java:app/concurrent/EJBContextA", maxAsync = 2, hungTaskThreshold = 300000) @ManagedExecutorDefinition(name = "java:comp/concurrent/EJBExecutorC") @Local(ManagedExecutorDefinitionInterface.class) @Stateless public class ManagedExecutorDefinitionWebBean implements ManagedExecutorDefinitionInterface { - - @Override - public Object doLookup(String name) throws NamingException { - return InitialContext.doLookup(name); - } + + @Override + public Object doLookup(String name) throws NamingException { + return InitialContext.doLookup(name); + } } 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 31fd0ec2..81ffdff3 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 @@ -38,95 +38,97 @@ import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionWebBean; import jakarta.enterprise.concurrent.spi.ThreadContextProvider;; -@Web @RunAsClient //Requires client testing due to multiple servlets and annotation configuration -@Common({PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS}) -public class ManagedExecutorDefinitionWebTests extends TestClient{ - - @ArquillianResource(ManagedExecutorDefinitionServlet.class) - URL baseURL; - - @ArquillianResource(ManagedExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; - - @Deployment(name="ManagedExecutorDefinitionTests") - public static WebArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedExecutorDefinitionTests_web.war") - .addPackages(false, ManagedExecutorDefinitionWebTests.class.getPackage()) - .addClasses( - ContextServiceDefinitionInterface.class, - ContextServiceDefinitionWebBean.class, - ContextServiceDefinitionServlet.class) - .deleteClasses(ManagedExecutorDefinitionBean.class) - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); - - return war; - } - +@Web +@RunAsClient // Requires client testing due to multiple servlets and annotation configuration +@Common({ PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS }) +public class ManagedExecutorDefinitionWebTests extends TestClient { + + @ArquillianResource(ManagedExecutorDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedExecutorDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name = "ManagedExecutorDefinitionTests") + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedExecutorDefinitionTests_web.war") + .addPackages(false, ManagedExecutorDefinitionWebTests.class.getPackage()) + .addClasses(ContextServiceDefinitionInterface.class, ContextServiceDefinitionWebBean.class, + ContextServiceDefinitionServlet.class) + .deleteClasses(ManagedExecutorDefinitionBean.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()); + + return war; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "ManagedExecutorDefinitionServlet"; - } - - @Test + + @Override + protected String getServletPath() { + return "ManagedExecutorDefinitionServlet"; + } + + @Test public void testAsyncCompletionStage() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodReturnsCompletableFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodReturnsCompletionStage() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodVoidReturnType() { - runTest(baseURL, testname); + runTest(baseURL, testname); } // TCK Accepted Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + @Disabled public void testCompletedFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testCopyCompletableFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testCopyCompletableFutureEJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testIncompleteFuture() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testIncompleteFutureEJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedExecutorDefinitionAllAttributes() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testManagedExecutorDefinitionDefaults() { - runTest(baseURL, testname); + runTest(baseURL, testname); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java index dfb74aa9..fd99a14f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java @@ -6,20 +6,24 @@ * Need to provide different JNDI names depending application deployment */ public class SecurityEJBProvider { - - public static class FullProvider implements EJBJNDIProvider { - public FullProvider() {} - @Override - public String getEJBJNDIName() { - return "java:global/security/security_ejb/SecurityTestEjb"; - } - } - - public static class WebProvider implements EJBJNDIProvider { - public WebProvider() {} - @Override - public String getEJBJNDIName() { - return "java:global/security_web/SecurityTestEjb"; - } - } + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:global/security/security_ejb/SecurityTestEjb"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:global/security_web/SecurityTestEjb"; + } + } } 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 75c224c6..2300c133 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 @@ -33,55 +33,58 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; -@Full @RunAsClient //Requires client testing due to login request +@Full +@RunAsClient // Requires client testing due to login request public class SecurityFullTests extends TestClient { - - @ArquillianResource - URL baseURL; - - @Deployment(name="SecurityTests") - 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; - - JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") - .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) - .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class);; - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "security.ear") - .addAsModules(war, jar); - - return ear; - } - + + @ArquillianResource + URL baseURL; + + @Deployment(name = "SecurityTests") + 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; + + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") + .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class); + ; + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "security.ear").addAsModules(war, jar); + + return ear; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "SecurityServlet"; - } - /* - * @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. + @Override + protected String getServletPath() { + return "SecurityServlet"; + } + + /* + * @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 - */ - @Disabled - public void managedExecutorServiceAPISecurityTest() { - runTest(baseURL, testname); - } + * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in + * next release of Concurrency + */ + @Disabled + public void managedExecutorServiceAPISecurityTest() { + runTest(baseURL, testname); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java index 533a1ee8..0840d3a5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java @@ -32,15 +32,16 @@ @SuppressWarnings("serial") @WebServlet("/SecurityServlet") public class SecurityServlet extends TestServlet { - + @Resource(lookup = TestConstants.DefaultManagedExecutorService) public ManagedExecutorService executor; - public void managedExecutorServiceAPISecurityTest(HttpServletRequest req, HttpServletResponse res) throws Exception { - req.login("javajoe", "javajoe"); - Future future = executor.submit(new SecurityTestTask()); - Object result = Wait.waitForTaskComplete(future); - assertEquals(result, TestConstants.SimpleReturnValue); - } + public void managedExecutorServiceAPISecurityTest(HttpServletRequest req, HttpServletResponse res) + throws Exception { + req.login("javajoe", "javajoe"); + Future future = executor.submit(new SecurityTestTask()); + Object result = Wait.waitForTaskComplete(future); + assertEquals(result, TestConstants.SimpleReturnValue); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java index 516feb4f..5ab96d19 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java @@ -23,8 +23,8 @@ @Stateless public class SecurityTestEjb implements SecurityTestInterface { - @RolesAllowed("Manager") - public String managerMethod1() { - return TestConstants.SimpleReturnValue; - } + @RolesAllowed("Manager") + public String managerMethod1() { + return TestConstants.SimpleReturnValue; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestInterface.java index 99cfc321..e41067ff 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestInterface.java @@ -16,9 +16,8 @@ package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.security; - public interface SecurityTestInterface { - public String managerMethod1(); + public String managerMethod1(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java index bea9f5d3..76c4d742 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java @@ -25,13 +25,13 @@ public class SecurityTestTask implements Callable { - public String call() { - try { - EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); - SecurityTestInterface str = InitialContext.doLookup(nameProvider.getEJBJNDIName()); - return str.managerMethod1(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + public String call() { + try { + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + SecurityTestInterface str = InitialContext.doLookup(nameProvider.getEJBJNDIName()); + return str.managerMethod1(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } 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 b32c267a..1aeee592 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 @@ -32,47 +32,48 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to login request -@Common({PACKAGE.TASKS}) +@Web +@RunAsClient // Requires client testing due to login request +@Common({ PACKAGE.TASKS }) public class SecurityWebTests extends TestClient { - - @ArquillianResource - URL baseURL; - - @Deployment(name="SecurityTests") - public static WebArchive createDeployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class, "security_web.war") - .addPackages(true, SecurityWebTests.class.getPackage()) - .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.WebProvider.class); - - return war; - } - + + @ArquillianResource + URL baseURL; + + @Deployment(name = "SecurityTests") + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class, "security_web.war") + .addPackages(true, SecurityWebTests.class.getPackage()) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.WebProvider.class); + + return war; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "SecurityServlet"; - } - /* - * @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. + @Override + protected String getServletPath() { + return "SecurityServlet"; + } + + /* + * @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 - */ - @Disabled - public void managedExecutorServiceAPISecurityTest() { - runTest(baseURL, testname); - } + * fix: https://github.com/jakartaee/concurrency/pull/218 Can be reenabled in + * next release of Concurrency + */ + @Disabled + public void managedExecutorServiceAPISecurityTest() { + runTest(baseURL, testname); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java index bf3230d9..82969fca 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java @@ -43,71 +43,65 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -@SuppressWarnings({"serial", "unused"}) +@SuppressWarnings({ "serial", "unused" }) @WebServlet(Constants.CONTEXT_PATH) -@DataSourceDefinition( - name = "java:comp/env/jdbc/ManagedExecutorServiceDB", - className = "org.apache.derby.jdbc.EmbeddedDataSource", - databaseName = "memory:ManagedExecutorServiceDB", - properties = { - "createDatabase=create" - } -) +@DataSourceDefinition(name = "java:comp/env/jdbc/ManagedExecutorServiceDB", className = "org.apache.derby.jdbc.EmbeddedDataSource", databaseName = "memory:ManagedExecutorServiceDB", properties = { + "createDatabase=create" }) public class TransactionServlet extends TestServlet { - private static final TestLogger log = TestLogger.get(TransactionServlet.class); + private static final TestLogger log = TestLogger.get(TransactionServlet.class); + + @Resource(lookup = "java:comp/env/jdbc/ManagedExecutorServiceDB") + private DataSource ds; - @Resource(lookup = "java:comp/env/jdbc/ManagedExecutorServiceDB") - private DataSource ds; - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; - @Override - protected void beforeClass() throws RemoteException { - log.enter("beforeClass"); - - Connections.setDataSource(ds); - - try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { - try { - stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); - } catch (SQLException e) { - log.finest("Could not drop table, assume table did not exist."); - } - stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); - log.exit("beforeClass"); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { - boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); - - Future taskResult = scheduledExecutor.submit( - new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT)); - - Wait.waitForTaskComplete(taskResult); - } - - public void cancelTest() { - int originTableCount = Counter.getCount(); - - CancelledTransactedTask cancelledTask = new CancelledTransactedTask(Constants.SQL_TEMPLATE_INSERT); - Future future = scheduledExecutor.submit(cancelledTask); - - // then cancel it after transaction begin and - Wait.waitForTransactionBegan(cancelledTask); - - // before it commit. - cancelledTask.cancelTransaction.set(true); - - // continue to run if possible. - cancelledTask.runQuery.set(true);; - - int afterTransacted = Counter.getCount(); - - assertEquals(originTableCount, afterTransacted,"task was not properly cancelled"); - } + @Override + protected void beforeClass() throws RemoteException { + log.enter("beforeClass"); + + Connections.setDataSource(ds); + + try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { + try { + stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); + } catch (SQLException e) { + log.finest("Could not drop table, assume table did not exist."); + } + stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); + log.exit("beforeClass"); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); + + Future taskResult = scheduledExecutor.submit(new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT)); + + Wait.waitForTaskComplete(taskResult); + } + + public void cancelTest() { + int originTableCount = Counter.getCount(); + + CancelledTransactedTask cancelledTask = new CancelledTransactedTask(Constants.SQL_TEMPLATE_INSERT); + Future future = scheduledExecutor.submit(cancelledTask); + + // then cancel it after transaction begin and + Wait.waitForTransactionBegan(cancelledTask); + + // before it commit. + cancelledTask.cancelTransaction.set(true); + + // continue to run if possible. + cancelledTask.runQuery.set(true); + ; + + int afterTransacted = Counter.getCount(); + + assertEquals(originTableCount, afterTransacted, "task was not properly cancelled"); + } } 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 24dddb38..fd2c7d2d 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 @@ -33,35 +33,36 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to annotation configuration +@Web +@RunAsClient // Requires client testing due to annotation configuration @Common({ PACKAGE.TRANSACTION }) public class TransactionTests extends TestClient { - @ArquillianResource - URL baseURL; - - @Deployment(name="TransactionTests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, TransactionTests.class.getPackage()); - } + @ArquillianResource + URL baseURL; - /* - * @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) - public void testRollbackTransactionWithManagedExecutorService() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); - } - - /* + @Deployment(name = "TransactionTests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class).addPackages(true, TransactionTests.class.getPackage()); + } + + /* + * @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) + public void testRollbackTransactionWithManagedExecutorService() { + runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) + .withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); + } + + /* * @testName: testCommitTransactionWithManagedExecutorService * * @assertion_ids: @@ -77,25 +78,27 @@ public void testRollbackTransactionWithManagedExecutorService() { * ManagedExecutorService.it support user-managed global transaction demarcation * using the jakarta.transaction.UserTransaction interface. */ - @Test //TODO rewrite test logic to avoid duplicate key violation + @Test // TODO rewrite test logic to avoid duplicate key violation @Order(2) public void testCommitTransactionWithManagedExecutorService() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_TRUE).withTestName("transactionTest")); + 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) - public void testCancelTransactionWithManagedExecutorService() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_CANCEL).withTestName("cancelTest")); - } + /* + * @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) + 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/CounterEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/CounterEJBProvider.java index f0f4ebfd..3d340dde 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/CounterEJBProvider.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/CounterEJBProvider.java @@ -6,20 +6,24 @@ * Need to provide different JNDI names depending application deployment */ public class CounterEJBProvider { - - public static class FullProvider implements EJBJNDIProvider { - public FullProvider() {} - @Override - public String getEJBJNDIName() { - return "java:global/inheritedapi/inheritedapi/CounterSingleton"; - } - } - - public static class WebProvider implements EJBJNDIProvider { - public WebProvider() {} - @Override - public String getEJBJNDIName() { - return "java:global/inheritedapi/CounterSingleton"; - } - } + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:global/inheritedapi/inheritedapi/CounterSingleton"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:global/inheritedapi/CounterSingleton"; + } + } } 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 9eeb64c1..912f5f7e 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 @@ -29,104 +29,107 @@ @Full public class InheritedAPIFullTests { - - @Deployment(name="InheritedAPITests") - public static EnterpriseArchive createDeployment() { - JavaArchive inheritedJAR = ShrinkWrap.create(JavaArchive.class, "inheritedapi.jar") - .addClasses(InheritedAPIFullTests.class, CounterEJBProvider.class, TestEjb.class, TestEjbInterface.class) - .addPackages(true, PACKAGE.TASKS.getPackageName(), PACKAGE.COUNTER.getPackageName(), PACKAGE.FIXED_COUNTER.getPackageName()) - .addAsServiceProvider(EJBJNDIProvider.class, CounterEJBProvider.FullProvider.class); - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "inheritedapi.ear").addAsModules(inheritedJAR); - - return ear; - } - - @EJB - private TestEjbInterface testEjb; - - /* - * @testName: testApiSubmit - * - * @assertion_ids: CONCURRENCY:SPEC:44.1 - * - * @test_Strategy: - */ - @Test - public void testApiSubmit() { - testEjb.testApiSubmit(); - } - - /* - * @testName: testApiExecute - * - * @assertion_ids: CONCURRENCY:SPEC:44.2 - * - * @test_Strategy: - */ - @Test - public void testApiExecute() { - testEjb.testApiExecute(); - } - - /* - * @testName: testApiInvokeAll - * - * @assertion_ids: CONCURRENCY:SPEC:44.3 - * - * @test_Strategy: - */ - @Test - public void testApiInvokeAll() { - testEjb.testApiInvokeAll(); - } - - /* - * @testName: testApiInvokeAny - * - * @assertion_ids: CONCURRENCY:SPEC:44.4 - * - * @test_Strategy: - */ - @Test - public void testApiInvokeAny() { - testEjb.testApiInvokeAny(); - } - - /* - * @testName: testApiSchedule - * - * @assertion_ids: CONCURRENCY:SPEC:44.5 - * - * @test_Strategy: - */ - @Test - public void testApiSchedule() { - testEjb.testApiSchedule(); - } - - /* - * @testName: testApiScheduleAtFixedRate - * - * @assertion_ids: CONCURRENCY:SPEC:44.6 - * - * @test_Strategy: - */ - @Test - public void testApiScheduleAtFixedRate() { - testEjb.testApiScheduleAtFixedRate(); - } - - /* - * @testName: testApiScheduleWithFixedDelay - * - * @assertion_ids: CONCURRENCY:SPEC:44.7 - * - * @test_Strategy: - */ - @Test - public void testApiScheduleWithFixedDelay() { - testEjb.testApiScheduleWithFixedDelay(); - } + + @Deployment(name = "InheritedAPITests") + public static EnterpriseArchive createDeployment() { + JavaArchive inheritedJAR = ShrinkWrap.create(JavaArchive.class, "inheritedapi.jar") + .addClasses(InheritedAPIFullTests.class, CounterEJBProvider.class, TestEjb.class, + TestEjbInterface.class) + .addPackages(true, PACKAGE.TASKS.getPackageName(), PACKAGE.COUNTER.getPackageName(), + PACKAGE.FIXED_COUNTER.getPackageName()) + .addAsServiceProvider(EJBJNDIProvider.class, CounterEJBProvider.FullProvider.class); + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "inheritedapi.ear") + .addAsModules(inheritedJAR); + + return ear; + } + + @EJB + private TestEjbInterface testEjb; + + /* + * @testName: testApiSubmit + * + * @assertion_ids: CONCURRENCY:SPEC:44.1 + * + * @test_Strategy: + */ + @Test + public void testApiSubmit() { + testEjb.testApiSubmit(); + } + + /* + * @testName: testApiExecute + * + * @assertion_ids: CONCURRENCY:SPEC:44.2 + * + * @test_Strategy: + */ + @Test + public void testApiExecute() { + testEjb.testApiExecute(); + } + + /* + * @testName: testApiInvokeAll + * + * @assertion_ids: CONCURRENCY:SPEC:44.3 + * + * @test_Strategy: + */ + @Test + public void testApiInvokeAll() { + testEjb.testApiInvokeAll(); + } + + /* + * @testName: testApiInvokeAny + * + * @assertion_ids: CONCURRENCY:SPEC:44.4 + * + * @test_Strategy: + */ + @Test + public void testApiInvokeAny() { + testEjb.testApiInvokeAny(); + } + + /* + * @testName: testApiSchedule + * + * @assertion_ids: CONCURRENCY:SPEC:44.5 + * + * @test_Strategy: + */ + @Test + public void testApiSchedule() { + testEjb.testApiSchedule(); + } + + /* + * @testName: testApiScheduleAtFixedRate + * + * @assertion_ids: CONCURRENCY:SPEC:44.6 + * + * @test_Strategy: + */ + @Test + public void testApiScheduleAtFixedRate() { + testEjb.testApiScheduleAtFixedRate(); + } + + /* + * @testName: testApiScheduleWithFixedDelay + * + * @assertion_ids: CONCURRENCY:SPEC:44.7 + * + * @test_Strategy: + */ + @Test + public void testApiScheduleWithFixedDelay() { + testEjb.testApiScheduleWithFixedDelay(); + } } 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 959acc13..b12d664d 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 @@ -28,102 +28,102 @@ import jakarta.ejb.EJB;; @Web -@Common({PACKAGE.TASKS, PACKAGE.COUNTER, PACKAGE.FIXED_COUNTER}) +@Common({ PACKAGE.TASKS, PACKAGE.COUNTER, PACKAGE.FIXED_COUNTER }) public class InheritedAPIWebTests { - - @Deployment(name="InheritedAPITests") - public static WebArchive createDeployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class, "inheritedapi.war") - .addClasses(InheritedAPIWebTests.class, CounterEJBProvider.class, TestEjb.class, TestEjbInterface.class) - .addAsServiceProvider(EJBJNDIProvider.class, CounterEJBProvider.WebProvider.class); - return war; - } - @EJB - private TestEjbInterface testEjb; + @Deployment(name = "InheritedAPITests") + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class, "inheritedapi.war") + .addClasses(InheritedAPIWebTests.class, CounterEJBProvider.class, TestEjb.class, TestEjbInterface.class) + .addAsServiceProvider(EJBJNDIProvider.class, CounterEJBProvider.WebProvider.class); + return war; + } - /* - * @testName: testApiSubmit - * - * @assertion_ids: CONCURRENCY:SPEC:44.1 - * - * @test_Strategy: - */ - @Test - public void testApiSubmit() { - testEjb.testApiSubmit(); - } + @EJB + private TestEjbInterface testEjb; - /* - * @testName: testApiExecute - * - * @assertion_ids: CONCURRENCY:SPEC:44.2 - * - * @test_Strategy: - */ - @Test - public void testApiExecute() { - testEjb.testApiExecute(); - } + /* + * @testName: testApiSubmit + * + * @assertion_ids: CONCURRENCY:SPEC:44.1 + * + * @test_Strategy: + */ + @Test + public void testApiSubmit() { + testEjb.testApiSubmit(); + } - /* - * @testName: testApiInvokeAll - * - * @assertion_ids: CONCURRENCY:SPEC:44.3 - * - * @test_Strategy: - */ - @Test - public void testApiInvokeAll() { - testEjb.testApiInvokeAll(); - } + /* + * @testName: testApiExecute + * + * @assertion_ids: CONCURRENCY:SPEC:44.2 + * + * @test_Strategy: + */ + @Test + public void testApiExecute() { + testEjb.testApiExecute(); + } - /* - * @testName: testApiInvokeAny - * - * @assertion_ids: CONCURRENCY:SPEC:44.4 - * - * @test_Strategy: - */ - @Test - public void testApiInvokeAny() { - testEjb.testApiInvokeAny(); - } + /* + * @testName: testApiInvokeAll + * + * @assertion_ids: CONCURRENCY:SPEC:44.3 + * + * @test_Strategy: + */ + @Test + public void testApiInvokeAll() { + testEjb.testApiInvokeAll(); + } - /* - * @testName: testApiSchedule - * - * @assertion_ids: CONCURRENCY:SPEC:44.5 - * - * @test_Strategy: - */ - @Test - public void testApiSchedule() { - testEjb.testApiSchedule(); - } + /* + * @testName: testApiInvokeAny + * + * @assertion_ids: CONCURRENCY:SPEC:44.4 + * + * @test_Strategy: + */ + @Test + public void testApiInvokeAny() { + testEjb.testApiInvokeAny(); + } - /* - * @testName: testApiScheduleAtFixedRate - * - * @assertion_ids: CONCURRENCY:SPEC:44.6 - * - * @test_Strategy: - */ - @Test - public void testApiScheduleAtFixedRate() { - testEjb.testApiScheduleAtFixedRate(); - } + /* + * @testName: testApiSchedule + * + * @assertion_ids: CONCURRENCY:SPEC:44.5 + * + * @test_Strategy: + */ + @Test + public void testApiSchedule() { + testEjb.testApiSchedule(); + } - /* - * @testName: testApiScheduleWithFixedDelay - * - * @assertion_ids: CONCURRENCY:SPEC:44.7 - * - * @test_Strategy: - */ - @Test - public void testApiScheduleWithFixedDelay() { - testEjb.testApiScheduleWithFixedDelay(); - } + /* + * @testName: testApiScheduleAtFixedRate + * + * @assertion_ids: CONCURRENCY:SPEC:44.6 + * + * @test_Strategy: + */ + @Test + public void testApiScheduleAtFixedRate() { + testEjb.testApiScheduleAtFixedRate(); + } + + /* + * @testName: testApiScheduleWithFixedDelay + * + * @assertion_ids: CONCURRENCY:SPEC:44.7 + * + * @test_Strategy: + */ + @Test + public void testApiScheduleWithFixedDelay() { + testEjb.testApiScheduleWithFixedDelay(); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java index 2adf623d..13db321f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java @@ -45,159 +45,163 @@ @Stateless public class TestEjb implements TestEjbInterface { - @EJB - private CounterInterface counter; - + @EJB + private CounterInterface counter; + @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; - public void testApiSubmit() { - try { - Future result = scheduledExecutor.submit(new CommonTasks.SimpleCallable()); - Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); - - result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable()); - Wait.waitTillFutureIsDone(result); - result.get(); - - result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), CommonTasks.SIMPLE_RETURN_STRING); - Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - - public void testApiExecute() { - try { - EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); - scheduledExecutor.execute(new CounterRunnableTask(nameProvider.getEJBJNDIName())); - StaticCounter.waitTillSurpassed(1); - }finally { - counter.reset(); - } - } - - public void testApiInvokeAll() { - try { - List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleArgCallable(1)); - taskList.add(new CommonTasks.SimpleArgCallable(2)); - taskList.add(new CommonTasks.SimpleArgCallable(3)); - List> resultList = scheduledExecutor.invokeAll(taskList); - for (Future each : resultList) { - Wait.waitTillFutureIsDone(each); - } - assertEquals(resultList.get(0).get(), 1); - assertEquals(resultList.get(1).get(), 2); - assertEquals(resultList.get(2).get(), 3); - - resultList = scheduledExecutor.invokeAll(taskList, TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); - for (Future each : resultList) { - Wait.waitTillFutureIsDone(each); - } - assertEquals(resultList.get(0).get(), 1); - assertEquals(resultList.get(1).get(), 2); - assertEquals(resultList.get(2).get(), 3); - } catch (Exception e) { - fail(e.getMessage()); - } - - try { - List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - List> resultList = scheduledExecutor.invokeAll(taskList, TestConstants.PollInterval.getSeconds(),TimeUnit.SECONDS); - for (Future each : resultList) { - Wait.waitTillFutureThrowsException(each, CancellationException.class); - } - } catch (Exception ex) { - fail(ex.getMessage()); - } - } - - public void testApiInvokeAny() { - try { - List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleArgCallable(1)); - taskList.add(new CommonTasks.SimpleArgCallable(2)); - taskList.add(new CommonTasks.SimpleArgCallable(3)); - Integer result = scheduledExecutor.invokeAny(taskList); - Assertions.assertBetween(result, 1, 3); - - result = scheduledExecutor.invokeAny(taskList, TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); - Assertions.assertBetween(result, 1, 3); - } catch (Exception e) { - throw new RuntimeException(e); - } - - try { - List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - scheduledExecutor.invokeAny(taskList, TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); - } catch (TimeoutException e) { - return; //expected - } catch (Exception ex) { - fail(ex.getMessage()); - } - fail("Task should be cancelled because of timeout"); - } - - public void testApiSchedule() { - try { - Future result = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), - TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); - Wait.waitTillFutureIsDone(result); - assertEquals(CommonTasks.SIMPLE_RETURN_STRING, result.get()); - - result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), TestConstants.PollInterval.getSeconds(), - TimeUnit.SECONDS); - Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), null); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - public void testApiScheduleAtFixedRate() { - ScheduledFuture result = null; - try { - EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); - result = scheduledExecutor.scheduleAtFixedRate(new CounterRunnableTask(nameProvider.getEJBJNDIName()), - TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); - Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(counter.getCount(), TestConstants.PollsPerTimeout - 2, TestConstants.PollsPerTimeout + 2); - } catch (Exception e) { - fail(e.getMessage()); - } finally { + public void testApiSubmit() { + try { + Future result = scheduledExecutor.submit(new CommonTasks.SimpleCallable()); + Wait.waitTillFutureIsDone(result); + assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + + result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable()); + Wait.waitTillFutureIsDone(result); + result.get(); + + result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), CommonTasks.SIMPLE_RETURN_STRING); + Wait.waitTillFutureIsDone(result); + assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public void testApiExecute() { + try { + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + scheduledExecutor.execute(new CounterRunnableTask(nameProvider.getEJBJNDIName())); + StaticCounter.waitTillSurpassed(1); + } finally { + counter.reset(); + } + } + + public void testApiInvokeAll() { + try { + List> taskList = new ArrayList<>(); + taskList.add(new CommonTasks.SimpleArgCallable(1)); + taskList.add(new CommonTasks.SimpleArgCallable(2)); + taskList.add(new CommonTasks.SimpleArgCallable(3)); + List> resultList = scheduledExecutor.invokeAll(taskList); + for (Future each : resultList) { + Wait.waitTillFutureIsDone(each); + } + assertEquals(resultList.get(0).get(), 1); + assertEquals(resultList.get(1).get(), 2); + assertEquals(resultList.get(2).get(), 3); + + resultList = scheduledExecutor.invokeAll(taskList, TestConstants.WaitTimeout.getSeconds(), + TimeUnit.SECONDS); + for (Future each : resultList) { + Wait.waitTillFutureIsDone(each); + } + assertEquals(resultList.get(0).get(), 1); + assertEquals(resultList.get(1).get(), 2); + assertEquals(resultList.get(2).get(), 3); + } catch (Exception e) { + fail(e.getMessage()); + } + + try { + List> taskList = new ArrayList<>(); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); + List> resultList = scheduledExecutor.invokeAll(taskList, + TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + for (Future each : resultList) { + Wait.waitTillFutureThrowsException(each, CancellationException.class); + } + } catch (Exception ex) { + fail(ex.getMessage()); + } + } + + public void testApiInvokeAny() { + try { + List> taskList = new ArrayList<>(); + taskList.add(new CommonTasks.SimpleArgCallable(1)); + taskList.add(new CommonTasks.SimpleArgCallable(2)); + taskList.add(new CommonTasks.SimpleArgCallable(3)); + Integer result = scheduledExecutor.invokeAny(taskList); + Assertions.assertBetween(result, 1, 3); + + result = scheduledExecutor.invokeAny(taskList, TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); + Assertions.assertBetween(result, 1, 3); + } catch (Exception e) { + throw new RuntimeException(e); + } + + try { + List> taskList = new ArrayList<>(); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); + scheduledExecutor.invokeAny(taskList, TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + } catch (TimeoutException e) { + return; // expected + } catch (Exception ex) { + fail(ex.getMessage()); + } + fail("Task should be cancelled because of timeout"); + } + + public void testApiSchedule() { + try { + Future result = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), + TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + Wait.waitTillFutureIsDone(result); + assertEquals(CommonTasks.SIMPLE_RETURN_STRING, result.get()); + + result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), + TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + Wait.waitTillFutureIsDone(result); + assertEquals(result.get(), null); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + public void testApiScheduleAtFixedRate() { + ScheduledFuture result = null; + try { + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + result = scheduledExecutor.scheduleAtFixedRate(new CounterRunnableTask(nameProvider.getEJBJNDIName()), + TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + Wait.sleep(TestConstants.WaitTimeout); + Assertions.assertBetween(counter.getCount(), TestConstants.PollsPerTimeout - 2, + TestConstants.PollsPerTimeout + 2); + } catch (Exception e) { + fail(e.getMessage()); + } finally { if (result != null) { Wait.waitCancelFuture(result); } - counter.reset(); - } - } - - public void testApiScheduleWithFixedDelay() { - ScheduledFuture result = null; - try { - EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); - result = scheduledExecutor.scheduleWithFixedDelay( - new CounterRunnableTask(nameProvider.getEJBJNDIName(), TestConstants.PollInterval), //task - TestConstants.PollInterval.getSeconds(), //initial delay - TestConstants.PollInterval.getSeconds(), //delay - TimeUnit.SECONDS); //Time units - Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(counter.getCount(), (TestConstants.PollsPerTimeout / 2) - 2, (TestConstants.PollsPerTimeout / 2) + 2); - } catch (Exception e) { - fail(e.getMessage()); - } finally { - if (result != null) { - Wait.waitCancelFuture(result); - } - counter.reset(); - } - } - + counter.reset(); + } + } + + public void testApiScheduleWithFixedDelay() { + ScheduledFuture result = null; + try { + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + result = scheduledExecutor.scheduleWithFixedDelay( + new CounterRunnableTask(nameProvider.getEJBJNDIName(), TestConstants.PollInterval), // task + TestConstants.PollInterval.getSeconds(), // initial delay + TestConstants.PollInterval.getSeconds(), // delay + TimeUnit.SECONDS); // Time units + Wait.sleep(TestConstants.WaitTimeout); + Assertions.assertBetween(counter.getCount(), (TestConstants.PollsPerTimeout / 2) - 2, + (TestConstants.PollsPerTimeout / 2) + 2); + } catch (Exception e) { + fail(e.getMessage()); + } finally { + if (result != null) { + Wait.waitCancelFuture(result); + } + counter.reset(); + } + } + } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjbInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjbInterface.java index f6b0f70c..b2c89aca 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjbInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjbInterface.java @@ -16,21 +16,20 @@ package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.inheritedapi; - public interface TestEjbInterface { - public void testApiSubmit(); + public void testApiSubmit(); - public void testApiExecute(); + public void testApiExecute(); - public void testApiInvokeAll(); + public void testApiInvokeAll(); - public void testApiInvokeAny(); + public void testApiInvokeAny(); - public void testApiSchedule(); + public void testApiSchedule(); - public void testApiScheduleAtFixedRate(); + public void testApiScheduleAtFixedRate(); - public void testApiScheduleWithFixedDelay(); + public void 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/servlet/InheritedAPIServletTests.java index 9fe405bd..ef20ea35 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/servlet/InheritedAPIServletTests.java @@ -55,7 +55,7 @@ public class InheritedAPIServletTests { public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class); } - + @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; @@ -81,8 +81,7 @@ public void testApiSubmit() throws Exception { Wait.waitTillFutureIsDone(result); result.get(); - result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), - CommonTasks.SIMPLE_RETURN_STRING); + result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), CommonTasks.SIMPLE_RETURN_STRING); Wait.waitTillFutureIsDone(result); assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); } @@ -125,8 +124,8 @@ public void testApiInvokeAll() throws Exception { assertEquals(resultList.get(0).get(), 1); assertEquals(resultList.get(1).get(), 2); assertEquals(resultList.get(2).get(), 3); - resultList = scheduledExecutor.invokeAll(taskList, - TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); + resultList = scheduledExecutor.invokeAll(taskList, TestConstants.WaitTimeout.getSeconds(), + TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureIsDone(each); } @@ -193,8 +192,8 @@ public void testApiSchedule() throws Exception { Wait.waitTillFutureIsDone(result); assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); - result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), - TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), TestConstants.PollInterval.getSeconds(), + TimeUnit.SECONDS); Wait.waitTillFutureIsDone(result); assertEquals(result.get(), null); } @@ -214,7 +213,8 @@ public void testApiScheduleAtFixedRate() { result = scheduledExecutor.scheduleAtFixedRate(new CounterRunnableTask(), TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(StaticCounter.getCount(), TestConstants.PollsPerTimeout - 2, TestConstants.PollsPerTimeout + 2); + Assertions.assertBetween(StaticCounter.getCount(), TestConstants.PollsPerTimeout - 2, + TestConstants.PollsPerTimeout + 2); } catch (Exception e) { fail(e.getMessage()); } finally { @@ -235,11 +235,11 @@ public void testApiScheduleAtFixedRate() { public void testApiScheduleWithFixedDelay() { ScheduledFuture result = null; try { - result = scheduledExecutor.scheduleWithFixedDelay( - new CounterRunnableTask(TestConstants.PollInterval), + result = scheduledExecutor.scheduleWithFixedDelay(new CounterRunnableTask(TestConstants.PollInterval), TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(StaticCounter.getCount(), (TestConstants.PollsPerTimeout / 2) - 2, (TestConstants.PollsPerTimeout / 2) + 2); + Assertions.assertBetween(StaticCounter.getCount(), (TestConstants.PollsPerTimeout / 2) - 2, + (TestConstants.PollsPerTimeout / 2) + 2); } catch (Exception e) { fail(e.getMessage()); } finally { 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 464bb09a..c70d3c18 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 @@ -27,75 +27,74 @@ import jakarta.ejb.EJB; @Web -@Common({PACKAGE.TASKS, PACKAGE.FIXED_COUNTER}) +@Common({ PACKAGE.TASKS, PACKAGE.FIXED_COUNTER }) public class ForbiddenAPIEJBTests { - - @Deployment(name="ForbiddenAPITests") - public static JavaArchive createDeployment() { - return ShrinkWrap.create(JavaArchive.class) - .addPackages(true, ForbiddenAPIEJBTests.class.getPackage()); - } - @EJB - private TestEjbInterface testEjb; + @Deployment(name = "ForbiddenAPITests") + public static JavaArchive createDeployment() { + return ShrinkWrap.create(JavaArchive.class).addPackages(true, ForbiddenAPIEJBTests.class.getPackage()); + } - /* - * @testName: testAwaitTermination - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.1 - * - * @test_Strategy: - */ - @Test - public void testAwaitTermination() { - testEjb.testAwaitTermination(); - } + @EJB + private TestEjbInterface testEjb; - /* - * @testName: testIsShutdown - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.2 - * - * @test_Strategy: - */ - @Test - public void testIsShutdown() { - testEjb.testIsShutdown(); - } + /* + * @testName: testAwaitTermination + * + * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.1 + * + * @test_Strategy: + */ + @Test + public void testAwaitTermination() { + testEjb.testAwaitTermination(); + } - /* - * @testName: testIsTerminated - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.3 - * - * @test_Strategy: - */ - @Test - public void testIsTerminated() { - testEjb.testIsTerminated(); - } + /* + * @testName: testIsShutdown + * + * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.2 + * + * @test_Strategy: + */ + @Test + public void testIsShutdown() { + testEjb.testIsShutdown(); + } - /* - * @testName: testShutdown - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.4 - * - * @test_Strategy: - */ - @Test - public void testShutdown() { - testEjb.testShutdown(); - } + /* + * @testName: testIsTerminated + * + * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.3 + * + * @test_Strategy: + */ + @Test + public void testIsTerminated() { + testEjb.testIsTerminated(); + } - /* - * @testName: testShutdownNow - * - * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.5 - * - * @test_Strategy: - */ - @Test - public void testShutdownNow() { - testEjb.testShutdownNow(); - } + /* + * @testName: testShutdown + * + * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.4 + * + * @test_Strategy: + */ + @Test + public void testShutdown() { + testEjb.testShutdown(); + } + + /* + * @testName: testShutdownNow + * + * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.5 + * + * @test_Strategy: + */ + @Test + public void testShutdownNow() { + testEjb.testShutdownNow(); + } } 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 61fa1dd1..78cb5f21 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 @@ -28,56 +28,56 @@ @Stateless public class TestEjb implements TestEjbInterface { - private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - + private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; + @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; - public void testAwaitTermination() { - try { - scheduledExecutor.awaitTermination(10, TimeUnit.SECONDS); - } catch (InterruptedException e) { - fail(e.getMessage()); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } + public void testAwaitTermination() { + try { + scheduledExecutor.awaitTermination(10, TimeUnit.SECONDS); + } catch (InterruptedException e) { + fail(e.getMessage()); + } catch (IllegalStateException e) { + return; + } + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } - public void testIsShutdown() { - try { - scheduledExecutor.isShutdown(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } + public void testIsShutdown() { + try { + scheduledExecutor.isShutdown(); + } catch (IllegalStateException e) { + return; + } + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } - public void testIsTerminated() { - try { - scheduledExecutor.isTerminated(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } + public void testIsTerminated() { + try { + scheduledExecutor.isTerminated(); + } catch (IllegalStateException e) { + return; + } + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } - public void testShutdown() { - try { - scheduledExecutor.shutdown(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } + public void testShutdown() { + try { + scheduledExecutor.shutdown(); + } catch (IllegalStateException e) { + return; + } + fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); + } - public void testShutdownNow() { - try { - scheduledExecutor.shutdownNow(); - } catch (IllegalStateException e) { - return; - } - fail(DIDNOT_CATCH_ILLEGALSTATEEXCEPTION); - } + public void testShutdownNow() { + try { + 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/TestEjbInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/TestEjbInterface.java index f5b6f12f..554bf64a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/TestEjbInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/managed/forbiddenapi/TestEjbInterface.java @@ -18,13 +18,13 @@ public interface TestEjbInterface { - public void testAwaitTermination(); + public void testAwaitTermination(); - public void testIsShutdown(); + public void testIsShutdown(); - public void testIsTerminated(); + public void testIsTerminated(); - public void testShutdown(); + public void testShutdown(); - public void testShutdownNow(); + public void testShutdownNow(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduleExecutorDefinitionInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduleExecutorDefinitionInterface.java index 9e7c1e83..9a56ad44 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduleExecutorDefinitionInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduleExecutorDefinitionInterface.java @@ -19,6 +19,6 @@ public interface ManagedScheduleExecutorDefinitionInterface { - Object doLookup(String name) throws NamingException; + Object doLookup(String name) throws NamingException; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java index 36b90726..1ff8e9b7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java @@ -25,22 +25,19 @@ import jakarta.enterprise.concurrent.ManagedScheduledExecutorDefinition; /** - * @ContextServiceDefinitions are defined under {@link ContextServiceDefinitionServlet} and {@link ContextServiceDefinitionBean} + * @ContextServiceDefinitions are defined under + * {@link ContextServiceDefinitionServlet} and + * {@link ContextServiceDefinitionBean} */ -@ManagedScheduledExecutorDefinition(name = "java:app/concurrent/EJBScheduledExecutorA", - context = "java:app/concurrent/ContextA", - maxAsync = 3, - hungTaskThreshold = 360000) -@ManagedScheduledExecutorDefinition(name = "java:module/concurrent/ScheduledExecutorB", - context = "java:module/concurrent/ContextB", - maxAsync = 4) +@ManagedScheduledExecutorDefinition(name = "java:app/concurrent/EJBScheduledExecutorA", context = "java:app/concurrent/ContextA", maxAsync = 3, hungTaskThreshold = 360000) +@ManagedScheduledExecutorDefinition(name = "java:module/concurrent/ScheduledExecutorB", context = "java:module/concurrent/ContextB", maxAsync = 4) @ManagedScheduledExecutorDefinition(name = "java:comp/concurrent/EJBScheduledExecutorC") @Local(ManagedScheduleExecutorDefinitionInterface.class) @Stateless public class ManagedScheduledExecutorDefinitionBean implements ManagedScheduleExecutorDefinitionInterface { - - @Override - public Object doLookup(String name) throws NamingException { - return InitialContext.doLookup(name); - } + + @Override + public Object doLookup(String name) throws NamingException { + return InitialContext.doLookup(name); + } } 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 7d63db08..ae0980bc 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 @@ -39,119 +39,118 @@ import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionServlet; import jakarta.enterprise.concurrent.spi.ThreadContextProvider; -@Full @RunAsClient //Requires client testing due to annotation configuration +@Full +@RunAsClient // Requires client testing due to annotation configuration public class ManagedScheduledExecutorDefinitionFullTests extends TestClient { - - @ArquillianResource(ManagedScheduledExecutorDefinitionServlet.class) - URL baseURL; - - @ArquillianResource(ManagedScheduledExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; - - @Deployment(name="ManagedScheduledExecutorDefinitionTests") - public static EnterpriseArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedScheduledExecutorDefinitionTests_web.war") - .addPackages(true, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) - .addClasses( - ReqBean.class, - ManagedScheduledExecutorDefinitionServlet.class, - ManagedScheduledExecutorDefinitionOnEJBServlet.class, - ContextServiceDefinitionServlet.class) - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); - - JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ManagedScheduledExecutorDefinitionTests_ejb.jar") - .addPackages(false, ManagedScheduledExecutorDefinitionFullTests.class.getPackage()) - .deleteClasses( - ReqBean.class, - ManagedScheduledExecutorDefinitionWebBean.class, - ManagedScheduledExecutorDefinitionServlet.class, - ManagedScheduledExecutorDefinitionOnEJBServlet.class) - .addClasses( - ContextServiceDefinitionInterface.class, - ContextServiceDefinitionBean.class) - .addAsManifestResource(ManagedScheduledExecutorDefinitionFullTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ManagedScheduledExecutorDefinitionTests.ear").addAsModules(war, jar); - - return ear; - } - + + @ArquillianResource(ManagedScheduledExecutorDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedScheduledExecutorDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name = "ManagedScheduledExecutorDefinitionTests") + public static EnterpriseArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedScheduledExecutorDefinitionTests_web.war") + .addPackages(true, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) + .addClasses(ReqBean.class, ManagedScheduledExecutorDefinitionServlet.class, + ManagedScheduledExecutorDefinitionOnEJBServlet.class, ContextServiceDefinitionServlet.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()); + + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ManagedScheduledExecutorDefinitionTests_ejb.jar") + .addPackages(false, ManagedScheduledExecutorDefinitionFullTests.class.getPackage()) + .deleteClasses(ReqBean.class, ManagedScheduledExecutorDefinitionWebBean.class, + ManagedScheduledExecutorDefinitionServlet.class, + ManagedScheduledExecutorDefinitionOnEJBServlet.class) + .addClasses(ContextServiceDefinitionInterface.class, ContextServiceDefinitionBean.class) + .addAsManifestResource(ManagedScheduledExecutorDefinitionFullTests.class.getPackage(), "ejb-jar.xml", + "ejb-jar.xml"); + + EnterpriseArchive ear = ShrinkWrap + .create(EnterpriseArchive.class, "ManagedScheduledExecutorDefinitionTests.ear").addAsModules(war, jar); + + return ear; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "ManagedScheduledExecutorDefinitionServlet"; - } - - - @Test + + @Override + protected String getServletPath() { + return "ManagedScheduledExecutorDefinitionServlet"; + } + + @Test public void testAsyncCompletionStageMSE() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodRunsWithContext() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodWithMaxAsync3() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - // Accepted TCK Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + + // Accepted TCK Challenge: https://github.com/jakartaee/concurrency/issues/224 + @Disabled public void testCompletedFutureMSE() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testIncompleteFutureMSE() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testIncompleteFutureMSE_EJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedScheduledExecutorDefinitionAllAttributes() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedScheduledExecutorDefinitionDefaults() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testManagedScheduledExecutorDefinitionDefaults_EJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testNotAnAsynchronousMethod() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testScheduleWithCronTrigger() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testScheduleWithZonedTrigger() { - runTest(baseURL, testname); + runTest(baseURL, testname); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java index e7d509ab..6180824d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java @@ -53,16 +53,17 @@ public class ManagedScheduledExecutorDefinitionOnEJBServlet extends TestServlet @Resource UserTransaction tx; - + @EJB private ManagedScheduleExecutorDefinitionInterface managedScheduleExecutorDefinitionBean; - - //Needed to initialize the ContextServiceDefinitions - @EJB - private ContextServiceDefinitionInterface contextServiceDefinitionBean; - + + // Needed to initialize the ContextServiceDefinitions + @EJB + private ContextServiceDefinitionInterface contextServiceDefinitionBean; + /** - * A ManagedScheduledExecutorDefinition defined on an EJB with all attributes configured enforces maxAsync and propagates context. + * A ManagedScheduledExecutorDefinition defined on an EJB with all attributes + * configured enforces maxAsync and propagates context. */ public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:app/concurrent/EJBScheduledExecutorA"); @@ -87,117 +88,120 @@ public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() throws Thr executor.submit(task); executor.submit(task, "TaskResult"); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run an async task."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run an async task."); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run 2 async tasks concurrently."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run 2 async tasks concurrently."); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run 3 async tasks concurrently."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run 3 async tasks concurrently."); - assertEquals(results.poll(1, TimeUnit.SECONDS), null, - "ManagedScheduledExecutorService with maxAsync=3 must not run 4 async tasks concurrently."); + assertEquals(results.poll(1, TimeUnit.SECONDS), null, + "ManagedScheduledExecutorService with maxAsync=3 must not run 4 async tasks concurrently."); } finally { IntContext.set(0); blocker.countDown(); } - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run 4th task after 1st completes."); - + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run 4th task after 1st completes."); } - + /** - * A 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. + * A 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 testManagedScheduledExecutorDefinitionDefaults_EJB() throws Throwable { - ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService)managedScheduleExecutorDefinitionBean.doLookup("java:comp/concurrent/EJBScheduledExecutorC"); - - CountDownLatch blocker = new CountDownLatch(1); - CountDownLatch allTasksRunning = new CountDownLatch(4); - - Callable txCallable = () -> { - allTasksRunning.countDown(); - UserTransaction tx = InitialContext.doLookup("java:comp/UserTransaction"); - int initialStatus = tx.getStatus(); - tx.begin(); - try { - blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); - } finally { - tx.rollback(); - } - return initialStatus; - }; - - Function lookupFunction = jndiName -> { - allTasksRunning.countDown(); - try { - blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); - return (ManagedScheduledExecutorService)managedScheduleExecutorDefinitionBean.doLookup(jndiName); - } catch (InterruptedException | NamingException x) { - throw new CompletionException(x); - } - }; - - try { - Future txFuture1 = executor.submit(txCallable); - - Future txFuture2 = executor.submit(txCallable); - - CompletableFuture lookupFuture1 = executor.completedFuture("java:comp/concurrent/EJBScheduledExecutorC") - .thenApplyAsync(lookupFunction); - - CompletableFuture lookupFuture2 = executor.completedFuture("java:module/concurrent/ScheduledExecutorB") - .thenApplyAsync(lookupFunction); - - assertTrue(allTasksRunning.await(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "ManagedScheduledExecutorService without maxAsync must be able to run async tasks concurrently."); - - blocker.countDown(); - - int status; - status = txFuture1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from first async Callable task " + - "per java:comp/concurrent/EJBScheduledExecutorC configuration."); - - status = txFuture2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from second async Callable task " + - "per java:comp/concurrent/EJBScheduledExecutorC configuration."); - - assertTrue(lookupFuture1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedScheduledExecutorService, - "Application context must be propagated to first async Function " + - "per java:comp/concurrent/EJBScheduledExecutorC configuration."); - - assertTrue(lookupFuture2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedScheduledExecutorService, - "Application context must be propagated to second async Function " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); - } finally { - IntContext.set(0); - blocker.countDown(); - } - - tx.begin(); - try { - // run inline to verify that transaction context is cleared - int status = executor.getContextService().contextualCallable(txCallable).call(); - assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from inline contextual Callable " + - "per java:comp/concurrent/EJBScheduledExecutorC configuration."); - } finally { - tx.rollback(); - } + ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) managedScheduleExecutorDefinitionBean + .doLookup("java:comp/concurrent/EJBScheduledExecutorC"); + + CountDownLatch blocker = new CountDownLatch(1); + CountDownLatch allTasksRunning = new CountDownLatch(4); + + Callable txCallable = () -> { + allTasksRunning.countDown(); + UserTransaction tx = InitialContext.doLookup("java:comp/UserTransaction"); + int initialStatus = tx.getStatus(); + tx.begin(); + try { + blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); + } finally { + tx.rollback(); + } + return initialStatus; + }; + + Function lookupFunction = jndiName -> { + allTasksRunning.countDown(); + try { + blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); + return (ManagedScheduledExecutorService) managedScheduleExecutorDefinitionBean.doLookup(jndiName); + } catch (InterruptedException | NamingException x) { + throw new CompletionException(x); + } + }; + + try { + Future txFuture1 = executor.submit(txCallable); + + Future txFuture2 = executor.submit(txCallable); + + CompletableFuture lookupFuture1 = executor.completedFuture("java:comp/concurrent/EJBScheduledExecutorC") + .thenApplyAsync(lookupFunction); + + CompletableFuture lookupFuture2 = executor.completedFuture("java:module/concurrent/ScheduledExecutorB") + .thenApplyAsync(lookupFunction); + + assertTrue(allTasksRunning.await(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "ManagedScheduledExecutorService without maxAsync must be able to run async tasks concurrently."); + + blocker.countDown(); + + int status; + status = txFuture1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertEquals(status, Status.STATUS_NO_TRANSACTION, + "Transaction context must be cleared from first async Callable task " + + "per java:comp/concurrent/EJBScheduledExecutorC configuration."); + + status = txFuture2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertEquals(status, Status.STATUS_NO_TRANSACTION, + "Transaction context must be cleared from second async Callable task " + + "per java:comp/concurrent/EJBScheduledExecutorC configuration."); + + assertTrue(lookupFuture1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedScheduledExecutorService, + "Application context must be propagated to first async Function " + + "per java:comp/concurrent/EJBScheduledExecutorC configuration."); + + assertTrue(lookupFuture2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedScheduledExecutorService, + "Application context must be propagated to second async Function " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); + } finally { + IntContext.set(0); + blocker.countDown(); + } + + tx.begin(); + try { + // run inline to verify that transaction context is cleared + int status = executor.getContextService().contextualCallable(txCallable).call(); + assertEquals(status, Status.STATUS_NO_TRANSACTION, + "Transaction context must be cleared from inline contextual Callable " + + "per java:comp/concurrent/EJBScheduledExecutorC configuration."); + } finally { + tx.rollback(); + } } - + /** - * 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. + * 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_EJB() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:app/concurrent/EJBScheduledExecutorA"); @@ -234,17 +238,15 @@ public void testIncompleteFutureMSE_EJB() throws Throwable { stage1a.complete("java:app"); stage1b.complete("concurrent/EJBScheduledExecutorA"); - assertEquals(stage3.join(), null, - "CompletableFuture with Void return type must return null from join."); + assertEquals(stage3.join(), null, "CompletableFuture with Void return type must return null from join."); String result = results.toString(); - assertEquals(result, "Application context propagated;StringContext cleared;IntContext propagated", - "Application context and IntContext must be propagated and StringContext must be cleared " + - "per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); + assertEquals(result, "Application context propagated;StringContext cleared;IntContext propagated", + "Application context and IntContext must be propagated and StringContext must be cleared " + + "per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); StringContext.set(null); } - } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java index f7645659..0bdc2039 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java @@ -57,15 +57,11 @@ import jakarta.transaction.UserTransaction; /** - * @ContextServiceDefinitions are defined under {@link ContextServiceDefinitionServlet} + * @ContextServiceDefinitions are defined under + * {@link ContextServiceDefinitionServlet} */ -@ManagedScheduledExecutorDefinition(name = "java:app/concurrent/ScheduledExecutorA", - context = "java:app/concurrent/ContextA", - maxAsync = 3, - hungTaskThreshold = 360000) -@ManagedScheduledExecutorDefinition(name = "java:module/concurrent/ScheduledExecutorB", - context = "java:module/concurrent/ContextB", - maxAsync = 4) +@ManagedScheduledExecutorDefinition(name = "java:app/concurrent/ScheduledExecutorA", context = "java:app/concurrent/ContextA", maxAsync = 3, hungTaskThreshold = 360000) +@ManagedScheduledExecutorDefinition(name = "java:module/concurrent/ScheduledExecutorB", context = "java:module/concurrent/ContextB", maxAsync = 4) @ManagedScheduledExecutorDefinition(name = "java:comp/concurrent/ScheduledExecutorC") @WebServlet("/ManagedScheduledExecutorDefinitionServlet") public class ManagedScheduledExecutorDefinitionServlet extends TestServlet { @@ -79,10 +75,10 @@ public class ManagedScheduledExecutorDefinitionServlet extends TestServlet { UserTransaction tx; /** - * 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. + * 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() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:app/concurrent/ScheduledExecutorA"); @@ -93,15 +89,15 @@ public void testAsyncCompletionStageMSE() throws Throwable { CompletableFuture future = executor.supplyAsync(() -> { try { - ManagedScheduledExecutorService mes = - InitialContext.doLookup("java:app/concurrent/ScheduledExecutorA"); + ManagedScheduledExecutorService mes = InitialContext + .doLookup("java:app/concurrent/ScheduledExecutorA"); return "Application context " + (mes == null ? "incorrect" : "propagated"); } catch (NamingException x) { throw new CompletionException(x); } }).applyToEitherAsync(executor.newIncompleteFuture(), status -> { int i = IntContext.get(); - return status + ";IntContext " + (i == 100 ? "propagated" : "incorrect:" + i); + return status + ";IntContext " + (i == 100 ? "propagated" : "incorrect:" + i); }).thenApply(status -> { String s = StringContext.get(); return status + ";StringContext " + ("".equals(s) ? "cleared" : "incorrect:" + s); @@ -111,14 +107,14 @@ public void testAsyncCompletionStageMSE() throws Throwable { String result = future.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); assertEquals(result, "Application context propagated;IntContext propagated;StringContext cleared", - "Application context and IntContext must be propagated and StringContext must be cleared " + - "per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); + "Application context and IntContext must be propagated and StringContext must be cleared " + + "per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); } finally { - IntContext.set(0);; + IntContext.set(0); + ; StringContext.set(null); } - } /** @@ -131,15 +127,14 @@ public void testAsynchronousMethodRunsWithContext() throws Throwable { Object result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); if (result instanceof Throwable) throw new AssertionError().initCause((Throwable) result); - assertTrue(result instanceof ContextService, - "Application context must be propagated to Asynchronous method " + - "per @ManagedScheduledExecutorDefinition config."); - + assertTrue(result instanceof ContextService, "Application context must be propagated to Asynchronous method " + + "per @ManagedScheduledExecutorDefinition config."); } /** - * Asynchronous method execution is constrained by executor's maxAsync, which for ScheduledExecutorA is 3. + * Asynchronous method execution is constrained by executor's maxAsync, which + * for ScheduledExecutorA is 3. */ public void testAsynchronousMethodWithMaxAsync3() throws Exception { Semaphore invocationsStarted = new Semaphore(0); @@ -158,50 +153,49 @@ public void testAsynchronousMethodWithMaxAsync3() throws Exception { future3 = reqBean.awaitAndGetThirdPartyContext(invocationsStarted, blocker); future4 = reqBean.awaitAndGetThirdPartyContext(invocationsStarted, blocker); - assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, - "Must be able to run 1 asynchronous method in parallel when maxAsync=3"); + assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, + "Must be able to run 1 asynchronous method in parallel when maxAsync=3"); - assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, - "Must be able to run 2 asynchronous methods in parallel when maxAsync=3"); + assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, + "Must be able to run 2 asynchronous methods in parallel when maxAsync=3"); - assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, - "Must be able to run 3 asynchronous methods in parallel when maxAsync=3"); + assertEquals(invocationsStarted.tryAcquire(1, MAX_WAIT_SECONDS, TimeUnit.SECONDS), true, + "Must be able to run 3 asynchronous methods in parallel when maxAsync=3"); - assertEquals(invocationsStarted.tryAcquire(1, 1, TimeUnit.SECONDS), false, - "Must not run 4 asynchronous methods in parallel when maxAsync=3"); + assertEquals(invocationsStarted.tryAcquire(1, 1, TimeUnit.SECONDS), false, + "Must not run 4 asynchronous methods in parallel when maxAsync=3"); } finally { StringContext.set(null); IntContext.set(0); blocker.countDown(); } - assertEquals(future1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", - "Third-party context type IntContext must be propagated and StringContext must be cleared " + - "on first asynchronous method invocation per the executor and ContextServiceDefinition."); + assertEquals(future1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", + "Third-party context type IntContext must be propagated and StringContext must be cleared " + + "on first asynchronous method invocation per the executor and ContextServiceDefinition."); - assertEquals(future2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", - "Third-party context type IntContext must be propagated and StringContext must be cleared " + - "on second asynchronous method invocation per the executor and ContextServiceDefinition."); + assertEquals(future2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", + "Third-party context type IntContext must be propagated and StringContext must be cleared " + + "on second asynchronous method invocation per the executor and ContextServiceDefinition."); - assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", - "Third-party context type IntContext must be propagated and StringContext must be cleared " + - "on third asynchronous method invocation per the executor and ContextServiceDefinition."); + assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", + "Third-party context type IntContext must be propagated and StringContext must be cleared " + + "on third asynchronous method invocation per the executor and ContextServiceDefinition."); - assertEquals(future4.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", - "Third-party context type IntContext must be propagated and StringContext must be cleared " + - "on fourth asynchronous method invocation per the executor and ContextServiceDefinition."); + assertEquals(future4.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "303", + "Third-party context type IntContext must be propagated and StringContext must be cleared " + + "on fourth asynchronous method invocation per the executor and ContextServiceDefinition."); } /** - * 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. + * 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() throws Throwable { - ManagedScheduledExecutorService executor = - InitialContext.doLookup("java:module/concurrent/ScheduledExecutorB"); + ManagedScheduledExecutorService executor = InitialContext.doLookup("java:module/concurrent/ScheduledExecutorB"); IntContext.set(41); StringContext.set("testCompletedFutureMSE-1"); @@ -222,9 +216,9 @@ public void testCompletedFutureMSE() throws Throwable { try { String result = stage2.join(); - throw new AssertionError("Application context must be left unchanged per " + - "ManagedExecutorDefinition and ContextServiceDefinition config. " + - "Instead, was able to look up " + result); + throw new AssertionError("Application context must be left unchanged per " + + "ManagedExecutorDefinition and ContextServiceDefinition config. " + + "Instead, was able to look up " + result); } catch (CompletionException x) { if (x.getCause() instanceof NamingException) ; // expected @@ -239,11 +233,12 @@ public void testCompletedFutureMSE() throws Throwable { int i = IntContext.get(); String s = StringContext.get(); - // CompletionException with chained NamingException is expected due to Application context + // CompletionException with chained NamingException is expected due to + // Application context // remaining unchanged (absent) on the async completion stage action if (failure instanceof CompletionException && failure.getCause() instanceof NamingException) return "StringContext " + ("testCompletedFutureMSE-3".equals(s) ? "propagated" : "incorrect:" + s) - + ";IntContext " + (i == 43 ? "unchanged" : "incorrect:" + i); + + ";IntContext " + (i == 43 ? "unchanged" : "incorrect:" + i); else if (failure == null) throw new AssertionError("Missing Throwable argument to exceptionally"); else @@ -253,22 +248,23 @@ else if (failure == null) StringContext.set("testCompletedFutureMSE-4"); String result = stage3.join(); - assertEquals(result, "StringContext propagated;IntContext unchanged", - "StringContext must be propagated and Application context and IntContext must be left " + - "unchanged per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); + assertEquals(result, "StringContext propagated;IntContext unchanged", + "StringContext must be propagated and Application context and IntContext must be left " + + "unchanged per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); } finally { - IntContext.set(0);; + IntContext.set(0); + ; StringContext.set(null); } - } /** - * 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. + * 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() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:app/concurrent/ScheduledExecutorA"); @@ -305,22 +301,21 @@ public void testIncompleteFutureMSE() throws Throwable { stage1a.complete("java:app"); stage1b.complete("concurrent/ScheduledExecutorA"); - assertEquals(stage3.join(), null, - "CompletableFuture with Void return type must return null from join."); + assertEquals(stage3.join(), null, "CompletableFuture with Void return type must return null from join."); String result = results.toString(); - assertEquals(result, "Application context propagated;StringContext cleared;IntContext propagated", - "Application context and IntContext must be propagated and StringContext must be cleared " + - "per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); + assertEquals(result, "Application context propagated;StringContext cleared;IntContext propagated", + "Application context and IntContext must be propagated and StringContext must be cleared " + + "per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); StringContext.set(null); } - } /** - * A ManagedScheduledExecutorDefinition with all attributes configured enforces maxAsync and propagates context. + * A ManagedScheduledExecutorDefinition with all attributes configured enforces + * maxAsync and propagates context. */ public void testManagedScheduledExecutorDefinitionAllAttributes() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:app/concurrent/ScheduledExecutorA"); @@ -345,31 +340,31 @@ public void testManagedScheduledExecutorDefinitionAllAttributes() throws Throwab executor.submit(task); executor.submit(task, "TaskResult"); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run an async task."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run an async task."); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run 2 async tasks concurrently."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run 2 async tasks concurrently."); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run 3 async tasks concurrently."); + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run 3 async tasks concurrently."); - assertEquals(results.poll(1, TimeUnit.SECONDS), null, - "ManagedScheduledExecutorService with maxAsync=3 must not run 4 async tasks concurrently."); + assertEquals(results.poll(1, TimeUnit.SECONDS), null, + "ManagedScheduledExecutorService with maxAsync=3 must not run 4 async tasks concurrently."); } finally { IntContext.set(0); blocker.countDown(); } - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), - "ManagedScheduledExecutorService with maxAsync=3 must be able to run 4th task after 1st completes."); - + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(33), + "ManagedScheduledExecutorService with maxAsync=3 must be able to run 4th task after 1st completes."); } /** - * A ManagedScheduledExecutorDefinition with minimal attributes can run multiple async tasks concurrently - * and uses java:comp/DefaultContextService to determine context propagation and clearing. + * A ManagedScheduledExecutorDefinition with minimal attributes can run multiple + * async tasks concurrently and uses java:comp/DefaultContextService to + * determine context propagation and clearing. */ public void testManagedScheduledExecutorDefinitionDefaults() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:comp/concurrent/ScheduledExecutorC"); @@ -406,34 +401,34 @@ public void testManagedScheduledExecutorDefinitionDefaults() throws Throwable { Future txFuture2 = executor.submit(txCallable); CompletableFuture lookupFuture1 = executor.completedFuture("java:comp/concurrent/ScheduledExecutorC") - .thenApplyAsync(lookupFunction); + .thenApplyAsync(lookupFunction); CompletableFuture lookupFuture2 = executor.completedFuture("java:module/concurrent/ScheduledExecutorB") - .thenApplyAsync(lookupFunction); + .thenApplyAsync(lookupFunction); assertTrue(allTasksRunning.await(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "ManagedScheduledExecutorService without maxAsync must be able to run async tasks concurrently."); + "ManagedScheduledExecutorService without maxAsync must be able to run async tasks concurrently."); blocker.countDown(); int status; status = txFuture1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from first async Callable task " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + assertEquals(status, Status.STATUS_NO_TRANSACTION, + "Transaction context must be cleared from first async Callable task " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); status = txFuture2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); - assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from second async Callable task " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + assertEquals(status, Status.STATUS_NO_TRANSACTION, + "Transaction context must be cleared from second async Callable task " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); assertTrue(lookupFuture1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedScheduledExecutorService, - "Application context must be propagated to first async Function " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to first async Function " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); assertTrue(lookupFuture2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS) instanceof ManagedScheduledExecutorService, - "Application context must be propagated to second async Function " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to second async Function " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); } finally { IntContext.set(0); blocker.countDown(); @@ -444,28 +439,26 @@ public void testManagedScheduledExecutorDefinitionDefaults() throws Throwable { // run inline to verify that transaction context is cleared int status = executor.getContextService().contextualCallable(txCallable).call(); assertEquals(status, Status.STATUS_NO_TRANSACTION, - "Transaction context must be cleared from inline contextual Callable " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Transaction context must be cleared from inline contextual Callable " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); } finally { tx.rollback(); } - } /** - * A method that lacks the Asynchronous annotation does not run as an asynchronous method, - * even if it returns a CompletableFuture. + * A method that lacks the Asynchronous annotation does not run as an + * asynchronous method, even if it returns a CompletableFuture. */ public void testNotAnAsynchronousMethod() throws Throwable { String threadName = Thread.currentThread().getName(); CompletableFuture future = reqBean.notAsynchronous(); - assertEquals(future.join(), threadName, - "A method that returns CompletableFuture but is not annotated as @Asynchronous " + - "must run inline on the same thread."); - + assertEquals(future.join(), threadName, + "A method that returns CompletableFuture but is not annotated as @Asynchronous " + + "must run inline on the same thread."); } @@ -486,57 +479,54 @@ public void testScheduleWithCronTrigger() throws Throwable { }, everyOtherSecond); try { CronTrigger weekendsAtNoon6MonthsFromNow = new CronTrigger(US_MOUNTAIN) - .daysOfWeek(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY) - .hours(12) - .months(ZonedDateTime.now(US_MOUNTAIN).plusMonths(6).getMonth()); + .daysOfWeek(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY).hours(12) + .months(ZonedDateTime.now(US_MOUNTAIN).plusMonths(6).getMonth()); ScheduledFuture distantFuture = executor.schedule(() -> { return results.add(InitialContext.doLookup("java:comp/concurrent/ScheduledExecutorC")); }, weekendsAtNoon6MonthsFromNow); - // Exact number of days until execution will vary, but should be around 5 to 6 months worth of days, + // Exact number of days until execution will vary, but should be around 5 to 6 + // months worth of days, long days = distantFuture.getDelay(TimeUnit.DAYS); - assertTrue(days > 140, - "Too few days (" + days+ ") until the next execution of " + weekendsAtNoon6MonthsFromNow + - " which is used by " + distantFuture); - assertTrue(days < 190, - "Too many days (" + days+ ") until the next execution of " + weekendsAtNoon6MonthsFromNow + - " which is used by " + distantFuture); + assertTrue(days > 140, "Too few days (" + days + ") until the next execution of " + + weekendsAtNoon6MonthsFromNow + " which is used by " + distantFuture); + assertTrue(days < 190, "Too many days (" + days + ") until the next execution of " + + weekendsAtNoon6MonthsFromNow + " which is used by " + distantFuture); - assertTrue(distantFuture.cancel(true), - "Must be able to cancel a repeating task before it runs: " + future); + assertTrue(distantFuture.cancel(true), "Must be able to cancel a repeating task before it runs: " + future); Object result; assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + everyOtherSecond + " did not run: " + future); + "Task scheduled with " + everyOtherSecond + " did not run: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, - "Application context must be propagated to first execution " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to first execution " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + everyOtherSecond + " did not repeat: " + future); + "Task scheduled with " + everyOtherSecond + " did not repeat: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, - "Application context must be propagated to second execution " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to second execution " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + everyOtherSecond + " did not run 3 times: " + future); + "Task scheduled with " + everyOtherSecond + " did not run 3 times: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, - "Application context must be propagated to third execution " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to third execution " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); assertTrue(future.cancel(true), - "Must be able to cancel a repeating task after it executes a few times: " + future); + "Must be able to cancel a repeating task after it executes a few times: " + future); } finally { if (!future.isDone()) future.cancel(true); } - } /** - * ManagedScheduledExecutorService can schedule a task with a ZonedTrigger implementation - * that uses the LastExecution methods with ZonedDateTime parameters. + * ManagedScheduledExecutorService can schedule a task with a ZonedTrigger + * implementation that uses the LastExecution methods with ZonedDateTime + * parameters. */ public void testScheduleWithZonedTrigger() throws Exception { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:comp/concurrent/ScheduledExecutorC"); @@ -563,9 +553,8 @@ public ZonedDateTime getNextRunTime(LastExecution lastExecution, ZonedDateTime s if (lastExecution == null) initSchedule(); else - startAndEndTimes.put(lastExecution.getRunStart(US_CENTRAL), - lastExecution.getRunEnd(US_CENTRAL)); - + startAndEndTimes.put(lastExecution.getRunStart(US_CENTRAL), lastExecution.getRunEnd(US_CENTRAL)); + long key = lastExecution == null ? 0l : lastExecution.getScheduledStart(US_CENTRAL).toEpochSecond(); return schedule.get(key); } @@ -583,22 +572,22 @@ public ZoneId getZoneId() { try { Object result; assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + monthlyOnThe15th + " did not run: " + future); + "Task scheduled with " + monthlyOnThe15th + " did not run: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, - "Application context must be propagated to first execution " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to first execution " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + monthlyOnThe15th + " did not repeat: " + future); + "Task scheduled with " + monthlyOnThe15th + " did not repeat: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, - "Application context must be propagated to second execution " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to second execution " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + monthlyOnThe15th + " did not run 3 times: " + future); + "Task scheduled with " + monthlyOnThe15th + " did not run 3 times: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, - "Application context must be propagated to third execution " + - "per java:comp/concurrent/ScheduledExecutorC configuration."); + "Application context must be propagated to third execution " + + "per java:comp/concurrent/ScheduledExecutorC configuration."); } finally { if (!future.isDone()) future.cancel(true); @@ -609,9 +598,8 @@ public ZoneId getZoneId() { ZonedDateTime startAt = entry.getKey(); ZonedDateTime endAt = entry.getValue(); assertTrue(startAt.isBefore(endAt) || startAt.isEqual(endAt), - "LastExecution runStart and runEnd methods returned inconsistent times: " + startAndEndTimes); + "LastExecution runStart and runEnd methods returned inconsistent times: " + startAndEndTimes); } - } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java index b5e0e639..a8f0c00f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java @@ -25,19 +25,18 @@ import jakarta.enterprise.concurrent.ManagedScheduledExecutorDefinition; /** - * @ContextServiceDefinitions are defined under {@link ContextServiceDefinitionServlet} and {@link ContextServiceDefinitionBean} + * @ContextServiceDefinitions are defined under + * {@link ContextServiceDefinitionServlet} and + * {@link ContextServiceDefinitionBean} */ -@ManagedScheduledExecutorDefinition(name = "java:app/concurrent/EJBScheduledExecutorA", - context = "java:app/concurrent/EJBContextA", - maxAsync = 3, - hungTaskThreshold = 360000) +@ManagedScheduledExecutorDefinition(name = "java:app/concurrent/EJBScheduledExecutorA", context = "java:app/concurrent/EJBContextA", maxAsync = 3, hungTaskThreshold = 360000) @ManagedScheduledExecutorDefinition(name = "java:comp/concurrent/EJBScheduledExecutorC") @Local(ManagedScheduleExecutorDefinitionInterface.class) @Stateless public class ManagedScheduledExecutorDefinitionWebBean implements ManagedScheduleExecutorDefinitionInterface { - - @Override - public Object doLookup(String name) throws NamingException { - return InitialContext.doLookup(name); - } + + @Override + public Object doLookup(String name) throws NamingException { + return InitialContext.doLookup(name); + } } 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 1ca12dc8..19841396 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 @@ -38,106 +38,108 @@ import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionWebBean; import jakarta.enterprise.concurrent.spi.ThreadContextProvider;; -@Web @RunAsClient //Requires client testing due to annotation configuration -@Common({PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS}) +@Web +@RunAsClient // Requires client testing due to annotation configuration +@Common({ PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS }) public class ManagedScheduledExecutorDefinitionWebTests extends TestClient { - - @ArquillianResource(ManagedScheduledExecutorDefinitionServlet.class) - URL baseURL; - - @ArquillianResource(ManagedScheduledExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; - - @Deployment(name="ManagedScheduledExecutorDefinitionTests") - public static WebArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedScheduledExecutorDefinitionTests_web.war") - .addPackages(false, ManagedScheduledExecutorDefinitionWebTests.class.getPackage()) - .addClasses( - ContextServiceDefinitionServlet.class, - ContextServiceDefinitionInterface.class, - ContextServiceDefinitionWebBean.class) - .deleteClasses(ManagedScheduledExecutorDefinitionBean.class) - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); - - return war; - } - + + @ArquillianResource(ManagedScheduledExecutorDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedScheduledExecutorDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name = "ManagedScheduledExecutorDefinitionTests") + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedScheduledExecutorDefinitionTests_web.war") + .addPackages(false, ManagedScheduledExecutorDefinitionWebTests.class.getPackage()) + .addClasses(ContextServiceDefinitionServlet.class, ContextServiceDefinitionInterface.class, + ContextServiceDefinitionWebBean.class) + .deleteClasses(ManagedScheduledExecutorDefinitionBean.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()); + + return war; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "ManagedScheduledExecutorDefinitionServlet"; - } - - - @Test + + @Override + protected String getServletPath() { + return "ManagedScheduledExecutorDefinitionServlet"; + } + + @Test public void testAsyncCompletionStageMSE() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodRunsWithContext() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testAsynchronousMethodWithMaxAsync3() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - // Accepted TCK Challenge: https://github.com/jakartaee/concurrency/issues/224 - @Disabled + + // Accepted TCK Challenge: https://github.com/jakartaee/concurrency/issues/224 + @Disabled public void testCompletedFutureMSE() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testIncompleteFutureMSE() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testIncompleteFutureMSE_EJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedScheduledExecutorDefinitionAllAttributes() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedScheduledExecutorDefinitionDefaults() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testManagedScheduledExecutorDefinitionDefaults_EJB() { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testNotAnAsynchronousMethod() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testScheduleWithCronTrigger() { - runTest(baseURL, testname); + runTest(baseURL, testname); } - @Test + @Test public void testScheduleWithZonedTrigger() { - runTest(baseURL, testname); + runTest(baseURL, testname); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java index 0984a08b..5a8a635a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java @@ -37,7 +37,7 @@ public class ReqBean { @Asynchronous(executor = "java:app/concurrent/ScheduledExecutorA") public CompletableFuture awaitAndGetThirdPartyContext(Semaphore invocationsStarted, - CountDownLatch blocker) { + CountDownLatch blocker) { invocationsStarted.release(1); CompletableFuture future = Asynchronous.Result.getFuture(); try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java index 9bb543eb..e8dd2263 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java @@ -6,20 +6,24 @@ * Need to provide different JNDI names depending application deployment */ public class SecurityEJBProvider { - - public static class FullProvider implements EJBJNDIProvider { - public FullProvider() {} - @Override - public String getEJBJNDIName() { - return "java:global/security/security_ejb/SecurityTestEjb"; - } - } - - public static class WebProvider implements EJBJNDIProvider { - public WebProvider() {} - @Override - public String getEJBJNDIName() { - return "java:global/security_web/SecurityTestEjb"; - } - } + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:global/security/security_ejb/SecurityTestEjb"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() { + } + + @Override + public String getEJBJNDIName() { + return "java:global/security_web/SecurityTestEjb"; + } + } } 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 959d65b2..fa37fbef 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 @@ -33,53 +33,55 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; -@Full @RunAsClient //Requires client testing due to login request +@Full +@RunAsClient // Requires client testing due to login request public class SecurityFullTests extends TestClient { - - @ArquillianResource(SecurityServlet.class) - URL baseURL; - - @Deployment(name="SecurityTests") - 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 - - JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") - .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) - .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class); - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "security.ear") - .addAsModules(war, jar); - - return ear; - } - + + @ArquillianResource(SecurityServlet.class) + URL baseURL; + + @Deployment(name = "SecurityTests") + 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 + + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") + .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class); + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "security.ear").addAsModules(war, jar); + + return ear; + } + @TestName String testname; - - @Override - 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. + @Override + 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 - public void managedScheduledExecutorServiceAPISecurityTest() { - runTest(baseURL, testname); - } + * fix: https://github.com/jakartaee/concurrency/pull/221 Can be reenabled in + * the next release of Jakarta Concurrency + */ + @Disabled + public void managedScheduledExecutorServiceAPISecurityTest() { + runTest(baseURL, testname); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java index 72efaa30..176833fc 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java @@ -35,13 +35,15 @@ @WebServlet("/SecurityServlet") public class SecurityServlet extends TestServlet { - public void managedScheduledExecutorServiceAPISecurityTest(HttpServletRequest req, HttpServletResponse res) throws Exception { - req.login("javajoe", "javajoe"); - - ManagedScheduledExecutorService executorService = InitialContext.doLookup(TestConstants.DefaultManagedScheduledExecutorService); - ScheduledFuture future = executorService.schedule(new SecurityTestTask(), new CommonTriggers.OnceTrigger()); - - Object result = Wait.waitForTaskComplete(future); - assertEquals(result, TestConstants.SimpleReturnValue); - } + public void managedScheduledExecutorServiceAPISecurityTest(HttpServletRequest req, HttpServletResponse res) + throws Exception { + req.login("javajoe", "javajoe"); + + ManagedScheduledExecutorService executorService = InitialContext + .doLookup(TestConstants.DefaultManagedScheduledExecutorService); + ScheduledFuture future = executorService.schedule(new SecurityTestTask(), new CommonTriggers.OnceTrigger()); + + Object result = Wait.waitForTaskComplete(future); + assertEquals(result, TestConstants.SimpleReturnValue); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java index a7625b9d..ed43b452 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java @@ -22,9 +22,9 @@ @Stateless public class SecurityTestEjb implements SecurityTestInterface { - - @RolesAllowed("Manager") - public String managerMethod1() { - return TestConstants.SimpleReturnValue; - } + + @RolesAllowed("Manager") + public String managerMethod1() { + return TestConstants.SimpleReturnValue; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestInterface.java index 30c17d9c..150b6271 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestInterface.java @@ -16,9 +16,8 @@ package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.security; - public interface SecurityTestInterface { - public String managerMethod1(); + public String managerMethod1(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java index dc47a607..3dbec6a9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java @@ -25,13 +25,13 @@ public class SecurityTestTask implements Callable { - public String call() { - try { - EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); - SecurityTestInterface str = InitialContext.doLookup(nameProvider.getEJBJNDIName()); - return str.managerMethod1(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } + public String call() { + try { + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + SecurityTestInterface str = InitialContext.doLookup(nameProvider.getEJBJNDIName()); + return str.managerMethod1(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } } 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 bbc60341..a0046fa8 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 @@ -32,45 +32,46 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to login request -@Common({PACKAGE.TASKS}) +@Web +@RunAsClient // Requires client testing due to login request +@Common({ PACKAGE.TASKS }) public class SecurityWebTests extends TestClient { - - @ArquillianResource(SecurityServlet.class) - URL baseURL; - - @Deployment(name="SecurityTests") - public static WebArchive createDeployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class, "security_web.war") - .addPackages(true, SecurityWebTests.class.getPackage()) - .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.WebProvider.class); - - return war; - } - + + @ArquillianResource(SecurityServlet.class) + URL baseURL; + + @Deployment(name = "SecurityTests") + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class, "security_web.war") + .addPackages(true, SecurityWebTests.class.getPackage()) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.WebProvider.class); + + return war; + } + @TestName String testname; - - @Override - 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. + @Override + 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 - public void managedScheduledExecutorServiceAPISecurityTest() { - runTest(baseURL, testname); - } + * fix: https://github.com/jakartaee/concurrency/pull/221 Can be reenabled in + * the next release of Jakarta Concurrency + */ + @Disabled + public void managedScheduledExecutorServiceAPISecurityTest() { + runTest(baseURL, testname); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java index bd35a2c4..439fe0c7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java @@ -22,14 +22,14 @@ import jakarta.enterprise.concurrent.Trigger; public class OnceTrigger implements Trigger { - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { - if (lastExecutionInfo != null) { - return null; - } - return new Date(); - } + public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + if (lastExecutionInfo != null) { + return null; + } + return new Date(); + } - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { - return false; - } + public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + return false; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java index 86f23a5e..473ff029 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java @@ -43,71 +43,64 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -@SuppressWarnings({"serial", "unused"}) +@SuppressWarnings({ "serial", "unused" }) @WebServlet(Constants.CONTEXT_PATH) -@DataSourceDefinition( - name = "java:comp/env/jdbc/ManagedScheduledExecutorServiceDB", - className = "org.apache.derby.jdbc.EmbeddedDataSource", - databaseName = "memory:ManagedScheduledExecutorServiceDB", - properties = { - "createDatabase=create" - } -) +@DataSourceDefinition(name = "java:comp/env/jdbc/ManagedScheduledExecutorServiceDB", className = "org.apache.derby.jdbc.EmbeddedDataSource", databaseName = "memory:ManagedScheduledExecutorServiceDB", properties = { + "createDatabase=create" }) public class TransactionServlet extends TestServlet { - private static final TestLogger log = TestLogger.get(TransactionServlet.class); - - @Resource(lookup = "java:comp/env/jdbc/ManagedScheduledExecutorServiceDB") - private DataSource ds; - - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) - private ManagedScheduledExecutorService managedScheduledExecutorService; - - @Override - protected void beforeClass() throws RemoteException { - log.enter("beforeClass"); - - Connections.setDataSource(ds); - - try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { - try { - stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); - } catch (SQLException e) { - log.finest("Could not drop table, assume table did not exist."); - } - stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); - log.exit("beforeClass"); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { - boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); - Future taskResult = managedScheduledExecutorService.schedule( - new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT), - new OnceTrigger()); - Wait.waitForTaskComplete(taskResult); - } - - public void cancelTest() { - int originTableCount = Counter.getCount(); - - CancelledTransactedTask cancelledTask = new CancelledTransactedTask(Constants.SQL_TEMPLATE_INSERT); - Future future = managedScheduledExecutorService.schedule(cancelledTask, new OnceTrigger()); - - + private static final TestLogger log = TestLogger.get(TransactionServlet.class); + + @Resource(lookup = "java:comp/env/jdbc/ManagedScheduledExecutorServiceDB") + private DataSource ds; + + @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + private ManagedScheduledExecutorService managedScheduledExecutorService; + + @Override + protected void beforeClass() throws RemoteException { + log.enter("beforeClass"); + + Connections.setDataSource(ds); + + try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { + try { + stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); + } catch (SQLException e) { + log.finest("Could not drop table, assume table did not exist."); + } + stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); + log.exit("beforeClass"); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); + Future taskResult = managedScheduledExecutorService + .schedule(new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT), new OnceTrigger()); + Wait.waitForTaskComplete(taskResult); + } + + public void cancelTest() { + int originTableCount = Counter.getCount(); + + CancelledTransactedTask cancelledTask = new CancelledTransactedTask(Constants.SQL_TEMPLATE_INSERT); + Future future = managedScheduledExecutorService.schedule(cancelledTask, new OnceTrigger()); + // then cancel it after transaction begin and Wait.waitForTransactionBegan(cancelledTask); - + // before it commit. cancelledTask.cancelTransaction.set(true); - + // continue to run if possible. - cancelledTask.runQuery.set(true);; - + cancelledTask.runQuery.set(true); + ; + int afterTransacted = Counter.getCount(); - + assertEquals(originTableCount, afterTransacted, "task was not properly cancelled"); - } + } } 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 eec960c5..a90622d7 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 @@ -33,38 +33,39 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to annotation configuration +@Web +@RunAsClient // Requires client testing due to annotation configuration @Common({ PACKAGE.TRANSACTION }) public class TransactionTests extends TestClient { - @ArquillianResource - URL baseURL; - - @Deployment(name="TransactionTests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, TransactionTests.class.getPackage()); - } + @ArquillianResource + URL baseURL; - /* - * @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) - public void testRollbackTransactionWithManagedScheduledExecutorService() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); - } - - /* + @Deployment(name = "TransactionTests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class).addPackages(true, TransactionTests.class.getPackage()); + } + + /* + * @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) + 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; @@ -76,27 +77,29 @@ public void testRollbackTransactionWithManagedScheduledExecutorService() { * ManagedScheduledExecutorService.it support user-managed global transaction * demarcation using the jakarta.transaction.UserTransaction interface. */ - @Test //TODO rewrite test logic to avoid duplicate key violation + @Test // TODO rewrite test logic to avoid duplicate key violation @Order(2) public void testCommitTransactionWithManagedScheduledExecutorService() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_TRUE).withTestName("transactionTest")); + 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) - public void testCancelTransactionWithManagedScheduledExecutorService() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_CANCEL).withTestName("cancelTest")); - } + /* + * @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) + 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 5840f58c..830b6d31 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 @@ -32,54 +32,55 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Full; import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; -@Full @RunAsClient //Requires client testing due to login request +@Full +@RunAsClient // Requires client testing due to login request public class ContextFullTests extends TestClient { - - @ArquillianResource - URL baseURL; - - @Deployment(name="ContextTests") - public static EnterpriseArchive createDeployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class) - .addPackages(true, ContextFullTests.class.getPackage()) - .addPackages(false, PACKAGE.TASKS.getPackageName()) - .deleteClass(SecurityTestEjb.class) // SecurityTestEjb and SecurityTestInterface are in the jar - .deleteClass(SecurityTestInterface.class) - .addAsWebInfResource(ContextFullTests.class.getPackage(), "web.xml", "web.xml"); - - JavaArchive jar = ShrinkWrap.create(JavaArchive.class) - .addClasses(SecurityTestInterface.class, SecurityTestEjb.class); - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class) - .addAsModules(war, jar); - - return ear; - } - + + @ArquillianResource + URL baseURL; + + @Deployment(name = "ContextTests") + public static EnterpriseArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class).addPackages(true, ContextFullTests.class.getPackage()) + .addPackages(false, PACKAGE.TASKS.getPackageName()).deleteClass(SecurityTestEjb.class) // SecurityTestEjb + // and + // SecurityTestInterface + // are in the jar + .deleteClass(SecurityTestInterface.class) + .addAsWebInfResource(ContextFullTests.class.getPackage(), "web.xml", "web.xml"); + + JavaArchive jar = ShrinkWrap.create(JavaArchive.class).addClasses(SecurityTestInterface.class, + SecurityTestEjb.class); + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class).addAsModules(war, jar); + + return ear; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "SecurityServlet"; - } - - /* - * @testName: jndiClassloaderPropagationTest - * - * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; - * CONCURRENCY:SPEC:106; - * - * @test_Strategy: - */ - @Test - public void jndiClassloaderPropagationTest() { - runTest(baseURL, testname); - } - - @Test - public void jndiClassloaderPropagationWithSecurityTest() { - runTest(baseURL, testname); - } + + @Override + protected String getServletPath() { + return "SecurityServlet"; + } + + /* + * @testName: jndiClassloaderPropagationTest + * + * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; + * CONCURRENCY:SPEC:106; + * + * @test_Strategy: + */ + @Test + public void jndiClassloaderPropagationTest() { + runTest(baseURL, testname); + } + + @Test + 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 ad1e22cf..42715cfc 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 @@ -31,46 +31,46 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.TestName; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to login request -@Common({PACKAGE.TASKS}) +@Web +@RunAsClient // Requires client testing due to login request +@Common({ PACKAGE.TASKS }) public class ContextWebTests extends TestClient { - - @ArquillianResource - URL baseURL; - - @Deployment(name="ContextTests") - public static WebArchive createDeployment() { - WebArchive war = ShrinkWrap.create(WebArchive.class) - .addPackages(true, ContextWebTests.class.getPackage()) - .addAsWebInfResource(ContextWebTests.class.getPackage(), "web.xml", "web.xml"); - - return war; - } - + + @ArquillianResource + URL baseURL; + + @Deployment(name = "ContextTests") + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class).addPackages(true, ContextWebTests.class.getPackage()) + .addAsWebInfResource(ContextWebTests.class.getPackage(), "web.xml", "web.xml"); + + return war; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "SecurityServlet"; - } - - /* - * @testName: jndiClassloaderPropagationTest - * - * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; - * CONCURRENCY:SPEC:106; - * - * @test_Strategy: - */ - @Test - public void jndiClassloaderPropagationTest() { - runTest(baseURL, testname); - } - - @Test - public void jndiClassloaderPropagationWithSecurityTest() { - runTest(baseURL, testname); - } + + @Override + protected String getServletPath() { + return "SecurityServlet"; + } + + /* + * @testName: jndiClassloaderPropagationTest + * + * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; + * CONCURRENCY:SPEC:106; + * + * @test_Strategy: + */ + @Test + public void jndiClassloaderPropagationTest() { + runTest(baseURL, testname); + } + + @Test + public void jndiClassloaderPropagationWithSecurityTest() { + runTest(baseURL, testname); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java index 9744ee5a..32a7d3d2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java @@ -33,77 +33,78 @@ @SuppressWarnings("serial") @WebServlet("/SecurityServlet") public class SecurityServlet extends TestServlet { - - @EJB - private SecurityTestInterface str; - private static final String TEST_JNDI_EVN_ENTRY_VALUE = "hello"; + @EJB + private SecurityTestInterface str; - private static final String TEST_JNDI_EVN_ENTRY_JNDI_NAME = "java:comp/env/ManagedThreadFactory_test_string"; + private static final String TEST_JNDI_EVN_ENTRY_VALUE = "hello"; - private static final String TEST_CLASSLOADER_CLASS_NAME = SecurityServlet.class.getCanonicalName(); + private static final String TEST_JNDI_EVN_ENTRY_JNDI_NAME = "java:comp/env/ManagedThreadFactory_test_string"; - public void jndiClassloaderPropagationTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + private static final String TEST_CLASSLOADER_CLASS_NAME = SecurityServlet.class.getCanonicalName(); - ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.DefaultManagedThreadFactory); + public void jndiClassloaderPropagationTest(HttpServletRequest req, HttpServletResponse res) throws Exception { - CounterRunnableWithContext task = new CounterRunnableWithContext(); - Thread thread = factory.newThread(task); - thread.start(); - Wait.waitTillThreadFinish(thread); - assertEquals(task.getCount(), 1); - } - - public void jndiClassloaderPropagationWithSecurityTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.DefaultManagedThreadFactory); - req.login("javajoe", "javajoe"); - - ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.DefaultManagedThreadFactory); + CounterRunnableWithContext task = new CounterRunnableWithContext(); + Thread thread = factory.newThread(task); + thread.start(); + Wait.waitTillThreadFinish(thread); + assertEquals(task.getCount(), 1); + } - CounterRunnableWithSecurityCheck task = new CounterRunnableWithSecurityCheck(str); - Thread thread = factory.newThread(task); - thread.start(); - Wait.waitTillThreadFinish(thread); - assertEquals(task.getCount(), 1); -} + public void jndiClassloaderPropagationWithSecurityTest(HttpServletRequest req, HttpServletResponse res) + throws Exception { + + req.login("javajoe", "javajoe"); + + ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.DefaultManagedThreadFactory); + + CounterRunnableWithSecurityCheck task = new CounterRunnableWithSecurityCheck(str); + Thread thread = factory.newThread(task); + thread.start(); + Wait.waitTillThreadFinish(thread); + assertEquals(task.getCount(), 1); + } + + public static class CounterRunnableWithContext extends RunnableTask { + private volatile int count = 0; + + public int getCount() { + return count; + } + + public CounterRunnableWithContext() { + super(TEST_JNDI_EVN_ENTRY_JNDI_NAME, TEST_JNDI_EVN_ENTRY_VALUE, TEST_CLASSLOADER_CLASS_NAME); + } + + public void run() { + super.run(); + count++; + } + } + + public static class CounterRunnableWithSecurityCheck implements Runnable { + private volatile int count = 0; + + private SecurityTestInterface str; + + CounterRunnableWithSecurityCheck(SecurityTestInterface str) { + this.str = str; + } + + public int getCount() { + return count; + } - public static class CounterRunnableWithContext extends RunnableTask { - private volatile int count = 0; - - public int getCount() { - return count; - } - - public CounterRunnableWithContext() { - super(TEST_JNDI_EVN_ENTRY_JNDI_NAME, TEST_JNDI_EVN_ENTRY_VALUE, TEST_CLASSLOADER_CLASS_NAME); - } - - public void run() { - super.run(); - count++; - } - } - - public static class CounterRunnableWithSecurityCheck implements Runnable { - private volatile int count = 0; - - private SecurityTestInterface str; - - CounterRunnableWithSecurityCheck(SecurityTestInterface str) { - this.str = str; - } - - public int getCount() { - return count; - } - - public void run() { - try { - assertEquals(str.managerMethod1(), TestConstants.SimpleReturnValue); - } catch (Exception e) { - return; - } - count++; - } - } + public void run() { + try { + assertEquals(str.managerMethod1(), TestConstants.SimpleReturnValue); + } catch (Exception e) { + return; + } + count++; + } + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java index 8659dd35..9aa987e7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java @@ -23,8 +23,8 @@ @Stateless public class SecurityTestEjb implements SecurityTestInterface { - @RolesAllowed("Manager") - public String managerMethod1() { - return TestConstants.SimpleReturnValue; - } + @RolesAllowed("Manager") + public String managerMethod1() { + return TestConstants.SimpleReturnValue; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestInterface.java index c53bf233..c800c4fe 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestInterface.java @@ -16,9 +16,8 @@ package ee.jakarta.tck.concurrent.spec.ManagedThreadFactory.context; - public interface SecurityTestInterface { - public String managerMethod1(); + public String managerMethod1(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java index 69d0ce19..70a015d0 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java @@ -24,18 +24,17 @@ import jakarta.enterprise.concurrent.ManagedThreadFactoryDefinition; /** - * @ContextServiceDefinitions are defined under {@link ContextServiceDefinitionServlet} + * @ContextServiceDefinitions are defined under + * {@link ContextServiceDefinitionServlet} */ -@ManagedThreadFactoryDefinition(name = "java:app/concurrent/EJBThreadFactoryA", - context = "java:app/concurrent/EJBContextA", - priority = 4) +@ManagedThreadFactoryDefinition(name = "java:app/concurrent/EJBThreadFactoryA", context = "java:app/concurrent/EJBContextA", priority = 4) @ManagedThreadFactoryDefinition(name = "java:comp/concurrent/EJBThreadFactoryB") @Local(ManagedThreadFactoryDefinitionInterface.class) @Stateless public class ManagedThreadFactoryDefinitionBean implements ManagedThreadFactoryDefinitionInterface { - @Override - public Object doLookup(String name) throws NamingException { - return InitialContext.doLookup(name); - } + @Override + public Object doLookup(String name) throws NamingException { + return InitialContext.doLookup(name); + } } 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 f055d326..4d227a67 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 @@ -39,84 +39,86 @@ import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionServlet; import jakarta.enterprise.concurrent.spi.ThreadContextProvider; -@Full @RunAsClient //Requires client testing due to multiple servlets and annotation configuration +@Full +@RunAsClient // Requires client testing due to multiple servlets and annotation configuration public class ManagedThreadFactoryDefinitionFullTests extends TestClient { - - @ArquillianResource(ManagedThreadFactoryDefinitionServlet.class) - URL baseURL; - - @ArquillianResource(ManagedThreadFactoryDefinitionOnEJBServlet.class) - URL ejbContextURL; - - @Deployment(name="ManagedThreadFactoryDefinitionTests") - public static EnterpriseArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedThreadFactoryDefinitionTests_web.war") - .addPackages(false, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) - .addClasses( - ManagedThreadFactoryDefinitionOnEJBServlet.class, - ManagedThreadFactoryDefinitionServlet.class, - ContextServiceDefinitionServlet.class) - .addAsWebInfResource(ManagedThreadFactoryDefinitionFullTests.class.getPackage(), "web.xml", "web.xml") - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); - - JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ManagedThreadFactoryDefinitionTests_ejb.jar") - .addPackages(false, ManagedThreadFactoryDefinitionFullTests.class.getPackage()) - .deleteClasses( - ManagedThreadFactoryDefinitionOnEJBServlet.class, - ManagedThreadFactoryDefinitionServlet.class) - .addClasses( - ContextServiceDefinitionInterface.class, - ContextServiceDefinitionBean.class) - .addAsManifestResource(ManagedThreadFactoryDefinitionFullTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); - - EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ManagedThreadFactoryDefinitionTests.ear").addAsModules(war, jar); - - return ear; - } - + + @ArquillianResource(ManagedThreadFactoryDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedThreadFactoryDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name = "ManagedThreadFactoryDefinitionTests") + public static EnterpriseArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedThreadFactoryDefinitionTests_web.war") + .addPackages(false, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) + .addClasses(ManagedThreadFactoryDefinitionOnEJBServlet.class, + ManagedThreadFactoryDefinitionServlet.class, ContextServiceDefinitionServlet.class) + .addAsWebInfResource(ManagedThreadFactoryDefinitionFullTests.class.getPackage(), "web.xml", "web.xml") + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()); + + JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ManagedThreadFactoryDefinitionTests_ejb.jar") + .addPackages(false, ManagedThreadFactoryDefinitionFullTests.class.getPackage()) + .deleteClasses(ManagedThreadFactoryDefinitionOnEJBServlet.class, + ManagedThreadFactoryDefinitionServlet.class) + .addClasses(ContextServiceDefinitionInterface.class, ContextServiceDefinitionBean.class) + .addAsManifestResource(ManagedThreadFactoryDefinitionFullTests.class.getPackage(), "ejb-jar.xml", + "ejb-jar.xml"); + + EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ManagedThreadFactoryDefinitionTests.ear") + .addAsModules(war, jar); + + return ear; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "ManagedThreadFactoryDefinitionServlet"; - } - + + @Override + protected String getServletPath() { + return "ManagedThreadFactoryDefinitionServlet"; + } + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { - runTest(baseURL, testname); + runTest(baseURL, testname); } - + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 + @Disabled public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { - runTest(baseURL, testname); + runTest(baseURL, testname); } - + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled public void testParallelStreamBackedByManagedThreadFactoryEJB() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); - } + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionInterface.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionInterface.java index b307f9c1..63df0d28 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionInterface.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionInterface.java @@ -19,6 +19,6 @@ public interface ManagedThreadFactoryDefinitionInterface { - Object doLookup(String name) throws NamingException; + Object doLookup(String name) throws NamingException; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java index 13d8ff81..8b89583d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java @@ -53,25 +53,26 @@ public class ManagedThreadFactoryDefinitionOnEJBServlet extends TestServlet { @Resource UserTransaction tx; - + @EJB private ManagedThreadFactoryDefinitionInterface managedThreadFactoryDefinitionBean; - //Needed to initialize the ContextServiceDefinitions - @EJB - private ContextServiceDefinitionInterface contextServiceDefinitionBean; - - @Override - public void init() throws ServletException { - try { - managedThreadFactoryDefinitionBean.doLookup("java:module/concurrent/ContextB"); - } catch (NamingException e) { - throw new ServletException(e); - } - } - + // Needed to initialize the ContextServiceDefinitions + @EJB + private ContextServiceDefinitionInterface contextServiceDefinitionBean; + + @Override + public void init() throws ServletException { + try { + managedThreadFactoryDefinitionBean.doLookup("java:module/concurrent/ContextB"); + } catch (NamingException e) { + throw new ServletException(e); + } + } + /** - * A ManagedThreadFactoryDefinition defined on an EJB with all attributes configured enforces priority and propagates context. + * A ManagedThreadFactoryDefinition defined on an EJB with all attributes + * configured enforces priority and propagates context. */ public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { try { @@ -83,10 +84,10 @@ public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwabl IntContext.set(162); StringContext.set("testManagedThreadFactoryDefinitionAllAttributesEJB-2"); - Thread thread1 = threadFactory.newThread(() -> {}); - assertEquals(thread1.getPriority(), 4, - "New threads must be created with the priority that is specified on " + - "ManagedThreadFactoryDefinition"); + Thread thread1 = threadFactory.newThread(() -> { + }); + assertEquals(thread1.getPriority(), 4, "New threads must be created with the priority that is specified on " + + "ManagedThreadFactoryDefinition"); BlockingQueue results = new LinkedBlockingQueue(); @@ -102,23 +103,22 @@ public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwabl }).start(); assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(4), - "ManagedThreadFactory must start threads with the configured priority."); + "ManagedThreadFactory must start threads with the configured priority."); assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "", - "Third-party context type StringContext must be cleared from thread " + - "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); + "Third-party context type StringContext must be cleared from thread " + + "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(161), - "Third-party context type IntContext must be propagated to thread " + - "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration " + - "based on the thread context at the time the ManagedThreadFactory was looked up."); + "Third-party context type IntContext must be propagated to thread " + + "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration " + + "based on the thread context at the time the ManagedThreadFactory was looked up."); Object lookupResult = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); if (lookupResult instanceof Throwable) throw new AssertionError().initCause((Throwable) lookupResult); - assertTrue(lookupResult instanceof ContextService, - "Application context must be propagated to thread " + - "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); + assertTrue(lookupResult instanceof ContextService, "Application context must be propagated to thread " + + "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); } finally { IntContext.set(0); StringContext.set(""); @@ -126,11 +126,13 @@ public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwabl } /** - * ManagedThreadFactoryDefinition defined on an EJB with minimal attributes creates threads with normal priority - * and uses java:comp/DefaultContextService to determine context propagation and clearing. + * 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 { - ManagedThreadFactory threadFactory = (ManagedThreadFactory) managedThreadFactoryDefinitionBean.doLookup("java:comp/concurrent/EJBThreadFactoryB"); + ManagedThreadFactory threadFactory = (ManagedThreadFactory) managedThreadFactoryDefinitionBean + .doLookup("java:comp/concurrent/EJBThreadFactoryB"); CountDownLatch blocker = new CountDownLatch(1); CountDownLatch allThreadsRunning = new CountDownLatch(2); @@ -141,7 +143,8 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { try { allThreadsRunning.countDown(); blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); - lookupTaskResult.complete((ManagedThreadFactory) managedThreadFactoryDefinitionBean.doLookup("java:comp/concurrent/EJBThreadFactoryB")); + lookupTaskResult.complete((ManagedThreadFactory) managedThreadFactoryDefinitionBean + .doLookup("java:comp/concurrent/EJBThreadFactoryB")); } catch (Throwable x) { lookupTaskResult.completeExceptionally(x); } @@ -169,7 +172,7 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { threadFactory.newThread(txTask).start(); assertTrue(allThreadsRunning.await(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "ManagedThreadFactory threads must start running."); + "ManagedThreadFactory threads must start running."); blocker.countDown(); @@ -177,14 +180,13 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { if ((result = txTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) throw new AssertionError().initCause((Throwable) result); assertEquals(result, Integer.valueOf(Status.STATUS_NO_TRANSACTION), - "Transaction context must be cleared from async Callable task " + - "per java:comp/concurrent/EJBThreadFactoryB configuration."); - + "Transaction context must be cleared from async Callable task " + + "per java:comp/concurrent/EJBThreadFactoryB configuration."); + if ((result = lookupTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) throw new AssertionError().initCause((Throwable) result); - assertTrue(result instanceof ManagedThreadFactory, - "Application context must be propagated to first thread " + - "per java:comp/concurrent/EJBThreadFactoryB configuration."); + assertTrue(result instanceof ManagedThreadFactory, "Application context must be propagated to first thread " + + "per java:comp/concurrent/EJBThreadFactoryB configuration."); } finally { IntContext.set(0); blocker.countDown(); @@ -192,15 +194,16 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { } /** - * ManagedThreadFactory defined on an EJB can be supplied to a ForkJoinPool, causing ForkJoinPool tasks to run with the - * thread context and priority as configured. + * ManagedThreadFactory defined on an EJB can be supplied to a ForkJoinPool, + * causing ForkJoinPool tasks to run with the thread context and priority as + * configured. */ public void testParallelStreamBackedByManagedThreadFactoryEJB() throws Throwable { ForkJoinPool fj = null; try { IntContext.set(1000); StringContext.set("testParallelStreamBackedByManagedThreadFactoryEJB-1"); - + ManagedThreadFactory threadFactory = InitialContext.doLookup("java:app/concurrent/EJBThreadFactoryA"); IntContext.set(2000); @@ -212,29 +215,25 @@ public void testParallelStreamBackedByManagedThreadFactoryEJB() throws Throwable StringContext.set("testParallelStreamBackedByManagedThreadFactoryEJB-3"); ForkJoinTask> task = fj.submit(() -> { - return Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9) - .parallelStream() - .map(num -> { - assertEquals(StringContext.get(), "", - "Third-party context type StringContext must be cleared on " + - "ForkJoin thread."); - try { - assertNotNull(InitialContext.doLookup("java:app/concurrent/ContextA"), - "Application context must be propagated to ForkJoin thread"); - } catch (NamingException x) { - throw new CompletionException(x); - } - return num * Thread.currentThread().getPriority() + IntContext.get(); - }) - .reduce(Integer::sum); + return Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9).parallelStream().map(num -> { + assertEquals(StringContext.get(), "", + "Third-party context type StringContext must be cleared on " + "ForkJoin thread."); + try { + assertNotNull(InitialContext.doLookup("java:app/concurrent/ContextA"), + "Application context must be propagated to ForkJoin thread"); + } catch (NamingException x) { + throw new CompletionException(x); + } + return num * Thread.currentThread().getPriority() + IntContext.get(); + }).reduce(Integer::sum); }); Optional result = task.join(); assertEquals(result.get(), Integer.valueOf(9180), - "Third-party context type IntContext must propagated to ForkJoin threads " + - "(thousands digit should be 9) and thread priority (4) must be enforced " + - "on ForkJoin threads (hundreds/tens/ones digits must be 4x5x9=180) " + - "per configuration of the ManagedThreadFactoryDefinition and ContextServiceDefinition."); + "Third-party context type IntContext must propagated to ForkJoin threads " + + "(thousands digit should be 9) and thread priority (4) must be enforced " + + "on ForkJoin threads (hundreds/tens/ones digits must be 4x5x9=180) " + + "per configuration of the ManagedThreadFactoryDefinition and ContextServiceDefinition."); } finally { IntContext.set(0); StringContext.set(null); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java index b7330c2a..eb129868 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java @@ -46,11 +46,10 @@ import jakarta.transaction.UserTransaction; /** - * @ContextServiceDefinitions are defined under {@link ContextServiceDefinitionServlet} + * @ContextServiceDefinitions are defined under + * {@link ContextServiceDefinitionServlet} */ -@ManagedThreadFactoryDefinition(name = "java:app/concurrent/ThreadFactoryA", - context = "java:app/concurrent/ContextA", - priority = 4) +@ManagedThreadFactoryDefinition(name = "java:app/concurrent/ThreadFactoryA", context = "java:app/concurrent/ContextA", priority = 4) @ManagedThreadFactoryDefinition(name = "java:comp/concurrent/ThreadFactoryB") @WebServlet("/ManagedThreadFactoryDefinitionServlet") public class ManagedThreadFactoryDefinitionServlet extends TestServlet { @@ -61,7 +60,8 @@ public class ManagedThreadFactoryDefinitionServlet extends TestServlet { UserTransaction tx; /** - * A ManagedThreadFactoryDefinition with all attributes configured enforces priority and propagates context. + * A ManagedThreadFactoryDefinition with all attributes configured enforces + * priority and propagates context. */ public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { try { @@ -73,10 +73,10 @@ public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { IntContext.set(162); StringContext.set("testManagedThreadFactoryDefinitionAllAttributes-2"); - Thread thread1 = threadFactory.newThread(() -> {}); - assertEquals(thread1.getPriority(), 4, - "New threads must be created with the priority that is specified on " + - "ManagedThreadFactoryDefinition"); + Thread thread1 = threadFactory.newThread(() -> { + }); + assertEquals(thread1.getPriority(), 4, "New threads must be created with the priority that is specified on " + + "ManagedThreadFactoryDefinition"); BlockingQueue results = new LinkedBlockingQueue(); @@ -92,23 +92,22 @@ public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { }).start(); assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(4), - "ManagedThreadFactory must start threads with the configured priority."); + "ManagedThreadFactory must start threads with the configured priority."); assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "", - "Third-party context type StringContext must be cleared from thread " + - "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); + "Third-party context type StringContext must be cleared from thread " + + "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(161), - "Third-party context type IntContext must be propagated to thread " + - "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration " + - "based on the thread context at the time the ManagedThreadFactory was looked up."); + "Third-party context type IntContext must be propagated to thread " + + "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration " + + "based on the thread context at the time the ManagedThreadFactory was looked up."); Object lookupResult = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); if (lookupResult instanceof Throwable) throw new AssertionError().initCause((Throwable) lookupResult); - assertTrue(lookupResult instanceof ContextService, - "Application context must be propagated to thread " + - "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); + assertTrue(lookupResult instanceof ContextService, "Application context must be propagated to thread " + + "per ManagedThreadFactoryDefinition and ContextServiceDefinition configuration."); } finally { IntContext.set(0); StringContext.set(""); @@ -116,8 +115,9 @@ public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { } /** - * ManagedThreadFactoryDefinition with minimal attributes creates threads with normal priority - * and uses java:comp/DefaultContextService to determine context propagation and clearing. + * ManagedThreadFactoryDefinition with minimal attributes creates threads with + * normal priority and uses java:comp/DefaultContextService to determine context + * propagation and clearing. */ public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { ManagedThreadFactory threadFactory = InitialContext.doLookup("java:comp/concurrent/ThreadFactoryB"); @@ -159,22 +159,21 @@ public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { threadFactory.newThread(txTask).start(); assertTrue(allThreadsRunning.await(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "ManagedThreadFactory threads must start running."); + "ManagedThreadFactory threads must start running."); blocker.countDown(); Object result; if ((result = lookupTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) throw new AssertionError().initCause((Throwable) result); - assertTrue(result instanceof ContextService, - "Application context must be propagated to first thread " + - "per java:comp/concurrent/ThreadFactoryB configuration."); + assertTrue(result instanceof ContextService, "Application context must be propagated to first thread " + + "per java:comp/concurrent/ThreadFactoryB configuration."); if ((result = txTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) throw new AssertionError().initCause((Throwable) result); assertEquals(result, Integer.valueOf(Status.STATUS_NO_TRANSACTION), - "Transaction context must be cleared from async Callable task " + - "per java:comp/concurrent/ThreadFactoryB configuration."); + "Transaction context must be cleared from async Callable task " + + "per java:comp/concurrent/ThreadFactoryB configuration."); } finally { IntContext.set(0); blocker.countDown(); @@ -182,8 +181,8 @@ public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { } /** - * ManagedThreadFactory can be supplied to a ForkJoinPool, causing ForkJoinPool tasks to run with the - * thread context and priority as configured. + * ManagedThreadFactory can be supplied to a ForkJoinPool, causing ForkJoinPool + * tasks to run with the thread context and priority as configured. */ public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { ForkJoinPool fj = null; @@ -202,29 +201,25 @@ public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { StringContext.set("testParallelStreamBackedByManagedThreadFactory-3"); ForkJoinTask> task = fj.submit(() -> { - return Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9) - .parallelStream() - .map(num -> { - assertEquals(StringContext.get(), "", - "Third-party context type StringContext must be cleared on " + - "ForkJoin thread."); - try { - assertNotNull(InitialContext.doLookup("java:app/concurrent/ContextA"), - "Application context must be propagated to ForkJoin thread"); - } catch (NamingException x) { - throw new CompletionException(x); - } - return num * Thread.currentThread().getPriority() + IntContext.get(); - }) - .reduce(Integer::sum); + return Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9).parallelStream().map(num -> { + assertEquals(StringContext.get(), "", + "Third-party context type StringContext must be cleared on " + "ForkJoin thread."); + try { + assertNotNull(InitialContext.doLookup("java:app/concurrent/ContextA"), + "Application context must be propagated to ForkJoin thread"); + } catch (NamingException x) { + throw new CompletionException(x); + } + return num * Thread.currentThread().getPriority() + IntContext.get(); + }).reduce(Integer::sum); }); Optional result = task.join(); assertEquals(result.get(), Integer.valueOf(9180), - "Third-party context type IntContext must propagated to ForkJoin threads " + - "(thousands digit should be 9) and thread priority (4) must be enforced " + - "on ForkJoin threads (hundreds/tens/ones digits must be 4x5x9=180) " + - "per configuration of the ManagedThreadFactoryDefinition and ContextServiceDefinition."); + "Third-party context type IntContext must propagated to ForkJoin threads " + + "(thousands digit should be 9) and thread priority (4) must be enforced " + + "on ForkJoin threads (hundreds/tens/ones digits must be 4x5x9=180) " + + "per configuration of the ManagedThreadFactoryDefinition and ContextServiceDefinition."); } finally { IntContext.set(0); StringContext.set(null); 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 48966016..f5cc397b 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 @@ -38,74 +38,78 @@ import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionWebBean; import jakarta.enterprise.concurrent.spi.ThreadContextProvider;; -@Web @RunAsClient //Requires client testing due to multiple servlets and annotation configuration -@Common({PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS}) +@Web +@RunAsClient // Requires client testing due to multiple servlets and annotation configuration +@Common({ PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS }) public class ManagedThreadFactoryDefinitionWebTests extends TestClient { - - @ArquillianResource(ManagedThreadFactoryDefinitionServlet.class) - URL baseURL; - - @ArquillianResource(ManagedThreadFactoryDefinitionOnEJBServlet.class) - URL ejbContextURL; - - @Deployment(name="ManagedThreadFactoryDefinitionTests") - public static WebArchive createDeployment() { - - WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedThreadFactoryDefinitionTests_web.war") - .addPackages(false, ManagedThreadFactoryDefinitionWebTests.class.getPackage()) - .addClasses( - ContextServiceDefinitionInterface.class, - ContextServiceDefinitionWebBean.class, - ContextServiceDefinitionServlet.class) - .addAsWebInfResource(ManagedThreadFactoryDefinitionWebTests.class.getPackage(), "web.xml", "web.xml") - .addAsWebInfResource(ManagedThreadFactoryDefinitionWebTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml") - .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); - - return war; - } - + + @ArquillianResource(ManagedThreadFactoryDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedThreadFactoryDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name = "ManagedThreadFactoryDefinitionTests") + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedThreadFactoryDefinitionTests_web.war") + .addPackages(false, ManagedThreadFactoryDefinitionWebTests.class.getPackage()) + .addClasses(ContextServiceDefinitionInterface.class, ContextServiceDefinitionWebBean.class, + ContextServiceDefinitionServlet.class) + .addAsWebInfResource(ManagedThreadFactoryDefinitionWebTests.class.getPackage(), "web.xml", "web.xml") + .addAsWebInfResource(ManagedThreadFactoryDefinitionWebTests.class.getPackage(), "ejb-jar.xml", + "ejb-jar.xml") + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), + StringContextProvider.class.getName()); + + return war; + } + @TestName String testname; - - @Override - protected String getServletPath() { - return "ManagedThreadFactoryDefinitionServlet"; - } - + + @Override + protected String getServletPath() { + return "ManagedThreadFactoryDefinitionServlet"; + } + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { - runTest(baseURL, testname); + runTest(baseURL, testname); } - + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } - @Test + @Test public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { - runTest(baseURL, testname); + runTest(baseURL, testname); } - - @Test + + @Test public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); } // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { - runTest(baseURL, testname); + runTest(baseURL, testname); } - + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 - @Disabled + @Disabled public void testParallelStreamBackedByManagedThreadFactoryEJB() throws Throwable { - URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); - runTest(requestURL); - } + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) + .withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testname); + runTest(requestURL); + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java index 0919d157..2d5280d6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java @@ -44,68 +44,63 @@ @SuppressWarnings("serial") @WebServlet(Constants.CONTEXT_PATH) -@DataSourceDefinition( - name = "java:comp/env/jdbc/ManagedThreadFactoryDB", - className = "org.apache.derby.jdbc.EmbeddedDataSource", - databaseName = "memory:ManagedThreadFactoryDB", - properties = { - "createDatabase=create" - } -) +@DataSourceDefinition(name = "java:comp/env/jdbc/ManagedThreadFactoryDB", className = "org.apache.derby.jdbc.EmbeddedDataSource", databaseName = "memory:ManagedThreadFactoryDB", properties = { + "createDatabase=create" }) public class TransactionServlet extends TestServlet { - private static final TestLogger log = TestLogger.get(TransactionServlet.class); + private static final TestLogger log = TestLogger.get(TransactionServlet.class); + + @Resource(lookup = "java:comp/env/jdbc/ManagedThreadFactoryDB") + private DataSource ds; - @Resource(lookup = "java:comp/env/jdbc/ManagedThreadFactoryDB") - private DataSource ds; - @Resource(lookup = TestConstants.DefaultManagedThreadFactory) public ManagedThreadFactory threadFactory; - @Override - protected void beforeClass() throws RemoteException { - log.enter("beforeClass"); - - Connections.setDataSource(ds); - - try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { - try { - stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); - } catch (SQLException e) { - log.finest("Could not drop table, assume table did not exist."); - } - stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); - log.exit("beforeClass"); - } catch (Exception e) { - fail(e.getMessage()); - } - } - - public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { - boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); - Thread thread = threadFactory.newThread(new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT)); - thread.start(); - Wait.waitTillThreadFinish(thread); - } - - public void cancelTest() { - int originTableCount = Counter.getCount(); - - CancelledTransactedTask cancelledTask = new CancelledTransactedTask(Constants.SQL_TEMPLATE_INSERT); - Thread thread = threadFactory.newThread(cancelledTask); - thread.start(); - + @Override + protected void beforeClass() throws RemoteException { + log.enter("beforeClass"); + + Connections.setDataSource(ds); + + try (Connection conn = Connections.getConnection(true); Statement stmt = conn.createStatement()) { + try { + stmt.executeUpdate(Constants.SQL_TEMPLATE_DROP); + } catch (SQLException e) { + log.finest("Could not drop table, assume table did not exist."); + } + stmt.executeUpdate(Constants.SQL_TEMPLATE_CREATE); + log.exit("beforeClass"); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); + Thread thread = threadFactory.newThread(new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT)); + thread.start(); + Wait.waitTillThreadFinish(thread); + } + + public void cancelTest() { + int originTableCount = Counter.getCount(); + + CancelledTransactedTask cancelledTask = new CancelledTransactedTask(Constants.SQL_TEMPLATE_INSERT); + Thread thread = threadFactory.newThread(cancelledTask); + thread.start(); + // then cancel it after transaction begin and Wait.waitForTransactionBegan(cancelledTask); - + // before it commit. cancelledTask.cancelTransaction.set(true); - + // continue to run if possible. - cancelledTask.runQuery.set(true);; - + cancelledTask.runQuery.set(true); + ; + int afterTransacted = Counter.getCount(); - - assertEquals(originTableCount, afterTransacted,"task was not properly cancelled"); - } + + assertEquals(originTableCount, afterTransacted, "task was not properly cancelled"); + } } 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 779a9715..8cf803df 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 @@ -33,39 +33,40 @@ import ee.jakarta.tck.concurrent.framework.junit.anno.Common.PACKAGE; import ee.jakarta.tck.concurrent.framework.junit.anno.Web; -@Web @RunAsClient //Requires client testing due to annotation configuration +@Web +@RunAsClient // Requires client testing due to annotation configuration @Common({ PACKAGE.TRANSACTION }) public class TransactionTests extends TestClient { - @ArquillianResource - URL baseURL; - - @Deployment(name="TransactionTests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class) - .addPackages(true, TransactionTests.class.getPackage()); - } + @ArquillianResource + URL baseURL; - /* - * @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) - public void testRollbackTransactionWithManagedThreadFactory() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); - } - - /* + @Deployment(name = "TransactionTests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class).addPackages(true, TransactionTests.class.getPackage()); + } + + /* + * @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) + public void testRollbackTransactionWithManagedThreadFactory() { + runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH) + .withQueries(Constants.COMMIT_FALSE).withTestName("transactionTest")); + } + + /* * @testName: testCommitTransactionWithManagedThreadFactory * * @assertion_ids: @@ -79,26 +80,28 @@ public void testRollbackTransactionWithManagedThreadFactory() { * ManagedThreadFactory.it support user-managed global transaction demarcation * using the jakarta.transaction.UserTransaction interface. */ - @Test //TODO rewrite test logic to avoid duplicate key violation + @Test // TODO rewrite test logic to avoid duplicate key violation @Order(2) public void testCommitTransactionWithManagedThreadFactory() throws InterruptedException { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_TRUE).withTestName("transactionTest")); + 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) - public void testCancelTransactionWithManagedThreadFactory() { - runTest(URLBuilder.get().withBaseURL(baseURL).withPaths(Constants.CONTEXT_PATH).withQueries(Constants.COMMIT_CANCEL).withTestName("cancelTest")); - } + /* + * @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) + 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 b10ea87e..60aa66c7 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 @@ -36,46 +36,44 @@ import jakarta.enterprise.concurrent.spi.ThreadContextProvider; /** - * Covers context-service, managed-executor, managed-scheduled-executor, - * and managed-thread-factory defined in a deployment descriptor. + * Covers context-service, managed-executor, managed-scheduled-executor, and + * managed-thread-factory defined in a deployment descriptor. */ -@Full @RunAsClient //Requires client testing due to annotation configuration +@Full +@RunAsClient // Requires client testing due to annotation configuration public class DeploymentDescriptorFullTests extends TestClient { - + @ArquillianResource(DeploymentDescriptorServlet.class) URL baseURL; - - @Deployment(name="DeploymentDescriptorTests") + + @Deployment(name = "DeploymentDescriptorTests") public static EnterpriseArchive createDeployment() { - + WebArchive war = ShrinkWrap.create(WebArchive.class, "DeploymentDescriptorTests_web.war") - .addClasses( - DeploymentDescriptorServlet.class); + .addClasses(DeploymentDescriptorServlet.class); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "DeploymentDescriptorTests_ejb.jar") - .addClasses( - DeploymentDescriptorTestBean.class, - DeploymentDescriptorTestBeanInterface.class) + .addClasses(DeploymentDescriptorTestBean.class, DeploymentDescriptorTestBeanInterface.class) .addPackages(false, PACKAGE.CONTEXT.getPackageName(), PACKAGE.CONTEXT_PROVIDERS.getPackageName()) - .addAsServiceProvider(ThreadContextProvider.class.getName(), - IntContextProvider.class.getName(), + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "DeploymentDescriptorTests.ear") - .addAsManifestResource(DeploymentDescriptorFullTests.class.getPackage(), "application.xml", "application.xml") + .addAsManifestResource(DeploymentDescriptorFullTests.class.getPackage(), "application.xml", + "application.xml") .addAsModules(war, jar); return ear; } - + @TestName String testname; - + @Override protected String getServletPath() { return "DeploymentDescriptorServlet"; } - + @Test public void testDeploymentDescriptorDefinesContextService() { 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 03f1e283..6b485fc8 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 @@ -50,14 +50,14 @@ public class DeploymentDescriptorServlet extends TestServlet { DeploymentDescriptorTestBeanInterface enterpriseBean; @Resource - UserTransaction tx; + UserTransaction tx; /** * Tests context-service defined in a deployment descriptor. */ public void testDeploymentDescriptorDefinesContextService() throws Throwable { ContextService contextSvc = InitialContext.doLookup("java:global/concurrent/ContextD"); - + Callable checkContextAndGetTransactionStatus; tx.begin(); @@ -131,10 +131,14 @@ public void testDeploymentDescriptorDefinesManagedExecutor() throws Throwable { taskCanEnd.countDown(); - assertEquals(future1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedExecutor-1"); - assertEquals(future2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedExecutor-2"); - assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedExecutor-3"); - assertEquals(future4.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedExecutor-4"); + assertEquals(future1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedExecutor-1"); + assertEquals(future2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedExecutor-2"); + assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedExecutor-3"); + assertEquals(future4.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedExecutor-4"); assertNotNull(started.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS)); } finally { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorTestBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorTestBean.java index fe6d735d..21909813 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorTestBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorTestBean.java @@ -55,7 +55,8 @@ public void testDeploymentDescriptorDefinesManagedScheduledExecutor() { return StringContext.get(); }; - ManagedScheduledExecutorService executor = InitialContext.doLookup("java:global/concurrent/ScheduledExecutorD"); + ManagedScheduledExecutorService executor = InitialContext + .doLookup("java:global/concurrent/ScheduledExecutorD"); IntContext.set(3000); @@ -77,9 +78,12 @@ public void testDeploymentDescriptorDefinesManagedScheduledExecutor() { taskCanEnd.countDown(); - assertEquals(future1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedScheduledExecutor-1"); - assertEquals(future2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedScheduledExecutor-2"); - assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedScheduledExecutor-3"); + assertEquals(future1.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedScheduledExecutor-1"); + assertEquals(future2.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedScheduledExecutor-2"); + assertEquals(future3.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedScheduledExecutor-3"); assertEquals(started.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(0)); } catch (ExecutionException | InterruptedException | NamingException | TimeoutException x) { @@ -96,8 +100,8 @@ public void testDeploymentDescriptorDefinesManagedThreadFactory() { IntContext.set(4000); StringContext.set("testDeploymentDescriptorDefinesManagedThreadFactory-1"); - ManagedThreadFactory threadFactory = - (ManagedThreadFactory) InitialContext.doLookup("java:app/concurrent/ThreadFactoryD"); + ManagedThreadFactory threadFactory = (ManagedThreadFactory) InitialContext + .doLookup("java:app/concurrent/ThreadFactoryD"); StringContext.set("testDeploymentDescriptorDefinesManagedThreadFactory-2"); @@ -118,9 +122,11 @@ public void testDeploymentDescriptorDefinesManagedThreadFactory() { thread.start(); - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(6)); // priority from managed-thread-factory + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(6)); // priority from + // managed-thread-factory assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), Integer.valueOf(0)); // IntContext cleared - assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), "testDeploymentDescriptorDefinesManagedThreadFactory-1"); // propagated + assertEquals(results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), + "testDeploymentDescriptorDefinesManagedThreadFactory-1"); // propagated Object lookupResult = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); if (lookupResult instanceof Exception) throw new EJBException((Exception) lookupResult); 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 7846299e..cc482da7 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 @@ -35,38 +35,37 @@ import jakarta.enterprise.concurrent.spi.ThreadContextProvider; /** - * Covers context-service, managed-executor, managed-scheduled-executor, - * and managed-thread-factory defined in a deployment descriptor. + * Covers context-service, managed-executor, managed-scheduled-executor, and + * managed-thread-factory defined in a deployment descriptor. */ -@Web @RunAsClient //Requires client testing due to annotation configuration -@Common({PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS}) -public class DeploymentDescriptorWebTests extends TestClient{ - +@Web +@RunAsClient // Requires client testing due to annotation configuration +@Common({ PACKAGE.CONTEXT, PACKAGE.CONTEXT_PROVIDERS }) +public class DeploymentDescriptorWebTests extends TestClient { + @ArquillianResource(DeploymentDescriptorServlet.class) URL baseURL; - - @Deployment(name="DeploymentDescriptorTests") + + @Deployment(name = "DeploymentDescriptorTests") public static WebArchive createDeployment() { - + WebArchive war = ShrinkWrap.create(WebArchive.class, "DeploymentDescriptorTests_web.war") .addPackages(false, DeploymentDescriptorWebTests.class.getPackage()) - .addAsServiceProvider(ThreadContextProvider.class.getName(), - IntContextProvider.class.getName(), + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()) .addAsWebInfResource(DeploymentDescriptorWebTests.class.getPackage(), "web.xml", "web.xml"); - return war; } - + @TestName String testname; - + @Override protected String getServletPath() { return "DeploymentDescriptorServlet"; } - + @Test public void testDeploymentDescriptorDefinesContextService() { 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 3bf25143..7c10e56d 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 @@ -28,15 +28,15 @@ @Signature public class SignatureTests { - @Deployment(name = "SignatureTests") - public static WebArchive createDeployment() { - return ShrinkWrap.create(WebArchive.class, "signatureTest.war"); - } + @Deployment(name = "SignatureTests") + public static WebArchive createDeployment() { + return ShrinkWrap.create(WebArchive.class, "signatureTest.war"); + } - @Test - public void testSignatures() throws Exception { - ConcurrencySignatureTestRunner.assertProjectSetup(); + @Test + public void testSignatures() throws Exception { + ConcurrencySignatureTestRunner.assertProjectSetup(); ConcurrencySignatureTestRunner sigTest = new ConcurrencySignatureTestRunner(); sigTest.signatureTest(); - } + } } From b59782ce83e7ed1cbcb93ed68e34068d04fe5b88 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 09:13:50 -0500 Subject: [PATCH 03/14] tck trailing spaces --- .../AbortedExceptionTests.java | 16 +++--- .../ContextService/ContextServiceTests.java | 56 +++++++++---------- .../api/LastExecution/LastExecutionTests.java | 16 +++--- .../ManagedExecutorsTests.java | 40 ++++++------- .../ManagedScheduledExecutorServiceTests.java | 15 +++-- .../api/ManagedTask/ManagedTaskTests.java | 8 +-- .../ManagedTaskListenerTests.java | 16 +++--- .../ManagedThreadFactoryTests.java | 12 ++-- .../SkippedExceptionTests.java | 16 +++--- .../concurrent/api/Trigger/TriggerTests.java | 8 +-- .../ConcurrencySignatureTestRunner.java | 4 +- .../common/signature/SigTestDriver.java | 2 +- .../common/signature/SignatureTestDriver.java | 2 +- .../concurrent/common/tasks/CallableTask.java | 4 +- .../concurrent/common/tasks/RunnableTask.java | 4 +- .../common/transaction/Counter.java | 2 +- .../tck/concurrent/framework/TestClient.java | 4 +- .../tck/concurrent/framework/TestServlet.java | 10 ++-- .../extensions/TCKFrameworkAppender.java | 4 +- .../concurrent/framework/junit/anno/Full.java | 2 +- .../concurrent/framework/junit/anno/Web.java | 2 +- .../framework/junit/extensions/Wait.java | 18 +++--- .../inheritedapi/InheritedAPITests.java | 4 +- .../forbiddenapi/ForbiddenAPIEJBTests.java | 22 ++++---- .../ForbiddenAPIServletTests.java | 20 +++---- .../security/SecurityFullTests.java | 4 +- .../security/SecurityWebTests.java | 4 +- .../tx/TransactionTests.java | 12 ++-- .../inheritedapi/InheritedAPIFullTests.java | 28 +++++----- .../inheritedapi/InheritedAPIWebTests.java | 28 +++++----- .../servlet/InheritedAPIServletTests.java | 28 +++++----- .../forbiddenapi/ForbiddenAPIEJBTests.java | 20 +++---- .../ForbiddenAPIServletTests.java | 20 +++---- .../security/SecurityFullTests.java | 4 +- .../security/SecurityWebTests.java | 4 +- .../tx/TransactionTests.java | 12 ++-- .../context/ContextFullTests.java | 4 +- .../context/ContextWebTests.java | 4 +- .../tx/TransactionTests.java | 10 ++-- 39 files changed, 244 insertions(+), 245 deletions(-) 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 960362aa..b7a0d15d 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 @@ -39,9 +39,9 @@ public static WebArchive createDeployment() { /* * @testName: AbortedExceptionNoArgTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:1 - * + * * @test_Strategy: Constructs an AbortedException. */ @Test @@ -55,9 +55,9 @@ public void AbortedExceptionNoArgTest() { /* * @testName: AbortedExceptionStringTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:3 - * + * * @test_Strategy: Constructs an AbortedException. */ @Test @@ -74,9 +74,9 @@ public void AbortedExceptionStringTest() { /* * @testName: AbortedExceptionThrowableTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:4 - * + * * @test_Strategy: Constructs an AbortedException. */ @Test @@ -103,9 +103,9 @@ public void AbortedExceptionThrowableTest() { /* * @testName: AbortedExceptionStringThrowableTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:2 - * + * * @test_Strategy: Constructs an AbortedException. */ @Test 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 7c3b7a96..dcda4840 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 @@ -55,9 +55,9 @@ public static WebArchive createDeployment() { /* * @testName: ContextServiceWithIntf - * + * * @assertion_ids: CONCURRENCY:JAVADOC:5 - * + * * @test_Strategy: Lookup default ContextService object and create proxy object * using instance and interface. */ @@ -71,9 +71,9 @@ 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 @@ -87,9 +87,9 @@ public void ContextServiceWithIntfAndIntfNoImplemented() { /* * @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 @@ -103,9 +103,9 @@ public void ContextServiceWithIntfAndInstanceIsNull() { /* * @testName: ContextServiceWithMultiIntfs - * + * * @assertion_ids: CONCURRENCY:JAVADOC:7 - * + * * @test_Strategy: Lookup default ContextService object and create proxy object * using instance and multiple interfaces. */ @@ -122,9 +122,9 @@ 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 @@ -139,9 +139,9 @@ 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 @@ -155,9 +155,9 @@ public void ContextServiceWithMultiIntfsAndInstanceIsNull() { /* * @testName: ContextServiceWithIntfAndProperties - * + * * @assertion_ids: CONCURRENCY:JAVADOC:9 - * + * * @test_Strategy: Lookup default ContextService object and create proxy object * using ExecutionProperties and interface. */ @@ -176,9 +176,9 @@ 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. */ @@ -199,9 +199,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 @@ -220,9 +220,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 @@ -240,9 +240,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 @@ -261,9 +261,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 @@ -281,9 +281,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. @@ -305,9 +305,9 @@ public void GetExecutionProperties() { /* * @testName: GetExecutionPropertiesNoProxy - * + * * @assertion_ids: CONCURRENCY:JAVADOC:14 - * + * * @test_Strategy: Lookup default ContextService object. Retrieve * ExecutionProperties from plain object. */ 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 5be982c1..e3914a2e 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 @@ -66,9 +66,9 @@ public void reset() { /* * @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. @@ -91,9 +91,9 @@ public void lastExecutionGetIdentityNameTest() { /* * @testName: lastExecutionGetResultTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:16 - * + * * @test_Strategy: Result of the last execution. */ @Test @@ -111,9 +111,9 @@ public void lastExecutionGetResultRunnableTest() { /* * @testName: lastExecutionGetResultTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:16 - * + * * @test_Strategy: Result of the last execution. */ @Test @@ -131,10 +131,10 @@ public void lastExecutionGetResultCallableTest() { /* * @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 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 8dbf1e92..80d8d320 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 @@ -115,12 +115,12 @@ private void assertListenerComplete(RunnableTask task) { /* * @testName: IsCurrentThreadShutdown - * + * * @assertion_ids: CONCURRENCY:JAVADOC:21 - * + * * @test_Strategy: Use a regular thread(non-Manageable thread) and verify * isCurrentThreadShutdown() returns false - * + * */ @Test public void IsCurrentThreadShutdown() { @@ -140,9 +140,9 @@ public void run() { /* * @testName: IsCurrentThreadShutdown_ManageableThread - * + * * @assertion_ids: CONCURRENCY:JAVADOC:21 - * + * * @test_Strategy: Create a ManageableThread from ManagedThreadFactory and check * the shutdown status. */ @@ -164,7 +164,7 @@ public void run() { /* * @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; @@ -184,9 +184,9 @@ public void ManageRunnableTaskWithTaskListener() { /* * @testName: ManageRunnableTaskWithNullArg - * + * * @assertion_ids: CONCURRENCY:JAVADOC:23 - * + * * @test_Strategy: Catch IllegalArgumentException when get the manage task with * null runnable task. */ @@ -200,9 +200,9 @@ 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 @@ -225,9 +225,9 @@ public void ManageRunnableTaskWithTaskListenerAndMap() { /* * @testName: ManageRunnableTaskWithMapAndNullArg - * + * * @assertion_ids: CONCURRENCY:JAVADOC:25 - * + * * @test_Strategy: Catch IllegalArgumentException when get the manage task with * null runnable task and additional execution properties. */ @@ -243,9 +243,9 @@ 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 @@ -263,9 +263,9 @@ public void ManageCallableTaskWithTaskListener() { /* * @testName: ManageCallableTaskWithNullArg - * + * * @assertion_ids: CONCURRENCY:JAVADOC:27 - * + * * @test_Strategy: Catch IllegalArgumentException when get the manage task with * null Callable task. */ @@ -279,10 +279,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 @@ -310,9 +310,9 @@ public void ManageCallableTaskWithTaskListenerAndMap() { /* * @testName: ManageCallableTaskWithMapAndNullArg - * + * * @assertion_ids: CONCURRENCY:JAVADOC:29 - * + * * @test_Strategy: Catch IllegalArgumentException when get the manage task with * null Callable task and additional execution properties. */ 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 c5850ffb..c7976390 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 @@ -64,11 +64,11 @@ public static WebArchive createDeployment() { /* * @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. */ @@ -83,9 +83,9 @@ public void normalScheduleProcess1Test() throws Exception { /* * @testName: nullCommandScheduleProcessTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:32 - * + * * @test_Strategy: if command is null. */ @Test @@ -99,12 +99,11 @@ 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. */ @@ -123,9 +122,9 @@ public void normalScheduleProcess2Test() throws Exception { /* * @testName: nullCallableScheduleProcessTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:35 - * + * * @test_Strategy: if callable is null. */ @Test 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 3fb5206d..2a206b4b 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 @@ -54,9 +54,9 @@ private RunnableTask createRunnableTask() { /* * @testName: GetExecutionProperties - * + * * @assertion_ids: CONCURRENCY:JAVADOC:36 - * + * * @test_Strategy: Get ManagedTask to provides additional information to the * ManagedExecutorService or ManagedScheduledExecutorService when executing this * task. @@ -77,9 +77,9 @@ public void GetExecutionProperties() { /* * @testName: GetManagedTaskListener - * + * * @assertion_ids: CONCURRENCY:JAVADOC:37 - * + * * @test_Strategy: Get ManagedTask with ManagedTaskListener to receive * notification of life cycle events of this task. */ 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 1dde9531..be14d163 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 @@ -67,11 +67,11 @@ public void cleanup() { /* * @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. */ @@ -93,10 +93,10 @@ public void TaskAborted() throws InterruptedException { /* * @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 . */ @@ -137,11 +137,11 @@ public void TaskDone() throws InterruptedException { /* * @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. @@ -163,11 +163,11 @@ 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. 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 b521bb1e..d661a18a 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 @@ -51,9 +51,9 @@ public static WebArchive createDeployment() { /* * @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. */ @@ -65,12 +65,12 @@ public void 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 @@ -85,9 +85,9 @@ public void interruptThreadApiTest() { /* * @testName: implementsManageableThreadInterfaceTest - * + * * @assertion_ids: CONCURRENCY:SPEC:97; - * + * * @test_Strategy: */ @Test 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 df3fd8bf..0b66c814 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 @@ -40,9 +40,9 @@ public static WebArchive createDeployment() { /* * @testName: SkippedExceptionNoArgTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:42 - * + * * @test_Strategy: Constructs an SkippedException. */ @Test @@ -56,9 +56,9 @@ public void SkippedExceptionNoArgTest() { /* * @testName: SkippedExceptionStringTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:43 - * + * * @test_Strategy: Constructs an SkippedException. */ @Test @@ -75,9 +75,9 @@ public void SkippedExceptionStringTest() { /* * @testName: SkippedExceptionThrowableTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:45 - * + * * @test_Strategy: Constructs an SkippedException. */ @Test @@ -104,9 +104,9 @@ public void SkippedExceptionThrowableTest() { /* * @testName: SkippedExceptionStringThrowableTest - * + * * @assertion_ids: CONCURRENCY:JAVADOC:44 - * + * * @test_Strategy: Constructs an SkippedException. */ @Test 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 aa27ffef..e4872997 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 @@ -63,9 +63,9 @@ public void 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 @@ -89,9 +89,9 @@ 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 diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index 8a8749b7..74c6d8ee 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -56,7 +56,7 @@ public ConcurrencySignatureTestRunner() { /** * Returns a list of strings where each string represents a package name. Each * package name will have it's signature tested by the signature test framework. - * + * * @return String[] The names of the packages whose signatures should be * verified. */ @@ -180,7 +180,7 @@ protected File writeStreamToSigFile(InputStream inputStream) throws IOException /***** * Boilerplate Code - * + * * /* The following comments are specified in the base class that defines the * signature tests. This is done so the test finders will find the right class * to run. The implementation of these methods is inherited from the super class diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java index 79865014..a9b6ad9a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java @@ -162,7 +162,7 @@ protected boolean runSignatureTest(String packageOrClassName, String[] testArgum } // END runSignatureTest /* - * + * * @return This returns true if the packageOrClassName is found in the impl. */ @Override diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java index 7ccd45f3..5ccb911e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java @@ -98,7 +98,7 @@ public String getMapFileImpl(String binDir) { /** * Returns true if the passed in version matches the current Java version being * used. - * + * */ public Boolean isJavaSEVersion(String ver) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java index aafeddd8..0cac7d73 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java @@ -32,7 +32,7 @@ public T call() { /** * Construct the callable task with expected properties. - * + * * @param jndiName the jndi name set for env-entry, ignore jndi test if it is * null. * @param jndiValue the jndi value set for jndiName @@ -48,7 +48,7 @@ public CallableTask(String jndiName, String jndiValue, String className, T retur /** * Construct the callable task with expected properties. - * + * * @param jndiName the jndi name set for env-entry, ignore jndi test if it is * null. * @param jndiValue the jndi value set for jndiName diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java index 30837908..c9bb732c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java @@ -61,7 +61,7 @@ public void run() { /** * Construct the runnable task with expected properties. - * + * * @param jndiName the jndi name set for env-entry, ignore jndi test if it is * null. * @param jndiValue the jndi value set for jndiName @@ -78,7 +78,7 @@ public RunnableTask(String jndiName, String jndiValue, String className, long bl /** * Construct the runnable task with expected properties. - * + * * @param jndiName the jndi name set for env-entry, ignore jndi test if it is * null. * @param jndiValue the jndi value set for jndiName diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java index 42b8832a..53839439 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java @@ -24,7 +24,7 @@ public class Counter { /** * Get count of rows in test table to verify if a transaction was committed or * rolled back. - * + * * @return number of rows, or -1 if error occurred while attempting to access * table. */ diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java index 01bf80de..723f9d18 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java @@ -35,7 +35,7 @@ * TestServlets are deployed to the application server and has custom * doGet/doPost methods that will return a successful or failure message * depending on the test outcome. - * + * * The TestClient class has runTest methods that will create an HTTP connection * to the TestServlet and provide the TestServlet with the method name it needs * to test. The TestClient class will then confirm that it recieved a successful @@ -182,7 +182,7 @@ protected String getServletPath() { /** * Asserts that the response from a runTestWithResponse method contains a * specific string. - * + * * @param message - message to display if test fails * @param expected - the expected string to find in the response * @param resp - the response you received from the servlet diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java index c1bc7291..0c79dae5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java @@ -35,7 +35,7 @@ * Standard superclass for test servlets that accepts a `testMethod` parameter * to the doGet / doPost methods that will attempt to run that method on the * subclass. - * + * * The doGet / doPost methods will append `SUCCESS` to the response if the test * is successfully. Otherwise, SUCCESS will not be appended to the response. */ @@ -155,7 +155,7 @@ protected void invokeTest(String method, HttpServletRequest request, HttpServlet * HTTP convenience method for servlets to get a response from another servlet. * Test clients should extend the {@link TestClient} class that has its own HTTP * methods. - * + * * @param con - the URLConnection * @return String - response body * @throws IOException @@ -177,13 +177,13 @@ public static String getResponse(URLConnection con) throws IOException { /** * HTTP convenience method for servlets to create a URLConnection and post * properties to that connection. - * + * * Test clients should extend the {@link TestClient} class that has its own HTTP * methods. - * + * * @param url - the URL to open a connection to * @param props - the properties to put into the connection input stream - * + * * @return the connection for further testing * @throws IOException */ diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java index df24e20e..df7065d9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java @@ -29,11 +29,11 @@ /** * This extension will intercept all archives before they are deployed to the * container and append a library with the following: - * + * * Package - ee.jakarta.tck.concurrent.framework Package - * ee.jakarta.tck.concurrent.framework.arquillian.extensions Package - * ee.jakarta.tck.concurrent.framework.junit.extensions - * + * */ public class TCKFrameworkAppender implements AuxiliaryArchiveAppender { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java index fca18ee2..84f5046f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Full.java @@ -32,7 +32,7 @@ * tests to run they must deploy an application to a Jakarta EE server using the * Arquillian {@code @Deployment} annotation. *

- * + * *

* At runtime the Arquillian Servlet protocol must be used for communication * with the Jakarta EE server. diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java index 8b9bafbc..562d6492 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/anno/Web.java @@ -32,7 +32,7 @@ * tests to run they must deploy an application to a Jakarta EE server using the * Arquillian {@code @Deployment} annotation. *

- * + * *

* At runtime the Arquillian Servlet protocol must be used for communication * with the Jakarta EE server. diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java index a1a9b3f1..4b9b0082 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java @@ -14,7 +14,7 @@ /** * Utility class for waiting for results. - * + * * Prioritize polling for results, and discourages sleeping */ public class Wait { @@ -28,7 +28,7 @@ private Wait() { /** * Waits for task to complete, but will timeout after * {@link TestConstants#WaitTimeout} - * + * * @param future to wait for * @return result */ @@ -38,7 +38,7 @@ public static T waitForTaskComplete(final Future future) { /** * Waits for task to complete, but will timeout after specified timeout - * + * * @param future - the future to wait for * @param timeout - the duration of timeout * @return result - result returned from future, or null if timeout was exceeded @@ -51,7 +51,7 @@ public static T waitForTaskComplete(final Future future, final Duration t * Wait for listener to complete, but will timeout after * {@link TestConstants#WaitTimeout}, and will be polled ever * {@link TestConstants#PollInterval} - * + * * @param managedTaskListener - the listener to be polled */ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener) { @@ -61,7 +61,7 @@ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskLi /** * Wait for listener to complete, but will timeout after a specified timeout, * and will be polled ever specified interval - * + * * @param managedTaskListener - the listener to be polled * @param maxWaitTimeMillis - timeout * @param pollIntervalMillis - poll interval @@ -78,11 +78,11 @@ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskLi * Waits for future to complete, but will timeout after * {@link TestConstants#WaitTimeout}, and will be polled every * {@link TestConstants#PollInterval} - * + * * The difference between this method and waitForTaskComplete is that some * scheduled task will return values for multiple times, in this situation * waitForTaskComplete does not work. - * + * * @param future - the future to wait for */ public static void waitTillFutureIsDone(final Future future) { @@ -96,7 +96,7 @@ public static void waitTillFutureIsDone(final Future future) { * Waits for future to throw an error, but will timeout after * {@link TestConstants#WaitTimeout}, and will be polled every * {@link TestConstants#PollInterval} - * + * * @param future - the future to wait for */ public static void waitTillFutureThrowsException(final Future future, @@ -121,7 +121,7 @@ public static void waitCancelFuture(final Future future) { * Waits until thread is finished, but will timeout after * {@link TestConstants#WaitTimeout}, and will be polled every * {@link TestConstants#PollInterval} - * + * * @param thread - the thread to wait for */ public static void waitTillThreadFinish(final Thread thread) { 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 63fcfe22..d853c4cb 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 @@ -59,7 +59,7 @@ public static WebArchive createDeployment() { /* * @testName: testBasicManagedExecutorService - * + * * @assertion_ids: * CONCURRENCY:SPEC:10.2;CONCURRENCY:SPEC:13;CONCURRENCY:SPEC:13.1;CONCURRENCY * :SPEC:13.2; @@ -69,7 +69,7 @@ public static WebArchive createDeployment() { * :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 */ 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 02aab1ef..653f82ca 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 @@ -37,10 +37,10 @@ public static JavaArchive createDeployment() { /* * @testName: testAwaitTermination - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.1; - * + * * @test_Strategy: */ @Test @@ -50,11 +50,11 @@ public void testAwaitTermination() { /* * @testName: testIsShutdown - * + * * @assertion_ids: - * + * * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.2; - * + * * @test_Strategy: */ @Test @@ -64,10 +64,10 @@ public void testIsShutdown() { /* * @testName: testIsTerminated - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.3; - * + * * @test_Strategy: */ @Test @@ -77,10 +77,10 @@ public void testIsTerminated() { /* * @testName: testShutdown - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.4; - * + * * @test_Strategy: */ @Test @@ -90,10 +90,10 @@ public void testShutdown() { /* * @testName: testShutdownNow - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.5; - * + * * @test_Strategy: */ @Test 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 352aa83b..c56ed566 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 @@ -43,10 +43,10 @@ public static WebArchive createDeployment() { /* * @testName: testAwaitTermination - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.1; - * + * * @test_Strategy: */ @Test @@ -62,10 +62,10 @@ public void testAwaitTermination() { /* * @testName: testIsShutdown - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.2; - * + * * @test_Strategy: */ @Test @@ -81,10 +81,10 @@ public void testIsShutdown() { /* * @testName: testIsTerminated - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.3; - * + * * @test_Strategy: */ @Test @@ -100,10 +100,10 @@ public void testIsTerminated() { /* * @testName: testShutdown - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.4; - * + * * @test_Strategy: */ @Test @@ -119,10 +119,10 @@ public void testShutdown() { /* * @testName: testShutdownNow - * + * * @assertion_ids: * CONCURRENCY:SPEC:23;CONCURRENCY:SPEC:24;CONCURRENCY:SPEC:24.5; - * + * * @test_Strategy: */ @Test 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 2300c133..a505a564 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 @@ -69,11 +69,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. 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 1aeee592..dc73fb0e 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 @@ -59,11 +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. 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 fd2c7d2d..3abbe41a 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 @@ -48,10 +48,10 @@ public static WebArchive createDeployment() { /* * @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. */ @@ -64,7 +64,7 @@ public void testRollbackTransactionWithManagedExecutorService() { /* * @testName: testCommitTransactionWithManagedExecutorService - * + * * @assertion_ids: * CONCURRENCY:SPEC:30;CONCURRENCY:SPEC:31;CONCURRENCY:SPEC:31.1; * CONCURRENCY:SPEC:31.2;CONCURRENCY:SPEC:32;CONCURRENCY:SPEC:33; @@ -73,7 +73,7 @@ public void testRollbackTransactionWithManagedExecutorService() { * 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. @@ -87,11 +87,11 @@ public void testCommitTransactionWithManagedExecutorService() { /* * @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. */ 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 912f5f7e..06ae639c 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 @@ -50,9 +50,9 @@ public static EnterpriseArchive createDeployment() { /* * @testName: testApiSubmit - * + * * @assertion_ids: CONCURRENCY:SPEC:44.1 - * + * * @test_Strategy: */ @Test @@ -62,9 +62,9 @@ public void testApiSubmit() { /* * @testName: testApiExecute - * + * * @assertion_ids: CONCURRENCY:SPEC:44.2 - * + * * @test_Strategy: */ @Test @@ -74,9 +74,9 @@ public void testApiExecute() { /* * @testName: testApiInvokeAll - * + * * @assertion_ids: CONCURRENCY:SPEC:44.3 - * + * * @test_Strategy: */ @Test @@ -86,9 +86,9 @@ public void testApiInvokeAll() { /* * @testName: testApiInvokeAny - * + * * @assertion_ids: CONCURRENCY:SPEC:44.4 - * + * * @test_Strategy: */ @Test @@ -98,9 +98,9 @@ public void testApiInvokeAny() { /* * @testName: testApiSchedule - * + * * @assertion_ids: CONCURRENCY:SPEC:44.5 - * + * * @test_Strategy: */ @Test @@ -110,9 +110,9 @@ public void testApiSchedule() { /* * @testName: testApiScheduleAtFixedRate - * + * * @assertion_ids: CONCURRENCY:SPEC:44.6 - * + * * @test_Strategy: */ @Test @@ -122,9 +122,9 @@ public void testApiScheduleAtFixedRate() { /* * @testName: testApiScheduleWithFixedDelay - * + * * @assertion_ids: CONCURRENCY:SPEC:44.7 - * + * * @test_Strategy: */ @Test 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 b12d664d..2cf3613d 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 @@ -44,9 +44,9 @@ public static WebArchive createDeployment() { /* * @testName: testApiSubmit - * + * * @assertion_ids: CONCURRENCY:SPEC:44.1 - * + * * @test_Strategy: */ @Test @@ -56,9 +56,9 @@ public void testApiSubmit() { /* * @testName: testApiExecute - * + * * @assertion_ids: CONCURRENCY:SPEC:44.2 - * + * * @test_Strategy: */ @Test @@ -68,9 +68,9 @@ public void testApiExecute() { /* * @testName: testApiInvokeAll - * + * * @assertion_ids: CONCURRENCY:SPEC:44.3 - * + * * @test_Strategy: */ @Test @@ -80,9 +80,9 @@ public void testApiInvokeAll() { /* * @testName: testApiInvokeAny - * + * * @assertion_ids: CONCURRENCY:SPEC:44.4 - * + * * @test_Strategy: */ @Test @@ -92,9 +92,9 @@ public void testApiInvokeAny() { /* * @testName: testApiSchedule - * + * * @assertion_ids: CONCURRENCY:SPEC:44.5 - * + * * @test_Strategy: */ @Test @@ -104,9 +104,9 @@ public void testApiSchedule() { /* * @testName: testApiScheduleAtFixedRate - * + * * @assertion_ids: CONCURRENCY:SPEC:44.6 - * + * * @test_Strategy: */ @Test @@ -116,9 +116,9 @@ public void testApiScheduleAtFixedRate() { /* * @testName: testApiScheduleWithFixedDelay - * + * * @assertion_ids: CONCURRENCY:SPEC:44.7 - * + * * @test_Strategy: */ @Test 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/servlet/InheritedAPIServletTests.java index ef20ea35..32da2572 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/servlet/InheritedAPIServletTests.java @@ -66,9 +66,9 @@ public void before() { /* * @testName: testApiSubmit - * + * * @assertion_ids: CONCURRENCY:SPEC:44.1 - * + * * @test_Strategy: */ @Test @@ -88,9 +88,9 @@ public void testApiSubmit() throws Exception { /* * @testName: testApiExecute - * + * * @assertion_ids: CONCURRENCY:SPEC:44.2 - * + * * @test_Strategy: */ @Test @@ -105,9 +105,9 @@ public void testApiExecute() { /* * @testName: testApiInvokeAll - * + * * @assertion_ids: CONCURRENCY:SPEC:44.3 - * + * * @test_Strategy: */ @Test @@ -152,9 +152,9 @@ public void testApiInvokeAll() throws Exception { /* * @testName: testApiInvokeAny - * + * * @assertion_ids: CONCURRENCY:SPEC:44.4 - * + * * @test_Strategy: */ @Test @@ -180,9 +180,9 @@ public void testApiInvokeAny() throws Exception { /* * @testName: testApiSchedule - * + * * @assertion_ids: CONCURRENCY:SPEC:44.5 - * + * * @test_Strategy: */ @Test @@ -200,9 +200,9 @@ public void testApiSchedule() throws Exception { /* * @testName: testApiScheduleAtFixedRate - * + * * @assertion_ids: CONCURRENCY:SPEC:44.6 - * + * * @test_Strategy: */ @Test @@ -226,9 +226,9 @@ public void testApiScheduleAtFixedRate() { /* * @testName: testApiScheduleWithFixedDelay - * + * * @assertion_ids: CONCURRENCY:SPEC:44.7 - * + * * @test_Strategy: */ @Test 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 c70d3c18..f19dc537 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 @@ -40,9 +40,9 @@ public static JavaArchive createDeployment() { /* * @testName: testAwaitTermination - * + * * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.1 - * + * * @test_Strategy: */ @Test @@ -52,9 +52,9 @@ public void testAwaitTermination() { /* * @testName: testIsShutdown - * + * * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.2 - * + * * @test_Strategy: */ @Test @@ -64,9 +64,9 @@ public void testIsShutdown() { /* * @testName: testIsTerminated - * + * * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.3 - * + * * @test_Strategy: */ @Test @@ -76,9 +76,9 @@ public void testIsTerminated() { /* * @testName: testShutdown - * + * * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.4 - * + * * @test_Strategy: */ @Test @@ -88,9 +88,9 @@ public void testShutdown() { /* * @testName: testShutdownNow - * + * * @assertion_ids: CONCURRENCY:SPEC:56;CONCURRENCY:SPEC:57.5 - * + * * @test_Strategy: */ @Test 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 658ad1b0..717e6ac3 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 @@ -55,9 +55,9 @@ protected void before() { /* * @testName: testAwaitTermination - * + * * @assertion_ids: CONCURRENCY:SPEC:57.1 - * + * * @test_Strategy: */ @Test @@ -74,9 +74,9 @@ public void testAwaitTermination() { /* * @testName: testIsShutdown - * + * * @assertion_ids: CONCURRENCY:SPEC:57.2 - * + * * @test_Strategy: */ @Test @@ -91,9 +91,9 @@ public void testIsShutdown() { /* * @testName: testIsTerminated - * + * * @assertion_ids: CONCURRENCY:SPEC:57.3 - * + * * @test_Strategy: */ @Test @@ -108,9 +108,9 @@ public void testIsTerminated() { /* * @testName: testShutdown - * + * * @assertion_ids: CONCURRENCY:SPEC:57.4 - * + * * @test_Strategy: */ @Test @@ -125,9 +125,9 @@ public void testShutdown() { /* * @testName: testShutdownNow - * + * * @assertion_ids: CONCURRENCY:SPEC:57.5 - * + * * @test_Strategy: */ @Test 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 fa37fbef..89f50a09 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 @@ -68,9 +68,9 @@ protected String getServletPath() { /* * @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. 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 a0046fa8..567c9d17 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 @@ -59,9 +59,9 @@ protected String getServletPath() { /* * @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. 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 a90622d7..e196687e 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 @@ -48,12 +48,12 @@ public static WebArchive createDeployment() { /* * @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. @@ -67,12 +67,12 @@ public void testRollbackTransactionWithManagedScheduledExecutorService() { /* * @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. @@ -86,13 +86,13 @@ public void testCommitTransactionWithManagedScheduledExecutorService() { /* * @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. */ 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 830b6d31..ac9687bb 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 @@ -67,10 +67,10 @@ protected String getServletPath() { /* * @testName: jndiClassloaderPropagationTest - * + * * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; * CONCURRENCY:SPEC:106; - * + * * @test_Strategy: */ @Test 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 42715cfc..977567da 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 @@ -57,10 +57,10 @@ protected String getServletPath() { /* * @testName: jndiClassloaderPropagationTest - * + * * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; * CONCURRENCY:SPEC:106; - * + * * @test_Strategy: */ @Test 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 8cf803df..aabfc5ed 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 @@ -48,14 +48,14 @@ public static WebArchive createDeployment() { /* * @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. */ @@ -68,7 +68,7 @@ public void testRollbackTransactionWithManagedThreadFactory() { /* * @testName: testCommitTransactionWithManagedThreadFactory - * + * * @assertion_ids: * CONCURRENCY:SPEC:107;CONCURRENCY:SPEC:108;CONCURRENCY:SPEC:110; * CONCURRENCY:SPEC:111;CONCURRENCY:SPEC:115;CONCURRENCY:SPEC:116; @@ -89,12 +89,12 @@ public void testCommitTransactionWithManagedThreadFactory() throws InterruptedEx /* * @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. */ From 8ae84d8aec79dc7147c4d371079fa91b84a7c806 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 09:31:07 -0500 Subject: [PATCH 04/14] TCK naming --- .../AbortedExceptionTests.java | 16 +++---- .../ContextService/ContextServiceTests.java | 48 +++++++++---------- .../api/LastExecution/LastExecutionTests.java | 12 ++--- .../api/LastExecution/LogicDrivenTrigger.java | 2 +- .../ManagedExecutorsTests.java | 44 ++++++++--------- .../ManagedScheduledExecutorServiceTests.java | 2 +- .../api/ManagedTask/ManagedTaskTests.java | 8 ++-- .../ManagedTaskListenerTests.java | 26 +++++----- .../ManagedThreadFactoryTests.java | 4 +- .../SkippedExceptionTests.java | 8 ++-- .../concurrent/api/Trigger/TriggerTests.java | 12 ++--- .../common/fixed/counter/StaticCounter.java | 8 ++-- .../ConcurrencySignatureTestRunner.java | 4 +- .../concurrent/common/tasks/CommonTasks.java | 6 +-- .../common/tasks/CommonTriggers.java | 2 +- .../transaction/CancelledTransactedTask.java | 6 +-- .../common/transaction/TransactedTask.java | 4 +- .../concurrent/framework/TestConstants.java | 20 ++++---- .../framework/junit/extensions/Wait.java | 44 ++++++++--------- .../contextPropagate/ClassloaderServlet.java | 2 +- .../ContextPropagateBean.java | 4 +- .../ContextPropagationFullTests.java | 4 +- .../ContextPropagationWebTests.java | 4 +- .../contextPropagate/JNDIServlet.java | 2 +- .../contextPropagate/LimitedBean.java | 2 +- .../contextPropagate/SecurityServlet.java | 2 +- .../TestClassloaderRunnableWork.java | 2 +- .../ContextPropagationServletTests.java | 2 +- .../servlet/DeserializeServlet.java | 2 +- .../servlet/ProxyCreatorServlet.java | 2 +- .../servlet/TestClassloaderRunnableWork.java | 2 +- .../ContextService/tx/TransactionServlet.java | 4 +- .../inheritedapi/InheritedAPITests.java | 18 +++---- .../ForbiddenAPIServletTests.java | 2 +- .../managed/forbiddenapi/TestEjb.java | 2 +- .../security/SecurityServlet.java | 4 +- .../security/SecurityTestEjb.java | 2 +- .../tx/TransactionServlet.java | 2 +- .../inheritedapi/TestEjb.java | 42 ++++++++-------- .../servlet/InheritedAPIServletTests.java | 40 ++++++++-------- .../ForbiddenAPIServletTests.java | 2 +- .../managed/forbiddenapi/TestEjb.java | 2 +- ...dScheduledExecutorDefinitionFullTests.java | 6 +-- ...heduledExecutorDefinitionOnEJBServlet.java | 6 +-- ...gedScheduledExecutorDefinitionServlet.java | 24 +++++----- ...edScheduledExecutorDefinitionWebTests.java | 6 +-- .../security/SecurityServlet.java | 4 +- .../security/SecurityTestEjb.java | 2 +- .../tx/TransactionServlet.java | 2 +- .../context/SecurityServlet.java | 6 +-- .../context/SecurityTestEjb.java | 2 +- .../tx/TransactionServlet.java | 2 +- 52 files changed, 243 insertions(+), 243 deletions(-) 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 b7a0d15d..1bec135b 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 @@ -38,14 +38,14 @@ public static WebArchive createDeployment() { } /* - * @testName: AbortedExceptionNoArgTest + * @testName: abortedExceptionNoArgTest * * @assertion_ids: CONCURRENCY:JAVADOC:1 * * @test_Strategy: Constructs an AbortedException. */ @Test - public void AbortedExceptionNoArgTest() { + public void abortedExceptionNoArgTest() { AbortedException thrown = assertThrows(AbortedException.class, () -> { throw new AbortedException(); }); @@ -54,14 +54,14 @@ public void AbortedExceptionNoArgTest() { } /* - * @testName: AbortedExceptionStringTest + * @testName: abortedExceptionStringTest * * @assertion_ids: CONCURRENCY:JAVADOC:3 * * @test_Strategy: Constructs an AbortedException. */ @Test - public void AbortedExceptionStringTest() { + public void abortedExceptionStringTest() { final String expected = "thisisthedetailmessage"; AbortedException thrown = assertThrows(AbortedException.class, () -> { @@ -73,14 +73,14 @@ public void AbortedExceptionStringTest() { } /* - * @testName: AbortedExceptionThrowableTest + * @testName: abortedExceptionThrowableTest * * @assertion_ids: CONCURRENCY:JAVADOC:4 * * @test_Strategy: Constructs an AbortedException. */ @Test - public void AbortedExceptionThrowableTest() { + public void abortedExceptionThrowableTest() { AbortedException thrown; final Throwable expected = new Throwable("thisisthethrowable"); @@ -102,14 +102,14 @@ public void AbortedExceptionThrowableTest() { } /* - * @testName: AbortedExceptionStringThrowableTest + * @testName: abortedExceptionStringThrowableTest * * @assertion_ids: CONCURRENCY:JAVADOC:2 * * @test_Strategy: Constructs an AbortedException. */ @Test - public void AbortedExceptionStringThrowableTest() { + public void abortedExceptionStringThrowableTest() { AbortedException thrown; String sExpected = "thisisthedetailmessage"; 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 dcda4840..c4823d11 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 @@ -50,11 +50,11 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class); } - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) public ContextService context; /* - * @testName: ContextServiceWithIntf + * @testName: contextServiceWithIntf * * @assertion_ids: CONCURRENCY:JAVADOC:5 * @@ -62,7 +62,7 @@ public static WebArchive createDeployment() { * using instance and interface. */ @Test - public void ContextServiceWithIntf() { + public void contextServiceWithIntf() { assertAll(() -> { Runnable proxy = (Runnable) context.createContextualProxy(new CounterRunnableTask(), Runnable.class); assertNotNull(proxy); @@ -70,7 +70,7 @@ public void ContextServiceWithIntf() { } /* - * @testName: ContextServiceWithIntfAndIntfNoImplemented + * @testName: contextServiceWithIntfAndIntfNoImplemented * * @assertion_ids: CONCURRENCY:JAVADOC:6 * @@ -79,14 +79,14 @@ public void ContextServiceWithIntf() { * specified interface, IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithIntfAndIntfNoImplemented() { + public void contextServiceWithIntfAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(new Object(), Runnable.class); }); } /* - * @testName: ContextServiceWithIntfAndInstanceIsNull + * @testName: contextServiceWithIntfAndInstanceIsNull * * @assertion_ids: CONCURRENCY:JAVADOC:6 * @@ -95,14 +95,14 @@ public void ContextServiceWithIntfAndIntfNoImplemented() { * IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithIntfAndInstanceIsNull() { + public void contextServiceWithIntfAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(null, Runnable.class); }); } /* - * @testName: ContextServiceWithMultiIntfs + * @testName: contextServiceWithMultiIntfs * * @assertion_ids: CONCURRENCY:JAVADOC:7 * @@ -110,7 +110,7 @@ public void ContextServiceWithIntfAndInstanceIsNull() { * using instance and multiple interfaces. */ @Test - public void ContextServiceWithMultiIntfs() { + public void contextServiceWithMultiIntfs() { assertAll(() -> { Object proxy = context.createContextualProxy(new CounterRunnableTask(), Runnable.class, WorkInterface.class); @@ -121,7 +121,7 @@ public void ContextServiceWithMultiIntfs() { } /* - * @testName: ContextServiceWithMultiIntfsAndIntfNoImplemented + * @testName: contextServiceWithMultiIntfsAndIntfNoImplemented * * @assertion_ids: CONCURRENCY:JAVADOC:8 * @@ -130,7 +130,7 @@ public void ContextServiceWithMultiIntfs() { * specified interface, IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithMultiIntfsAndIntfNoImplemented() { + public void contextServiceWithMultiIntfsAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(new CounterRunnableTask(), Runnable.class, WorkInterface.class, ManagedTaskListener.class); @@ -138,7 +138,7 @@ public void ContextServiceWithMultiIntfsAndIntfNoImplemented() { } /* - * @testName: ContextServiceWithMultiIntfsAndInstanceIsNull + * @testName: contextServiceWithMultiIntfsAndInstanceIsNull * * @assertion_ids: CONCURRENCY:JAVADOC:8 * @@ -147,7 +147,7 @@ public void ContextServiceWithMultiIntfsAndIntfNoImplemented() { * IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithMultiIntfsAndInstanceIsNull() { + public void contextServiceWithMultiIntfsAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { context.createContextualProxy(null, Runnable.class, WorkInterface.class); }); @@ -162,7 +162,7 @@ public void ContextServiceWithMultiIntfsAndInstanceIsNull() { * using ExecutionProperties and interface. */ @Test - public void ContextServiceWithIntfAndProperties() { + public void contextServiceWithIntfAndProperties() { assertAll(() -> { Map execProps = new HashMap(); execProps.put("vendor_a.security.tokenexpiration", "15000"); @@ -183,7 +183,7 @@ public void ContextServiceWithIntfAndProperties() { * using ExecutionProperties and multiple interfaces. */ @Test - public void ContextServiceWithMultiIntfsAndProperties() { + public void contextServiceWithMultiIntfsAndProperties() { assertAll(() -> { Map execProps = new HashMap(); execProps.put("vendor_a.security.tokenexpiration", "15000"); @@ -207,7 +207,7 @@ public void ContextServiceWithMultiIntfsAndProperties() { * the specified interface, IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithIntfAndPropertiesAndIntfNoImplemented() { + public void contextServiceWithIntfAndPropertiesAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); execProps.put("vendor_a.security.tokenexpiration", "15000"); @@ -228,7 +228,7 @@ public void ContextServiceWithIntfAndPropertiesAndIntfNoImplemented() { * IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithIntfsAndPropertiesAndInstanceIsNull() { + public void contextServiceWithIntfsAndPropertiesAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); execProps.put("vendor_a.security.tokenexpiration", "15000"); @@ -248,7 +248,7 @@ public void ContextServiceWithIntfsAndPropertiesAndInstanceIsNull() { * implement the specified interface, IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithMultiIntfsAndPropertiesAndIntfNoImplemented() { + public void contextServiceWithMultiIntfsAndPropertiesAndIntfNoImplemented() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); execProps.put("vendor_a.security.tokenexpiration", "15000"); @@ -260,7 +260,7 @@ public void ContextServiceWithMultiIntfsAndPropertiesAndIntfNoImplemented() { } /* - * @testName: ContextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull + * @testName: contextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull * * @assertion_ids: CONCURRENCY:JAVADOC:12 * @@ -269,7 +269,7 @@ public void ContextServiceWithMultiIntfsAndPropertiesAndIntfNoImplemented() { * IllegalArgumentException will be thrown */ @Test - public void ContextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull() { + public void contextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull() { assertThrows(IllegalArgumentException.class, () -> { Map execProps = new HashMap(); execProps.put("vendor_a.security.tokenexpiration", "15000"); @@ -280,7 +280,7 @@ public void ContextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull() { } /* - * @testName: GetExecutionProperties + * @testName: getExecutionProperties * * @assertion_ids: CONCURRENCY:JAVADOC:13 * @@ -289,7 +289,7 @@ public void ContextServiceWithMultiIntfsAndPropertiesAndInstanceIsNull() { * ExecutionProperties from proxy object and verify property value. */ @Test - public void GetExecutionProperties() { + public void getExecutionProperties() { assertAll(() -> { Map execProps = new HashMap(); execProps.put("USE_PARENT_TRANSACTION", "true"); @@ -304,7 +304,7 @@ public void GetExecutionProperties() { } /* - * @testName: GetExecutionPropertiesNoProxy + * @testName: getExecutionPropertiesNoProxy * * @assertion_ids: CONCURRENCY:JAVADOC:14 * @@ -312,7 +312,7 @@ public void GetExecutionProperties() { * ExecutionProperties from plain object. */ @Test - public void GetExecutionPropertiesNoProxy() { + public void getExecutionPropertiesNoProxy() { assertAll(() -> { try { context.getExecutionProperties(new Object()); 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 e3914a2e..dc1413ed 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 @@ -61,7 +61,7 @@ public void reset() { @TestName public String testname; - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; /* @@ -81,7 +81,7 @@ public void lastExecutionGetIdentityNameTest() { ScheduledFuture sf = scheduledExecutor.schedule( ManagedExecutors.managedTask(new CounterRunnableTask(), executionProperties, null), - new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + new LogicDrivenTrigger(TestConstants.pollInterval.toMillis(), testname)); Wait.waitTillFutureIsDone(sf); assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected @@ -101,7 +101,7 @@ public void lastExecutionGetResultRunnableTest() { // test with runnable, LastExecution should return null ScheduledFuture sf = scheduledExecutor.schedule( ManagedExecutors.managedTask(new CounterRunnableTask(), null, null), - new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + new LogicDrivenTrigger(TestConstants.pollInterval.toMillis(), testname)); Wait.waitTillFutureIsDone(sf); assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected @@ -121,7 +121,7 @@ public void lastExecutionGetResultCallableTest() { // test with callable, LastExecution should return 1 ScheduledFuture sf = scheduledExecutor.schedule( ManagedExecutors.managedTask(new CounterCallableTask(), null, null), - new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + new LogicDrivenTrigger(TestConstants.pollInterval.toMillis(), testname)); Wait.waitTillFutureIsDone(sf); assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected @@ -140,8 +140,8 @@ public void lastExecutionGetResultCallableTest() { @Test public void lastExecutionGetRunningTimeTest() { ScheduledFuture sf = scheduledExecutor.schedule( - ManagedExecutors.managedTask(new CounterRunnableTask(TestConstants.PollInterval), null, null), - new LogicDrivenTrigger(TestConstants.PollInterval.toMillis(), testname)); + ManagedExecutors.managedTask(new CounterRunnableTask(TestConstants.pollInterval), null, null), + new LogicDrivenTrigger(TestConstants.pollInterval.toMillis(), testname)); Wait.waitTillFutureIsDone(sf); assertEquals(LogicDrivenTrigger.RIGHT_COUNT, // expected StaticCounter.getCount(), // actual diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java index b6a87b31..59db6f04 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java @@ -128,7 +128,7 @@ public Date lastExecutionGetRunningTimeTest(LastExecution lastExecutionInfo, Dat } if ((lastExecutionInfo.getRunEnd().getTime() - - lastExecutionInfo.getRunStart().getTime()) < TestConstants.PollInterval.toMillis()) { + - lastExecutionInfo.getRunStart().getTime()) < TestConstants.pollInterval.toMillis()) { log.warning(testName + "failed, the difference between getRunEnd and getRunStart " + "is shorter than the real running time"); return 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 80d8d320..5a05f931 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 @@ -70,10 +70,10 @@ public static WebArchive createDeployment() { private boolean shutdown = true; - @Resource(lookup = TestConstants.DefaultManagedThreadFactory) + @Resource(lookup = TestConstants.defaultManagedThreadFactory) public ManagedThreadFactory threadFactory; - @Resource(lookup = TestConstants.DefaultManagedExecutorService) + @Resource(lookup = TestConstants.defaultManagedExecutorService) public ManagedExecutorService executor; @AfterEach @@ -114,7 +114,7 @@ private void assertListenerComplete(RunnableTask task) { } /* - * @testName: IsCurrentThreadShutdown + * @testName: isCurrentThreadShutdown * * @assertion_ids: CONCURRENCY:JAVADOC:21 * @@ -123,7 +123,7 @@ private void assertListenerComplete(RunnableTask task) { * */ @Test - public void IsCurrentThreadShutdown() { + public void isCurrentThreadShutdown() { Thread createdThread = threadFactory.newThread(new Runnable() { @Override public void run() { @@ -139,7 +139,7 @@ public void run() { } /* - * @testName: IsCurrentThreadShutdown_ManageableThread + * @testName: isCurrentThreadShutdown_ManageableThread * * @assertion_ids: CONCURRENCY:JAVADOC:21 * @@ -147,7 +147,7 @@ public void run() { * the shutdown status. */ @Test - public void IsCurrentThreadShutdown_ManageableThread() { + public void isCurrentThreadShutdownManageableThread() { Thread createdThread = threadFactory.newThread(new Runnable() { @Override public void run() { @@ -163,7 +163,7 @@ public void run() { } /* - * @testName: ManageRunnableTaskWithTaskListener + * @testName: manageRunnableTaskWithTaskListener * * @assertion_ids: CONCURRENCY:JAVADOC:22;CONCURRENCY:SPEC:7; * CONCURRENCY:SPEC:7.1;CONCURRENCY:SPEC:7.2; @@ -175,7 +175,7 @@ public void run() { * ManagedExecutorService or a ManagedScheduledExecutorService. */ @Test - public void ManageRunnableTaskWithTaskListener() { + public void manageRunnableTaskWithTaskListener() { RunnableTask runnableTask = createRunnableTask(); Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); Future futureResult = executor.submit(taskWithListener); @@ -183,7 +183,7 @@ public void ManageRunnableTaskWithTaskListener() { } /* - * @testName: ManageRunnableTaskWithNullArg + * @testName: manageRunnableTaskWithNullArg * * @assertion_ids: CONCURRENCY:JAVADOC:23 * @@ -191,7 +191,7 @@ public void ManageRunnableTaskWithTaskListener() { * null runnable task. */ @Test - public void ManageRunnableTaskWithNullArg() { + public void manageRunnableTaskWithNullArg() { Runnable nullTask = null; assertThrows(IllegalArgumentException.class, () -> { ManagedExecutors.managedTask(nullTask, managedTaskListener); @@ -199,7 +199,7 @@ public void ManageRunnableTaskWithNullArg() { } /* - * @testName: ManageRunnableTaskWithTaskListenerAndMap + * @testName: manageRunnableTaskWithTaskListenerAndMap * * @assertion_ids: CONCURRENCY:JAVADOC:24;CONCURRENCY:SPEC:13; * @@ -209,7 +209,7 @@ public void ManageRunnableTaskWithNullArg() { * when the task is submitted to a ManagedExecutorService */ @Test - public void ManageRunnableTaskWithTaskListenerAndMap() { + public void manageRunnableTaskWithTaskListenerAndMap() { Map properties = new HashMap(); properties.put("key", "value"); RunnableTask runnableTask = createRunnableTask(); @@ -224,7 +224,7 @@ public void ManageRunnableTaskWithTaskListenerAndMap() { } /* - * @testName: ManageRunnableTaskWithMapAndNullArg + * @testName: manageRunnableTaskWithMapAndNullArg * * @assertion_ids: CONCURRENCY:JAVADOC:25 * @@ -232,7 +232,7 @@ public void ManageRunnableTaskWithTaskListenerAndMap() { * null runnable task and additional execution properties. */ @Test - public void ManageRunnableTaskWithMapAndNullArg() { + public void manageRunnableTaskWithMapAndNullArg() { Runnable nullTask = null; Map properties = new HashMap(); @@ -242,7 +242,7 @@ public void ManageRunnableTaskWithMapAndNullArg() { } /* - * @testName: ManageCallableTaskWithTaskListener + * @testName: manageCallableTaskWithTaskListener * * @assertion_ids: CONCURRENCY:JAVADOC:26 * @@ -252,7 +252,7 @@ public void ManageRunnableTaskWithMapAndNullArg() { * ManagedExecutorService */ @Test - public void ManageCallableTaskWithTaskListener() { + public void manageCallableTaskWithTaskListener() { String expectedResultStr = "expected something"; CallableTask callableTask = createCallableTask(expectedResultStr); Callable taskWithListener = ManagedExecutors.managedTask((Callable) callableTask, @@ -262,7 +262,7 @@ public void ManageCallableTaskWithTaskListener() { } /* - * @testName: ManageCallableTaskWithNullArg + * @testName: manageCallableTaskWithNullArg * * @assertion_ids: CONCURRENCY:JAVADOC:27 * @@ -270,7 +270,7 @@ public void ManageCallableTaskWithTaskListener() { * null Callable task. */ @Test - public void ManageCallableTaskWithNullArg() { + public void manageCallableTaskWithNullArg() { Callable nullTask = null; assertThrows(IllegalArgumentException.class, () -> { ManagedExecutors.managedTask(nullTask, managedTaskListener); @@ -278,7 +278,7 @@ public void ManageCallableTaskWithNullArg() { } /* - * @testName: ManageCallableTaskWithTaskListenerAndMap + * @testName: manageCallableTaskWithTaskListenerAndMap * * @assertion_ids: CONCURRENCY:JAVADOC:28;CONCURRENCY:SPEC:13.1; * CONCURRENCY:SPEC:45;CONCURRENCY:SPEC:45.1; @@ -289,7 +289,7 @@ public void ManageCallableTaskWithNullArg() { * when the task is submitted to a ManagedExecutorService */ @Test - public void ManageCallableTaskWithTaskListenerAndMap() { + public void manageCallableTaskWithTaskListenerAndMap() { Map properties = new HashMap(); properties.put("key", "value"); properties.put(ManagedTask.IDENTITY_NAME, "id"); @@ -309,7 +309,7 @@ public void ManageCallableTaskWithTaskListenerAndMap() { } /* - * @testName: ManageCallableTaskWithMapAndNullArg + * @testName: manageCallableTaskWithMapAndNullArg * * @assertion_ids: CONCURRENCY:JAVADOC:29 * @@ -317,7 +317,7 @@ public void ManageCallableTaskWithTaskListenerAndMap() { * null Callable task and additional execution properties. */ @Test - public void ManageCallableTaskWithMapAndNullArg() { + 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 c7976390..a241e81b 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 @@ -59,7 +59,7 @@ public static WebArchive createDeployment() { private static final String TEST_CLASSLOADER_CLASS_NAME = ManagedScheduledExecutorServiceTests.class .getCanonicalName(); - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; /* 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 2a206b4b..0d022d4c 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 @@ -53,7 +53,7 @@ private RunnableTask createRunnableTask() { } /* - * @testName: GetExecutionProperties + * @testName: getExecutionProperties * * @assertion_ids: CONCURRENCY:JAVADOC:36 * @@ -62,7 +62,7 @@ private RunnableTask createRunnableTask() { * task. */ @Test - public void GetExecutionProperties() { + public void getExecutionProperties() { Map properties = new HashMap(); properties.put("key", "value"); Runnable runnableTask = createRunnableTask(); @@ -76,7 +76,7 @@ public void GetExecutionProperties() { } /* - * @testName: GetManagedTaskListener + * @testName: getManagedTaskListener * * @assertion_ids: CONCURRENCY:JAVADOC:37 * @@ -84,7 +84,7 @@ public void GetExecutionProperties() { * notification of life cycle events of this task. */ @Test - public void GetManagedTaskListener() { + public void getManagedTaskListener() { Map properties = new HashMap(); properties.put("key", "value"); RunnableTask runnableTask = createRunnableTask(); 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 be14d163..2f24f5c3 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 @@ -57,7 +57,7 @@ public static WebArchive createDeployment() { private ManagedTaskListenerImpl managedTaskListener = new ManagedTaskListenerImpl(); - @Resource(lookup = TestConstants.DefaultManagedExecutorService) + @Resource(lookup = TestConstants.defaultManagedExecutorService) public ManagedExecutorService executor; @AfterEach @@ -66,7 +66,7 @@ public void cleanup() { } /* - * @testName: TaskAborted + * @testName: taskAborted * * @assertion_ids: * CONCURRENCY:JAVADOC:38;CONCURRENCY:SPEC:7;CONCURRENCY:SPEC:7.1;CONCURRENCY: @@ -76,15 +76,15 @@ public void cleanup() { * Future has been cancelled anytime during the life of a task. */ @Test - public void TaskAborted() throws InterruptedException { + public void taskAborted() throws InterruptedException { final Duration blockTime = Duration.ofMillis(3000); Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener, blockTime); Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); Future futureResult = executor.submit(taskWithListener); Wait.sleep(Duration.ofMillis(1000)); futureResult.cancel(true); - Wait.waitForListenerComplete(managedTaskListener, TestConstants.WaitTimeout.plus(blockTime), - TestConstants.PollInterval); + Wait.waitForListenerComplete(managedTaskListener, TestConstants.waitTimeout.plus(blockTime), + TestConstants.pollInterval); List events = managedTaskListener.events(); assertTrue(events.contains(ListenerEvent.ABORTED), "Listener taskAborted failed"); @@ -92,7 +92,7 @@ public void TaskAborted() throws InterruptedException { } /* - * @testName: TaskDone + * @testName: taskDone * * @assertion_ids: * CONCURRENCY:JAVADOC:39;CONCURRENCY:SPEC:13.3;CONCURRENCY:SPEC:45.3; @@ -101,7 +101,7 @@ public void TaskAborted() throws InterruptedException { * running, either successfully or failed . */ @Test - public void TaskDone() throws InterruptedException { + public void taskDone() throws InterruptedException { // in cancel case final Duration blockTime = Duration.ofMillis(3000); Runnable taskToCancelled = new RunnableTaskWithStatus(managedTaskListener, blockTime); @@ -109,8 +109,8 @@ public void TaskDone() throws InterruptedException { Future futureResult = executor.submit(taskToCancelledWithListener); Wait.sleep(Duration.ofMillis(1000)); futureResult.cancel(true); - Wait.waitForListenerComplete(managedTaskListener, TestConstants.WaitTimeout.plus(blockTime), - TestConstants.PollInterval); + Wait.waitForListenerComplete(managedTaskListener, TestConstants.waitTimeout.plus(blockTime), + TestConstants.pollInterval); List events = managedTaskListener.events(); assertTrue(events.contains(ListenerEvent.DONE), "Listener taskDone failed in cancel case"); managedTaskListener.clearEvents(); @@ -136,7 +136,7 @@ public void TaskDone() throws InterruptedException { } /* - * @testName: TaskStarting + * @testName: taskStarting * * @assertion_ids: * CONCURRENCY:JAVADOC:40;CONCURRENCY:SPEC:7;CONCURRENCY:SPEC:7.3;CONCURRENCY: @@ -147,7 +147,7 @@ public void TaskDone() throws InterruptedException { * completed. */ @Test - public void TaskStarting() { + public void taskStarting() { Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); executor.submit(taskWithListener); @@ -162,7 +162,7 @@ public void TaskStarting() { } /* - * @testName: TaskSubmitted + * @testName: taskSubmitted * * @assertion_ids: * CONCURRENCY:JAVADOC:41;CONCURRENCY:SPEC:7;CONCURRENCY:SPEC:7.2;CONCURRENCY: @@ -173,7 +173,7 @@ public void TaskStarting() { * taskSubmitted listener has completed. */ @Test - public void TaskSubmitted() { + public void taskSubmitted() { Runnable runnableTask = new RunnableTaskWithStatus(managedTaskListener); Runnable taskWithListener = ManagedExecutors.managedTask(runnableTask, managedTaskListener); executor.submit(taskWithListener); 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 d661a18a..c703e1e4 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 @@ -46,7 +46,7 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class).addPackages(true, ManagedThreadFactoryTests.class.getPackage()); } - @Resource(lookup = TestConstants.DefaultManagedThreadFactory) + @Resource(lookup = TestConstants.defaultManagedThreadFactory) public ManagedThreadFactory threadFactory; /* @@ -75,7 +75,7 @@ public void isShutdown() { */ @Test public void interruptThreadApiTest() { - CounterRunnableTask task = new CounterRunnableTask(TestConstants.PollInterval); + CounterRunnableTask task = new CounterRunnableTask(TestConstants.pollInterval); Thread thread = threadFactory.newThread(task); thread.start(); thread.interrupt(); 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 0b66c814..6bd5ca4e 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 @@ -46,7 +46,7 @@ public static WebArchive createDeployment() { * @test_Strategy: Constructs an SkippedException. */ @Test - public void SkippedExceptionNoArgTest() { + public void skippedExceptionNoArgTest() { SkippedException thrown = assertThrows(SkippedException.class, () -> { throw new SkippedException(); }); @@ -62,7 +62,7 @@ public void SkippedExceptionNoArgTest() { * @test_Strategy: Constructs an SkippedException. */ @Test - public void SkippedExceptionStringTest() { + public void skippedExceptionStringTest() { final String expected = "thisisthedetailmessage"; SkippedException thrown = assertThrows(SkippedException.class, () -> { @@ -81,7 +81,7 @@ public void SkippedExceptionStringTest() { * @test_Strategy: Constructs an SkippedException. */ @Test - public void SkippedExceptionThrowableTest() { + public void skippedExceptionThrowableTest() { SkippedException thrown; final Throwable expected = new Throwable("thisisthethrowable"); @@ -110,7 +110,7 @@ public void SkippedExceptionThrowableTest() { * @test_Strategy: Constructs an SkippedException. */ @Test - public void SkippedExceptionStringThrowableTest() { + public void skippedExceptionStringThrowableTest() { SkippedException thrown; String sExpected = "thisisthedetailmessage"; 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 e4872997..837d0201 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 @@ -53,7 +53,7 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class).addPackages(true, TriggerTests.class.getPackage()); } - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; @BeforeEach @@ -74,14 +74,14 @@ public void reset() { @Disabled public void triggerGetNextRunTimeTest() throws Exception { Future result = scheduledExecutor.schedule(new CounterRunnableTask(), - new CommonTriggers.TriggerFixedRate(new Date(), TestConstants.PollInterval.toMillis())); + new CommonTriggers.TriggerFixedRate(new Date(), TestConstants.pollInterval.toMillis())); assertFalse(StaticCounter.getCount() == 0, "The first trigger is too fast."); try { - Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(StaticCounter.getCount(), TestConstants.PollsPerTimeout - 2, - TestConstants.PollsPerTimeout + 2); + Wait.sleep(TestConstants.waitTimeout); + Assertions.assertBetween(StaticCounter.getCount(), TestConstants.pollsPerTimeout - 2, + TestConstants.pollsPerTimeout + 2); } finally { Wait.waitTillFutureIsDone(result); } @@ -101,7 +101,7 @@ public void triggerGetNextRunTimeTest() throws Exception { @Test public void triggerSkipRunTest() { ScheduledFuture sf = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), - new CommonTriggers.OnceTriggerDelaySkip(TestConstants.PollInterval)); + new CommonTriggers.OnceTriggerDelaySkip(TestConstants.pollInterval)); try { Wait.waitTillFutureThrowsException(sf, SkippedException.class); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java index 4d6fc516..56c3f72e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java @@ -40,15 +40,15 @@ public static void reset() { } public static void waitTill(int expected) { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (; expected != StaticCounter.getCount(); Wait.sleep(TestConstants.PollInterval)) + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (; expected != StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) ; }); } public static void waitTillSurpassed(int expected) { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (; expected <= StaticCounter.getCount(); Wait.sleep(TestConstants.PollInterval)) + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (; expected <= StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) ; }); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index 74c6d8ee..a8517d85 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -82,7 +82,7 @@ protected String getClasspath() { }; // The JDK modules we want added to our classpath - String[] JDKModules = new String[] { "java.base", "java.rmi", "java.sql", "java.naming" }; + String[] jdkModules = new String[] { "java.base", "java.rmi", "java.sql", "java.naming" }; // Get Jakarta artifacts from application server Set classPaths = new HashSet(); @@ -108,7 +108,7 @@ protected String getClasspath() { // Get JDK modules from jimage // Add JDK classes to classpath File jimageOutput = new File(testInfo.getJImageDir()); - for (String module : JDKModules) { + for (String module : jdkModules) { Path modulePath = Paths.get(jimageOutput.getAbsolutePath(), module); if (Files.isDirectory(modulePath)) { classPaths.add(modulePath.toString()); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java index 798b4594..6675c774 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java @@ -41,7 +41,7 @@ public String call() { if (!waitTime.isZero()) { Wait.sleep(waitTime); } else { - Wait.sleep(TestConstants.PollInterval); + Wait.sleep(TestConstants.pollInterval); } } catch (Exception e) { throw new RuntimeException(e); @@ -53,7 +53,7 @@ public String call() { public static class SimpleRunnable implements Runnable { public void run() { try { - Wait.sleep(TestConstants.PollInterval); + Wait.sleep(TestConstants.pollInterval); } catch (Exception e) { throw new RuntimeException(e); } @@ -69,7 +69,7 @@ public SimpleArgCallable(int arg) { public Integer call() { try { - Wait.sleep(TestConstants.PollInterval); + Wait.sleep(TestConstants.pollInterval); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java index 0d94d3ee..a9e88895 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java @@ -74,7 +74,7 @@ public static class TriggerFixedRate implements Trigger { private int executionCount = 0; - private static final int executionCountLimit = TestConstants.PollsPerTimeout * 2; + private static final int executionCountLimit = TestConstants.pollsPerTimeout * 2; public TriggerFixedRate(Date startTime, long delta) { this.startTime = startTime; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java index 4d6fe4a8..1272ee12 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java @@ -43,8 +43,8 @@ public CancelledTransactedTask(String sqlTemplate) { } private void waitForRun() { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (; !runQuery.get(); Wait.sleep(TestConstants.PollInterval)) + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (; !runQuery.get(); Wait.sleep(TestConstants.pollInterval)) ; }); } @@ -52,7 +52,7 @@ private void waitForRun() { @Override public void run() { try { - UserTransaction ut = InitialContext.doLookup(TestConstants.UserTransaction); + UserTransaction ut = InitialContext.doLookup(TestConstants.userTransaction); ut.begin(); beginTransaction.set(true); waitForRun(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java index a64da77c..38667495 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java @@ -55,7 +55,7 @@ public void run() { try { if (beginTransaction) { - ut = InitialContext.doLookup(TestConstants.UserTransaction); + ut = InitialContext.doLookup(TestConstants.userTransaction); ut.begin(); } try (Connection conn = Connections.getConnection(false); @@ -103,7 +103,7 @@ public void doWork() { try { if (beginTransaction) { - ut = InitialContext.doLookup(TestConstants.UserTransaction); + ut = InitialContext.doLookup(TestConstants.userTransaction); ut.begin(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java index f1875f7e..ce15264f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java @@ -24,23 +24,23 @@ public final class TestConstants { // JNDI Names - public static final String DefaultContextService = "java:comp/DefaultContextService"; - public static final String DefaultManagedScheduledExecutorService = "java:comp/DefaultManagedScheduledExecutorService"; - public static final String DefaultManagedExecutorService = "java:comp/DefaultManagedExecutorService"; - public static final String DefaultManagedThreadFactory = "java:comp/DefaultManagedThreadFactory"; - public static final String UserTransaction = "java:comp/UserTransaction"; + public static final String defaultContextService = "java:comp/DefaultContextService"; + public static final String defaultManagedScheduledExecutorService = "java:comp/DefaultManagedScheduledExecutorService"; + public static final String defaultManagedExecutorService = "java:comp/DefaultManagedExecutorService"; + public static final String defaultManagedThreadFactory = "java:comp/DefaultManagedThreadFactory"; + public static final String userTransaction = "java:comp/UserTransaction"; // Durations /** 1 second */ - public static final Duration PollInterval = Duration.ofSeconds(1); + public static final Duration pollInterval = Duration.ofSeconds(1); /** 15 seconds */ - public static final Duration WaitTimeout = Duration.ofSeconds(15); + public static final Duration waitTimeout = Duration.ofSeconds(15); /** Approximate number of polls performed before timeout */ - public static final int PollsPerTimeout = (int) (WaitTimeout.getSeconds() / PollInterval.getSeconds()); + public static final int pollsPerTimeout = (int) (waitTimeout.getSeconds() / pollInterval.getSeconds()); // Return values - public static final String SimpleReturnValue = "ok"; - public static final String ComplexReturnValue = "ConcurrentResultOkay"; + public static final String simpleReturnValue = "ok"; + public static final String complexReturnValue = "ConcurrentResultOkay"; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java index 4b9b0082..a38c173e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java @@ -27,13 +27,13 @@ private Wait() { /** * Waits for task to complete, but will timeout after - * {@link TestConstants#WaitTimeout} + * {@link TestConstants#waitTimeout} * * @param future to wait for * @return result */ public static T waitForTaskComplete(final Future future) { - return waitForTaskComplete(future, TestConstants.WaitTimeout); + return waitForTaskComplete(future, TestConstants.waitTimeout); } /** @@ -49,13 +49,13 @@ public static T waitForTaskComplete(final Future future, final Duration t /** * Wait for listener to complete, but will timeout after - * {@link TestConstants#WaitTimeout}, and will be polled ever - * {@link TestConstants#PollInterval} + * {@link TestConstants#waitTimeout}, and will be polled ever + * {@link TestConstants#pollInterval} * * @param managedTaskListener - the listener to be polled */ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener) { - waitForListenerComplete(managedTaskListener, TestConstants.WaitTimeout, TestConstants.PollInterval); + waitForListenerComplete(managedTaskListener, TestConstants.waitTimeout, TestConstants.pollInterval); } /** @@ -69,15 +69,15 @@ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskLi public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener, Duration timeout, Duration pollInterval) { assertTimeoutPreemptively(timeout, () -> { - for (; !managedTaskListener.eventCalled(ListenerEvent.DONE); sleep(TestConstants.PollInterval)) + for (; !managedTaskListener.eventCalled(ListenerEvent.DONE); sleep(TestConstants.pollInterval)) ; }); } /** * Waits for future to complete, but will timeout after - * {@link TestConstants#WaitTimeout}, and will be polled every - * {@link TestConstants#PollInterval} + * {@link TestConstants#waitTimeout}, and will be polled every + * {@link TestConstants#pollInterval} * * The difference between this method and waitForTaskComplete is that some * scheduled task will return values for multiple times, in this situation @@ -86,24 +86,24 @@ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskLi * @param future - the future to wait for */ public static void waitTillFutureIsDone(final Future future) { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (; !future.isDone(); sleep(TestConstants.PollInterval)) + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (; !future.isDone(); sleep(TestConstants.pollInterval)) ; }); } /** * Waits for future to throw an error, but will timeout after - * {@link TestConstants#WaitTimeout}, and will be polled every - * {@link TestConstants#PollInterval} + * {@link TestConstants#waitTimeout}, and will be polled every + * {@link TestConstants#pollInterval} * * @param future - the future to wait for */ public static void waitTillFutureThrowsException(final Future future, final Class expected) { assertThrows(expected, () -> { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (;; sleep(TestConstants.PollInterval)) { + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (;; sleep(TestConstants.pollInterval)) { future.get(); } }); @@ -111,29 +111,29 @@ public static void waitTillFutureThrowsException(final Fut } public static void waitCancelFuture(final Future future) { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (future.cancel(true); !future.isDone(); sleep(TestConstants.PollInterval)) + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (future.cancel(true); !future.isDone(); sleep(TestConstants.pollInterval)) ; }); } /** * Waits until thread is finished, but will timeout after - * {@link TestConstants#WaitTimeout}, and will be polled every - * {@link TestConstants#PollInterval} + * {@link TestConstants#waitTimeout}, and will be polled every + * {@link TestConstants#pollInterval} * * @param thread - the thread to wait for */ public static void waitTillThreadFinish(final Thread thread) { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (; thread.isAlive(); sleep(TestConstants.PollInterval)) + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (; thread.isAlive(); sleep(TestConstants.pollInterval)) ; }); } public static void waitForTransactionBegan(CancelledTransactedTask task) { - assertTimeoutPreemptively(TestConstants.WaitTimeout, () -> { - for (; !task.beginTransaction.get(); sleep(TestConstants.PollInterval)) + assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { + for (; !task.beginTransaction.get(); sleep(TestConstants.pollInterval)) ; }); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java index 9f3c9e0b..acc1f215 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java @@ -34,7 +34,7 @@ public class ClassloaderServlet extends TestServlet { @EJB private ContextPropagateInterface intf; - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) public ContextService context; public void testClassloaderAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java index 01f1a222..59ec1612 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java @@ -27,10 +27,10 @@ @Stateless public class ContextPropagateBean implements ContextPropagateInterface { - @Resource(lookup = TestConstants.DefaultManagedThreadFactory) + @Resource(lookup = TestConstants.defaultManagedThreadFactory) public ManagedThreadFactory threadFactory; - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) public ContextService context; @Override 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 574410b5..7993e930 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 @@ -169,7 +169,7 @@ public void testClassloaderAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet") .withTestName(testname); String resp = runTestWithResponse(requestURL, null); - this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.ComplexReturnValue, resp); + this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } /* @@ -190,7 +190,7 @@ public void testSecurityAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet") .withTestName(testname); String resp = runTestWithResponse(requestURL, null); - this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.ComplexReturnValue, resp); + this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } /** 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 b4e4882f..5e398f69 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 @@ -159,7 +159,7 @@ public void testClassloaderAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet") .withTestName(testname); String resp = runTestWithResponse(requestURL, null); - this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.ComplexReturnValue, resp); + this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } /* @@ -180,7 +180,7 @@ public void testSecurityAndCreateProxyInServlet() { URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet") .withTestName(testname); String resp = runTestWithResponse(requestURL, null); - this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.ComplexReturnValue, resp); + this.assertStringInResponse(testname + "failed to get correct result.", TestConstants.complexReturnValue, resp); } /** diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java index 9f9dc2fb..2a504639 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java @@ -34,7 +34,7 @@ public class JNDIServlet extends TestServlet { @EJB private ContextPropagateInterface intf; - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) public ContextService context; public void testJNDIContextAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java index b63ac2e3..b42d1fe8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/LimitedBean.java @@ -27,6 +27,6 @@ public class LimitedBean implements LimitedInterface { @RolesAllowed("Manager") public String doSomething() { - return TestConstants.ComplexReturnValue; + return TestConstants.complexReturnValue; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java index 1c2155ef..d8faff60 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java @@ -34,7 +34,7 @@ public class SecurityServlet extends TestServlet { @EJB private ContextPropagateInterface intf; - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) public ContextService context; public void testSecurityAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java index 8dc97461..8d2a6195 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestClassloaderRunnableWork.java @@ -29,6 +29,6 @@ protected String work() { } catch (ClassNotFoundException e) { return "can not load class in web module from ejb module."; } - return TestConstants.ComplexReturnValue; + return TestConstants.complexReturnValue; } } 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 05b9aa2c..6308356a 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 @@ -132,7 +132,7 @@ public void testClassloaderInServlet() { String resp = runTestWithResponse(requestURL, props); assertNotNull("Response should not be null", resp); - assertStringInResponse(testname + " failed to get correct result.", TestConstants.ComplexReturnValue, + assertStringInResponse(testname + " failed to get correct result.", TestConstants.complexReturnValue, resp.trim()); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java index dec165ea..c79b2f25 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java @@ -36,7 +36,7 @@ @WebServlet("/DeserializeServlet") public class DeserializeServlet extends HttpServlet { - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) public ContextService context; @Override diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java index bc18acc1..078039c1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java @@ -39,7 +39,7 @@ public class ProxyCreatorServlet extends TestServlet { private static final TestLogger log = TestLogger.get(ProxyCreatorServlet.class); - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) public ContextService context; public void testJNDIContextInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java index db3fecf2..501e48a2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/TestClassloaderRunnableWork.java @@ -29,6 +29,6 @@ protected String work() { } catch (ClassNotFoundException e) { throw new RuntimeException(e); } - return TestConstants.ComplexReturnValue; + return TestConstants.complexReturnValue; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java index b31783aa..8ceed305 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/tx/TransactionServlet.java @@ -53,10 +53,10 @@ public class TransactionServlet extends TestServlet { @Resource(lookup = "java:comp/env/jdbc/ContextServiceDB") private DataSource ds; - @Resource(lookup = TestConstants.DefaultContextService) + @Resource(lookup = TestConstants.defaultContextService) private ContextService cx; - @Resource(lookup = TestConstants.UserTransaction) + @Resource(lookup = TestConstants.userTransaction) private UserTransaction ut; @Override 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 d853c4cb..56a2a57c 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 @@ -54,7 +54,7 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class); } - @Resource(lookup = TestConstants.DefaultManagedExecutorService) + @Resource(lookup = TestConstants.defaultManagedExecutorService) public ManagedExecutorService executor; /* @@ -109,7 +109,7 @@ public void testInvokeAny() { Integer result = executor.invokeAny(taskList); Assertions.assertBetween(result, 1, 3); - result = executor.invokeAny(taskList, TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); + result = executor.invokeAny(taskList, TestConstants.waitTimeout.getSeconds(), TimeUnit.SECONDS); Assertions.assertBetween(result, 1, 3); } catch (Exception e) { throw new RuntimeException(e); @@ -117,9 +117,9 @@ public void testInvokeAny() { assertThrows(TimeoutException.class, () -> { List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - executor.invokeAny(taskList, TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + executor.invokeAny(taskList, TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); }); } @@ -138,7 +138,7 @@ public void testInvokeAll() { assertEquals(resultList.get(1).get(), 2); assertEquals(resultList.get(2).get(), 3); - resultList = executor.invokeAll(taskList, TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); + resultList = executor.invokeAll(taskList, TestConstants.waitTimeout.getSeconds(), TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureIsDone(each); } @@ -151,9 +151,9 @@ public void testInvokeAll() { try { List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - List> resultList = executor.invokeAll(taskList, TestConstants.PollInterval.getSeconds(), + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + List> resultList = executor.invokeAll(taskList, TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureThrowsException(each, CancellationException.class); 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 c56ed566..ff9ecf1a 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 @@ -38,7 +38,7 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class); } - @Resource(lookup = TestConstants.DefaultManagedExecutorService) + @Resource(lookup = TestConstants.defaultManagedExecutorService) public ManagedExecutorService mes; /* 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 a8ce8d1b..44308095 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 @@ -30,7 +30,7 @@ public class TestEjb implements TestEjbInterface { private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - @Resource(lookup = TestConstants.DefaultManagedExecutorService) + @Resource(lookup = TestConstants.defaultManagedExecutorService) public ManagedExecutorService executor; public void testAwaitTermination() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java index 0840d3a5..2a172bf5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java @@ -33,7 +33,7 @@ @WebServlet("/SecurityServlet") public class SecurityServlet extends TestServlet { - @Resource(lookup = TestConstants.DefaultManagedExecutorService) + @Resource(lookup = TestConstants.defaultManagedExecutorService) public ManagedExecutorService executor; public void managedExecutorServiceAPISecurityTest(HttpServletRequest req, HttpServletResponse res) @@ -41,7 +41,7 @@ public void managedExecutorServiceAPISecurityTest(HttpServletRequest req, HttpSe req.login("javajoe", "javajoe"); Future future = executor.submit(new SecurityTestTask()); Object result = Wait.waitForTaskComplete(future); - assertEquals(result, TestConstants.SimpleReturnValue); + assertEquals(result, TestConstants.simpleReturnValue); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java index 5ab96d19..facde798 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestEjb.java @@ -25,6 +25,6 @@ public class SecurityTestEjb implements SecurityTestInterface { @RolesAllowed("Manager") public String managerMethod1() { - return TestConstants.SimpleReturnValue; + return TestConstants.simpleReturnValue; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java index 82969fca..89623e95 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java @@ -54,7 +54,7 @@ public class TransactionServlet extends TestServlet { @Resource(lookup = "java:comp/env/jdbc/ManagedExecutorServiceDB") private DataSource ds; - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; @Override diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java index 13db321f..560dc533 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java @@ -48,7 +48,7 @@ public class TestEjb implements TestEjbInterface { @EJB private CounterInterface counter; - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; public void testApiSubmit() { @@ -93,7 +93,7 @@ public void testApiInvokeAll() { assertEquals(resultList.get(1).get(), 2); assertEquals(resultList.get(2).get(), 3); - resultList = scheduledExecutor.invokeAll(taskList, TestConstants.WaitTimeout.getSeconds(), + resultList = scheduledExecutor.invokeAll(taskList, TestConstants.waitTimeout.getSeconds(), TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureIsDone(each); @@ -107,10 +107,10 @@ public void testApiInvokeAll() { try { List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); List> resultList = scheduledExecutor.invokeAll(taskList, - TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureThrowsException(each, CancellationException.class); } @@ -128,7 +128,7 @@ public void testApiInvokeAny() { Integer result = scheduledExecutor.invokeAny(taskList); Assertions.assertBetween(result, 1, 3); - result = scheduledExecutor.invokeAny(taskList, TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); + result = scheduledExecutor.invokeAny(taskList, TestConstants.waitTimeout.getSeconds(), TimeUnit.SECONDS); Assertions.assertBetween(result, 1, 3); } catch (Exception e) { throw new RuntimeException(e); @@ -136,9 +136,9 @@ public void testApiInvokeAny() { try { List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - scheduledExecutor.invokeAny(taskList, TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + scheduledExecutor.invokeAny(taskList, TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); } catch (TimeoutException e) { return; // expected } catch (Exception ex) { @@ -150,12 +150,12 @@ public void testApiInvokeAny() { public void testApiSchedule() { try { Future result = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), - TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); Wait.waitTillFutureIsDone(result); assertEquals(CommonTasks.SIMPLE_RETURN_STRING, result.get()); result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), - TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); Wait.waitTillFutureIsDone(result); assertEquals(result.get(), null); } catch (Exception e) { @@ -168,10 +168,10 @@ public void testApiScheduleAtFixedRate() { try { EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); result = scheduledExecutor.scheduleAtFixedRate(new CounterRunnableTask(nameProvider.getEJBJNDIName()), - TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); - Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(counter.getCount(), TestConstants.PollsPerTimeout - 2, - TestConstants.PollsPerTimeout + 2); + TestConstants.pollInterval.getSeconds(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); + Wait.sleep(TestConstants.waitTimeout); + Assertions.assertBetween(counter.getCount(), TestConstants.pollsPerTimeout - 2, + TestConstants.pollsPerTimeout + 2); } catch (Exception e) { fail(e.getMessage()); } finally { @@ -187,13 +187,13 @@ public void testApiScheduleWithFixedDelay() { try { EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); result = scheduledExecutor.scheduleWithFixedDelay( - new CounterRunnableTask(nameProvider.getEJBJNDIName(), TestConstants.PollInterval), // task - TestConstants.PollInterval.getSeconds(), // initial delay - TestConstants.PollInterval.getSeconds(), // delay + new CounterRunnableTask(nameProvider.getEJBJNDIName(), TestConstants.pollInterval), // task + TestConstants.pollInterval.getSeconds(), // initial delay + TestConstants.pollInterval.getSeconds(), // delay TimeUnit.SECONDS); // Time units - Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(counter.getCount(), (TestConstants.PollsPerTimeout / 2) - 2, - (TestConstants.PollsPerTimeout / 2) + 2); + Wait.sleep(TestConstants.waitTimeout); + Assertions.assertBetween(counter.getCount(), (TestConstants.pollsPerTimeout / 2) - 2, + (TestConstants.pollsPerTimeout / 2) + 2); } catch (Exception e) { fail(e.getMessage()); } finally { 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/servlet/InheritedAPIServletTests.java index 32da2572..589729d7 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/servlet/InheritedAPIServletTests.java @@ -56,7 +56,7 @@ public static WebArchive createDeployment() { return ShrinkWrap.create(WebArchive.class); } - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; @BeforeEach @@ -124,7 +124,7 @@ public void testApiInvokeAll() throws Exception { assertEquals(resultList.get(0).get(), 1); assertEquals(resultList.get(1).get(), 2); assertEquals(resultList.get(2).get(), 3); - resultList = scheduledExecutor.invokeAll(taskList, TestConstants.WaitTimeout.getSeconds(), + resultList = scheduledExecutor.invokeAll(taskList, TestConstants.waitTimeout.getSeconds(), TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureIsDone(each); @@ -138,10 +138,10 @@ public void testApiInvokeAll() throws Exception { try { List> taskList = new ArrayList<>(); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + taskList.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); List> resultList = scheduledExecutor.invokeAll(taskList, - TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); for (Future each : resultList) { Wait.waitTillFutureThrowsException(each, CancellationException.class); } @@ -167,14 +167,14 @@ public void testApiInvokeAny() throws Exception { Integer result = scheduledExecutor.invokeAny(taskList); Assertions.assertBetween(result, 1, 3); - result = scheduledExecutor.invokeAny(taskList, TestConstants.WaitTimeout.getSeconds(), TimeUnit.SECONDS); + result = scheduledExecutor.invokeAny(taskList, TestConstants.waitTimeout.getSeconds(), TimeUnit.SECONDS); Assertions.assertBetween(result, 1, 3); assertThrows(TimeoutException.class, () -> { List> taskList2 = new ArrayList<>(); - taskList2.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - taskList2.add(new CommonTasks.SimpleCallable(TestConstants.WaitTimeout)); - scheduledExecutor.invokeAny(taskList2, TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + taskList2.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + taskList2.add(new CommonTasks.SimpleCallable(TestConstants.waitTimeout)); + scheduledExecutor.invokeAny(taskList2, TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); }); } @@ -188,11 +188,11 @@ public void testApiInvokeAny() throws Exception { @Test public void testApiSchedule() throws Exception { Future result = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), - TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); + TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); Wait.waitTillFutureIsDone(result); assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); - result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), TestConstants.PollInterval.getSeconds(), + result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); Wait.waitTillFutureIsDone(result); assertEquals(result.get(), null); @@ -211,10 +211,10 @@ public void testApiScheduleAtFixedRate() { try { result = scheduledExecutor.scheduleAtFixedRate(new CounterRunnableTask(), - TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); - Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(StaticCounter.getCount(), TestConstants.PollsPerTimeout - 2, - TestConstants.PollsPerTimeout + 2); + TestConstants.pollInterval.getSeconds(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); + Wait.sleep(TestConstants.waitTimeout); + Assertions.assertBetween(StaticCounter.getCount(), TestConstants.pollsPerTimeout - 2, + TestConstants.pollsPerTimeout + 2); } catch (Exception e) { fail(e.getMessage()); } finally { @@ -235,11 +235,11 @@ public void testApiScheduleAtFixedRate() { public void testApiScheduleWithFixedDelay() { ScheduledFuture result = null; try { - result = scheduledExecutor.scheduleWithFixedDelay(new CounterRunnableTask(TestConstants.PollInterval), - TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); - Wait.sleep(TestConstants.WaitTimeout); - Assertions.assertBetween(StaticCounter.getCount(), (TestConstants.PollsPerTimeout / 2) - 2, - (TestConstants.PollsPerTimeout / 2) + 2); + result = scheduledExecutor.scheduleWithFixedDelay(new CounterRunnableTask(TestConstants.pollInterval), + TestConstants.pollInterval.getSeconds(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); + Wait.sleep(TestConstants.waitTimeout); + Assertions.assertBetween(StaticCounter.getCount(), (TestConstants.pollsPerTimeout / 2) - 2, + (TestConstants.pollsPerTimeout / 2) + 2); } catch (Exception e) { fail(e.getMessage()); } finally { 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 717e6ac3..c777a9d7 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 @@ -45,7 +45,7 @@ public static WebArchive createDeployment() { private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; @BeforeEach 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 78cb5f21..77dae122 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 @@ -30,7 +30,7 @@ public class TestEjb implements TestEjbInterface { private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) public ManagedScheduledExecutorService scheduledExecutor; public void testAwaitTermination() { 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 ae0980bc..878422eb 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 @@ -109,7 +109,7 @@ public void testIncompleteFutureMSE() { } @Test - public void testIncompleteFutureMSE_EJB() { + public void testIncompleteFutureMSEEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); @@ -121,7 +121,7 @@ public void testManagedScheduledExecutorDefinitionAllAttributes() { } @Test - public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() { + public void testManagedScheduledExecutorDefinitionAllAttributesEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); @@ -133,7 +133,7 @@ public void testManagedScheduledExecutorDefinitionDefaults() { } @Test - public void testManagedScheduledExecutorDefinitionDefaults_EJB() { + public void testManagedScheduledExecutorDefinitionDefaultsEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java index 6180824d..5a7f0b8c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java @@ -65,7 +65,7 @@ public class ManagedScheduledExecutorDefinitionOnEJBServlet extends TestServlet * A ManagedScheduledExecutorDefinition defined on an EJB with all attributes * configured enforces maxAsync and propagates context. */ - public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() throws Throwable { + public void testManagedScheduledExecutorDefinitionAllAttributesEJB() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:app/concurrent/EJBScheduledExecutorA"); BlockingQueue results = new LinkedBlockingQueue(); @@ -115,7 +115,7 @@ public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() throws Thr * java:comp/DefaultContextService to determine context propagation and * clearing. */ - public void testManagedScheduledExecutorDefinitionDefaults_EJB() throws Throwable { + public void testManagedScheduledExecutorDefinitionDefaultsEJB() throws Throwable { ManagedScheduledExecutorService executor = (ManagedScheduledExecutorService) managedScheduleExecutorDefinitionBean .doLookup("java:comp/concurrent/EJBScheduledExecutorC"); @@ -203,7 +203,7 @@ public void testManagedScheduledExecutorDefinitionDefaults_EJB() throws Throwabl * run with the thread context of the thread from which they were created, per * ManagedScheduledExecutorDefinition config. */ - public void testIncompleteFutureMSE_EJB() throws Throwable { + public void testIncompleteFutureMSEEJB() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:app/concurrent/EJBScheduledExecutorA"); StringBuilder results = new StringBuilder(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java index 0bdc2039..97fb4d91 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java @@ -468,19 +468,19 @@ public void testNotAnAsynchronousMethod() throws Throwable { public void testScheduleWithCronTrigger() throws Throwable { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:comp/concurrent/ScheduledExecutorC"); - ZoneId US_CENTRAL = ZoneId.of("America/Chicago"); - ZoneId US_MOUNTAIN = ZoneId.of("America/Denver"); + ZoneId usCentral = ZoneId.of("America/Chicago"); + ZoneId usMountain = ZoneId.of("America/Denver"); - Trigger everyOtherSecond = new CronTrigger("*/2 * * * JAN-DEC SUN-SAT", US_CENTRAL); + Trigger everyOtherSecond = new CronTrigger("*/2 * * * JAN-DEC SUN-SAT", usCentral); BlockingQueue results = new LinkedBlockingQueue(); ScheduledFuture future = executor.schedule(() -> { return results.add(InitialContext.doLookup("java:comp/concurrent/ScheduledExecutorC")); }, everyOtherSecond); try { - CronTrigger weekendsAtNoon6MonthsFromNow = new CronTrigger(US_MOUNTAIN) + CronTrigger weekendsAtNoon6MonthsFromNow = new CronTrigger(usMountain) .daysOfWeek(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY).hours(12) - .months(ZonedDateTime.now(US_MOUNTAIN).plusMonths(6).getMonth()); + .months(ZonedDateTime.now(usMountain).plusMonths(6).getMonth()); ScheduledFuture distantFuture = executor.schedule(() -> { return results.add(InitialContext.doLookup("java:comp/concurrent/ScheduledExecutorC")); }, weekendsAtNoon6MonthsFromNow); @@ -531,7 +531,7 @@ public void testScheduleWithCronTrigger() throws Throwable { public void testScheduleWithZonedTrigger() throws Exception { ManagedScheduledExecutorService executor = InitialContext.doLookup("java:comp/concurrent/ScheduledExecutorC"); - ZoneId US_CENTRAL = ZoneId.of("America/Chicago"); + ZoneId usCentral = ZoneId.of("America/Chicago"); Map startAndEndTimes = new ConcurrentHashMap(); @@ -540,9 +540,9 @@ public void testScheduleWithZonedTrigger() throws Exception { private void initSchedule() { // Use times from the past to make the test predictable - ZonedDateTime sept15 = ZonedDateTime.of(2021, 9, 15, 8, 0, 0, 0, US_CENTRAL); - ZonedDateTime oct15 = ZonedDateTime.of(2021, 10, 15, 8, 0, 0, 0, US_CENTRAL); - ZonedDateTime nov15 = ZonedDateTime.of(2021, 11, 15, 8, 0, 0, 0, US_CENTRAL); + ZonedDateTime sept15 = ZonedDateTime.of(2021, 9, 15, 8, 0, 0, 0, usCentral); + ZonedDateTime oct15 = ZonedDateTime.of(2021, 10, 15, 8, 0, 0, 0, usCentral); + ZonedDateTime nov15 = ZonedDateTime.of(2021, 11, 15, 8, 0, 0, 0, usCentral); schedule.put(0l, sept15); schedule.put(sept15.toEpochSecond(), oct15); schedule.put(oct15.toEpochSecond(), nov15); @@ -553,15 +553,15 @@ public ZonedDateTime getNextRunTime(LastExecution lastExecution, ZonedDateTime s if (lastExecution == null) initSchedule(); else - startAndEndTimes.put(lastExecution.getRunStart(US_CENTRAL), lastExecution.getRunEnd(US_CENTRAL)); + startAndEndTimes.put(lastExecution.getRunStart(usCentral), lastExecution.getRunEnd(usCentral)); - long key = lastExecution == null ? 0l : lastExecution.getScheduledStart(US_CENTRAL).toEpochSecond(); + long key = lastExecution == null ? 0l : lastExecution.getScheduledStart(usCentral).toEpochSecond(); return schedule.get(key); } @Override public ZoneId getZoneId() { - return US_CENTRAL; + return usCentral; } }; BlockingQueue results = new LinkedBlockingQueue(); 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 19841396..828ac388 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 @@ -98,7 +98,7 @@ public void testIncompleteFutureMSE() { } @Test - public void testIncompleteFutureMSE_EJB() { + public void testIncompleteFutureMSEEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); @@ -110,7 +110,7 @@ public void testManagedScheduledExecutorDefinitionAllAttributes() { } @Test - public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() { + public void testManagedScheduledExecutorDefinitionAllAttributesEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); @@ -122,7 +122,7 @@ public void testManagedScheduledExecutorDefinitionDefaults() { } @Test - public void testManagedScheduledExecutorDefinitionDefaults_EJB() { + public void testManagedScheduledExecutorDefinitionDefaultsEJB() { URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL) .withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testname); runTest(requestURL); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java index 176833fc..a6b17d52 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java @@ -40,10 +40,10 @@ public void managedScheduledExecutorServiceAPISecurityTest(HttpServletRequest re req.login("javajoe", "javajoe"); ManagedScheduledExecutorService executorService = InitialContext - .doLookup(TestConstants.DefaultManagedScheduledExecutorService); + .doLookup(TestConstants.defaultManagedScheduledExecutorService); ScheduledFuture future = executorService.schedule(new SecurityTestTask(), new CommonTriggers.OnceTrigger()); Object result = Wait.waitForTaskComplete(future); - assertEquals(result, TestConstants.SimpleReturnValue); + assertEquals(result, TestConstants.simpleReturnValue); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java index ed43b452..a0ed49b8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestEjb.java @@ -25,6 +25,6 @@ public class SecurityTestEjb implements SecurityTestInterface { @RolesAllowed("Manager") public String managerMethod1() { - return TestConstants.SimpleReturnValue; + return TestConstants.simpleReturnValue; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java index 473ff029..24fbf2f6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java @@ -54,7 +54,7 @@ public class TransactionServlet extends TestServlet { @Resource(lookup = "java:comp/env/jdbc/ManagedScheduledExecutorServiceDB") private DataSource ds; - @Resource(lookup = TestConstants.DefaultManagedScheduledExecutorService) + @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) private ManagedScheduledExecutorService managedScheduledExecutorService; @Override diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java index 32a7d3d2..83dfeca1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java @@ -45,7 +45,7 @@ public class SecurityServlet extends TestServlet { public void jndiClassloaderPropagationTest(HttpServletRequest req, HttpServletResponse res) throws Exception { - ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.DefaultManagedThreadFactory); + ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.defaultManagedThreadFactory); CounterRunnableWithContext task = new CounterRunnableWithContext(); Thread thread = factory.newThread(task); @@ -59,7 +59,7 @@ public void jndiClassloaderPropagationWithSecurityTest(HttpServletRequest req, H req.login("javajoe", "javajoe"); - ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.DefaultManagedThreadFactory); + ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.defaultManagedThreadFactory); CounterRunnableWithSecurityCheck task = new CounterRunnableWithSecurityCheck(str); Thread thread = factory.newThread(task); @@ -100,7 +100,7 @@ public int getCount() { public void run() { try { - assertEquals(str.managerMethod1(), TestConstants.SimpleReturnValue); + assertEquals(str.managerMethod1(), TestConstants.simpleReturnValue); } catch (Exception e) { return; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java index 9aa987e7..cb09677b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityTestEjb.java @@ -25,6 +25,6 @@ public class SecurityTestEjb implements SecurityTestInterface { @RolesAllowed("Manager") public String managerMethod1() { - return TestConstants.SimpleReturnValue; + return TestConstants.simpleReturnValue; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java index 2d5280d6..e099d988 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java @@ -53,7 +53,7 @@ public class TransactionServlet extends TestServlet { @Resource(lookup = "java:comp/env/jdbc/ManagedThreadFactoryDB") private DataSource ds; - @Resource(lookup = TestConstants.DefaultManagedThreadFactory) + @Resource(lookup = TestConstants.defaultManagedThreadFactory) public ManagedThreadFactory threadFactory; @Override From 2dcc80ef4743e11bdf279ab29dbd6ba87719d7ad Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 10:19:25 -0500 Subject: [PATCH 05/14] TCK final params --- .../ContextService/ContextServiceTests.java | 2 +- .../api/LastExecution/LogicDrivenTrigger.java | 18 +++---- .../ManagedExecutorsTests.java | 10 ++-- .../RunnableTaskWithException.java | 2 +- .../common/counter/CounterCallableTask.java | 2 +- .../common/counter/CounterRunnableTask.java | 4 +- .../fixed/counter/CounterRunnableTask.java | 2 +- .../common/fixed/counter/StaticCounter.java | 4 +- .../listener/ManagedTaskListenerImpl.java | 12 ++--- .../task/listener/RunnableTaskWithStatus.java | 4 +- .../common/signature/ApiCheckDriver.java | 12 ++--- .../ConcurrencySignatureTestRunner.java | 6 +-- .../common/signature/PackageList.java | 16 +++--- .../concurrent/common/signature/SigTest.java | 22 ++++---- .../common/signature/SigTestData.java | 2 +- .../common/signature/SigTestDriver.java | 14 ++--- .../common/signature/SigTestEE.java | 16 +++--- .../common/signature/SigTestResult.java | 10 ++-- .../common/signature/SignatureTestDriver.java | 40 +++++++------- .../signature/SignatureTestDriverFactory.java | 2 +- .../concurrent/common/tasks/CallableTask.java | 4 +- .../concurrent/common/tasks/CommonTasks.java | 4 +- .../common/tasks/CommonTriggers.java | 16 +++--- .../concurrent/common/tasks/RunnableTask.java | 4 +- .../transaction/CancelledTransactedTask.java | 2 +- .../common/transaction/Connections.java | 4 +- .../common/transaction/Counter.java | 2 +- .../common/transaction/TransactedTask.java | 4 +- .../tck/concurrent/framework/TestClient.java | 14 ++--- .../tck/concurrent/framework/TestLogger.java | 54 +++++++++---------- .../tck/concurrent/framework/TestServlet.java | 10 ++-- .../tck/concurrent/framework/URLBuilder.java | 12 ++--- .../extensions/TCKArchiveProcessor.java | 2 +- .../extensions/TCKLoadableExtension.java | 2 +- .../extensions/TCKSignatureProcessor.java | 2 +- .../junit/extensions/AssertionExtension.java | 6 +-- .../junit/extensions/Assertions.java | 6 +-- .../framework/junit/extensions/Wait.java | 10 ++-- .../contextPropagate/ClassloaderServlet.java | 2 +- .../ContextPropagateBean.java | 4 +- .../contextPropagate/JNDIServlet.java | 4 +- .../contextPropagate/SecurityServlet.java | 2 +- .../servlet/DeserializeServlet.java | 2 +- .../servlet/ProxyCreatorServlet.java | 6 +-- .../servlet/WorkInterfaceServlet.java | 2 +- .../resourcedef/AppBean.java | 6 +-- .../ManagedExecutorDefinitionBean.java | 2 +- .../ManagedExecutorDefinitionWebBean.java | 2 +- .../security/SecurityServlet.java | 2 +- .../tx/TransactionServlet.java | 2 +- ...anagedScheduledExecutorDefinitionBean.java | 2 +- ...gedScheduledExecutorDefinitionServlet.java | 6 +-- ...gedScheduledExecutorDefinitionWebBean.java | 2 +- .../resourcedef/ReqBean.java | 4 +- .../security/SecurityServlet.java | 2 +- .../tx/OnceTrigger.java | 4 +- .../tx/TransactionServlet.java | 2 +- .../context/SecurityServlet.java | 6 +-- .../ManagedThreadFactoryDefinitionBean.java | 2 +- .../tx/TransactionServlet.java | 2 +- 60 files changed, 213 insertions(+), 213 deletions(-) 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 c4823d11..b5e3289e 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 @@ -321,4 +321,4 @@ public void getExecutionPropertiesNoProxy() { } }); } -} \ No newline at end of file +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java index 59db6f04..3ba2d596 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java @@ -44,20 +44,20 @@ public class LogicDrivenTrigger implements Trigger { public static final int RIGHT_COUNT = 2; public static final int WRONG_COUNT = 1; - public LogicDrivenTrigger(long delta, String testName) { + public LogicDrivenTrigger(final long delta, final String testName) { this.delta = delta; this.testName = testName; this.startTime = new Date(); } - private String getErrStr4NotEqual(String testName, Object expected, Object real) { + private String getErrStr4NotEqual(final String testName, final Object expected, final Object real) { String result = testName + "failed, "; result += "expected " + expected + ","; result += "but got " + real; return result; } - private boolean validateDateTimeEquals(Date time1, Date time2) { + private boolean validateDateTimeEquals(final Date time1, final Date time2) { long diff = time1.getTime() - time2.getTime(); if (Math.abs(diff) < TIME_COMPARE_INACCURACY) { @@ -67,7 +67,7 @@ private boolean validateDateTimeEquals(Date time1, Date time2) { } } - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (lastExecutionInfo == null) { return new Date(); } @@ -86,7 +86,7 @@ public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTi } - public Date lastExecutionGetIdentityNameTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date lastExecutionGetIdentityNameTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (!LastExecutionTests.IDENTITY_NAME_TEST_ID.equals(lastExecutionInfo.getIdentityName())) { log.warning(getErrStr4NotEqual(testName, LastExecutionTests.IDENTITY_NAME_TEST_ID, lastExecutionInfo.getIdentityName())); @@ -97,7 +97,7 @@ public Date lastExecutionGetIdentityNameTest(LastExecution lastExecutionInfo, Da return new Date(new Date().getTime() + delta); } - public Date lastExecutionGetResultRunnableTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date lastExecutionGetResultRunnableTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (lastExecutionInfo.getResult() != null) { log.warning(getErrStr4NotEqual(testName, null, lastExecutionInfo.getResult())); return null; @@ -107,7 +107,7 @@ public Date lastExecutionGetResultRunnableTest(LastExecution lastExecutionInfo, return new Date(new Date().getTime() + delta); } - public Date lastExecutionGetResultCallableTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date lastExecutionGetResultCallableTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (!Integer.valueOf(1).equals(lastExecutionInfo.getResult())) { log.warning(getErrStr4NotEqual(testName, 1, lastExecutionInfo.getResult())); return null; @@ -116,7 +116,7 @@ public Date lastExecutionGetResultCallableTest(LastExecution lastExecutionInfo, return new Date(new Date().getTime() + delta); } - public Date lastExecutionGetRunningTimeTest(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date lastExecutionGetRunningTimeTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (!validateDateTimeEquals(this.startTime, lastExecutionInfo.getScheduledStart())) { log.warning(getErrStr4NotEqual(testName, this.startTime, lastExecutionInfo.getScheduledStart())); return null; @@ -138,7 +138,7 @@ public Date lastExecutionGetRunningTimeTest(LastExecution lastExecutionInfo, Dat return new Date(new Date().getTime() + delta); } - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + public boolean skipRun(final LastExecution lastExecutionInfo, final Date scheduledRunTime) { return false; } } 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 5a05f931..39ff1acf 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 @@ -85,24 +85,24 @@ private RunnableTask createRunnableTask() { return new RunnableTask(ENV_ENTRY_JNDI_NAME, ENV_ENTRY_VALUE, this.getClass().getName()); } - private CallableTask createCallableTask(String expectedReturnValue) { + private CallableTask createCallableTask(final String expectedReturnValue) { return new CallableTask(ENV_ENTRY_JNDI_NAME, ENV_ENTRY_VALUE, this.getClass().getName(), expectedReturnValue); } - private void assertTaskAndListenerComplete(Future future, RunnableTask runnableTask) { + private void assertTaskAndListenerComplete(final Future future, final RunnableTask runnableTask) { Wait.waitForTaskComplete(future); assertListenerComplete(runnableTask); } - private void assertTaskAndListenerComplete(String expectedResult, Future future, - CallableTask callableTask) { + private void assertTaskAndListenerComplete(final String expectedResult, final Future future, + final CallableTask callableTask) { String result = Wait.waitForTaskComplete(future); assertTrue(expectedResult.endsWith(result)); assertListenerComplete(callableTask); } - private void assertListenerComplete(RunnableTask task) { + private void assertListenerComplete(final RunnableTask task) { // wait for the listener run done. Wait.waitForListenerComplete(managedTaskListener); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java index 4c528c49..7d201b74 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java @@ -22,7 +22,7 @@ public class RunnableTaskWithException extends RunnableTaskWithStatus implements Runnable { - public RunnableTaskWithException(ManagedTaskListenerImpl listener) { + public RunnableTaskWithException(final ManagedTaskListenerImpl listener) { super(listener); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java index ce10452e..f6729c54 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterCallableTask.java @@ -24,7 +24,7 @@ public class CounterCallableTask implements Callable { private String countSingletionJndi = ""; - public CounterCallableTask(String countSingletionJndi) { + public CounterCallableTask(final String countSingletionJndi) { this.countSingletionJndi = countSingletionJndi; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java index 1f6b0775..d2193d4c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/counter/CounterRunnableTask.java @@ -27,11 +27,11 @@ public class CounterRunnableTask implements Runnable { private String countSingletionJndi = ""; private Duration sleepTime = Duration.ZERO; - public CounterRunnableTask(String countSingletionJndi) { + public CounterRunnableTask(final String countSingletionJndi) { this.countSingletionJndi = countSingletionJndi; } - public CounterRunnableTask(String countSingletionJndi, Duration sleepTime) { + public CounterRunnableTask(final String countSingletionJndi, final Duration sleepTime) { this.countSingletionJndi = countSingletionJndi; this.sleepTime = sleepTime; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/CounterRunnableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/CounterRunnableTask.java index 1f2a761d..9e59c6b3 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/CounterRunnableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/CounterRunnableTask.java @@ -26,7 +26,7 @@ public class CounterRunnableTask implements Runnable, WorkInterface { public CounterRunnableTask() { } - public CounterRunnableTask(Duration sleepTime) { + public CounterRunnableTask(final Duration sleepTime) { this.sleepTime = sleepTime; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java index 56c3f72e..a98b16f4 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java @@ -39,14 +39,14 @@ public static void reset() { count.set(0); } - public static void waitTill(int expected) { + public static void waitTill(final int expected) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { for (; expected != StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) ; }); } - public static void waitTillSurpassed(int expected) { + public static void waitTillSurpassed(final int expected) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { for (; expected <= StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) ; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java index bc656561..0c0c9330 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/ManagedTaskListenerImpl.java @@ -32,30 +32,30 @@ public class ManagedTaskListenerImpl implements ManagedTaskListener { private final List events = Collections.synchronizedList(new ArrayList()); @Override - public void taskAborted(Future future, ManagedExecutorService mes, Object arg2, Throwable arg3) { + public void taskAborted(final Future future, final ManagedExecutorService mes, final Object arg2, final Throwable arg3) { events.add(ListenerEvent.ABORTED); log.info("task aborted"); } @Override - public void taskDone(Future future, ManagedExecutorService mes, Object arg2, Throwable arg3) { + public void taskDone(final Future future, final ManagedExecutorService mes, final Object arg2, final Throwable arg3) { events.add(ListenerEvent.DONE); log.info("task done"); } @Override - public void taskStarting(Future future, ManagedExecutorService mes, Object arg2) { + public void taskStarting(final Future future, final ManagedExecutorService mes, final Object arg2) { events.add(ListenerEvent.STARTING); log.info("task starting"); } @Override - public void taskSubmitted(Future future, ManagedExecutorService mes, Object arg2) { + public void taskSubmitted(final Future future, final ManagedExecutorService mes, final Object arg2) { events.add(ListenerEvent.SUBMITTED); log.info("task submitted"); } - public boolean eventCalled(ListenerEvent event) { + public boolean eventCalled(final ListenerEvent event) { return events.contains(event); } @@ -63,7 +63,7 @@ public void clearEvents() { events.clear(); } - public void update(ListenerEvent event) { + public void update(final ListenerEvent event) { events.add(event); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java index dce0eb5f..4b2ab6b1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java @@ -26,12 +26,12 @@ public class RunnableTaskWithStatus implements Runnable { private final Duration blockTime; - public RunnableTaskWithStatus(ManagedTaskListenerImpl listener) { + public RunnableTaskWithStatus(final ManagedTaskListenerImpl listener) { this.listener = listener; blockTime = Duration.ZERO; } - public RunnableTaskWithStatus(ManagedTaskListenerImpl listener, Duration blockTime) { + public RunnableTaskWithStatus(final ManagedTaskListenerImpl listener, final Duration blockTime) { this.listener = listener; this.blockTime = blockTime; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java index 8b4b7e15..7514855e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java @@ -50,13 +50,13 @@ public final class ApiCheckDriver extends SignatureTestDriver implements Seriali // ---------------------------------------- Methods from SignatureTestDriver @Override - protected String normalizeFileName(File f) { + protected String normalizeFileName(final File f) { return f.getPath(); } @Override - protected String[] createTestArguments(String packageListFile, String mapFile, String signatureRepositoryDir, - String packageOrClassUnderTest, String classpath, boolean bStaticMode) throws Exception { + protected String[] createTestArguments(final String packageListFile, final String mapFile, final String signatureRepositoryDir, + final String packageOrClassUnderTest, final String classpath, final boolean bStaticMode) throws Exception { Class pkgListClass = Class.forName("javasoft.sqe.apiCheck.PackageList"); Constructor pkgCtor = pkgListClass.getDeclaredConstructor(new Class[] { String.class }); @@ -91,7 +91,7 @@ protected String[] createTestArguments(String packageListFile, String mapFile, S } // END createTestArguments @Override - protected boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception { + protected boolean runSignatureTest(final String packageOrClassName, final String[] testArguments) throws Exception { Class diffClass = Class.forName("javasoft.sqe.apiCheck.Diff"); Method mainMethod = diffClass.getDeclaredMethod("main", new Class[] { String[].class }); @@ -103,7 +103,7 @@ protected boolean runSignatureTest(String packageOrClassName, String[] testArgum } // END runSignatureTest @Override - protected boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception { + protected boolean runPackageSearch(final String packageOrClassName, final String[] testArguments) throws Exception { Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); Object sigTestInstance = sigTestClass.getConstructor().newInstance(); @@ -136,7 +136,7 @@ protected boolean runPackageSearch(String packageOrClassName, String[] testArgum } @Override - protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception { + protected boolean verifyJTAJarForNoXA(final String classpath, final String repositoryDir) throws Exception { // Need to find out whether implementing this method is really required now. // By default, signature test framework will use sigtest return true; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index a8517d85..114a5b28 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -61,7 +61,7 @@ public ConcurrencySignatureTestRunner() { * verified. */ @Override - protected String[] getPackages(String vehicleName) { + protected String[] getPackages(final String vehicleName) { return new String[] { "jakarta.enterprise.concurrent", "jakarta.enterprise.concurrent.spi" }; } @@ -122,7 +122,7 @@ protected String getClasspath() { } - protected File writeStreamToTempFile(InputStream inputStream, String tempFilePrefix, String tempFileSuffix) + protected File writeStreamToTempFile(final InputStream inputStream, final String tempFilePrefix, final String tempFileSuffix) throws IOException { FileOutputStream outputStream = null; @@ -147,7 +147,7 @@ protected File writeStreamToTempFile(InputStream inputStream, String tempFilePre } } - protected File writeStreamToSigFile(InputStream inputStream) throws IOException { + protected File writeStreamToSigFile(final InputStream inputStream) throws IOException { FileOutputStream outputStream = null; String tmpdir = System.getProperty("java.io.tmpdir"); try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java index 8cf9509f..bcffeaca 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java @@ -98,7 +98,7 @@ class PackageList { * * @throws Exception when the packageFileName does not exist. */ - public PackageList(String packageFileName) throws Exception { + public PackageList(final String packageFileName) throws Exception { packageFile = new File(packageFileName); if (packageFile.exists() && packageFile.isFile()) { extractExistingPackageNames(); @@ -131,7 +131,7 @@ public PackageList(String packageFileName) throws Exception { * @throws Exception when an error occurs reading the packageFileName or the * sigFileName does not exist. */ - public PackageList(String packageName, String sigFileName, String packageFileName) throws Exception { + public PackageList(final String packageName, final String sigFileName, final String packageFileName) throws Exception { this.additionalPackageName = packageName; sigFile = new File(sigFileName); if (!sigFile.exists() || !sigFile.isFile()) { @@ -179,7 +179,7 @@ private void extractExistingPackageNames() throws Exception { * * @return boolean True if the specified line is a comment line else false. */ - private boolean isComment(String line) { + private boolean isComment(final String line) { if (line == null) { return false; } @@ -244,7 +244,7 @@ public void writePkgListFile() throws Exception { * @throws Exception if the specified string does not conform to the expected * format. */ - private String parsePackageName(String packageLine) throws Exception { + private String parsePackageName(final String packageLine) throws Exception { // sig test framework doesn't have the concept of package entries // as the ApiCheck signature format does. @@ -305,7 +305,7 @@ private void removePkgFile() throws Exception { * @throws Exception if there is any errors writing the header to the specified * BufferedWriter. */ - private void writeHeader(BufferedWriter out) throws Exception { + private void writeHeader(final BufferedWriter out) throws Exception { out.write(COMMENT_CHAR); out.write(COMMENT_CHAR); out.newLine(); @@ -357,7 +357,7 @@ private void writePkgFile() throws Exception { * @return String[] The sub-packages that live under the specified parent * package. */ - public String[] getSubPackages(String pkgName) { + public String[] getSubPackages(final String pkgName) { List result = new ArrayList<>(); String subPackageName = pkgName + "."; for (Iterator i = packageNames.iterator(); i.hasNext();) { @@ -379,7 +379,7 @@ public String[] getSubPackages(String pkgName) { * * @return String The sub-packages that live under the specified parent package. */ - public String getSubPackagesFormatted(String pkgName) { + public String getSubPackagesFormatted(final String pkgName) { StringBuffer formattedResult = new StringBuffer(); String[] result = getSubPackages(pkgName); for (int i = 0; i < result.length; i++) { @@ -394,7 +394,7 @@ public String getSubPackagesFormatted(String pkgName) { /* * Test Driver */ - public static void main(String[] args) throws Exception { + public static void main(final String[] args) throws Exception { System.out.println("\n\n*** Creating package list file ***\n\n"); PackageList list = new PackageList("jakarta.ejb", "/home/ryano/cts-tools-master/tools/api-check/test/jakarta.ejb.sig_2.1", diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java index bd32c718..c350093a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java @@ -201,7 +201,7 @@ public static class Fault extends Exception { /** * creates a Fault with a message */ - public Fault(String msg) { + public Fault(final String msg) { super(msg); System.out.println(msg); } @@ -212,7 +212,7 @@ public Fault(String msg) { * @param msg the message * @param t prints this exception's stacktrace */ - public Fault(String msg, Throwable t) { + public Fault(final String msg, final Throwable t) { super(msg); this.t = t; // System.out.println(msg, t); @@ -223,7 +223,7 @@ public Fault(String msg, Throwable t) { * * @param t the Throwable */ - public Fault(Throwable t) { + public Fault(final Throwable t) { super(t); this.t = t; } @@ -245,7 +245,7 @@ public void printStackTrace() { * * @param s PrintStream to use for output */ - public void printStackTrace(PrintStream s) { + public void printStackTrace(final PrintStream s) { if (this.t != null) { this.t.printStackTrace(s); } else { @@ -258,7 +258,7 @@ public void printStackTrace(PrintStream s) { * * @param s PrintWriter to use for output */ - public void printStackTrace(PrintWriter s) { + public void printStackTrace(final PrintWriter s) { if (this.t != null) { this.t.printStackTrace(s); } else { @@ -272,7 +272,7 @@ public Throwable getCause() { } @Override - public synchronized Throwable initCause(Throwable cause) { + public synchronized Throwable initCause(final Throwable cause) { if (t != null) throw new IllegalStateException("Can't overwrite cause"); if (!Exception.class.isInstance(cause)) @@ -297,7 +297,7 @@ public static class SetupException extends Exception { /** * creates a Fault with a message */ - public SetupException(String msg) { + public SetupException(final String msg) { super(msg); } @@ -307,7 +307,7 @@ public SetupException(String msg) { * @param msg the message * @param e prints this exception's stacktrace */ - public SetupException(String msg, Exception e) { + public SetupException(final String msg, final Exception e) { super(msg); this.e = e; } @@ -329,7 +329,7 @@ public void printStackTrace() { * * @param s PrintStream to use for output */ - public void printStackTrace(PrintStream s) { + public void printStackTrace(final PrintStream s) { if (this.e != null) { this.e.printStackTrace(s); } else { @@ -342,7 +342,7 @@ public void printStackTrace(PrintStream s) { * * @param s PrintWriter to use for output */ - public void printStackTrace(PrintWriter s) { + public void printStackTrace(final PrintWriter s) { if (this.e != null) { this.e.printStackTrace(s); } else { @@ -356,7 +356,7 @@ public Throwable getCause() { } @Override - public synchronized Throwable initCause(Throwable cause) { + public synchronized Throwable initCause(final Throwable cause) { if (e != null) throw new IllegalStateException("Can't overwrite cause"); if (!Exception.class.isInstance(cause)) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java index 691aa4af..4284b1c1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java @@ -60,7 +60,7 @@ public String getCurrentKeywords() { return props.getProperty("current.keywords", ""); } - public String getProperty(String prop) { + public String getProperty(final String prop) { return props.getProperty(prop); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java index a9b6ad9a..f0e07fce 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java @@ -67,7 +67,7 @@ public class SigTestDriver extends SignatureTestDriver { // ---------------------------------------- Methods from SignatureTestDriver @Override - protected String normalizeFileName(File f) { + protected String normalizeFileName(final File f) { String sURL = null; try { sURL = f.toURI().toURL().toExternalForm(); @@ -78,8 +78,8 @@ protected String normalizeFileName(File f) { } @Override - protected String[] createTestArguments(String packageListFile, String mapFile, String signatureRepositoryDir, - String packageOrClassUnderTest, String classpath, boolean bStaticMode) throws Exception { + protected String[] createTestArguments(final String packageListFile, final String mapFile, final String signatureRepositoryDir, + final String packageOrClassUnderTest, final String classpath, final boolean bStaticMode) throws Exception { SignatureFileInfo info = getSigFileInfo(packageOrClassUnderTest, mapFile, signatureRepositoryDir); @@ -134,7 +134,7 @@ protected String[] createTestArguments(String packageListFile, String mapFile, S } // END createTestArguments @Override - protected boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception { + protected boolean runSignatureTest(final String packageOrClassName, final String[] testArguments) throws Exception { Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); Object sigTestInstance = sigTestClass.getConstructor().newInstance(); @@ -166,7 +166,7 @@ protected boolean runSignatureTest(String packageOrClassName, String[] testArgum * @return This returns true if the packageOrClassName is found in the impl. */ @Override - protected boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception { + protected boolean runPackageSearch(final String packageOrClassName, final String[] testArguments) throws Exception { Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); Object sigTestInstance = sigTestClass.getConstructor().newInstance(); @@ -204,7 +204,7 @@ protected boolean runPackageSearch(String packageOrClassName, String[] testArgum * @return This returns true if javax.transaction.xa is not found in the JTA API * jar */ - protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception { + protected boolean verifyJTAJarForNoXA(final String classpath, final String repositoryDir) throws Exception { System.out.println("SigTestDriver#verifyJTAJarForNoXA - Starting:"); List command = new ArrayList<>(); @@ -218,7 +218,7 @@ protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) th command.add(CLASSPATH_FLAG); command.add(classpath); - String testArguments[] = (String[]) command.toArray(new String[command.size()]); + String[] testArguments = (String[]) command.toArray(new String[command.size()]); // do some logging to help with troubleshooting System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java index a314342b..5c1b9b5a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java @@ -154,7 +154,7 @@ protected ArrayList getUnlistedOptionalPackages() { * the specified vehicle has no package signatures to be verified within * it. */ - protected abstract String[] getPackages(String vehicleName); + protected abstract String[] getPackages(final String vehicleName); /** *

@@ -178,7 +178,7 @@ protected ArrayList getUnlistedOptionalPackages() { * of this method returns a zero-length array no matter the vehicle * specified. */ - protected String[] getClasses(String vehicleName) { + protected String[] getClasses(final String vehicleName) { return new String[] {}; @@ -306,7 +306,7 @@ public static class Fault extends Exception { /** * creates a Fault with a message */ - public Fault(String msg) { + public Fault(final String msg) { super(msg); System.out.println(msg); } @@ -317,7 +317,7 @@ public Fault(String msg) { * @param msg the message * @param t prints this exception's stacktrace */ - public Fault(String msg, Throwable t) { + public Fault(final String msg, final Throwable t) { super(msg); this.t = t; System.out.println(msg); @@ -329,7 +329,7 @@ public Fault(String msg, Throwable t) { * * @param t the Throwable */ - public Fault(Throwable t) { + public Fault(final Throwable t) { super(t); this.t = t; } @@ -351,7 +351,7 @@ public void printStackTrace() { * * @param s PrintStream to use for output */ - public void printStackTrace(PrintStream s) { + public void printStackTrace(final PrintStream s) { if (this.t != null) { this.t.printStackTrace(s); } else { @@ -364,7 +364,7 @@ public void printStackTrace(PrintStream s) { * * @param s PrintWriter to use for output */ - public void printStackTrace(PrintWriter s) { + public void printStackTrace(final PrintWriter s) { if (this.t != null) { this.t.printStackTrace(s); } else { @@ -378,7 +378,7 @@ public Throwable getCause() { } @Override - public synchronized Throwable initCause(Throwable cause) { + public synchronized Throwable initCause(final Throwable cause) { if (t != null) throw new IllegalStateException("Can't overwrite cause"); if (!Exception.class.isInstance(cause)) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java index 96700a90..0de4d418 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestResult.java @@ -45,25 +45,25 @@ public synchronized boolean passed() { } // end passed - public synchronized void addFailedPkg(String pkg) { + public synchronized void addFailedPkg(final String pkg) { failedPkgs.add(pkg); } // END addFailedPkg - public synchronized void addPassedPkg(String pkg) { + public synchronized void addPassedPkg(final String pkg) { passedPkgs.add(pkg); } // END addPassedPkg - public synchronized void addFailedClass(String className) { + public synchronized void addFailedClass(final String className) { failedClasses.add(className); } // END addFailedClass - public synchronized void addPassedClass(String className) { + public synchronized void addPassedClass(final String className) { passedClasses.add(className); @@ -108,7 +108,7 @@ public String toString() { // --------------------------------------------------------- Private Methods - private synchronized void formatList(List list, StringBuffer buf) { + private synchronized void formatList(final List list, final StringBuffer buf) { synchronized (this) { for (int i = 0; i < list.size(); i++) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java index 5ccb911e..9eb0727b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java @@ -39,7 +39,7 @@ public abstract class SignatureTestDriver { * Implementation of the getPackageFile method defined in both the SigTest and * SigTestEE class. */ - public String getPackageFileImpl(String binDir) { + public String getPackageFileImpl(final String binDir) { String thePkgListFile = "sig-test-pkg-list.txt"; @@ -69,7 +69,7 @@ public String getPackageFileImpl(String binDir) { * Implementation of the getMapFile method defined in both the SigTest and * SigTestEE class. */ - public String getMapFileImpl(String binDir) { + public String getMapFileImpl(final String binDir) { String theMapFile = "sig-test.map"; @@ -100,7 +100,7 @@ public String getMapFileImpl(String binDir) { * used. * */ - public Boolean isJavaSEVersion(String ver) { + public Boolean isJavaSEVersion(final String ver) { String strOSVersion = System.getProperty("java.version"); if (strOSVersion.startsWith(ver)) { @@ -114,7 +114,7 @@ public Boolean isJavaSEVersion(String ver) { * Implementation of the getRepositoryDir method defined in both the SigTest and * SigTestEE class. */ - public String getRepositoryDirImpl(String tsHome) { + public String getRepositoryDirImpl(final String tsHome) { return (tsHome + File.separator + "src" + File.separator + "com" + File.separator + "sun" + File.separator + "ts" + File.separator + "tests" + File.separator + "signaturetest" + File.separator @@ -166,9 +166,9 @@ public void cleanupImpl() throws Exception { * * @return a {@link SigTestResult} containing the result of the test execution */ - public SigTestResult executeSigTest(String packageListFile, String mapFile, String signatureRepositoryDir, - String[] packagesUnderTest, String[] classesUnderTest, String classpath, - ArrayList unaccountedTechPkgs, String optionalPkgToIgnore) throws Exception { + public SigTestResult executeSigTest(final String packageListFile, final String mapFile, final String signatureRepositoryDir, + final String[] packagesUnderTest, final String[] classesUnderTest, final String classpath, + final ArrayList unaccountedTechPkgs, final String optionalPkgToIgnore) throws Exception { SigTestResult result = new SigTestResult(); @@ -368,8 +368,8 @@ public SigTestResult executeSigTest(String packageListFile, String mapFile, Stri * not be part of the test environment and will * have to specified using this parameter. */ - protected abstract String[] createTestArguments(String packageListFile, String mapFile, - String signatureRepositoryDir, String packageOrClassUnderTest, String classpath, boolean bStaticMode) + protected abstract String[] createTestArguments(final String packageListFile, final String mapFile, + final String signatureRepositoryDir, final String packageOrClassUnderTest, final String classpath, final boolean bStaticMode) throws Exception; /** @@ -382,7 +382,7 @@ protected abstract String[] createTestArguments(String packageListFile, String m * * @return true if the test passed, otherwise false */ - protected abstract boolean runSignatureTest(String packageOrClassName, String[] testArguments) throws Exception; + protected abstract boolean runSignatureTest(final String packageOrClassName, final String[] testArguments) throws Exception; /** * This checks if a class exists or not within the impl. @@ -392,7 +392,7 @@ protected abstract String[] createTestArguments(String packageListFile, String m * @return true if the package was found to exist, otherwise * false */ - protected abstract boolean runPackageSearch(String packageOrClassName, String[] testArguments) throws Exception; + protected abstract boolean runPackageSearch(final String packageOrClassName, final String[] testArguments) throws Exception; /** * This method checks whether JTA API jar contains classes from @@ -404,7 +404,7 @@ protected abstract String[] createTestArguments(String packageListFile, String m * @return true if the package javax.transaction.xa is not found in * the JTA API jar, otherwise false */ - protected abstract boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception; + protected abstract boolean verifyJTAJarForNoXA(final String classpath, final String repositoryDir) throws Exception; /** * Loads the specified file into a Properties object provided the specified file @@ -421,7 +421,7 @@ protected abstract String[] createTestArguments(String packageListFile, String m * is an error creating an input stream from the * specified file. */ - public Properties loadMapFile(String mapFile) throws IOException, FileNotFoundException { + public Properties loadMapFile(final String mapFile) throws IOException, FileNotFoundException { FileInputStream in = null; try { @@ -455,7 +455,7 @@ public Properties loadMapFile(String mapFile) throws IOException, FileNotFoundEx * @return a valid, fully qualified filename, appropriate for the system the * test is being run on */ - protected String getSigFileName(String baseName, String repositoryDir, String version) + protected String getSigFileName(final String baseName, final String repositoryDir, final String version) throws FileNotFoundException { String sigFile; @@ -500,10 +500,10 @@ protected String getSigFileName(String baseName, String repositoryDir, String ve * @throws Exception if the determined signature file is not a regular file or * does not exist */ - protected SignatureFileInfo getSigFileInfo(String packageName, String mapFile, String repositoryDir) + protected SignatureFileInfo getSigFileInfo(final String originalPackage, final String mapFile, final String repositoryDir) throws Exception { - String originalPackage = packageName; + String packageName = originalPackage; String name = null; String version = null; Properties props = loadMapFile(mapFile); @@ -535,7 +535,7 @@ protected SignatureFileInfo getSigFileInfo(String packageName, String mapFile, S throw new Exception( "Package \"" + originalPackage + "\" not specified in mapping file \"" + mapFile + "\"."); } - packageName = packageName.substring(0, index); + packageName.substring(0, index); } // end while /* Return the expected name of the signature file */ @@ -554,7 +554,7 @@ protected SignatureFileInfo getSigFileInfo(String packageName, String mapFile, S * arrayOptionalPkgsToIgnore matches the packageName then that means we return * TRUE to indicate we should ignore and NOT TEST that particular package. */ - private static boolean isIgnorePackageUnderTest(String packageName, String[] arrayOptionalPkgsToIgnore) { + private static boolean isIgnorePackageUnderTest(final String packageName, final String[] arrayOptionalPkgsToIgnore) { // if anything is null - consider no match if ((packageName == null) || (arrayOptionalPkgsToIgnore == null)) { @@ -577,7 +577,7 @@ private static boolean isIgnorePackageUnderTest(String packageName, String[] arr * * @param params The list of parameters to dump. */ - private static void dumpTestArguments(String[] params) { + private static void dumpTestArguments(final String[] params) { if (params != null && params.length > 0) { System.out.println("----------------- BEGIN SIG PARAM DUMP -----------------"); @@ -603,7 +603,7 @@ protected static class SignatureFileInfo { // -------------------------------------------------------- Constructors - public SignatureFileInfo(String file, String version) { + public SignatureFileInfo(final String file, final String version) { if (file == null) { throw new IllegalArgumentException("'file' argument cannot be null"); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java index 3cbe3464..430220cf 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java @@ -59,7 +59,7 @@ private SignatureTestDriverFactory() { * @param type the driver type to create * @return a {@link SignatureTestDriver} implementation */ - public static SignatureTestDriver getInstance(String type) { + public static SignatureTestDriver getInstance(final String type) { if (type == null || type.length() == 0) { throw new IllegalArgumentException("Type was null or empty"); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java index 0cac7d73..857d2ebd 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CallableTask.java @@ -41,7 +41,7 @@ public T call() { * @param returned expected returned object. * @param blockTime block time(in millisecond) for this task. */ - public CallableTask(String jndiName, String jndiValue, String className, T returned, long blockTime) { + public CallableTask(final String jndiName, final String jndiValue, final String className, final T returned, final long blockTime) { super(jndiName, jndiValue, className, blockTime); this.expectedReturnValue = returned; } @@ -56,7 +56,7 @@ public CallableTask(String jndiName, String jndiValue, String className, T retur * loading test if it is null. * @param returned expected returned object. */ - public CallableTask(String jndiName, String jndiValue, String className, T returned) { + public CallableTask(final String jndiName, final String jndiValue, final String className, final T returned) { super(jndiName, jndiValue, className); this.expectedReturnValue = returned; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java index 6675c774..1f71da58 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java @@ -32,7 +32,7 @@ public static class SimpleCallable implements Callable { public SimpleCallable() { } - public SimpleCallable(Duration waitTime) { + public SimpleCallable(final Duration waitTime) { this.waitTime = waitTime; } @@ -63,7 +63,7 @@ public void run() { public static class SimpleArgCallable implements Callable { private int value = -1; - public SimpleArgCallable(int arg) { + public SimpleArgCallable(final int arg) { value = arg; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java index a9e88895..adcab1f1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTriggers.java @@ -29,14 +29,14 @@ public class CommonTriggers { * A trigger that only run once. */ public static class OnceTrigger implements Trigger { - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (lastExecutionInfo != null) { return null; } return new Date(); } - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + public boolean skipRun(final LastExecution lastExecutionInfo, final Date scheduledRunTime) { return false; } } @@ -48,18 +48,18 @@ public static class OnceTriggerDelaySkip implements Trigger { private Duration delay; - public OnceTriggerDelaySkip(Duration delay) { + public OnceTriggerDelaySkip(final Duration delay) { this.delay = delay; } - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (lastExecutionInfo != null) { return null; } return new Date(new Date().getTime() + delay.toMillis()); } - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + public boolean skipRun(final LastExecution lastExecutionInfo, final Date scheduledRunTime) { return true; } } @@ -76,12 +76,12 @@ public static class TriggerFixedRate implements Trigger { private static final int executionCountLimit = TestConstants.pollsPerTimeout * 2; - public TriggerFixedRate(Date startTime, long delta) { + public TriggerFixedRate(final Date startTime, final long delta) { this.startTime = startTime; this.delta = delta; } - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { executionCount++; if (executionCount > executionCountLimit) { return null; @@ -93,7 +93,7 @@ public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTi return new Date(lastExecutionInfo.getScheduledStart().getTime() + delta); } - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + public boolean skipRun(final LastExecution lastExecutionInfo, final Date scheduledRunTime) { return false; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java index c9bb732c..38ad9684 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/RunnableTask.java @@ -69,7 +69,7 @@ public void run() { * loading test if it is null. * @param blockTime block time(in millisecond) for this task. */ - public RunnableTask(String jndiName, String jndiValue, String className, long blockTime) { + public RunnableTask(final String jndiName, final String jndiValue, final String className, final long blockTime) { this.contexualClassName = className; this.jndiName = jndiName; this.expectedJndiValue = jndiValue; @@ -85,7 +85,7 @@ public RunnableTask(String jndiName, String jndiValue, String className, long bl * @param className class name to be loaded inside the task, ignore class * loading test if it is null. */ - public RunnableTask(String jndiName, String jndiValue, String className) { + public RunnableTask(final String jndiName, final String jndiValue, final String className) { this.contexualClassName = className; this.jndiName = jndiName; this.expectedJndiValue = jndiValue; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java index 1272ee12..173436f8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java @@ -38,7 +38,7 @@ public class CancelledTransactedTask implements Runnable { private final String sqlTemplate; - public CancelledTransactedTask(String sqlTemplate) { + public CancelledTransactedTask(final String sqlTemplate) { this.sqlTemplate = sqlTemplate; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java index 0ac85afe..44457f31 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java @@ -28,7 +28,7 @@ private Connections() { private static DataSource ds; - public static void setDataSource(DataSource ds) { + public static void setDataSource(final DataSource ds) { Connections.ds = ds; } @@ -36,7 +36,7 @@ public static void unsetDataSource() { Connections.ds = null; } - public static Connection getConnection(boolean autoCommit) { + public static Connection getConnection(final boolean autoCommit) { Connection conn = null; try { conn = ds.getConnection(); // Try without user password for EE case diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java index 53839439..1783bec4 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java @@ -37,7 +37,7 @@ public static int getCount() { return -1; } - private static int getCount(Connection conn) { + private static int getCount(final Connection conn) { final String queryStr = "select count(*) from " + Constants.TABLE_P; try (Statement stmt = conn.createStatement()) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java index 38667495..d1d3612d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/TransactedTask.java @@ -36,13 +36,13 @@ public class TransactedTask implements WorkInterface { private final String sqlTemplate; - public TransactedTask(boolean commitOrRollback, boolean beginTransaction, String sqlTemplate) { + public TransactedTask(final boolean commitOrRollback, final boolean beginTransaction, final String sqlTemplate) { this.sqlTemplate = sqlTemplate; this.beginTransaction = beginTransaction; this.isCommit = commitOrRollback; } - public TransactedTask(boolean commitOrRollback, String sqlTemplate) { + public TransactedTask(final boolean commitOrRollback, final String sqlTemplate) { this.sqlTemplate = sqlTemplate; this.beginTransaction = true; this.isCommit = commitOrRollback; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java index 723f9d18..c784d1b3 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestClient.java @@ -58,7 +58,7 @@ public abstract class TestClient { * Runs test against servlet at baseURL, and will run against a specified * testName. */ - public void runTest(URL baseURL, String testName) { + public void runTest(final URL baseURL, final String testName) { try { assertSuccessfulURLResponse( URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testName).build(), @@ -72,7 +72,7 @@ public void runTest(URL baseURL, String testName) { * Runs test against servlet using a URLBuilder. This is useful for complicated * testing situations. */ - public void runTest(URLBuilder builder) { + public void runTest(final URLBuilder builder) { assertSuccessfulURLResponse(builder.build(), null); } @@ -83,7 +83,7 @@ public void runTest(URLBuilder builder) { * testName. Provide properties if you want them included in a POST request, * otherwise pass in null. */ - public String runTestWithResponse(URL baseURL, String testName, Properties props) { + public String runTestWithResponse(final URL baseURL, final String testName, final Properties props) { try { return assertSuccessfulURLResponse( URLBuilder.get().withBaseURL(baseURL).withPaths(getServletPath()).withTestName(testName).build(), @@ -98,12 +98,12 @@ public String runTestWithResponse(URL baseURL, String testName, Properties props * testing situations. Provide properties if you want them included in a POST * request, otherwise pass in null. */ - public String runTestWithResponse(URLBuilder builder, Properties props) { + public String runTestWithResponse(final URLBuilder builder, final Properties props) { return assertSuccessfulURLResponse(builder.build(), props); } // ##### test runner ###### - private String assertSuccessfulURLResponse(URL url, Properties props) { + private String assertSuccessfulURLResponse(final URL url, final Properties props) { log.enter("assertSuccessfulURLResponse", "Calling application with URL=" + url.toString()); boolean withProps = props != null; @@ -155,7 +155,7 @@ private String assertSuccessfulURLResponse(URL url, Properties props) { } } - static String toEncodedString(Properties args) throws UnsupportedEncodingException { + static String toEncodedString(final Properties args) throws UnsupportedEncodingException { StringBuffer buf = new StringBuffer(); Enumeration names = args.propertyNames(); while (names.hasMoreElements()) { @@ -187,7 +187,7 @@ protected String getServletPath() { * @param expected - the expected string to find in the response * @param resp - the response you received from the servlet */ - protected void assertStringInResponse(String message, String expected, String resp) { + protected void assertStringInResponse(final String message, final String expected, final String resp) { assertTrue(resp.toLowerCase().contains(expected.toLowerCase()), message); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java index 13153bef..d1841ac5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestLogger.java @@ -29,111 +29,111 @@ public final class TestLogger { private static final String nl = System.lineSeparator(); - private Logger log; + private final Logger log; /* * Private constructor since there should only be one TestLogger per class */ - private TestLogger(Class clazz) { + private TestLogger(final Class clazz) { log = Logger.getLogger(clazz.getCanonicalName()); } - private TestLogger(String clazz) { + private TestLogger(final String clazz) { log = Logger.getLogger(clazz); } - public static TestLogger get(Class clazz) { + public static TestLogger get(final Class clazz) { return new TestLogger(clazz); } - public static TestLogger get(String clazz) { + public static TestLogger get(final String clazz) { return new TestLogger(clazz); } - public void severe(String s) { + public void severe(final String s) { log.severe(s); } - public void severe(String s, Throwable t) { + public void severe(final String s, final Throwable t) { log.severe(messageWithThrowable(s, t)); } - public void warning(String s) { + public void warning(final String s) { log.warning(s); } - public void warning(String s, Throwable t) { + public void warning(final String s, final Throwable t) { log.warning(messageWithThrowable(s, t)); } - public void info(String s) { + public void info(final String s) { log.info(s); } - public void info(String s, Throwable t) { + public void info(final String s, final Throwable t) { log.info(messageWithThrowable(s, t)); } - public void info(String s, Object... objs) { + public void info(final String s, final Object... objs) { log.log(Level.INFO, s + getObjectSuffix(objs), removeNewLines(objs)); } - public void config(String s) { + public void config(final String s) { log.config(s); } - public void config(String s, Throwable t) { + public void config(final String s, final Throwable t) { log.config(messageWithThrowable(s, t)); } - public void fine(String s) { + public void fine(final String s) { log.fine(s); } - public void fine(String s, Throwable t) { + public void fine(final String s, final Throwable t) { log.fine(messageWithThrowable(s, t)); } - public void finer(String s) { + public void finer(final String s) { log.fine(s); } - public void finer(String s, Throwable t) { + public void finer(final String s, final Throwable t) { log.finer(messageWithThrowable(s, t)); } - public void finest(String s) { + public void finest(final String s) { log.fine(s); } - public void finest(String s, Throwable t) { + public void finest(final String s, final Throwable t) { log.finest(messageWithThrowable(s, t)); } - public void enter(Method method, Object... objs) { + public void enter(final Method method, final Object... objs) { log.log(Level.INFO, "--> " + method.getName() + getObjectSuffix(objs), removeNewLines(objs)); } - public void enter(String method, Object... objs) { + public void enter(final String method, final Object... objs) { log.log(Level.INFO, "--> " + method + getObjectSuffix(objs), removeNewLines(objs)); } - public void exit(Method method, Object... objs) { + public void exit(final Method method, final Object... objs) { log.log(Level.INFO, "<-- " + method.getName() + getObjectSuffix(objs), removeNewLines(objs)); } - public void exit(String method, Object... objs) { + public void exit(final String method, final Object... objs) { log.log(Level.INFO, "<-- " + method + getObjectSuffix(objs), removeNewLines(objs)); } - private String messageWithThrowable(String s, Throwable t) { + private String messageWithThrowable(final String s, final Throwable t) { Writer buffer = new StringWriter(); PrintWriter pw = new PrintWriter(buffer); t.printStackTrace(pw); return s + nl + buffer.toString(); } - private String getObjectSuffix(Object[] objs) { + private String getObjectSuffix(final Object[] objs) { if (objs == null || objs.length == 0) return ""; @@ -144,7 +144,7 @@ private String getObjectSuffix(Object[] objs) { return suffix.substring(0, suffix.length() - 2) + " ]"; } - private String[] removeNewLines(Object[] objs) { + private String[] removeNewLines(final Object[] objs) { if (objs == null || objs.length == 0) return new String[] {}; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java index 0c79dae5..1acb7df1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestServlet.java @@ -53,13 +53,13 @@ public class TestServlet extends HttpServlet { public static final String TEST_METHOD = "testMethod"; @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) + protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) + protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException { String method = request.getParameter(TEST_METHOD); @@ -144,7 +144,7 @@ protected void after() throws Exception { * Implement this method for custom test invocation, such as specific test * method signatures */ - protected void invokeTest(String method, HttpServletRequest request, HttpServletResponse response) + protected void invokeTest(final String method, final HttpServletRequest request, final HttpServletResponse response) throws Exception { throw new NoSuchMethodException("No such method '" + method + "' found on class " + getClass() + " with any of the following signatures: " + method + "(HttpServletRequest, HttpServletResponse) " @@ -160,7 +160,7 @@ protected void invokeTest(String method, HttpServletRequest request, HttpServlet * @return String - response body * @throws IOException */ - public static String getResponse(URLConnection con) throws IOException { + public static String getResponse(final URLConnection con) throws IOException { try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()))) { StringBuffer response = new StringBuffer(); @@ -187,7 +187,7 @@ public static String getResponse(URLConnection con) throws IOException { * @return the connection for further testing * @throws IOException */ - public static URLConnection sendPostData(URL url, Properties props) throws IOException { + public static URLConnection sendPostData(final URL url, final Properties props) throws IOException { log.info("Opening url connection to: " + url.toString()); URLConnection urlConn = url.openConnection(); // Begin POST of properties to SERVLET diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java index 6a7b5755..13f91986 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java @@ -50,7 +50,7 @@ public static URLBuilder get() { /** * Base URL obtained from ArquillianResource */ - public URLBuilder withBaseURL(URL baseURL) { + public URLBuilder withBaseURL(final URL baseURL) { this.baseURL = baseURL; return this; } @@ -60,7 +60,7 @@ public URLBuilder withBaseURL(URL baseURL) { * http://localhost:80/servlet/ query = count=5 result = * http://localhost:80/servlet/?count=5 */ - public URLBuilder withQueries(String... queries) { + public URLBuilder withQueries(final String... queries) { if (this.queries == null) { this.queries = new ArrayList<>(Arrays.asList(queries)); } else { @@ -74,7 +74,7 @@ public URLBuilder withQueries(String... queries) { * http://localhost:80/servlet/ path = app, inventory result = * http://localhost:80/servlet/app/inventory */ - public URLBuilder withPaths(String... paths) { + public URLBuilder withPaths(final String... paths) { if (this.paths == null) { this.paths = new ArrayList<>(Arrays.asList(paths)); } else { @@ -88,7 +88,7 @@ public URLBuilder withPaths(String... paths) { * http://localhost:80/servlet/ testName = transactionTest result = * http://localhost:80/servlet/?testMethod=transactionTest */ - public URLBuilder withTestName(String testName) { + public URLBuilder withTestName(final String testName) { if (testNameSet) { throw new UnsupportedOperationException("Cannot call withTestName more than once."); } @@ -126,7 +126,7 @@ public URL build() { return extendedURL; } - public static URL extendQuery(URL baseURL, List queries) { + public static URL extendQuery(final URL baseURL, final List queries) { if (queries == null) return baseURL; @@ -151,7 +151,7 @@ public static URL extendQuery(URL baseURL, List queries) { } } - public static URL extendPath(URL baseURL, List paths) { + public static URL extendPath(final URL baseURL, final List paths) { if (paths == null) return baseURL; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java index 8e8af8cc..ccb468d1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java @@ -38,7 +38,7 @@ public class TCKArchiveProcessor implements ApplicationArchiveProcessor { private static final Logger log = Logger.getLogger(TCKArchiveProcessor.class.getCanonicalName()); @Override - public void process(Archive applicationArchive, TestClass testClass) { + public void process(final Archive applicationArchive, final TestClass testClass) { String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() : applicationArchive.getName(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java index aa7e3f2b..c83067fa 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java @@ -25,7 +25,7 @@ public class TCKLoadableExtension implements LoadableExtension { @Override - public void register(ExtensionBuilder builder) { + public void register(final ExtensionBuilder builder) { builder.service(ApplicationArchiveProcessor.class, TCKArchiveProcessor.class); builder.service(ApplicationArchiveProcessor.class, TCKSignatureProcessor.class); builder.service(AuxiliaryArchiveAppender.class, TCKFrameworkAppender.class); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java index 0fbe89e7..f2aa28eb 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java @@ -38,7 +38,7 @@ public class TCKSignatureProcessor implements ApplicationArchiveProcessor { private static final Package signaturePackage = ConcurrencySignatureTestRunner.class.getPackage(); @Override - public void process(Archive applicationArchive, TestClass testClass) { + public void process(final Archive applicationArchive, final TestClass testClass) { String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() : applicationArchive.getName(); 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 582a98bb..d23018fd 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 @@ -33,20 +33,20 @@ public class AssertionExtension implements BeforeTestExecutionCallback, AfterTes private static final Logger log = Logger.getLogger(AssertionExtension.class.getCanonicalName()); @Override - public void beforeTestExecution(ExtensionContext context) throws Exception { + public void beforeTestExecution(final ExtensionContext context) throws Exception { log.info(">>> Begin test: " + context.getDisplayName()); injectTestName(context, context.getRequiredTestMethod().getName()); } @Override - public void afterTestExecution(ExtensionContext context) throws Exception { + public void afterTestExecution(final ExtensionContext context) throws Exception { log.info("<<< End test: " + context.getDisplayName()); injectTestName(context, null); } // TODO could consider using getFields to allow for injection into superclass, // but will affect performance. - private void injectTestName(ExtensionContext context, String testname) { + private void injectTestName(final ExtensionContext context, final String testname) { Class testClass = context.getRequiredTestClass(); Stream.of(testClass.getDeclaredFields()).filter(field -> field.isAnnotationPresent(TestName.class)) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java index d96cc334..ca48cc29 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java @@ -15,7 +15,7 @@ private Assertions() { * Asserts expected integer is within the range ( lowerBound, upperBound ) * (exclusive). */ - public static void assertWithin(int expected, int lowerBound, int upperBound) { + public static void assertWithin(final int expected, final int lowerBound, final int upperBound) { if (lowerBound < expected && upperBound > expected) { return; // pass } @@ -28,7 +28,7 @@ public static void assertWithin(int expected, int lowerBound, int upperBound) { * Asserts expected integer is within the range [ lowerBound, upperBound ] * [inclusive]. */ - public static void assertBetween(int expected, int lowerBound, int upperBound) { + public static void assertBetween(final int expected, final int lowerBound, final int upperBound) { if (lowerBound <= expected && upperBound >= expected) { return; // pass } @@ -40,7 +40,7 @@ public static void assertBetween(int expected, int lowerBound, int upperBound) { /** * Asserts expected object is within a range represented by an Iterable */ - public static void assertRangeContains(Object expected, Iterable range) { + public static void assertRangeContains(final Object expected, final Iterable range) { Iterator it = range.iterator(); while (it.hasNext()) { if (it.equals(expected)) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java index a38c173e..d796cc86 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java @@ -54,7 +54,7 @@ public static T waitForTaskComplete(final Future future, final Duration t * * @param managedTaskListener - the listener to be polled */ - public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener) { + public static void waitForListenerComplete(final ManagedTaskListenerImpl managedTaskListener) { waitForListenerComplete(managedTaskListener, TestConstants.waitTimeout, TestConstants.pollInterval); } @@ -66,8 +66,8 @@ public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskLi * @param maxWaitTimeMillis - timeout * @param pollIntervalMillis - poll interval */ - public static void waitForListenerComplete(ManagedTaskListenerImpl managedTaskListener, Duration timeout, - Duration pollInterval) { + public static void waitForListenerComplete(final ManagedTaskListenerImpl managedTaskListener, final Duration timeout, + final Duration pollInterval) { assertTimeoutPreemptively(timeout, () -> { for (; !managedTaskListener.eventCalled(ListenerEvent.DONE); sleep(TestConstants.pollInterval)) ; @@ -131,14 +131,14 @@ public static void waitTillThreadFinish(final Thread thread) { }); } - public static void waitForTransactionBegan(CancelledTransactedTask task) { + public static void waitForTransactionBegan(final CancelledTransactedTask task) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { for (; !task.beginTransaction.get(); sleep(TestConstants.pollInterval)) ; }); } - public static void sleep(Duration time) { + public static void sleep(final Duration time) { try { Thread.sleep(time.toMillis()); } catch (InterruptedException e) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java index acc1f215..990c29f2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java @@ -37,7 +37,7 @@ public class ClassloaderServlet extends TestServlet { @Resource(lookup = TestConstants.defaultContextService) public ContextService context; - public void testClassloaderAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) + public void testClassloaderAndCreateProxyInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { String result = intf .executeWorker((TestWorkInterface) context.createContextualProxy(new TestClassloaderRunnableWork(), diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java index 59ec1612..6ae7f0b5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java @@ -34,7 +34,7 @@ public class ContextPropagateBean implements ContextPropagateInterface { public ContextService context; @Override - public TestWorkInterface createWorker(String classname) { + public TestWorkInterface createWorker(final String classname) { try { return (TestWorkInterface) context.createContextualProxy( Class.forName(classname).getConstructor().newInstance(), Runnable.class, TestWorkInterface.class); @@ -44,7 +44,7 @@ public TestWorkInterface createWorker(String classname) { } @Override - public String executeWorker(TestWorkInterface worker) { + public String executeWorker(final TestWorkInterface worker) { Thread workThread = threadFactory.newThread(worker); workThread.start(); try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java index 2a504639..ae9bf611 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java @@ -37,7 +37,7 @@ public class JNDIServlet extends TestServlet { @Resource(lookup = TestConstants.defaultContextService) public ContextService context; - public void testJNDIContextAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) + public void testJNDIContextAndCreateProxyInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { String result = intf.executeWorker((TestWorkInterface) context.createContextualProxy(new TestJNDIRunnableWork(), Runnable.class, TestWorkInterface.class, Serializable.class)); @@ -45,7 +45,7 @@ public void testJNDIContextAndCreateProxyInServlet(HttpServletRequest req, HttpS } - public void testJNDIContextAndCreateProxyInEJB(HttpServletRequest req, HttpServletResponse resp) throws Exception { + public void testJNDIContextAndCreateProxyInEJB(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { String result = intf.createWorker(TestJNDIRunnableWork.class.getCanonicalName()).doSomeWork(); resp.getWriter().println(result); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java index d8faff60..6cfd6294 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java @@ -37,7 +37,7 @@ public class SecurityServlet extends TestServlet { @Resource(lookup = TestConstants.defaultContextService) public ContextService context; - public void testSecurityAndCreateProxyInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { + public void testSecurityAndCreateProxyInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { req.login("javajoe", "javajoe"); String result = intf diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java index c79b2f25..a7dd9fc7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java @@ -40,7 +40,7 @@ public class DeserializeServlet extends HttpServlet { public ContextService context; @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { try { Object proxy = context.createContextualProxy(new TestJNDIRunnableWork(), Runnable.class, TestWorkInterface.class, Serializable.class); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java index 078039c1..d383af05 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java @@ -42,7 +42,7 @@ public class ProxyCreatorServlet extends TestServlet { @Resource(lookup = TestConstants.defaultContextService) public ContextService context; - public void testJNDIContextInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { + public void testJNDIContextInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { Object proxy = true; String result = null; String proxyURLString = req.getParameter("proxyURL"); @@ -61,7 +61,7 @@ public void testJNDIContextInServlet(HttpServletRequest req, HttpServletResponse resp.getWriter().println(result); } - public void testClassloaderInServlet(HttpServletRequest req, HttpServletResponse resp) throws Exception { + public void testClassloaderInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { Object proxy = true; String result = null; String proxyURLString = req.getParameter("proxyURL"); @@ -80,7 +80,7 @@ public void testClassloaderInServlet(HttpServletRequest req, HttpServletResponse resp.getWriter().println(result); } - private String proxyToString(Object proxy) throws IOException { + private String proxyToString(final Object proxy) throws IOException { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(proxy); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java index a7c1189c..d5c5e20f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/WorkInterfaceServlet.java @@ -32,7 +32,7 @@ public class WorkInterfaceServlet extends HttpServlet { @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { byte[] proxyAsBytes = Base64.getDecoder().decode(req.getParameter("proxy")); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(proxyAsBytes)); try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java index afa6ae47..29ba976e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java @@ -35,7 +35,7 @@ public class AppBean { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Asynchronous(executor = "java:module/concurrent/ExecutorB") - public CompletionStage addStringContextAndWait(BlockingQueue queue, CountDownLatch blocker) { + public CompletionStage addStringContextAndWait(final BlockingQueue queue, final CountDownLatch blocker) { String s = StringContext.get(); try { queue.add(s); @@ -47,7 +47,7 @@ public CompletionStage addStringContextAndWait(BlockingQueue que } @Asynchronous - public void exchange(Exchanger exchanger, String value) { + public void exchange(final Exchanger exchanger, final String value) { try { exchanger.exchange(value, MAX_WAIT_SECONDS, TimeUnit.SECONDS); } catch (InterruptedException | TimeoutException x) { @@ -56,7 +56,7 @@ public void exchange(Exchanger exchanger, String value) { } @Asynchronous(executor = "java:app/concurrent/ExecutorA") - public CompletableFuture waitAndGetIntContext(Semaphore started, CountDownLatch blocker) { + public CompletableFuture waitAndGetIntContext(final Semaphore started, final CountDownLatch blocker) { started.release(1); CompletableFuture future = Asynchronous.Result.getFuture(); try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java index 796a585a..f27523ca 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionBean.java @@ -35,7 +35,7 @@ public class ManagedExecutorDefinitionBean implements ManagedExecutorDefinitionInterface { @Override - public Object doLookup(String name) throws NamingException { + public Object doLookup(final String name) throws NamingException { return InitialContext.doLookup(name); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java index c3f70585..03973439 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebBean.java @@ -33,7 +33,7 @@ public class ManagedExecutorDefinitionWebBean implements ManagedExecutorDefinitionInterface { @Override - public Object doLookup(String name) throws NamingException { + public Object doLookup(final String name) throws NamingException { return InitialContext.doLookup(name); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java index 2a172bf5..721962ca 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java @@ -36,7 +36,7 @@ public class SecurityServlet extends TestServlet { @Resource(lookup = TestConstants.defaultManagedExecutorService) public ManagedExecutorService executor; - public void managedExecutorServiceAPISecurityTest(HttpServletRequest req, HttpServletResponse res) + public void managedExecutorServiceAPISecurityTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { req.login("javajoe", "javajoe"); Future future = executor.submit(new SecurityTestTask()); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java index 89623e95..9a4a6775 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java @@ -76,7 +76,7 @@ protected void beforeClass() throws RemoteException { } } - public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + public void transactionTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); Future taskResult = scheduledExecutor.submit(new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT)); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java index 1ff8e9b7..72d22f9e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionBean.java @@ -37,7 +37,7 @@ public class ManagedScheduledExecutorDefinitionBean implements ManagedScheduleExecutorDefinitionInterface { @Override - public Object doLookup(String name) throws NamingException { + public Object doLookup(final String name) throws NamingException { return InitialContext.doLookup(name); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java index 97fb4d91..43df78d0 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java @@ -543,19 +543,19 @@ private void initSchedule() { ZonedDateTime sept15 = ZonedDateTime.of(2021, 9, 15, 8, 0, 0, 0, usCentral); ZonedDateTime oct15 = ZonedDateTime.of(2021, 10, 15, 8, 0, 0, 0, usCentral); ZonedDateTime nov15 = ZonedDateTime.of(2021, 11, 15, 8, 0, 0, 0, usCentral); - schedule.put(0l, sept15); + schedule.put(0L, sept15); schedule.put(sept15.toEpochSecond(), oct15); schedule.put(oct15.toEpochSecond(), nov15); } @Override - public ZonedDateTime getNextRunTime(LastExecution lastExecution, ZonedDateTime scheduledAt) { + public ZonedDateTime getNextRunTime(final LastExecution lastExecution, final ZonedDateTime scheduledAt) { if (lastExecution == null) initSchedule(); else startAndEndTimes.put(lastExecution.getRunStart(usCentral), lastExecution.getRunEnd(usCentral)); - long key = lastExecution == null ? 0l : lastExecution.getScheduledStart(usCentral).toEpochSecond(); + long key = lastExecution == null ? 0L : lastExecution.getScheduledStart(usCentral).toEpochSecond(); return schedule.get(key); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java index a8f0c00f..07088ce3 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebBean.java @@ -36,7 +36,7 @@ public class ManagedScheduledExecutorDefinitionWebBean implements ManagedScheduleExecutorDefinitionInterface { @Override - public Object doLookup(String name) throws NamingException { + public Object doLookup(final String name) throws NamingException { return InitialContext.doLookup(name); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java index 5a8a635a..83286f56 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ReqBean.java @@ -36,8 +36,8 @@ public class ReqBean { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Asynchronous(executor = "java:app/concurrent/ScheduledExecutorA") - public CompletableFuture awaitAndGetThirdPartyContext(Semaphore invocationsStarted, - CountDownLatch blocker) { + public CompletableFuture awaitAndGetThirdPartyContext(final Semaphore invocationsStarted, + final CountDownLatch blocker) { invocationsStarted.release(1); CompletableFuture future = Asynchronous.Result.getFuture(); try { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java index a6b17d52..a65c94e9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityServlet.java @@ -35,7 +35,7 @@ @WebServlet("/SecurityServlet") public class SecurityServlet extends TestServlet { - public void managedScheduledExecutorServiceAPISecurityTest(HttpServletRequest req, HttpServletResponse res) + public void managedScheduledExecutorServiceAPISecurityTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { req.login("javajoe", "javajoe"); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java index 439fe0c7..3fa4fad0 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/OnceTrigger.java @@ -22,14 +22,14 @@ import jakarta.enterprise.concurrent.Trigger; public class OnceTrigger implements Trigger { - public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) { + public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (lastExecutionInfo != null) { return null; } return new Date(); } - public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) { + public boolean skipRun(final LastExecution lastExecutionInfo, final Date scheduledRunTime) { return false; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java index 24fbf2f6..31580975 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java @@ -76,7 +76,7 @@ protected void beforeClass() throws RemoteException { } } - public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + public void transactionTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); Future taskResult = managedScheduledExecutorService .schedule(new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT), new OnceTrigger()); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java index 83dfeca1..d330026d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/SecurityServlet.java @@ -43,7 +43,7 @@ public class SecurityServlet extends TestServlet { private static final String TEST_CLASSLOADER_CLASS_NAME = SecurityServlet.class.getCanonicalName(); - public void jndiClassloaderPropagationTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + public void jndiClassloaderPropagationTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { ManagedThreadFactory factory = InitialContext.doLookup(TestConstants.defaultManagedThreadFactory); @@ -54,7 +54,7 @@ public void jndiClassloaderPropagationTest(HttpServletRequest req, HttpServletRe assertEquals(task.getCount(), 1); } - public void jndiClassloaderPropagationWithSecurityTest(HttpServletRequest req, HttpServletResponse res) + public void jndiClassloaderPropagationWithSecurityTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { req.login("javajoe", "javajoe"); @@ -90,7 +90,7 @@ public static class CounterRunnableWithSecurityCheck implements Runnable { private SecurityTestInterface str; - CounterRunnableWithSecurityCheck(SecurityTestInterface str) { + CounterRunnableWithSecurityCheck(final SecurityTestInterface str) { this.str = str; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java index 70a015d0..a08e60aa 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionBean.java @@ -34,7 +34,7 @@ public class ManagedThreadFactoryDefinitionBean implements ManagedThreadFactoryDefinitionInterface { @Override - public Object doLookup(String name) throws NamingException { + public Object doLookup(final String name) throws NamingException { return InitialContext.doLookup(name); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java index e099d988..b61195e3 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java @@ -75,7 +75,7 @@ protected void beforeClass() throws RemoteException { } } - public void transactionTest(HttpServletRequest req, HttpServletResponse res) throws Exception { + public void transactionTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { boolean isCommit = Boolean.parseBoolean(req.getParameter(Constants.PARAM_COMMIT)); Thread thread = threadFactory.newThread(new TransactedTask(isCommit, Constants.SQL_TEMPLATE_INSERT)); thread.start(); From 28bd9225d9762cb6fbee2ce019772decb07c6b9f Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 11:07:32 -0500 Subject: [PATCH 06/14] TCK fix visability issues --- .../ContextService/ContextServiceTests.java | 2 +- .../api/LastExecution/LastExecutionTests.java | 4 ++-- .../ManagedExecutorsTests.java | 7 ++---- .../ManagedScheduledExecutorServiceTests.java | 2 +- .../ManagedTaskListenerTests.java | 2 +- .../RunnableTaskWithException.java | 2 +- .../ManagedThreadFactoryTests.java | 2 +- .../concurrent/api/Trigger/TriggerTests.java | 2 +- .../concurrent/common/context/IntContext.java | 6 ++++- .../common/context/StringContext.java | 6 ++++- .../common/fixed/counter/StaticCounter.java | 6 ++++- .../task/listener/RunnableTaskWithStatus.java | 6 ++++- .../ConcurrencySignatureTestRunner.java | 10 ++++----- .../concurrent/common/signature/SigTest.java | 8 +++---- .../common/signature/SigTestEE.java | 16 +++++++++----- .../signature/SignatureTestDriverFactory.java | 2 +- .../concurrent/common/tasks/CommonTasks.java | 10 +++++---- .../transaction/CancelledTransactedTask.java | 22 ++++++++++++++++--- .../common/transaction/Connections.java | 2 +- .../common/transaction/Constants.java | 6 ++++- .../common/transaction/Counter.java | 6 ++++- .../concurrent/framework/TestConstants.java | 4 ++++ .../tck/concurrent/framework/URLBuilder.java | 2 +- .../junit/extensions/Assertions.java | 2 +- .../framework/junit/extensions/Wait.java | 7 ++---- .../contextPropagate/ClassloaderServlet.java | 2 +- .../ContextPropagateBean.java | 4 ++-- .../ContextPropagationFullTests.java | 14 ++++++------ .../ContextPropagationWebTests.java | 14 ++++++------ ...ontextServiceDefinitionFromEJBServlet.java | 2 +- .../ContextServiceDefinitionServlet.java | 2 +- .../contextPropagate/JNDIServlet.java | 2 +- .../contextPropagate/SecurityServlet.java | 2 +- .../ContextPropagationServletTests.java | 6 ++--- .../servlet/DeserializeServlet.java | 2 +- .../servlet/ProxyCreatorServlet.java | 2 +- .../ContextService/tx/TransactionTests.java | 4 ++-- .../inheritedapi/InheritedAPITests.java | 8 +++---- .../ForbiddenAPIServletTests.java | 2 +- .../managed/forbiddenapi/TestEjb.java | 2 +- .../ManagedExecutorDefinitionFullTests.java | 6 ++--- ...ManagedExecutorDefinitionOnEJBServlet.java | 4 ++-- .../ManagedExecutorDefinitionServlet.java | 4 ++-- .../ManagedExecutorDefinitionWebTests.java | 6 ++--- .../security/SecurityFullTests.java | 4 ++-- .../security/SecurityServlet.java | 2 +- .../security/SecurityWebTests.java | 4 ++-- .../tx/TransactionServlet.java | 6 ++--- .../tx/TransactionTests.java | 2 +- .../inheritedapi/TestEjb.java | 10 ++++----- .../servlet/InheritedAPIServletTests.java | 10 ++++----- .../ForbiddenAPIServletTests.java | 2 +- .../managed/forbiddenapi/TestEjb.java | 2 +- ...dScheduledExecutorDefinitionFullTests.java | 6 ++--- ...heduledExecutorDefinitionOnEJBServlet.java | 4 ++-- ...gedScheduledExecutorDefinitionServlet.java | 6 ++--- ...edScheduledExecutorDefinitionWebTests.java | 6 ++--- .../security/SecurityFullTests.java | 4 ++-- .../security/SecurityWebTests.java | 4 ++-- .../tx/TransactionServlet.java | 4 ++-- .../tx/TransactionTests.java | 2 +- .../context/ContextFullTests.java | 9 +++----- .../context/ContextWebTests.java | 4 ++-- ...nagedThreadFactoryDefinitionFullTests.java | 6 ++--- ...edThreadFactoryDefinitionOnEJBServlet.java | 2 +- ...ManagedThreadFactoryDefinitionServlet.java | 2 +- ...anagedThreadFactoryDefinitionWebTests.java | 6 ++--- .../tx/TransactionServlet.java | 6 ++--- .../tx/TransactionTests.java | 2 +- .../dd/DeploymentDescriptorFullTests.java | 4 ++-- .../dd/DeploymentDescriptorServlet.java | 4 ++-- .../dd/DeploymentDescriptorWebTests.java | 4 ++-- 72 files changed, 201 insertions(+), 158 deletions(-) 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 b5e3289e..4be4d552 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 @@ -51,7 +51,7 @@ public static WebArchive createDeployment() { } @Resource(lookup = TestConstants.defaultContextService) - public ContextService context; + private ContextService context; /* * @testName: contextServiceWithIntf 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 dc1413ed..e9f26457 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 @@ -59,10 +59,10 @@ public void reset() { } @TestName - public String testname; + private String testname; @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; /* * @testName: lastExecutionGetIdentityNameTest 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 39ff1acf..321f8ca0 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 @@ -38,7 +38,6 @@ 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.TestLogger; 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,8 +52,6 @@ @Common({ PACKAGE.MANAGED_TASK_LISTENER, PACKAGE.TASKS }) public class ManagedExecutorsTests { - private static final TestLogger log = TestLogger.get(ManagedExecutorsTests.class); - // TODO deploy as EJB and JSP artifacts @Deployment(name = "ManagedExecutorsTests") public static WebArchive createDeployment() { @@ -71,10 +68,10 @@ public static WebArchive createDeployment() { private boolean shutdown = true; @Resource(lookup = TestConstants.defaultManagedThreadFactory) - public ManagedThreadFactory threadFactory; + private ManagedThreadFactory threadFactory; @Resource(lookup = TestConstants.defaultManagedExecutorService) - public ManagedExecutorService executor; + private ManagedExecutorService executor; @AfterEach public void after() { 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 a241e81b..f9b8295e 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 @@ -60,7 +60,7 @@ public static WebArchive createDeployment() { .getCanonicalName(); @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; /* * @testName: normalScheduleProcess1Test 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 2f24f5c3..0ca73cd0 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 @@ -58,7 +58,7 @@ public static WebArchive createDeployment() { private ManagedTaskListenerImpl managedTaskListener = new ManagedTaskListenerImpl(); @Resource(lookup = TestConstants.defaultManagedExecutorService) - public ManagedExecutorService executor; + private ManagedExecutorService executor; @AfterEach public void cleanup() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java index 7d201b74..2da375ba 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/ManagedTaskListener/RunnableTaskWithException.java @@ -28,7 +28,7 @@ public RunnableTaskWithException(final ManagedTaskListenerImpl listener) { @Override public void run() { - listener.update(ListenerEvent.TASK_RUN); + getListener().update(ListenerEvent.TASK_RUN); throw new RuntimeException("wrong happend"); } } 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 c703e1e4..5e1023a9 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 @@ -47,7 +47,7 @@ public static WebArchive createDeployment() { } @Resource(lookup = TestConstants.defaultManagedThreadFactory) - public ManagedThreadFactory threadFactory; + private ManagedThreadFactory threadFactory; /* * @testName: isShutdown 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 837d0201..ed571740 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 @@ -54,7 +54,7 @@ public static WebArchive createDeployment() { } @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; @BeforeEach public void reset() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java index 9f0deca9..1cf7224f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java @@ -18,9 +18,13 @@ /** * A mock context type that consists of an int value. */ -public class IntContext { +public final class IntContext { private static final ThreadLocal local = ThreadLocal.withInitial(() -> 0); public static final String NAME = "IntContext"; + + private IntContext() { + //utility class + } public static int get() { return (int) local.get(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java index 12cb124b..7a97cec0 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java @@ -18,9 +18,13 @@ /** * A mock context type that consists of String value. */ -public class StringContext { +public final class StringContext { private static final ThreadLocal local = new ThreadLocal(); public static final String NAME = "StringContext"; + + private StringContext() { + //utility class + } public static String get() { return local.get(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java index a98b16f4..600d76d0 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java @@ -23,9 +23,13 @@ import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.junit.extensions.Wait; -public class StaticCounter { +public final class StaticCounter { private static AtomicInteger count = new AtomicInteger(0); + + private StaticCounter() { + //utility class + } public static int getCount() { return count.get(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java index 4b2ab6b1..0888ee45 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/managed/task/listener/RunnableTaskWithStatus.java @@ -22,7 +22,7 @@ public class RunnableTaskWithStatus implements Runnable { - protected final ManagedTaskListenerImpl listener; + private final ManagedTaskListenerImpl listener; private final Duration blockTime; @@ -42,5 +42,9 @@ public void run() { Wait.sleep(blockTime); } } + + public ManagedTaskListenerImpl getListener() { + return listener; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index 114a5b28..b666cf75 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -107,7 +107,7 @@ protected String getClasspath() { // Get JDK modules from jimage // Add JDK classes to classpath - File jimageOutput = new File(testInfo.getJImageDir()); + File jimageOutput = new File(getTestInfo().getJImageDir()); for (String module : jdkModules) { Path modulePath = Paths.get(jimageOutput.getAbsolutePath(), module); if (Files.isDirectory(modulePath)) { @@ -225,9 +225,9 @@ public void signatureTest() throws Fault { log.info("Exception while creating temp files :" + ex); } - String[] packagesUnderTest = getPackages(testInfo.getVehicle()); - String[] classesUnderTest = getClasses(testInfo.getVehicle()); - String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); + String[] packagesUnderTest = getPackages(getTestInfo().getVehicle()); + String[] classesUnderTest = getClasses(getTestInfo().getVehicle()); + String optionalPkgToIgnore = getTestInfo().getOptionalTechPackagesToIgnore(); // unlisted optional packages are technology packages for those optional // technologies (e.g. jsr-88) that might not have been specified by the @@ -241,7 +241,7 @@ public void signatureTest() throws Fault { Properties sysProps = System.getProperties(); String version = (String) sysProps.get("java.version"); if (!version.startsWith("1.")) { - String jimageDir = testInfo.getJImageDir(); + String jimageDir = getTestInfo().getJImageDir(); File f = new File(jimageDir); f.mkdirs(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java index c350093a..686db173 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java @@ -33,7 +33,7 @@ */ public abstract class SigTest { - protected SignatureTestDriver driver; + private SignatureTestDriver driver; /** *

@@ -155,7 +155,7 @@ protected String[] getClasses() { } // END getClasses - protected SigTestData testInfo; // holds the bin.dir property + private SigTestData testInfo; // holds the bin.dir property /** * Called by the test framework to initialize this test. The method simply @@ -196,7 +196,7 @@ public void cleanup() throws Fault { public static class Fault extends Exception { private static final long serialVersionUID = -1574745208867827913L; - public Throwable t; + private Throwable t; /** * creates a Fault with a message @@ -292,7 +292,7 @@ public synchronized Throwable initCause(final Throwable cause) { public static class SetupException extends Exception { private static final long serialVersionUID = -7616313680616499158L; - public Exception e; + private Exception e; /** * creates a Fault with a message diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java index 5c1b9b5a..88ed4595 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java @@ -32,9 +32,7 @@ */ public abstract class SigTestEE { - String[] sVehicles; - - protected SignatureTestDriver driver; + private SignatureTestDriver driver; /** *

@@ -184,7 +182,7 @@ protected String[] getClasses(final String vehicleName) { } // END getClasses - protected SigTestData testInfo; // holds the bin.dir and vehicle properties + private SigTestData testInfo; // holds the bin.dir and vehicle properties /** * Called by the test framework to initialize this test. The method simply @@ -200,6 +198,14 @@ public void setup() { System.out.println("Unexpected exception " + e.getMessage()); } } + + protected SigTestData getTestInfo() { + if (testInfo == null) { + setup(); + } + + return testInfo; + } /** * Called by the test framework to run this test. This method utilizes the state @@ -301,7 +307,7 @@ public void cleanup() throws Fault { public static class Fault extends Exception { private static final long serialVersionUID = -1574745208867827913L; - public Throwable t; + private Throwable t; /** * creates a Fault with a message diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java index 430220cf..56dfcb01 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriverFactory.java @@ -25,7 +25,7 @@ * Factory to obtain SignatureTestDriver implementations. *

*/ -public class SignatureTestDriverFactory { +public final class SignatureTestDriverFactory { /** *

diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java index 1f71da58..fc7d58f0 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/tasks/CommonTasks.java @@ -22,9 +22,11 @@ import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.junit.extensions.Wait; -public class CommonTasks { - - public static final String SIMPLE_RETURN_STRING = "ok"; +public final class CommonTasks { + + private CommonTasks() { + //utility class + } public static class SimpleCallable implements Callable { private Duration waitTime = Duration.ZERO; @@ -46,7 +48,7 @@ public String call() { } catch (Exception e) { throw new RuntimeException(e); } - return SIMPLE_RETURN_STRING; + return TestConstants.simpleReturnValue; } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java index 173436f8..fc6df469 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java @@ -30,11 +30,11 @@ public class CancelledTransactedTask implements Runnable { - public AtomicBoolean runQuery = new AtomicBoolean(false); + private AtomicBoolean runQuery = new AtomicBoolean(false); - public AtomicBoolean beginTransaction = new AtomicBoolean(false); + private AtomicBoolean beginTransaction = new AtomicBoolean(false); - public AtomicBoolean cancelTransaction = new AtomicBoolean(false); + private AtomicBoolean cancelTransaction = new AtomicBoolean(false); private final String sqlTemplate; @@ -82,4 +82,20 @@ public void run() { e.printStackTrace(); } } + + public AtomicBoolean getRunQuery() { + return runQuery; + } + + public AtomicBoolean getBeginTransaction() { + return beginTransaction; + } + + public AtomicBoolean getCancelTransaction() { + return cancelTransaction; + } + + public String getSqlTemplate() { + return sqlTemplate; + } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java index 44457f31..8a6d48c4 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java @@ -20,7 +20,7 @@ import javax.sql.DataSource; -public class Connections { +public final class Connections { private Connections() { // ignore diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Constants.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Constants.java index 511c1496..5f321a45 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Constants.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Constants.java @@ -16,7 +16,11 @@ package ee.jakarta.tck.concurrent.common.transaction; -public class Constants { +public final class Constants { + + private Constants() { + //utility class + } public static final String CONTEXT_PATH = "/TransactionServlet"; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java index 1783bec4..33a424ce 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Counter.java @@ -19,7 +19,11 @@ import java.sql.ResultSet; import java.sql.Statement; -public class Counter { +public final class Counter { + + private Counter() { + //utility class + } /** * Get count of rows in test table to verify if a transaction was committed or diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java index ce15264f..1c9abed0 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/TestConstants.java @@ -22,6 +22,10 @@ * infrastructure. */ public final class TestConstants { + + private TestConstants() { + //utility class + } // JNDI Names public static final String defaultContextService = "java:comp/DefaultContextService"; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java index 13f91986..b48f7797 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java @@ -26,7 +26,7 @@ * baseURL will be provided by Arquillian using the * ArquillianResource annotation to get the URL of the servlet. */ -public class URLBuilder { +public final class URLBuilder { private static final TestLogger log = TestLogger.get(URLBuilder.class); public static final String TEST_METHOD = "testMethod"; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java index ca48cc29..65ba65a9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Assertions.java @@ -5,7 +5,7 @@ /** * Helper class for custom assertions not supported by JUnit 5 */ -public class Assertions { +public final class Assertions { private Assertions() { // helper method diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java index d796cc86..47c6a287 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java @@ -10,16 +10,13 @@ import ee.jakarta.tck.concurrent.common.managed.task.listener.ManagedTaskListenerImpl; import ee.jakarta.tck.concurrent.common.transaction.CancelledTransactedTask; import ee.jakarta.tck.concurrent.framework.TestConstants; -import ee.jakarta.tck.concurrent.framework.TestLogger; /** * Utility class for waiting for results. * * Prioritize polling for results, and discourages sleeping */ -public class Wait { - - static TestLogger log = TestLogger.get(Wait.class); +public final class Wait { private Wait() { // Utility class no constructor @@ -133,7 +130,7 @@ public static void waitTillThreadFinish(final Thread thread) { public static void waitForTransactionBegan(final CancelledTransactedTask task) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (; !task.beginTransaction.get(); sleep(TestConstants.pollInterval)) + for (; !task.getBeginTransaction().get(); sleep(TestConstants.pollInterval)) ; }); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java index 990c29f2..5608958f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ClassloaderServlet.java @@ -35,7 +35,7 @@ public class ClassloaderServlet extends TestServlet { private ContextPropagateInterface intf; @Resource(lookup = TestConstants.defaultContextService) - public ContextService context; + private ContextService context; public void testClassloaderAndCreateProxyInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java index 6ae7f0b5..3422bc4d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagateBean.java @@ -28,10 +28,10 @@ public class ContextPropagateBean implements ContextPropagateInterface { @Resource(lookup = TestConstants.defaultManagedThreadFactory) - public ManagedThreadFactory threadFactory; + private ManagedThreadFactory threadFactory; @Resource(lookup = TestConstants.defaultContextService) - public ContextService context; + private ContextService context; @Override public TestWorkInterface createWorker(final String classname) { 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 7993e930..df11ad9f 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 @@ -70,25 +70,25 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @ArquillianResource(JNDIServlet.class) - URL jndiURL; + private URL jndiURL; @ArquillianResource(JSPSecurityServlet.class) - URL jspURL; + private URL jspURL; @ArquillianResource(ClassloaderServlet.class) - URL classloaderURL; + private URL classloaderURL; @ArquillianResource(SecurityServlet.class) - URL securityURL; + private URL securityURL; @ArquillianResource(ContextServiceDefinitionServlet.class) - URL contextURL; + private URL contextURL; @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from // another thread or the current user is changed 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 5e398f69..63fa63af 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 @@ -59,25 +59,25 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @ArquillianResource(JNDIServlet.class) - URL jndiURL; + private URL jndiURL; @ArquillianResource(JSPSecurityServlet.class) - URL jspURL; + private URL jspURL; @ArquillianResource(ClassloaderServlet.class) - URL classloaderURL; + private URL classloaderURL; @ArquillianResource(SecurityServlet.class) - URL securityURL; + private URL securityURL; @ArquillianResource(ContextServiceDefinitionServlet.class) - URL contextURL; + private URL contextURL; @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from // another thread or the current user is changed diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java index e53450a6..a5391c11 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java @@ -56,7 +56,7 @@ public class ContextServiceDefinitionFromEJBServlet extends TestServlet { private ExecutorService unmanagedThreads; @Resource - UserTransaction tx; + private UserTransaction tx; @EJB private ContextServiceDefinitionInterface contextServiceDefinitionBean; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java index 582cd83a..f8ca6a44 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java @@ -71,7 +71,7 @@ public class ContextServiceDefinitionServlet extends TestServlet { private ExecutorService unmanagedThreads; @Resource - UserTransaction tx; + private UserTransaction tx; @Override public void destroy() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java index ae9bf611..aef74ecf 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/JNDIServlet.java @@ -35,7 +35,7 @@ public class JNDIServlet extends TestServlet { private ContextPropagateInterface intf; @Resource(lookup = TestConstants.defaultContextService) - public ContextService context; + private ContextService context; public void testJNDIContextAndCreateProxyInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java index 6cfd6294..caaeac4e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/SecurityServlet.java @@ -35,7 +35,7 @@ public class SecurityServlet extends TestServlet { private ContextPropagateInterface intf; @Resource(lookup = TestConstants.defaultContextService) - public ContextService context; + private ContextService context; public void testSecurityAndCreateProxyInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { req.login("javajoe", "javajoe"); 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 6308356a..e9b0c1c2 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 @@ -66,15 +66,15 @@ public static WebArchive createDeployment3() { } @TestName - String testname; + private String testname; @ArquillianResource @OperateOnDeployment(APP_NAME_PROXY) - URL baseURL; + private URL baseURL; @ArquillianResource @OperateOnDeployment(APP_NAME_WORK) - URL workInterfaceURL; + private URL workInterfaceURL; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java index a7dd9fc7..0b99f408 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/DeserializeServlet.java @@ -37,7 +37,7 @@ public class DeserializeServlet extends HttpServlet { @Resource(lookup = TestConstants.defaultContextService) - public ContextService context; + private ContextService context; @Override protected void service(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java index d383af05..3be7e8ea 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/servlet/ProxyCreatorServlet.java @@ -40,7 +40,7 @@ public class ProxyCreatorServlet extends TestServlet { private static final TestLogger log = TestLogger.get(ProxyCreatorServlet.class); @Resource(lookup = TestConstants.defaultContextService) - public ContextService context; + private ContextService context; public void testJNDIContextInServlet(final HttpServletRequest req, final HttpServletResponse resp) throws Exception { Object proxy = true; 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 ec1893ff..dc4feae3 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 @@ -37,7 +37,7 @@ public class TransactionTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "TransactionTests") public static WebArchive createDeployment() { @@ -50,7 +50,7 @@ protected String getServletPath() { } @TestName - String testname; + private String testname; /* * @testName: testTransactionOfExecuteThreadAndCommit 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 56a2a57c..b895fb3e 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 @@ -55,7 +55,7 @@ public static WebArchive createDeployment() { } @Resource(lookup = TestConstants.defaultManagedExecutorService) - public ManagedExecutorService executor; + private ManagedExecutorService executor; /* * @testName: testBasicManagedExecutorService @@ -88,15 +88,15 @@ public void testExecute() { public void testSubmit() throws Exception { Future result = executor.submit(new CommonTasks.SimpleCallable()); Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + assertEquals(result.get(), TestConstants.simpleReturnValue); result = executor.submit(new CommonTasks.SimpleRunnable()); Wait.waitTillFutureIsDone(result); result.get(); - result = executor.submit(new CommonTasks.SimpleRunnable(), CommonTasks.SIMPLE_RETURN_STRING); + result = executor.submit(new CommonTasks.SimpleRunnable(), TestConstants.simpleReturnValue); Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + assertEquals(result.get(), TestConstants.simpleReturnValue); } @Test 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 ff9ecf1a..e501bc35 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 @@ -39,7 +39,7 @@ public static WebArchive createDeployment() { } @Resource(lookup = TestConstants.defaultManagedExecutorService) - public ManagedExecutorService mes; + private ManagedExecutorService mes; /* * @testName: testAwaitTermination 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 44308095..6ef1c36b 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 @@ -31,7 +31,7 @@ public class TestEjb implements TestEjbInterface { private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; @Resource(lookup = TestConstants.defaultManagedExecutorService) - public ManagedExecutorService executor; + private ManagedExecutorService executor; public void testAwaitTermination() { try { 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 385743e5..0616a020 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 @@ -44,10 +44,10 @@ public class ManagedExecutorDefinitionFullTests extends TestClient { @ArquillianResource(ManagedExecutorDefinitionServlet.class) - URL baseURL; + private URL baseURL; @ArquillianResource(ManagedExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; @Deployment(name = "ManagedExecutorDefinitionTests") public static EnterpriseArchive createDeployment() { @@ -75,7 +75,7 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java index 85007187..d677e0e7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java @@ -42,10 +42,10 @@ public class ManagedExecutorDefinitionOnEJBServlet extends TestServlet { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Inject - AppBean appBean; + private AppBean appBean; @Resource - UserTransaction tx; + private UserTransaction tx; @EJB private ManagedExecutorDefinitionInterface managedExecutorDefinitionBean; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java index 33448a9a..abcf44f2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java @@ -59,10 +59,10 @@ public class ManagedExecutorDefinitionServlet extends TestServlet { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Inject - AppBean appBean; + private AppBean appBean; @Resource - UserTransaction tx; + private UserTransaction tx; /** * ManagedExecutorService submits an action to run asynchronously as a 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 81ffdff3..d4db0aac 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 @@ -44,10 +44,10 @@ public class ManagedExecutorDefinitionWebTests extends TestClient { @ArquillianResource(ManagedExecutorDefinitionServlet.class) - URL baseURL; + private URL baseURL; @ArquillianResource(ManagedExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; @Deployment(name = "ManagedExecutorDefinitionTests") public static WebArchive createDeployment() { @@ -64,7 +64,7 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { 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 a505a564..55e11224 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 @@ -38,7 +38,7 @@ public class SecurityFullTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "SecurityTests") public static EnterpriseArchive createDeployment() { @@ -60,7 +60,7 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java index 721962ca..7345a9a7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityServlet.java @@ -34,7 +34,7 @@ public class SecurityServlet extends TestServlet { @Resource(lookup = TestConstants.defaultManagedExecutorService) - public ManagedExecutorService executor; + private ManagedExecutorService executor; public void managedExecutorServiceAPISecurityTest(final HttpServletRequest req, final HttpServletResponse res) throws Exception { 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 dc73fb0e..ae88133b 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 @@ -38,7 +38,7 @@ public class SecurityWebTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "SecurityTests") public static WebArchive createDeployment() { @@ -50,7 +50,7 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java index 9a4a6775..d29b51cc 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java @@ -55,7 +55,7 @@ public class TransactionServlet extends TestServlet { private DataSource ds; @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; @Override protected void beforeClass() throws RemoteException { @@ -94,10 +94,10 @@ public void cancelTest() { Wait.waitForTransactionBegan(cancelledTask); // before it commit. - cancelledTask.cancelTransaction.set(true); + cancelledTask.getCancelTransaction().set(true); // continue to run if possible. - cancelledTask.runQuery.set(true); + cancelledTask.getRunQuery().set(true); ; int afterTransacted = Counter.getCount(); 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 3abbe41a..35467025 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 @@ -39,7 +39,7 @@ public class TransactionTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "TransactionTests") public static WebArchive createDeployment() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java index 560dc533..46ac97d8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java @@ -49,21 +49,21 @@ public class TestEjb implements TestEjbInterface { private CounterInterface counter; @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; public void testApiSubmit() { try { Future result = scheduledExecutor.submit(new CommonTasks.SimpleCallable()); Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + assertEquals(result.get(), TestConstants.simpleReturnValue); result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable()); Wait.waitTillFutureIsDone(result); result.get(); - result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), CommonTasks.SIMPLE_RETURN_STRING); + result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), TestConstants.simpleReturnValue); Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + assertEquals(result.get(), TestConstants.simpleReturnValue); } catch (Exception e) { throw new RuntimeException(e); } @@ -152,7 +152,7 @@ public void testApiSchedule() { Future result = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); Wait.waitTillFutureIsDone(result); - assertEquals(CommonTasks.SIMPLE_RETURN_STRING, result.get()); + assertEquals(TestConstants.simpleReturnValue, result.get()); result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); 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/servlet/InheritedAPIServletTests.java index 589729d7..cba12dea 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/servlet/InheritedAPIServletTests.java @@ -57,7 +57,7 @@ public static WebArchive createDeployment() { } @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; @BeforeEach public void before() { @@ -75,15 +75,15 @@ public void before() { public void testApiSubmit() throws Exception { Future result = scheduledExecutor.submit(new CommonTasks.SimpleCallable()); Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + assertEquals(result.get(), TestConstants.simpleReturnValue); result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable()); Wait.waitTillFutureIsDone(result); result.get(); - result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), CommonTasks.SIMPLE_RETURN_STRING); + result = scheduledExecutor.submit(new CommonTasks.SimpleRunnable(), TestConstants.simpleReturnValue); Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + assertEquals(result.get(), TestConstants.simpleReturnValue); } /* @@ -190,7 +190,7 @@ public void testApiSchedule() throws Exception { Future result = scheduledExecutor.schedule(new CommonTasks.SimpleCallable(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); Wait.waitTillFutureIsDone(result); - assertEquals(result.get(), CommonTasks.SIMPLE_RETURN_STRING); + assertEquals(result.get(), TestConstants.simpleReturnValue); result = scheduledExecutor.schedule(new CommonTasks.SimpleRunnable(), TestConstants.pollInterval.getSeconds(), TimeUnit.SECONDS); 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 c777a9d7..aa1fc413 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 @@ -46,7 +46,7 @@ public static WebArchive createDeployment() { private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; @BeforeEach protected void before() { 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 77dae122..a397fff8 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 @@ -31,7 +31,7 @@ public class TestEjb implements TestEjbInterface { private static final String DIDNOT_CATCH_ILLEGALSTATEEXCEPTION = "IllegalStateException expected"; @Resource(lookup = TestConstants.defaultManagedScheduledExecutorService) - public ManagedScheduledExecutorService scheduledExecutor; + private ManagedScheduledExecutorService scheduledExecutor; public void testAwaitTermination() { try { 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 878422eb..f60735fd 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 @@ -44,10 +44,10 @@ public class ManagedScheduledExecutorDefinitionFullTests extends TestClient { @ArquillianResource(ManagedScheduledExecutorDefinitionServlet.class) - URL baseURL; + private URL baseURL; @ArquillianResource(ManagedScheduledExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; @Deployment(name = "ManagedScheduledExecutorDefinitionTests") public static EnterpriseArchive createDeployment() { @@ -75,7 +75,7 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java index 5a7f0b8c..f19c1e35 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java @@ -49,10 +49,10 @@ public class ManagedScheduledExecutorDefinitionOnEJBServlet extends TestServlet private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Inject - ReqBean reqBean; + private ReqBean reqBean; @Resource - UserTransaction tx; + private UserTransaction tx; @EJB private ManagedScheduleExecutorDefinitionInterface managedScheduleExecutorDefinitionBean; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java index 43df78d0..437110b7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java @@ -69,10 +69,10 @@ public class ManagedScheduledExecutorDefinitionServlet extends TestServlet { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Inject - ReqBean reqBean; + private ReqBean reqBean; @Resource - UserTransaction tx; + private UserTransaction tx; /** * ManagedScheduledExecutorService submits an action to run asynchronously as a @@ -536,7 +536,7 @@ public void testScheduleWithZonedTrigger() throws Exception { Map startAndEndTimes = new ConcurrentHashMap(); Trigger monthlyOnThe15th = new ZonedTrigger() { - final Map schedule = new ConcurrentHashMap(); + private final Map schedule = new ConcurrentHashMap(); private void initSchedule() { // Use times from the past to make the test predictable 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 828ac388..dce266b5 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 @@ -44,10 +44,10 @@ public class ManagedScheduledExecutorDefinitionWebTests extends TestClient { @ArquillianResource(ManagedScheduledExecutorDefinitionServlet.class) - URL baseURL; + private URL baseURL; @ArquillianResource(ManagedScheduledExecutorDefinitionOnEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; @Deployment(name = "ManagedScheduledExecutorDefinitionTests") public static WebArchive createDeployment() { @@ -64,7 +64,7 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { 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 89f50a09..e5b5d51c 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 @@ -38,7 +38,7 @@ public class SecurityFullTests extends TestClient { @ArquillianResource(SecurityServlet.class) - URL baseURL; + private URL baseURL; @Deployment(name = "SecurityTests") public static EnterpriseArchive createDeployment() { @@ -59,7 +59,7 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { 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 567c9d17..7a023b11 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 @@ -38,7 +38,7 @@ public class SecurityWebTests extends TestClient { @ArquillianResource(SecurityServlet.class) - URL baseURL; + private URL baseURL; @Deployment(name = "SecurityTests") public static WebArchive createDeployment() { @@ -50,7 +50,7 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java index 31580975..519213db 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java @@ -93,10 +93,10 @@ public void cancelTest() { Wait.waitForTransactionBegan(cancelledTask); // before it commit. - cancelledTask.cancelTransaction.set(true); + cancelledTask.getCancelTransaction().set(true); // continue to run if possible. - cancelledTask.runQuery.set(true); + cancelledTask.getRunQuery().set(true); ; int afterTransacted = Counter.getCount(); 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 e196687e..21699786 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 @@ -39,7 +39,7 @@ public class TransactionTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "TransactionTests") public static WebArchive createDeployment() { 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 ac9687bb..a0f69050 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 @@ -37,15 +37,12 @@ public class ContextFullTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "ContextTests") public static EnterpriseArchive createDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class).addPackages(true, ContextFullTests.class.getPackage()) - .addPackages(false, PACKAGE.TASKS.getPackageName()).deleteClass(SecurityTestEjb.class) // SecurityTestEjb - // and - // SecurityTestInterface - // are in the jar + .addPackages(false, PACKAGE.TASKS.getPackageName()).deleteClass(SecurityTestEjb.class) .deleteClass(SecurityTestInterface.class) .addAsWebInfResource(ContextFullTests.class.getPackage(), "web.xml", "web.xml"); @@ -58,7 +55,7 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { 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 977567da..b9723c90 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 @@ -37,7 +37,7 @@ public class ContextWebTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "ContextTests") public static WebArchive createDeployment() { @@ -48,7 +48,7 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { 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 4d227a67..e1bdf111 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 @@ -44,10 +44,10 @@ public class ManagedThreadFactoryDefinitionFullTests extends TestClient { @ArquillianResource(ManagedThreadFactoryDefinitionServlet.class) - URL baseURL; + private URL baseURL; @ArquillianResource(ManagedThreadFactoryDefinitionOnEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; @Deployment(name = "ManagedThreadFactoryDefinitionTests") public static EnterpriseArchive createDeployment() { @@ -75,7 +75,7 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java index 8b89583d..e7f9bd37 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java @@ -52,7 +52,7 @@ public class ManagedThreadFactoryDefinitionOnEJBServlet extends TestServlet { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Resource - UserTransaction tx; + private UserTransaction tx; @EJB private ManagedThreadFactoryDefinitionInterface managedThreadFactoryDefinitionBean; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java index eb129868..a5f05457 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java @@ -57,7 +57,7 @@ public class ManagedThreadFactoryDefinitionServlet extends TestServlet { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @Resource - UserTransaction tx; + private UserTransaction tx; /** * A ManagedThreadFactoryDefinition with all attributes configured enforces 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 f5cc397b..076c295e 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 @@ -44,10 +44,10 @@ public class ManagedThreadFactoryDefinitionWebTests extends TestClient { @ArquillianResource(ManagedThreadFactoryDefinitionServlet.class) - URL baseURL; + private URL baseURL; @ArquillianResource(ManagedThreadFactoryDefinitionOnEJBServlet.class) - URL ejbContextURL; + private URL ejbContextURL; @Deployment(name = "ManagedThreadFactoryDefinitionTests") public static WebArchive createDeployment() { @@ -66,7 +66,7 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java index b61195e3..01944de2 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java @@ -54,7 +54,7 @@ public class TransactionServlet extends TestServlet { private DataSource ds; @Resource(lookup = TestConstants.defaultManagedThreadFactory) - public ManagedThreadFactory threadFactory; + private ManagedThreadFactory threadFactory; @Override protected void beforeClass() throws RemoteException { @@ -93,10 +93,10 @@ public void cancelTest() { Wait.waitForTransactionBegan(cancelledTask); // before it commit. - cancelledTask.cancelTransaction.set(true); + cancelledTask.getCancelTransaction().set(true); // continue to run if possible. - cancelledTask.runQuery.set(true); + cancelledTask.getRunQuery().set(true); ; int afterTransacted = Counter.getCount(); 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 aabfc5ed..3156d367 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 @@ -39,7 +39,7 @@ public class TransactionTests extends TestClient { @ArquillianResource - URL baseURL; + private URL baseURL; @Deployment(name = "TransactionTests") public static WebArchive createDeployment() { 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 60aa66c7..c4d5291d 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 @@ -44,7 +44,7 @@ public class DeploymentDescriptorFullTests extends TestClient { @ArquillianResource(DeploymentDescriptorServlet.class) - URL baseURL; + private URL baseURL; @Deployment(name = "DeploymentDescriptorTests") public static EnterpriseArchive createDeployment() { @@ -67,7 +67,7 @@ public static EnterpriseArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { 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 6b485fc8..9af6866f 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 @@ -47,10 +47,10 @@ public class DeploymentDescriptorServlet extends TestServlet { private static final long MAX_WAIT_SECONDS = TimeUnit.MINUTES.toSeconds(2); @EJB - DeploymentDescriptorTestBeanInterface enterpriseBean; + private DeploymentDescriptorTestBeanInterface enterpriseBean; @Resource - UserTransaction tx; + private UserTransaction tx; /** * Tests context-service defined in a deployment descriptor. 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 cc482da7..bd5e71fb 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 @@ -44,7 +44,7 @@ public class DeploymentDescriptorWebTests extends TestClient { @ArquillianResource(DeploymentDescriptorServlet.class) - URL baseURL; + private URL baseURL; @Deployment(name = "DeploymentDescriptorTests") public static WebArchive createDeployment() { @@ -59,7 +59,7 @@ public static WebArchive createDeployment() { } @TestName - String testname; + private String testname; @Override protected String getServletPath() { From eab4c98a18449414deccae759d793974c351687c Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 11:20:44 -0500 Subject: [PATCH 07/14] TCK whitespace issues --- .../common/signature/ApiCheckDriver.java | 39 ++++++++++++----- .../ConcurrencySignatureTestRunner.java | 22 ++++++---- .../common/signature/PackageList.java | 3 +- .../common/signature/SigTestDriver.java | 43 +++++++++++++------ .../common/signature/SigTestEE.java | 4 +- .../common/signature/SignatureTestDriver.java | 24 ++++++----- 6 files changed, 89 insertions(+), 46 deletions(-) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java index 7514855e..79c8f26b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ApiCheckDriver.java @@ -55,16 +55,25 @@ protected String normalizeFileName(final File f) { } @Override - protected String[] createTestArguments(final String packageListFile, final String mapFile, final String signatureRepositoryDir, - final String packageOrClassUnderTest, final String classpath, final boolean bStaticMode) throws Exception { + protected String[] createTestArguments(final String packageListFile, final String mapFile, + final String signatureRepositoryDir, final String packageOrClassUnderTest, final String classpath, + final boolean bStaticMode) throws Exception { Class pkgListClass = Class.forName("javasoft.sqe.apiCheck.PackageList"); - Constructor pkgCtor = pkgListClass.getDeclaredConstructor(new Class[] { String.class }); - Object pkgInstance = pkgCtor.newInstance(new Object[] { packageListFile }); + Constructor pkgCtor = pkgListClass.getDeclaredConstructor(new Class[] { + String.class + }); + Object pkgInstance = pkgCtor.newInstance(new Object[] { + packageListFile + }); - Method pkgMethod = pkgListClass.getDeclaredMethod("getSubPackagesFormatted", new Class[] { String.class }); + Method pkgMethod = pkgListClass.getDeclaredMethod("getSubPackagesFormatted", new Class[] { + String.class + }); - String excludePkgs = (String) pkgMethod.invoke(pkgInstance, new Object[] { packageOrClassUnderTest }); + String excludePkgs = (String) pkgMethod.invoke(pkgInstance, new Object[] { + packageOrClassUnderTest + }); List sigArgsList = new LinkedList<>(); @@ -94,8 +103,12 @@ protected String[] createTestArguments(final String packageListFile, final Strin protected boolean runSignatureTest(final String packageOrClassName, final String[] testArguments) throws Exception { Class diffClass = Class.forName("javasoft.sqe.apiCheck.Diff"); - Method mainMethod = diffClass.getDeclaredMethod("main", new Class[] { String[].class }); - mainMethod.invoke(null, new Object[] { testArguments }); + Method mainMethod = diffClass.getDeclaredMethod("main", new Class[] { + String[].class + }); + mainMethod.invoke(null, new Object[] { + testArguments + }); Method diffMethod = diffClass.getDeclaredMethod("diffsFound", new Class[] {}); return (!((Boolean) diffMethod.invoke(null, new Object[] {})).booleanValue()); @@ -119,12 +132,16 @@ protected boolean runPackageSearch(final String packageOrClassName, final String // dump args for debugging aid System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); for (int ii = 0; ii < testArguments.length; ii++) { - System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + System.out.println("\t testArguments[" + ii + "] = " + testArguments[ii]); } Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + new Class[] { + String[].class, PrintWriter.class, PrintWriter.class + }); + runMethod.invoke(sigTestInstance, new Object[] { + testArguments, new PrintWriter(output, true), null + }); String rawMessages = output.toString(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index b666cf75..8038b0ad 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -45,7 +45,9 @@ public class ConcurrencySignatureTestRunner extends SigTestEE { public static final String SIG_MAP_NAME = "sig-test.map"; public static final String SIG_PKG_NAME = "sig-test-pkg-list.txt"; - public static final String[] SIG_RESOURCES = { SIG_FILE_NAME, SIG_MAP_NAME, SIG_PKG_NAME }; + public static final String[] SIG_RESOURCES = { + SIG_FILE_NAME, SIG_MAP_NAME, SIG_PKG_NAME + }; private static final TestLogger log = TestLogger.get(ConcurrencySignatureTestRunner.class); @@ -62,7 +64,9 @@ public ConcurrencySignatureTestRunner() { */ @Override protected String[] getPackages(final String vehicleName) { - return new String[] { "jakarta.enterprise.concurrent", "jakarta.enterprise.concurrent.spi" }; + return new String[] { + "jakarta.enterprise.concurrent", "jakarta.enterprise.concurrent.spi" + }; } @@ -75,14 +79,16 @@ protected String getClasspath() { return defined; } // The Jakarta artifacts we want added to our classpath - String[] classes = new String[] { "jakarta.enterprise.concurrent.AbortedException", // For - // jakarta.enterprise.concurrent-api-3.0.0.jar + String[] classes = new String[] { + "jakarta.enterprise.concurrent.AbortedException", // For jakarta.enterprise.concurrent-api-3.0.0.jar "jakarta.enterprise.util.Nonbinding", // For jakarta.enterprise.cdi-api-4.0.0.jar "jakarta.interceptor.InterceptorBinding" // For jakarta.interceptor-api-2.1.0.jar }; // The JDK modules we want added to our classpath - String[] jdkModules = new String[] { "java.base", "java.rmi", "java.sql", "java.naming" }; + String[] jdkModules = new String[] { + "java.base", "java.rmi", "java.sql", "java.naming" + }; // Get Jakarta artifacts from application server Set classPaths = new HashSet(); @@ -122,8 +128,8 @@ protected String getClasspath() { } - protected File writeStreamToTempFile(final InputStream inputStream, final String tempFilePrefix, final String tempFileSuffix) - throws IOException { + protected File writeStreamToTempFile(final InputStream inputStream, final String tempFilePrefix, + final String tempFileSuffix) throws IOException { FileOutputStream outputStream = null; try { @@ -273,7 +279,7 @@ public void signatureTest() throws Fault { String classpath = getClasspath(); try { - results = getSigTestDriver().executeSigTest( // + results = getSigTestDriver().executeSigTest( packageListFile, // file containing the packages/classes that are to be verified mapFile, // sig-test.map file signatureRepositoryDir, // directory containing the recorded signatures diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java index bcffeaca..bc047874 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/PackageList.java @@ -131,7 +131,8 @@ public PackageList(final String packageFileName) throws Exception { * @throws Exception when an error occurs reading the packageFileName or the * sigFileName does not exist. */ - public PackageList(final String packageName, final String sigFileName, final String packageFileName) throws Exception { + public PackageList(final String packageName, final String sigFileName, final String packageFileName) + throws Exception { this.additionalPackageName = packageName; sigFile = new File(sigFileName); if (!sigFile.exists() || !sigFile.isFile()) { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java index f0e07fce..190ae15b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java @@ -47,22 +47,24 @@ public class SigTestDriver extends SignatureTestDriver { private static final String CHECKVALUE_FLAG = "-CheckValue"; // only valid w/ // -static -// private static final String NO_CHECKVALUE_FLAG = "-NoCheckValue"; +// private static final String NO_CHECKVALUE_FLAG = "-NoCheckValue"; private static final String SMODE_FLAG = "-mode"; // requires arg of bin or // src -// private static final String DEBUG_FLAG = "-Debug"; +// private static final String DEBUG_FLAG = "-Debug"; -// private static final String FORMATPLAIN_FLAG = "-FormatPlain"; +// private static final String FORMATPLAIN_FLAG = "-FormatPlain"; private static final String EXCLUDE_JDK_CLASS_FLAG = "-IgnoreJDKClass"; - private static String[] excludeJdkClasses = { "java.util.Map", "java.lang.Object", "java.io.ByteArrayInputStream", + private static String[] excludeJdkClasses = { + "java.util.Map", "java.lang.Object", "java.io.ByteArrayInputStream", "java.io.InputStream", "java.lang.Deprecated", "java.io.Writer", "java.io.OutputStream", "java.util.List", "java.util.Collection", "java.lang.instrument.IllegalClassFormatException", "javax.transaction.xa.XAException", "java.lang.annotation.Repeatable", "java.lang.InterruptedException", - "java.lang.CloneNotSupportedException", "java.lang.Throwable", "java.lang.Thread", "java.lang.Enum" }; + "java.lang.CloneNotSupportedException", "java.lang.Throwable", "java.lang.Thread", "java.lang.Enum" + }; // ---------------------------------------- Methods from SignatureTestDriver @@ -78,8 +80,9 @@ protected String normalizeFileName(final File f) { } @Override - protected String[] createTestArguments(final String packageListFile, final String mapFile, final String signatureRepositoryDir, - final String packageOrClassUnderTest, final String classpath, final boolean bStaticMode) throws Exception { + protected String[] createTestArguments(final String packageListFile, final String mapFile, + final String signatureRepositoryDir, final String packageOrClassUnderTest, final String classpath, + final boolean bStaticMode) throws Exception { SignatureFileInfo info = getSigFileInfo(packageOrClassUnderTest, mapFile, signatureRepositoryDir); @@ -148,8 +151,12 @@ protected boolean runSignatureTest(final String packageOrClassName, final String } Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + new Class[] { + String[].class, PrintWriter.class, PrintWriter.class + }); + runMethod.invoke(sigTestInstance, new Object[] { + testArguments, new PrintWriter(output, true), null + }); String rawMessages = output.toString(); @@ -183,12 +190,16 @@ protected boolean runPackageSearch(final String packageOrClassName, final String // dump args for debugging aid System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); for (int ii = 0; ii < testArguments.length; ii++) { - System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + System.out.println("\t testArguments[" + ii + "] = " + testArguments[ii]); } Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + new Class[] { + String[].class, PrintWriter.class, PrintWriter.class + }); + runMethod.invoke(sigTestInstance, new Object[] { + testArguments, new PrintWriter(output, true), null + }); String rawMessages = output.toString(); @@ -231,8 +242,12 @@ protected boolean verifyJTAJarForNoXA(final String classpath, final String repos ByteArrayOutputStream output = new ByteArrayOutputStream(); Method runMethod = sigTestClass.getDeclaredMethod("run", - new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); - runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null }); + new Class[] { + String[].class, PrintWriter.class, PrintWriter.class + }); + runMethod.invoke(sigTestInstance, new Object[] { + testArguments, new PrintWriter(output, true), null + }); String rawMessages = output.toString(); // currently, there is no way to determine if there are error msgs in diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java index 88ed4595..e2ef3813 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java @@ -198,12 +198,12 @@ public void setup() { System.out.println("Unexpected exception " + e.getMessage()); } } - + protected SigTestData getTestInfo() { if (testInfo == null) { setup(); } - + return testInfo; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java index 9eb0727b..d178fab6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java @@ -166,9 +166,10 @@ public void cleanupImpl() throws Exception { * * @return a {@link SigTestResult} containing the result of the test execution */ - public SigTestResult executeSigTest(final String packageListFile, final String mapFile, final String signatureRepositoryDir, - final String[] packagesUnderTest, final String[] classesUnderTest, final String classpath, - final ArrayList unaccountedTechPkgs, final String optionalPkgToIgnore) throws Exception { + public SigTestResult executeSigTest(final String packageListFile, final String mapFile, + final String signatureRepositoryDir, final String[] packagesUnderTest, final String[] classesUnderTest, + final String classpath, final ArrayList unaccountedTechPkgs, final String optionalPkgToIgnore) + throws Exception { SigTestResult result = new SigTestResult(); @@ -369,8 +370,8 @@ public SigTestResult executeSigTest(final String packageListFile, final String m * have to specified using this parameter. */ protected abstract String[] createTestArguments(final String packageListFile, final String mapFile, - final String signatureRepositoryDir, final String packageOrClassUnderTest, final String classpath, final boolean bStaticMode) - throws Exception; + final String signatureRepositoryDir, final String packageOrClassUnderTest, final String classpath, + final boolean bStaticMode) throws Exception; /** * Invoke the underlying signature test framework for the specified package or @@ -382,7 +383,8 @@ protected abstract String[] createTestArguments(final String packageListFile, fi * * @return true if the test passed, otherwise false */ - protected abstract boolean runSignatureTest(final String packageOrClassName, final String[] testArguments) throws Exception; + protected abstract boolean runSignatureTest(final String packageOrClassName, final String[] testArguments) + throws Exception; /** * This checks if a class exists or not within the impl. @@ -392,7 +394,8 @@ protected abstract String[] createTestArguments(final String packageListFile, fi * @return true if the package was found to exist, otherwise * false */ - protected abstract boolean runPackageSearch(final String packageOrClassName, final String[] testArguments) throws Exception; + protected abstract boolean runPackageSearch(final String packageOrClassName, final String[] testArguments) + throws Exception; /** * This method checks whether JTA API jar contains classes from @@ -500,8 +503,8 @@ protected String getSigFileName(final String baseName, final String repositoryDi * @throws Exception if the determined signature file is not a regular file or * does not exist */ - protected SignatureFileInfo getSigFileInfo(final String originalPackage, final String mapFile, final String repositoryDir) - throws Exception { + protected SignatureFileInfo getSigFileInfo(final String originalPackage, final String mapFile, + final String repositoryDir) throws Exception { String packageName = originalPackage; String name = null; @@ -554,7 +557,8 @@ protected SignatureFileInfo getSigFileInfo(final String originalPackage, final S * arrayOptionalPkgsToIgnore matches the packageName then that means we return * TRUE to indicate we should ignore and NOT TEST that particular package. */ - private static boolean isIgnorePackageUnderTest(final String packageName, final String[] arrayOptionalPkgsToIgnore) { + private static boolean isIgnorePackageUnderTest(final String packageName, + final String[] arrayOptionalPkgsToIgnore) { // if anything is null - consider no match if ((packageName == null) || (arrayOptionalPkgsToIgnore == null)) { From b982cbfcd5530484a50d8de1d511f616a9b5f246 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 11:50:22 -0500 Subject: [PATCH 08/14] TCK coding errors --- .../api/LastExecution/LogicDrivenTrigger.java | 17 +++----- .../common/fixed/counter/StaticCounter.java | 10 +++-- .../common/signature/SigTestData.java | 1 - .../common/signature/SignatureTestDriver.java | 7 +-- .../transaction/CancelledTransactedTask.java | 5 ++- .../common/transaction/Connections.java | 4 +- .../tck/concurrent/framework/URLBuilder.java | 16 +++---- .../framework/junit/extensions/Wait.java | 25 ++++++----- ...ontextServiceDefinitionFromEJBServlet.java | 9 ++-- .../ContextServiceDefinitionServlet.java | 24 ++++++----- ...ManagedExecutorDefinitionOnEJBServlet.java | 1 - .../ManagedExecutorDefinitionServlet.java | 11 ++--- .../security/SecurityFullTests.java | 1 - .../tx/TransactionServlet.java | 1 - ...heduledExecutorDefinitionOnEJBServlet.java | 8 ++-- ...gedScheduledExecutorDefinitionServlet.java | 43 ++++++++++--------- .../tx/TransactionServlet.java | 1 - ...edThreadFactoryDefinitionOnEJBServlet.java | 15 ++++--- ...ManagedThreadFactoryDefinitionServlet.java | 15 ++++--- .../tx/TransactionServlet.java | 1 - 20 files changed, 108 insertions(+), 107 deletions(-) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java index 3ba2d596..571de733 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/api/LastExecution/LogicDrivenTrigger.java @@ -50,7 +50,7 @@ public LogicDrivenTrigger(final long delta, final String testName) { this.startTime = new Date(); } - private String getErrStr4NotEqual(final String testName, final Object expected, final Object real) { + private String getErrStr4NotEqual(final Object expected, final Object real) { String result = testName + "failed, "; result += "expected " + expected + ","; result += "but got " + real; @@ -59,12 +59,7 @@ private String getErrStr4NotEqual(final String testName, final Object expected, private boolean validateDateTimeEquals(final Date time1, final Date time2) { long diff = time1.getTime() - time2.getTime(); - - if (Math.abs(diff) < TIME_COMPARE_INACCURACY) { - return true; - } else { - return false; - } + return Math.abs(diff) < TIME_COMPARE_INACCURACY; } public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { @@ -88,7 +83,7 @@ public Date getNextRunTime(final LastExecution lastExecutionInfo, final Date tas public Date lastExecutionGetIdentityNameTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (!LastExecutionTests.IDENTITY_NAME_TEST_ID.equals(lastExecutionInfo.getIdentityName())) { - log.warning(getErrStr4NotEqual(testName, LastExecutionTests.IDENTITY_NAME_TEST_ID, + log.warning(getErrStr4NotEqual(LastExecutionTests.IDENTITY_NAME_TEST_ID, lastExecutionInfo.getIdentityName())); return null; } @@ -99,7 +94,7 @@ public Date lastExecutionGetIdentityNameTest(final LastExecution lastExecutionIn public Date lastExecutionGetResultRunnableTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (lastExecutionInfo.getResult() != null) { - log.warning(getErrStr4NotEqual(testName, null, lastExecutionInfo.getResult())); + log.warning(getErrStr4NotEqual(null, lastExecutionInfo.getResult())); return null; } @@ -109,7 +104,7 @@ public Date lastExecutionGetResultRunnableTest(final LastExecution lastExecution public Date lastExecutionGetResultCallableTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (!Integer.valueOf(1).equals(lastExecutionInfo.getResult())) { - log.warning(getErrStr4NotEqual(testName, 1, lastExecutionInfo.getResult())); + log.warning(getErrStr4NotEqual(1, lastExecutionInfo.getResult())); return null; } moreThanTwice = true; @@ -118,7 +113,7 @@ public Date lastExecutionGetResultCallableTest(final LastExecution lastExecution public Date lastExecutionGetRunningTimeTest(final LastExecution lastExecutionInfo, final Date taskScheduledTime) { if (!validateDateTimeEquals(this.startTime, lastExecutionInfo.getScheduledStart())) { - log.warning(getErrStr4NotEqual(testName, this.startTime, lastExecutionInfo.getScheduledStart())); + log.warning(getErrStr4NotEqual(this.startTime, lastExecutionInfo.getScheduledStart())); return null; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java index 600d76d0..546059e6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/fixed/counter/StaticCounter.java @@ -45,15 +45,17 @@ public static void reset() { public static void waitTill(final int expected) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (; expected != StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) - ; + for (; expected != StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) { + //empty + } }); } public static void waitTillSurpassed(final int expected) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (; expected <= StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) - ; + for (; expected <= StaticCounter.getCount(); Wait.sleep(TestConstants.pollInterval)) { + //empty + } }); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java index 4284b1c1..36e8d351 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java @@ -33,7 +33,6 @@ public class SigTestData { public SigTestData() { this.props = System.getProperties(); - ; } public String getVehicle() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java index d178fab6..a13c171a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java @@ -101,13 +101,8 @@ public String getMapFileImpl(final String binDir) { * */ public Boolean isJavaSEVersion(final String ver) { - String strOSVersion = System.getProperty("java.version"); - if (strOSVersion.startsWith(ver)) { - return true; - } else { - return false; - } + return strOSVersion.startsWith(ver); } /** diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java index fc6df469..1dee5aae 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/CancelledTransactedTask.java @@ -44,8 +44,9 @@ public CancelledTransactedTask(final String sqlTemplate) { private void waitForRun() { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (; !runQuery.get(); Wait.sleep(TestConstants.pollInterval)) - ; + for (; !runQuery.get(); Wait.sleep(TestConstants.pollInterval)) { + //empty + } }); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java index 8a6d48c4..a191c9cb 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/transaction/Connections.java @@ -28,8 +28,8 @@ private Connections() { private static DataSource ds; - public static void setDataSource(final DataSource ds) { - Connections.ds = ds; + public static void setDataSource(final DataSource dsIn) { + Connections.ds = dsIn; } public static void unsetDataSource() { diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java index b48f7797..30852bd1 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/URLBuilder.java @@ -50,8 +50,8 @@ public static URLBuilder get() { /** * Base URL obtained from ArquillianResource */ - public URLBuilder withBaseURL(final URL baseURL) { - this.baseURL = baseURL; + public URLBuilder withBaseURL(final URL baseURLIn) { + this.baseURL = baseURLIn; return this; } @@ -60,11 +60,11 @@ public URLBuilder withBaseURL(final URL baseURL) { * http://localhost:80/servlet/ query = count=5 result = * http://localhost:80/servlet/?count=5 */ - public URLBuilder withQueries(final String... queries) { + public URLBuilder withQueries(final String... queriesIn) { if (this.queries == null) { - this.queries = new ArrayList<>(Arrays.asList(queries)); + this.queries = new ArrayList<>(Arrays.asList(queriesIn)); } else { - this.queries.addAll(Arrays.asList(queries)); + this.queries.addAll(Arrays.asList(queriesIn)); } return this; } @@ -74,11 +74,11 @@ public URLBuilder withQueries(final String... queries) { * http://localhost:80/servlet/ path = app, inventory result = * http://localhost:80/servlet/app/inventory */ - public URLBuilder withPaths(final String... paths) { + public URLBuilder withPaths(final String... pathsIn) { if (this.paths == null) { - this.paths = new ArrayList<>(Arrays.asList(paths)); + this.paths = new ArrayList<>(Arrays.asList(pathsIn)); } else { - this.paths.addAll(Arrays.asList(paths)); + this.paths.addAll(Arrays.asList(pathsIn)); } return this; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java index 47c6a287..35d68a17 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/junit/extensions/Wait.java @@ -66,8 +66,9 @@ public static void waitForListenerComplete(final ManagedTaskListenerImpl managed public static void waitForListenerComplete(final ManagedTaskListenerImpl managedTaskListener, final Duration timeout, final Duration pollInterval) { assertTimeoutPreemptively(timeout, () -> { - for (; !managedTaskListener.eventCalled(ListenerEvent.DONE); sleep(TestConstants.pollInterval)) - ; + for (; !managedTaskListener.eventCalled(ListenerEvent.DONE); sleep(TestConstants.pollInterval)) { + //empty + } }); } @@ -84,8 +85,9 @@ public static void waitForListenerComplete(final ManagedTaskListenerImpl managed */ public static void waitTillFutureIsDone(final Future future) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (; !future.isDone(); sleep(TestConstants.pollInterval)) - ; + for (; !future.isDone(); sleep(TestConstants.pollInterval)) { + //empty + } }); } @@ -109,8 +111,9 @@ public static void waitTillFutureThrowsException(final Fut public static void waitCancelFuture(final Future future) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (future.cancel(true); !future.isDone(); sleep(TestConstants.pollInterval)) - ; + for (future.cancel(true); !future.isDone(); sleep(TestConstants.pollInterval)) { + //empty + } }); } @@ -123,15 +126,17 @@ public static void waitCancelFuture(final Future future) { */ public static void waitTillThreadFinish(final Thread thread) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (; thread.isAlive(); sleep(TestConstants.pollInterval)) - ; + for (; thread.isAlive(); sleep(TestConstants.pollInterval)) { + //empty + } }); } public static void waitForTransactionBegan(final CancelledTransactedTask task) { assertTimeoutPreemptively(TestConstants.waitTimeout, () -> { - for (; !task.getBeginTransaction().get(); sleep(TestConstants.pollInterval)) - ; + for (; !task.getBeginTransaction().get(); sleep(TestConstants.pollInterval)) { + //empty + } }); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java index a5391c11..49ed171e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionFromEJBServlet.java @@ -215,13 +215,14 @@ public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { } Object result; - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Contextual runnable did not start on thread."); + + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Contextual runnable did not start on thread."); assertEquals(result, Integer.valueOf(13), "Third-party context type IntContext must be propagated to contextual Runnable."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Contextual runnable did not complete on thread."); + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(results, "Contextual runnable did not complete on thread."); if (result instanceof Throwable) throw new AssertionError("Unable to look up java:comp name from contextual Runnable.") .initCause((Throwable) result); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java index f8ca6a44..c922dd30 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionServlet.java @@ -227,13 +227,14 @@ public void testContextServiceDefinitionDefaults() throws Throwable { } Object result; - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Contextual runnable did not start on thread."); + + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Contextual runnable did not start on thread."); assertEquals(result, Integer.valueOf(13), "Third-party context type IntContext must be propagated to contextual Runnable."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Contextual runnable did not complete on thread."); + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Contextual runnable did not complete on thread."); if (result instanceof Throwable) throw new AssertionError("Unable to look up java:comp name from contextual Runnable.") .initCause((Throwable) result); @@ -341,17 +342,20 @@ public void testContextualConsumer() throws Throwable { } Object result; - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Contextual Consumer did not start running."); + + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Contextual Consumer did not start running."); assertEquals(result, Integer.valueOf(121), "Third-party context type IntContext must be propagated to contextual Consumer " + "per java:app/concurrent/ContextA configuration."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Contextual Consumer did not continue running."); + + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Contextual Consumer did not continue running."); assertEquals(result, "", "Third-party context type StringContext must be cleared on contextual Consumer " + "per java:app/concurrent/ContextA configuration."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Contextual Consumer did not complete."); + + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Contextual Consumer did not complete."); if (result instanceof Throwable) throw new AssertionError("Application context must be propagated to contextual Consumer") .initCause((Throwable) result); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java index d677e0e7..33d82d7c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionOnEJBServlet.java @@ -150,7 +150,6 @@ public void testCopyCompletableFutureEJB() throws Throwable { + "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); - ; StringContext.set(null); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java index abcf44f2..058a4dd7 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java @@ -101,7 +101,6 @@ public void testAsyncCompletionStage() throws Throwable { + "per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); - ; StringContext.set(null); } } @@ -283,7 +282,6 @@ else if (failure == null) + "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); - ; StringContext.set(null); } } @@ -331,7 +329,6 @@ public void testCopyCompletableFuture() throws Throwable { + "unchanged per ManagedExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); - ; StringContext.set(null); } } @@ -443,13 +440,13 @@ public void testManagedExecutorDefinitionDefaults() throws Throwable { Callable txCallable = () -> { allTasksRunning.countDown(); - UserTransaction tx = InitialContext.doLookup("java:comp/UserTransaction"); - int initialStatus = tx.getStatus(); - tx.begin(); + UserTransaction trans = InitialContext.doLookup("java:comp/UserTransaction"); + int initialStatus = trans.getStatus(); + trans.begin(); try { blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); } finally { - tx.rollback(); + trans.rollback(); } return initialStatus; }; 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 55e11224..ac6c5fef 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 @@ -52,7 +52,6 @@ public static EnterpriseArchive createDeployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class); - ; EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "security.ear").addAsModules(war, jar); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java index d29b51cc..9d5ca16c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java @@ -98,7 +98,6 @@ public void cancelTest() { // continue to run if possible. cancelledTask.getRunQuery().set(true); - ; int afterTransacted = Counter.getCount(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java index f19c1e35..61cfe394 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionOnEJBServlet.java @@ -124,13 +124,13 @@ public void testManagedScheduledExecutorDefinitionDefaultsEJB() throws Throwable Callable txCallable = () -> { allTasksRunning.countDown(); - UserTransaction tx = InitialContext.doLookup("java:comp/UserTransaction"); - int initialStatus = tx.getStatus(); - tx.begin(); + UserTransaction trans = InitialContext.doLookup("java:comp/UserTransaction"); + int initialStatus = trans.getStatus(); + trans.begin(); try { blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); } finally { - tx.rollback(); + trans.rollback(); } return initialStatus; }; diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java index 437110b7..80e3e8db 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java @@ -111,7 +111,6 @@ public void testAsyncCompletionStageMSE() throws Throwable { + "per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); - ; StringContext.set(null); } @@ -220,10 +219,11 @@ public void testCompletedFutureMSE() throws Throwable { + "ManagedExecutorDefinition and ContextServiceDefinition config. " + "Instead, was able to look up " + result); } catch (CompletionException x) { - if (x.getCause() instanceof NamingException) - ; // expected - else + if (x.getCause() instanceof NamingException) { + //expected + } else { throw x; + } } IntContext.set(43); @@ -253,7 +253,6 @@ else if (failure == null) + "unchanged per ManagedScheduledExecutorDefinition and ContextServiceDefinition config."); } finally { IntContext.set(0); - ; StringContext.set(null); } @@ -374,13 +373,13 @@ public void testManagedScheduledExecutorDefinitionDefaults() throws Throwable { Callable txCallable = () -> { allTasksRunning.countDown(); - UserTransaction tx = InitialContext.doLookup("java:comp/UserTransaction"); - int initialStatus = tx.getStatus(); - tx.begin(); + UserTransaction trans = InitialContext.doLookup("java:comp/UserTransaction"); + int initialStatus = trans.getStatus(); + trans.begin(); try { blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); } finally { - tx.rollback(); + trans.rollback(); } return initialStatus; }; @@ -496,20 +495,21 @@ public void testScheduleWithCronTrigger() throws Throwable { assertTrue(distantFuture.cancel(true), "Must be able to cancel a repeating task before it runs: " + future); Object result; - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + everyOtherSecond + " did not run: " + future); + + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Task scheduled with " + everyOtherSecond + " did not run: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, "Application context must be propagated to first execution " + "per java:comp/concurrent/ScheduledExecutorC configuration."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + everyOtherSecond + " did not repeat: " + future); + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Task scheduled with " + everyOtherSecond + " did not repeat: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, "Application context must be propagated to second execution " + "per java:comp/concurrent/ScheduledExecutorC configuration."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + everyOtherSecond + " did not run 3 times: " + future); + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Task scheduled with " + everyOtherSecond + " did not run 3 times: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, "Application context must be propagated to third execution " + "per java:comp/concurrent/ScheduledExecutorC configuration."); @@ -571,20 +571,21 @@ public ZoneId getZoneId() { }, monthlyOnThe15th); try { Object result; - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + monthlyOnThe15th + " did not run: " + future); + + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Task scheduled with " + monthlyOnThe15th + " did not run: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, "Application context must be propagated to first execution " + "per java:comp/concurrent/ScheduledExecutorC configuration."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + monthlyOnThe15th + " did not repeat: " + future); + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Task scheduled with " + monthlyOnThe15th + " did not repeat: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, "Application context must be propagated to second execution " + "per java:comp/concurrent/ScheduledExecutorC configuration."); - assertNotNull(result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS), - "Task scheduled with " + monthlyOnThe15th + " did not run 3 times: " + future); + result = results.poll(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + assertNotNull(result, "Task scheduled with " + monthlyOnThe15th + " did not run 3 times: " + future); assertTrue(result instanceof ManagedScheduledExecutorService, "Application context must be propagated to third execution " + "per java:comp/concurrent/ScheduledExecutorC configuration."); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java index 519213db..3707fe30 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java @@ -97,7 +97,6 @@ public void cancelTest() { // continue to run if possible. cancelledTask.getRunQuery().set(true); - ; int afterTransacted = Counter.getCount(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java index e7f9bd37..fa9c7d07 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionOnEJBServlet.java @@ -153,13 +153,13 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { Runnable txTask = () -> { try { allThreadsRunning.countDown(); - UserTransaction tx = InitialContext.doLookup("java:comp/UserTransaction"); - int initialStatus = tx.getStatus(); - tx.begin(); + UserTransaction trans = InitialContext.doLookup("java:comp/UserTransaction"); + int initialStatus = trans.getStatus(); + trans.begin(); try { blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); } finally { - tx.rollback(); + trans.rollback(); } txTaskResult.complete(initialStatus); } catch (Throwable x) { @@ -177,13 +177,16 @@ public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { blocker.countDown(); Object result; - if ((result = txTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) + + result = txTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + if (result instanceof Throwable) throw new AssertionError().initCause((Throwable) result); assertEquals(result, Integer.valueOf(Status.STATUS_NO_TRANSACTION), "Transaction context must be cleared from async Callable task " + "per java:comp/concurrent/EJBThreadFactoryB configuration."); - if ((result = lookupTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) + result = lookupTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + if (result instanceof Throwable) throw new AssertionError().initCause((Throwable) result); assertTrue(result instanceof ManagedThreadFactory, "Application context must be propagated to first thread " + "per java:comp/concurrent/EJBThreadFactoryB configuration."); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java index a5f05457..2eef32a9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionServlet.java @@ -140,13 +140,13 @@ public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { Runnable txTask = () -> { try { allThreadsRunning.countDown(); - UserTransaction tx = InitialContext.doLookup("java:comp/UserTransaction"); - int initialStatus = tx.getStatus(); - tx.begin(); + UserTransaction trans = InitialContext.doLookup("java:comp/UserTransaction"); + int initialStatus = trans.getStatus(); + trans.begin(); try { blocker.await(MAX_WAIT_SECONDS * 5, TimeUnit.SECONDS); } finally { - tx.rollback(); + trans.rollback(); } txTaskResult.complete(initialStatus); } catch (Throwable x) { @@ -164,12 +164,15 @@ public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { blocker.countDown(); Object result; - if ((result = lookupTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) + + result = lookupTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + if (result instanceof Throwable) throw new AssertionError().initCause((Throwable) result); assertTrue(result instanceof ContextService, "Application context must be propagated to first thread " + "per java:comp/concurrent/ThreadFactoryB configuration."); - if ((result = txTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS)) instanceof Throwable) + result = txTaskResult.get(MAX_WAIT_SECONDS, TimeUnit.SECONDS); + if (result instanceof Throwable) throw new AssertionError().initCause((Throwable) result); assertEquals(result, Integer.valueOf(Status.STATUS_NO_TRANSACTION), "Transaction context must be cleared from async Callable task " diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java index 01944de2..a63ec6d8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java @@ -97,7 +97,6 @@ public void cancelTest() { // continue to run if possible. cancelledTask.getRunQuery().set(true); - ; int afterTransacted = Counter.getCount(); From b0e588d047d43e76f487ef67b85ac198996f1bfc Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 12:04:46 -0500 Subject: [PATCH 09/14] TCK blocking --- .../tck/concurrent/common/context/IntContext.java | 5 +++-- .../tck/concurrent/common/context/StringContext.java | 5 +++-- .../signature/ConcurrencySignatureTestRunner.java | 8 ++------ .../ManagedExecutorService/resourcedef/AppBean.java | 3 ++- .../ManagedExecutorDefinitionServlet.java | 12 +++++++----- .../ManagedScheduledExecutorDefinitionServlet.java | 12 +++++++----- 6 files changed, 24 insertions(+), 21 deletions(-) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java index 1cf7224f..5141676a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/IntContext.java @@ -31,9 +31,10 @@ public static int get() { } public static void set(final int value) { - if (value == 0) + if (value == 0) { local.remove(); - else + } else { local.set(value); + } } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java index 7a97cec0..9a4b6acd 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/context/StringContext.java @@ -31,9 +31,10 @@ public static String get() { } public static void set(final String value) { - if (value == null) + if (value == null) { local.remove(); - else + } else { local.set(value); + } } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index 8038b0ad..451a5813 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -144,9 +144,7 @@ protected File writeStreamToTempFile(final InputStream inputStream, final String outputStream.write(buffer, 0, bytesRead); } return file; - } - - finally { + } finally { if (outputStream != null) { outputStream.close(); } @@ -175,9 +173,7 @@ protected File writeStreamToSigFile(final InputStream inputStream) throws IOExce outputStream.write(buffer, 0, bytesRead); } return sigfile; - } - - finally { + } finally { if (outputStream != null) { outputStream.close(); } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java index 29ba976e..431f1ca3 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/AppBean.java @@ -60,9 +60,10 @@ public CompletableFuture waitAndGetIntContext(final Semaphore started, started.release(1); CompletableFuture future = Asynchronous.Result.getFuture(); try { - while (!future.isDone() && !blocker.await(300, TimeUnit.MILLISECONDS)) + while (!future.isDone() && !blocker.await(300, TimeUnit.MILLISECONDS)) { System.out.println( Thread.currentThread().getName() + ": waitAndGetIntContext awaiting signal from caller"); + } future.complete(IntContext.get()); } catch (Exception x) { future.completeExceptionally(x); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java index 058a4dd7..76ec8f29 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionServlet.java @@ -199,11 +199,12 @@ public void testAsynchronousMethodReturnsCompletionStage() throws Exception { "Two asynchronous method invocations should not run at same time per maxAsync=1."); stage1.thenAcceptBoth(stage2, (result1, result2) -> { - if (result1.equals(result2)) + if (result1.equals(result2)) { queue.add(StringContext.get()); - else + } else { queue.add("Both asynchronous method invocations must have same result. Instead: " + result1 + " and " + result2); + } }); } finally { StringContext.set(null); @@ -265,13 +266,14 @@ public void testCompletedFuture() throws Throwable { // CompletionException with chained NamingException is expected due to // Application context // remaining unchanged (absent) on the async completion stage action - if (failure instanceof CompletionException && failure.getCause() instanceof NamingException) + if (failure instanceof CompletionException && failure.getCause() instanceof NamingException) { return "StringContext " + ("testCompletedFuture-3".equals(s) ? "propagated" : "incorrect:" + s) + ";IntContext " + (i == 0 ? "unchanged" : "incorrect:" + i); - else if (failure == null) + } else if (failure == null) { throw new AssertionError("Missing Throwable argument to handleAsync"); - else + } else { throw new CompletionException(failure); + } }); StringContext.set("testCompletedFuture-4"); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java index 80e3e8db..d9c486b4 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionServlet.java @@ -236,13 +236,14 @@ public void testCompletedFutureMSE() throws Throwable { // CompletionException with chained NamingException is expected due to // Application context // remaining unchanged (absent) on the async completion stage action - if (failure instanceof CompletionException && failure.getCause() instanceof NamingException) + if (failure instanceof CompletionException && failure.getCause() instanceof NamingException) { return "StringContext " + ("testCompletedFutureMSE-3".equals(s) ? "propagated" : "incorrect:" + s) + ";IntContext " + (i == 43 ? "unchanged" : "incorrect:" + i); - else if (failure == null) + } else if (failure == null) { throw new AssertionError("Missing Throwable argument to exceptionally"); - else + } else { throw new CompletionException(failure); + } }); StringContext.set("testCompletedFutureMSE-4"); @@ -550,10 +551,11 @@ private void initSchedule() { @Override public ZonedDateTime getNextRunTime(final LastExecution lastExecution, final ZonedDateTime scheduledAt) { - if (lastExecution == null) + if (lastExecution == null) { initSchedule(); - else + } else { startAndEndTimes.put(lastExecution.getRunStart(usCentral), lastExecution.getRunEnd(usCentral)); + } long key = lastExecution == null ? 0L : lastExecution.getScheduledStart(usCentral).toEpochSecond(); return schedule.get(key); From 15a94707ab615d22f70f14977dd2d3608d953caa Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 12:24:10 -0500 Subject: [PATCH 10/14] TCK ignore javadoc --- tck/etc/config/checkstyle-suppressions.xml | 26 +++++++++++++++++++ tck/pom.xml | 16 +++++++++++- .../tx/TransactionServlet.java | 9 +++++-- .../tx/TransactionServlet.java | 9 +++++-- .../tx/TransactionServlet.java | 9 +++++-- 5 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 tck/etc/config/checkstyle-suppressions.xml diff --git a/tck/etc/config/checkstyle-suppressions.xml b/tck/etc/config/checkstyle-suppressions.xml new file mode 100644 index 00000000..1beb18f7 --- /dev/null +++ b/tck/etc/config/checkstyle-suppressions.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/tck/pom.xml b/tck/pom.xml index 35e996ce..7ca15d04 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -19,7 +19,7 @@ - + 4.0.0 @@ -143,6 +143,20 @@ + + + org.apache.maven.plugins + maven-checkstyle-plugin + + + etc/config/checkstyle-suppressions.xml + + + checkstyle.suppressions.file + + + + org.apache.maven.plugins maven-javadoc-plugin diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java index 9d5ca16c..dd664046 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/tx/TransactionServlet.java @@ -45,8 +45,13 @@ @SuppressWarnings({ "serial", "unused" }) @WebServlet(Constants.CONTEXT_PATH) -@DataSourceDefinition(name = "java:comp/env/jdbc/ManagedExecutorServiceDB", className = "org.apache.derby.jdbc.EmbeddedDataSource", databaseName = "memory:ManagedExecutorServiceDB", properties = { - "createDatabase=create" }) +@DataSourceDefinition( + name = "java:comp/env/jdbc/ManagedExecutorServiceDB", + className = "org.apache.derby.jdbc.EmbeddedDataSource", + databaseName = "memory:ManagedExecutorServiceDB", + properties = { + "createDatabase=create" + }) public class TransactionServlet extends TestServlet { private static final TestLogger log = TestLogger.get(TransactionServlet.class); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java index 3707fe30..cf342a11 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/tx/TransactionServlet.java @@ -45,8 +45,13 @@ @SuppressWarnings({ "serial", "unused" }) @WebServlet(Constants.CONTEXT_PATH) -@DataSourceDefinition(name = "java:comp/env/jdbc/ManagedScheduledExecutorServiceDB", className = "org.apache.derby.jdbc.EmbeddedDataSource", databaseName = "memory:ManagedScheduledExecutorServiceDB", properties = { - "createDatabase=create" }) +@DataSourceDefinition( + name = "java:comp/env/jdbc/ManagedScheduledExecutorServiceDB", + className = "org.apache.derby.jdbc.EmbeddedDataSource", + databaseName = "memory:ManagedScheduledExecutorServiceDB", + properties = { + "createDatabase=create" + }) public class TransactionServlet extends TestServlet { private static final TestLogger log = TestLogger.get(TransactionServlet.class); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java index a63ec6d8..c762b85a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/tx/TransactionServlet.java @@ -44,8 +44,13 @@ @SuppressWarnings("serial") @WebServlet(Constants.CONTEXT_PATH) -@DataSourceDefinition(name = "java:comp/env/jdbc/ManagedThreadFactoryDB", className = "org.apache.derby.jdbc.EmbeddedDataSource", databaseName = "memory:ManagedThreadFactoryDB", properties = { - "createDatabase=create" }) +@DataSourceDefinition( + name = "java:comp/env/jdbc/ManagedThreadFactoryDB", + className = "org.apache.derby.jdbc.EmbeddedDataSource", + databaseName = "memory:ManagedThreadFactoryDB", + properties = { + "createDatabase=create" + }) public class TransactionServlet extends TestServlet { private static final TestLogger log = TestLogger.get(TransactionServlet.class); From 97a306abf060b1aad89329c8ba1cc51f325a85db Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 13 Jul 2023 12:35:45 -0500 Subject: [PATCH 11/14] TCK regex issues --- tck/pom.xml | 6 +++++- .../tck/concurrent/common/signature/SigTestDriver.java | 6 +++--- .../spec/ManagedThreadFactory/context/ContextFullTests.java | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tck/pom.xml b/tck/pom.xml index 7ca15d04..86d9670c 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -143,7 +143,11 @@ - + + org.apache.maven.plugins maven-checkstyle-plugin diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java index 190ae15b..2ba84537 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestDriver.java @@ -63,7 +63,7 @@ public class SigTestDriver extends SignatureTestDriver { "java.io.InputStream", "java.lang.Deprecated", "java.io.Writer", "java.io.OutputStream", "java.util.List", "java.util.Collection", "java.lang.instrument.IllegalClassFormatException", "javax.transaction.xa.XAException", "java.lang.annotation.Repeatable", "java.lang.InterruptedException", - "java.lang.CloneNotSupportedException", "java.lang.Throwable", "java.lang.Thread", "java.lang.Enum" + "java.lang.CloneNotSupportedException", "java.lang.Throwable", "java.lang.Thread", "java.lang.Enum" }; // ---------------------------------------- Methods from SignatureTestDriver @@ -152,7 +152,7 @@ protected boolean runSignatureTest(final String packageOrClassName, final String Method runMethod = sigTestClass.getDeclaredMethod("run", new Class[] { - String[].class, PrintWriter.class, PrintWriter.class + String[].class, PrintWriter.class, PrintWriter.class }); runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null @@ -195,7 +195,7 @@ protected boolean runPackageSearch(final String packageOrClassName, final String Method runMethod = sigTestClass.getDeclaredMethod("run", new Class[] { - String[].class, PrintWriter.class, PrintWriter.class + String[].class, PrintWriter.class, PrintWriter.class }); runMethod.invoke(sigTestInstance, new Object[] { testArguments, new PrintWriter(output, true), null 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 a0f69050..df529cab 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 @@ -42,7 +42,7 @@ public class ContextFullTests extends TestClient { @Deployment(name = "ContextTests") public static EnterpriseArchive createDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class).addPackages(true, ContextFullTests.class.getPackage()) - .addPackages(false, PACKAGE.TASKS.getPackageName()).deleteClass(SecurityTestEjb.class) + .addPackages(false, PACKAGE.TASKS.getPackageName()).deleteClass(SecurityTestEjb.class) .deleteClass(SecurityTestInterface.class) .addAsWebInfResource(ContextFullTests.class.getPackage(), "web.xml", "web.xml"); From 3aeb427aa0ebc2a9f1a4a26a8a884d682bba2cbf Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Wed, 19 Jul 2023 12:05:22 -0500 Subject: [PATCH 12/14] Fixing bugs --- .../ConcurrencySignatureTestRunner.java | 10 +-- .../concurrent/common/signature/SigTest.java | 9 +-- .../common/signature/SigTestData.java | 30 ++++---- .../common/signature/SigTestEE.java | 27 +++---- .../extensions/TCKArchiveProcessor.java | 40 ++++++++++- .../extensions/TCKLoadableExtension.java | 1 - .../extensions/TCKSignatureProcessor.java | 72 ------------------- 7 files changed, 70 insertions(+), 119 deletions(-) delete mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java index 451a5813..6bdd6bb8 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/ConcurrencySignatureTestRunner.java @@ -113,7 +113,7 @@ protected String getClasspath() { // Get JDK modules from jimage // Add JDK classes to classpath - File jimageOutput = new File(getTestInfo().getJImageDir()); + File jimageOutput = new File(SigTestData.getJImageDir()); for (String module : jdkModules) { Path modulePath = Paths.get(jimageOutput.getAbsolutePath(), module); if (Files.isDirectory(modulePath)) { @@ -227,9 +227,9 @@ public void signatureTest() throws Fault { log.info("Exception while creating temp files :" + ex); } - String[] packagesUnderTest = getPackages(getTestInfo().getVehicle()); - String[] classesUnderTest = getClasses(getTestInfo().getVehicle()); - String optionalPkgToIgnore = getTestInfo().getOptionalTechPackagesToIgnore(); + String[] packagesUnderTest = getPackages(SigTestData.getVehicle()); + String[] classesUnderTest = getClasses(SigTestData.getVehicle()); + String optionalPkgToIgnore = SigTestData.getOptionalTechPackagesToIgnore(); // unlisted optional packages are technology packages for those optional // technologies (e.g. jsr-88) that might not have been specified by the @@ -243,7 +243,7 @@ public void signatureTest() throws Fault { Properties sysProps = System.getProperties(); String version = (String) sysProps.get("java.version"); if (!version.startsWith("1.")) { - String jimageDir = getTestInfo().getJImageDir(); + String jimageDir = SigTestData.getJImageDir(); File f = new File(jimageDir); f.mkdirs(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java index 686db173..191aca8f 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTest.java @@ -68,7 +68,7 @@ protected SignatureTestDriver getSigTestDriver() { * @return String The path and name of the package list file. */ protected String getPackageFile() { - return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); + return getSigTestDriver().getPackageFileImpl(SigTestData.getBinDir()); } /** @@ -85,7 +85,7 @@ protected String getPackageFile() { * @return String The path and name of the signature map file. */ protected String getMapFile() { - return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); + return getSigTestDriver().getMapFileImpl(SigTestData.getBinDir()); } /** @@ -98,7 +98,7 @@ protected String getMapFile() { * @return String The signature repository directory. */ protected String getRepositoryDir() { - return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); + return getSigTestDriver().getRepositoryDirImpl(SigTestData.getTSHome()); } /** @@ -155,8 +155,6 @@ protected String[] getClasses() { } // END getClasses - private SigTestData testInfo; // holds the bin.dir property - /** * Called by the test framework to initialize this test. The method simply * retrieves some state information that is necessary to run the test when when @@ -168,7 +166,6 @@ protected String[] getClasses() { public void setup() { try { System.out.println("$$$ SigTest.setup() called"); - this.testInfo = new SigTestData(); System.out.println("$$$ SigTest.setup() complete"); } catch (Exception e) { System.out.println("Unexpected exception " + e.getMessage()); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java index 36e8d351..f386aa3b 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestData.java @@ -27,51 +27,51 @@ * setup phase. This allows us to keep the passed data separate and reuse the * data between the signature test framework base classes. */ -public class SigTestData { +public final class SigTestData { - private Properties props; - - public SigTestData() { - this.props = System.getProperties(); + private SigTestData() { + // Helper class } - public String getVehicle() { + private static Properties props = System.getProperties(); + + public static String getVehicle() { return props.getProperty("vehicle", ""); } - public String getBinDir() { + public static String getBinDir() { return props.getProperty("bin.dir", ""); } - public String getTSHome() { + public static String getTSHome() { return props.getProperty("ts_home", ""); } - public String getTestClasspath() { + public static String getTestClasspath() { return props.getProperty("sigTestClasspath", ""); } - public String getJavaeeLevel() { + public static String getJavaeeLevel() { return props.getProperty("javaee.level", ""); } - public String getCurrentKeywords() { + public static String getCurrentKeywords() { return props.getProperty("current.keywords", ""); } - public String getProperty(final String prop) { + public static String getProperty(final String prop) { return props.getProperty(prop); } - public String getOptionalTechPackagesToIgnore() { + public static String getOptionalTechPackagesToIgnore() { return props.getProperty("optional.tech.packages.to.ignore", ""); } - public String getJtaJarClasspath() { + public static String getJtaJarClasspath() { return props.getProperty("jtaJarClasspath", ""); } - public String getJImageDir() { + public static String getJImageDir() { return props.getProperty("jimage.dir", ""); } } // end class SigTestData diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java index e2ef3813..bc01aee9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SigTestEE.java @@ -67,7 +67,7 @@ protected SignatureTestDriver getSigTestDriver() { * @return String The path and name of the package list file. */ protected String getPackageFile() { - return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); + return getSigTestDriver().getPackageFileImpl(SigTestData.getBinDir()); } /** @@ -84,7 +84,7 @@ protected String getPackageFile() { * @return String The path and name of the signature map file. */ protected String getMapFile() { - return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); + return getSigTestDriver().getMapFileImpl(SigTestData.getBinDir()); } /** @@ -97,7 +97,7 @@ protected String getMapFile() { * @return String The signature repository directory. */ protected String getRepositoryDir() { - return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); + return getSigTestDriver().getRepositoryDirImpl(SigTestData.getTSHome()); } /** @@ -182,8 +182,6 @@ protected String[] getClasses(final String vehicleName) { } // END getClasses - private SigTestData testInfo; // holds the bin.dir and vehicle properties - /** * Called by the test framework to initialize this test. The method simply * retrieves some state information that is necessary to run the test when when @@ -192,21 +190,12 @@ protected String[] getClasses(final String vehicleName) { public void setup() { try { System.out.println("$$$ SigTestEE.setup() called"); - this.testInfo = new SigTestData(); System.out.println("$$$ SigTestEE.setup() complete"); } catch (Exception e) { System.out.println("Unexpected exception " + e.getMessage()); } } - protected SigTestData getTestInfo() { - if (testInfo == null) { - setup(); - } - - return testInfo; - } - /** * Called by the test framework to run this test. This method utilizes the state * information set in the setup method to run the signature tests. All signature @@ -220,11 +209,11 @@ public void signatureTest() throws Fault { SigTestResult results = null; String mapFile = getMapFile(); String repositoryDir = getRepositoryDir(); - String[] packages = getPackages(testInfo.getVehicle()); - String[] classes = getClasses(testInfo.getVehicle()); + String[] packages = getPackages(SigTestData.getVehicle()); + String[] classes = getClasses(SigTestData.getVehicle()); String packageFile = getPackageFile(); - String testClasspath = testInfo.getTestClasspath(); - String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); + String testClasspath = SigTestData.getTestClasspath(); + String optionalPkgToIgnore = SigTestData.getOptionalTechPackagesToIgnore(); // unlisted optional packages are technology packages for those optional // technologies (e.g. jsr-88) that might not have been specified by the @@ -238,7 +227,7 @@ public void signatureTest() throws Fault { Properties sysProps = System.getProperties(); String version = (String) sysProps.get("java.version"); if (!version.startsWith("1.")) { - String jimageDir = testInfo.getJImageDir(); + String jimageDir = SigTestData.getJImageDir(); File f = new File(jimageDir); f.mkdirs(); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java index ccb468d1..bb63d448 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java @@ -15,6 +15,7 @@ */ package ee.jakarta.tck.concurrent.framework.arquillian.extensions; +import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import java.util.stream.Collectors; @@ -24,11 +25,14 @@ import org.jboss.arquillian.test.spi.TestClass; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.container.ClassContainer; +import org.jboss.shrinkwrap.api.container.ResourceContainer; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; +import ee.jakarta.tck.concurrent.common.signature.ConcurrencySignatureTestRunner; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; +import ee.jakarta.tck.concurrent.framework.junit.anno.Signature; /** * This extension will intercept archives before they are deployed to the @@ -39,9 +43,16 @@ public class TCKArchiveProcessor implements ApplicationArchiveProcessor { @Override public void process(final Archive applicationArchive, final TestClass testClass) { - String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() + String applicationName = applicationArchive.getName() == null + ? applicationArchive.getId() : applicationArchive.getName(); + + appendCommonPackages(applicationArchive, testClass, applicationName); + appendSignaturePackages(applicationArchive, testClass, applicationName); + } + + private static void appendCommonPackages(final Archive applicationArchive, final TestClass testClass, final String applicationName) { if (!testClass.isAnnotationPresent(Common.class)) { return; } @@ -59,6 +70,33 @@ public void process(final Archive applicationArchive, final TestClass testCla packages.stream().forEach(pkg -> ((ClassContainer) applicationArchive).addPackage(pkg)); } + } + + private static void appendSignaturePackages(final Archive applicationArchive, final TestClass testClass, final String applicationName) { + + if (!testClass.isAnnotationPresent(Signature.class)) { + return; + } + + final boolean isJava21orAbove = Integer.parseInt(System.getProperty("java.specification.version")) >= 21; + final Package signaturePackage = ConcurrencySignatureTestRunner.class.getPackage(); + if (applicationArchive instanceof ClassContainer) { + log.info("Application Archive [" + applicationName + "] is being appended with packages [" + + signaturePackage + ", com.sun.tdk, org.netbeans.apitest]"); + log.info("Application Archive [" + applicationName + "] is being appended with resources " + + Arrays.asList(ConcurrencySignatureTestRunner.SIG_RESOURCES)); + ((ClassContainer) applicationArchive).addPackage(signaturePackage); + // These are the packages from the sig-test plugin that are needed to run the test. + ((ClassContainer) applicationArchive).addPackages(true, "com.sun.tdk", "org.netbeans.apitest"); + ((ResourceContainer) applicationArchive).addAsResources(signaturePackage, + ConcurrencySignatureTestRunner.SIG_MAP_NAME, ConcurrencySignatureTestRunner.SIG_PKG_NAME); + ((ResourceContainer) applicationArchive).addAsResource(signaturePackage, + // Get local resource based on JDK level + isJava21orAbove ? ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_21" + : ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_17", + // Target same package as test + signaturePackage.getName().replace(".", "/") + "/" + ConcurrencySignatureTestRunner.SIG_FILE_NAME); + } } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java index c83067fa..7c387efa 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKLoadableExtension.java @@ -27,7 +27,6 @@ public class TCKLoadableExtension implements LoadableExtension { @Override public void register(final ExtensionBuilder builder) { builder.service(ApplicationArchiveProcessor.class, TCKArchiveProcessor.class); - builder.service(ApplicationArchiveProcessor.class, TCKSignatureProcessor.class); builder.service(AuxiliaryArchiveAppender.class, TCKFrameworkAppender.class); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java deleted file mode 100644 index f2aa28eb..00000000 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKSignatureProcessor.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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.arquillian.extensions; - -import java.util.Arrays; -import java.util.logging.Logger; - -import org.jboss.arquillian.container.test.spi.client.deployment.ApplicationArchiveProcessor; -import org.jboss.arquillian.test.spi.TestClass; -import org.jboss.shrinkwrap.api.Archive; -import org.jboss.shrinkwrap.api.container.ClassContainer; -import org.jboss.shrinkwrap.api.container.ResourceContainer; - -import ee.jakarta.tck.concurrent.common.signature.ConcurrencySignatureTestRunner; -import ee.jakarta.tck.concurrent.framework.junit.anno.Full; -import ee.jakarta.tck.concurrent.framework.junit.anno.Signature; - -/** - * This extension will intercept archives before they are deployed to the - * container and append the signature files. - */ -public class TCKSignatureProcessor implements ApplicationArchiveProcessor { - private static final Logger log = Logger.getLogger(TCKSignatureProcessor.class.getCanonicalName()); - - private static final Package signaturePackage = ConcurrencySignatureTestRunner.class.getPackage(); - - @Override - public void process(final Archive applicationArchive, final TestClass testClass) { - String applicationName = applicationArchive.getName() == null ? applicationArchive.getId() - : applicationArchive.getName(); - - if (!testClass.isAnnotationPresent(Signature.class)) { - return; - } - - if (testClass.isAnnotationPresent(Full.class)) { - throw new RuntimeException("Signature tests must be run using the @Web annotation"); - } - - boolean isJava21orAbove = Integer.parseInt(System.getProperty("java.specification.version")) >= 21; - - if (applicationArchive instanceof ClassContainer) { - log.info("Application Archive [" + applicationName + "] is being appended with packages [" - + signaturePackage + "]"); - log.info("Application Archive [" + applicationName + "] is being appended with resources " - + Arrays.asList(ConcurrencySignatureTestRunner.SIG_RESOURCES)); - ((ClassContainer) applicationArchive).addPackage(signaturePackage); - ((ResourceContainer) applicationArchive).addAsResources(signaturePackage, - ConcurrencySignatureTestRunner.SIG_MAP_NAME, ConcurrencySignatureTestRunner.SIG_PKG_NAME); - ((ResourceContainer) applicationArchive).addAsResource(signaturePackage, - // Get local resource based on JDK level - isJava21orAbove ? ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_21" - : ConcurrencySignatureTestRunner.SIG_FILE_NAME + "_17", - // Target same package as test - signaturePackage.getName().replace(".", "/") + "/" + ConcurrencySignatureTestRunner.SIG_FILE_NAME); - } - - } -} From 0eea2c00fbc7581e2d5827f26f93231e55e021df Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Tue, 1 Aug 2023 11:05:20 -0500 Subject: [PATCH 13/14] Cleanup signature testing --- tck/pom.xml | 15 +++++++++- .../common/signature/SignatureTestDriver.java | 4 +-- .../extensions/TCKArchiveProcessor.java | 30 +++++++++++++------ .../extensions/TCKFrameworkAppender.java | 6 ++-- 4 files changed, 40 insertions(+), 15 deletions(-) diff --git a/tck/pom.xml b/tck/pom.xml index 86d9670c..a6687316 100644 --- a/tck/pom.xml +++ b/tck/pom.xml @@ -49,6 +49,7 @@ 3.1.0-SNAPSHOT 1.6 + 3.2.1 @@ -58,36 +59,42 @@ ${jakarta.concurrent.api.version} provided + jakarta.servlet jakarta.servlet-api + provided jakarta.servlet.jsp jakarta.servlet.jsp-api + provided jakarta.ejb jakarta.ejb-api + provided jakarta.annotation jakarta.annotation-api + provided jakarta.interceptor jakarta.interceptor-api + provided jakarta.enterprise jakarta.enterprise.cdi-api + provided org.netbeans.tools sigtest-maven-plugin ${sigtest.version} - provided org.junit.jupiter @@ -99,6 +106,12 @@ arquillian-junit5-container ${arquillian.version} + + org.jboss.shrinkwrap.resolver + shrinkwrap-resolver-impl-maven + ${shrinkwrap.resolver.version} + + diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java index a13c171a..1474fb8c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/signature/SignatureTestDriver.java @@ -490,7 +490,7 @@ protected String getSigFileName(final String baseName, final String repositoryDi * * @param packageName The package under test * @param mapFile The name of the file that maps package names to versions - * @param repositoryDir The directory that conatisn all signature files + * @param repositoryDir The directory that contains all signature files * * @return String The path and name of the siganture file that contains the * specified package's signatures @@ -533,7 +533,7 @@ protected SignatureFileInfo getSigFileInfo(final String originalPackage, final S throw new Exception( "Package \"" + originalPackage + "\" not specified in mapping file \"" + mapFile + "\"."); } - packageName.substring(0, index); + packageName = packageName.substring(0, index); } // end while /* Return the expected name of the signature file */ diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java index bb63d448..adba27d6 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKArchiveProcessor.java @@ -15,6 +15,7 @@ */ package ee.jakarta.tck.concurrent.framework.arquillian.extensions; +import java.io.File; import java.util.Arrays; import java.util.List; import java.util.logging.Logger; @@ -25,10 +26,12 @@ import org.jboss.arquillian.test.spi.TestClass; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.container.ClassContainer; +import org.jboss.shrinkwrap.api.container.LibraryContainer; import org.jboss.shrinkwrap.api.container.ResourceContainer; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.jboss.shrinkwrap.resolver.api.maven.Maven; import ee.jakarta.tck.concurrent.common.signature.ConcurrencySignatureTestRunner; import ee.jakarta.tck.concurrent.framework.junit.anno.Common; @@ -54,14 +57,18 @@ public void process(final Archive applicationArchive, final TestClass testCla private static void appendCommonPackages(final Archive applicationArchive, final TestClass testClass, final String applicationName) { if (!testClass.isAnnotationPresent(Common.class)) { - return; + return; //Nothing to append } List packages = Stream.of(testClass.getAnnotation(Common.class).value()) .map(pkg -> pkg.getPackageName()).collect(Collectors.toList()); + + if (packages.isEmpty()) { + return; //Nothing to append + } // TODO research to see if there is a way around this - if (applicationArchive instanceof EnterpriseArchive && !packages.isEmpty()) { + if (applicationArchive instanceof EnterpriseArchive) { throw new RuntimeException("Cannot append packages to Enterprise Archives since modules are immutable"); } @@ -73,22 +80,27 @@ private static void appendCommonPackages(final Archive applicationArchive, fi } private static void appendSignaturePackages(final Archive applicationArchive, final TestClass testClass, final String applicationName) { - if (!testClass.isAnnotationPresent(Signature.class)) { - return; + return; //Nothing to append } final boolean isJava21orAbove = Integer.parseInt(System.getProperty("java.specification.version")) >= 21; final Package signaturePackage = ConcurrencySignatureTestRunner.class.getPackage(); if (applicationArchive instanceof ClassContainer) { - log.info("Application Archive [" + applicationName + "] is being appended with packages [" - + signaturePackage + ", com.sun.tdk, org.netbeans.apitest]"); + + // Add the Concurrency runner + log.info("Application Archive [" + applicationName + "] is being appended with packages [" + signaturePackage + "]"); + ((ClassContainer) applicationArchive).addPackage(signaturePackage); + + // Add the sigtest plugin library + File sigTestDep = Maven.resolver().resolve("org.netbeans.tools:sigtest-maven-plugin:1.6").withoutTransitivity().asSingleFile(); + log.info("Application Archive [" + applicationName + "] is being appended with library " + sigTestDep.getName()); + ((LibraryContainer) applicationArchive).addAsLibrary(sigTestDep); + + // Add signature resources log.info("Application Archive [" + applicationName + "] is being appended with resources " + Arrays.asList(ConcurrencySignatureTestRunner.SIG_RESOURCES)); - ((ClassContainer) applicationArchive).addPackage(signaturePackage); - // These are the packages from the sig-test plugin that are needed to run the test. - ((ClassContainer) applicationArchive).addPackages(true, "com.sun.tdk", "org.netbeans.apitest"); ((ResourceContainer) applicationArchive).addAsResources(signaturePackage, ConcurrencySignatureTestRunner.SIG_MAP_NAME, ConcurrencySignatureTestRunner.SIG_PKG_NAME); ((ResourceContainer) applicationArchive).addAsResource(signaturePackage, diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java index df7065d9..34827a76 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/arquillian/extensions/TCKFrameworkAppender.java @@ -30,9 +30,9 @@ * This extension will intercept all archives before they are deployed to the * container and append a library with the following: * - * Package - ee.jakarta.tck.concurrent.framework Package - - * ee.jakarta.tck.concurrent.framework.arquillian.extensions Package - - * ee.jakarta.tck.concurrent.framework.junit.extensions + * Package - ee.jakarta.tck.concurrent.framework + * Package - ee.jakarta.tck.concurrent.framework.arquillian.extensions + * Package - ee.jakarta.tck.concurrent.framework.junit.extensions * */ public class TCKFrameworkAppender implements AuxiliaryArchiveAppender { From 821ce06762f2177f4aa531253f4ae2df56d6b017 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Tue, 1 Aug 2023 11:28:58 -0500 Subject: [PATCH 14/14] Everything is a module --- .github/workflows/ci.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5359dbd..9b8010ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,9 +28,5 @@ jobs: java-version: ${{ matrix.java-version }} distribution: 'temurin' cache: maven - - name: Build API and TCK + - name: Build API, SPEC, and TCK run: mvn -B install --file pom.xml - - name: Build SPEC - run: mvn -B package --file specification/pom.xml - - name: Build TCK-DIST - run: mvn -B package --file tck-dist/pom.xml \ No newline at end of file