This is an automated email from the ASF dual-hosted git repository. rzo1 pushed a commit to branch concurency in repository https://gitbox.apache.org/repos/asf/tomee.git
commit 020017b41d25fe3ef522942a2e969c3502ee9424 Author: Richard Zowalla <[email protected]> AuthorDate: Thu Apr 2 14:48:16 2026 +0200 Add multiple schedules and maxAsync unit tests for scheduled async Extend TCK-style test coverage with multipleSchedules (composite trigger with two @Schedule annotations) and ignoresMaxAsync (concurrent scheduled method invocations). Both pass — remaining TCK failures for these tests are JNDI scoping issues with java:module/ executor names. --- .../AsynchronousScheduledTCKStyleTest.java | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/container/openejb-core/src/test/java/org/apache/openejb/cdi/concurrency/AsynchronousScheduledTCKStyleTest.java b/container/openejb-core/src/test/java/org/apache/openejb/cdi/concurrency/AsynchronousScheduledTCKStyleTest.java index b2a13cae21..b6a5f7555e 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/cdi/concurrency/AsynchronousScheduledTCKStyleTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/cdi/concurrency/AsynchronousScheduledTCKStyleTest.java @@ -157,6 +157,44 @@ public class AsynchronousScheduledTCKStyleTest { } } + /** + * TCK: testScheduledAsynchWithMultipleSchedules + * Method with two @Schedule annotations — should use composite trigger. + */ + @Test + public void scheduledWithMultipleSchedules() throws Exception { + final AtomicInteger counter = new AtomicInteger(); + final CompletableFuture<String> future = reqBean.scheduledMultipleSchedules(1, counter); + + assertNotNull("Future should be returned by interceptor", future); + + final String result = future.get(15, TimeUnit.SECONDS); + assertNotNull("Should have completed with a result", result); + assertEquals("Should have run exactly once", 1, counter.get()); + } + + /** + * TCK: testScheduledAsynchIgnoresMaxAsync + * Multiple concurrent scheduled async method invocations should all run regardless of maxAsync. + * Here we just verify that the scheduled method works when called multiple times. + */ + @Test + public void scheduledIgnoresMaxAsync() throws Exception { + final AtomicInteger counter1 = new AtomicInteger(); + final AtomicInteger counter2 = new AtomicInteger(); + final CompletableFuture<Integer> future1 = reqBean.scheduledEverySecond(3, ReturnType.COMPLETE_RESULT, counter1); + final CompletableFuture<Integer> future2 = reqBean.scheduledEverySecond(3, ReturnType.COMPLETE_RESULT, counter2); + + assertNotNull("First future should not be null", future1); + assertNotNull("Second future should not be null", future2); + + // Both should complete + final Integer result1 = future1.get(15, TimeUnit.SECONDS); + final Integer result2 = future2.get(15, TimeUnit.SECONDS); + assertEquals(Integer.valueOf(3), result1); + assertEquals(Integer.valueOf(3), result2); + } + // --- Bean --- public enum ReturnType { @@ -205,6 +243,20 @@ public class AsynchronousScheduledTCKStyleTest { } } + @Asynchronous(runAt = { + @Schedule(cron = "* * * * * *"), + @Schedule(cron = "*/2 * * * * *") + }) + public CompletableFuture<String> scheduledMultipleSchedules(final int runs, final AtomicInteger counter) { + final int count = counter.incrementAndGet(); + if (runs != count) { + return null; + } + final CompletableFuture<String> future = Asynchronous.Result.getFuture(); + future.complete("completed-" + count); + return future; + } + @Asynchronous(executor = "java:comp/env/invalid/executor", runAt = @Schedule(cron = "* * * * * *")) public CompletableFuture<String> scheduledInvalidExecutor() {
