From b9bf0ff3dc4693486b64504e47a45184a068af27 Mon Sep 17 00:00:00 2001 From: Richard Zowalla Date: Tue, 13 Oct 2026 14:52:59 +0200 Subject: [PATCH] make the scan exclusion and async MP-JWT tests independent of their environment Check the excluded webapp jars directly instead of capturing a log record, and let the fake AsyncContext return null instead of throwing in getRequest. --- .../openejb/config/NewLoaderLogicTest.java | 43 +++---------------- .../jwt/MPJWTFilterExitWebAppTest.java | 4 +- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/NewLoaderLogicTest.java b/container/openejb-core/src/test/java/org/apache/openejb/config/NewLoaderLogicTest.java index f62892fe84d..0b88b304c07 100644 --- a/container/openejb-core/src/test/java/org/apache/openejb/config/NewLoaderLogicTest.java +++ b/container/openejb-core/src/test/java/org/apache/openejb/config/NewLoaderLogicTest.java @@ -16,7 +16,7 @@ */ package org.apache.openejb.config; -import org.apache.openejb.util.LogCategory; +import org.apache.xbean.finder.filter.Filters; import org.junit.Test; import java.io.File; @@ -26,9 +26,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -59,39 +56,11 @@ public void reportWebappJarsDroppedByContainerExclusions() throws Exception { exclusions.getParentFile().mkdirs(); Files.write(exclusions.toPath(), "internal-\n".getBytes(StandardCharsets.UTF_8)); - final List records = new ArrayList<>(); - final Handler handler = new Handler() { - @Override - public void publish(final LogRecord record) { - records.add(record); - } + final List scannable = DeploymentLoader.filterWebappUrls(webUrls, null, exclusions.toURI().toURL()); + assertEquals(Collections.singletonList(appJar), scannable); - @Override - public void flush() { - // no-op - } - - @Override - public void close() { - // no-op - } - }; - final Logger logger = Logger.getLogger(LogCategory.OPENEJB_STARTUP_CONFIG.getName()); - logger.addHandler(handler); - try { - final List scannable = DeploymentLoader.filterWebappUrls(webUrls, null, exclusions.toURI().toURL()); - assertEquals(Collections.singletonList(appJar), scannable); - } finally { - logger.removeHandler(handler); - } - - final List messages = new ArrayList<>(); - for (final LogRecord record : records) { - if (record.getMessage().startsWith("Application jars not scanned")) { - messages.add(record.getMessage()); - } - } - assertEquals(1, messages.size()); - assertTrue(messages.get(0), messages.get(0).contains("[ant-reporting-web.jar (prefix 'ant-')]")); + // only the application jar dropped by the container list is reported, not the one excluded by the app itself + assertEquals(Collections.singletonList("ant-reporting-web.jar (prefix 'ant-')"), + new ArrayList<>(DeploymentLoader.builtinExcludedWebappJars(webUrls, scannable, Filters.prefixes("internal-")))); } } diff --git a/mp-jwt/src/test/java/org/apache/tomee/microprofile/jwt/MPJWTFilterExitWebAppTest.java b/mp-jwt/src/test/java/org/apache/tomee/microprofile/jwt/MPJWTFilterExitWebAppTest.java index 28dab8844b0..e6cfa2de854 100644 --- a/mp-jwt/src/test/java/org/apache/tomee/microprofile/jwt/MPJWTFilterExitWebAppTest.java +++ b/mp-jwt/src/test/java/org/apache/tomee/microprofile/jwt/MPJWTFilterExitWebAppTest.java @@ -359,12 +359,12 @@ public void addListener(final AsyncListener listener, final ServletRequest reque @Override public ServletRequest getRequest() { - throw new UnsupportedOperationException(); + return null; // AsyncEvent(AsyncContext) reads both with some Servlet API versions } @Override public ServletResponse getResponse() { - throw new UnsupportedOperationException(); + return null; // AsyncEvent(AsyncContext) reads both with some Servlet API versions } @Override