This is an automated email from the ASF dual-hosted git repository.
rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/main by this push:
new 0f97a18b20 Fix the tests that fail with Surefire 3.6
0f97a18b20 is described below
commit 0f97a18b203c5c386193b535c1b30885195dcca0
Author: Richard Zowalla <[email protected]>
AuthorDate: Mon Nov 2 20:33:53 2026 +0100
Fix the tests that fail with Surefire 3.6
Surefire 3.6 captures a stack trace for every write to System.out of a
forked test JVM. The server composer Pipe copied the TomEE output byte by
byte, so the microprofile-jwt-itests log watchers fell behind the HTTP
responses and missed the expected log lines. Copy the output per line
instead; the input is still read byte by byte because the swizzle watchers
block a byte[] read until it is full. The openejb-core Pipe gets an 8 KB
buffer for the same reason.
RealmInWebAppForEjbRemoteTest logged in through a remote InitialContext
and never closed it. The remote adapter executions reuse the fork, and
with Surefire 3.6 every following test class failed to deploy with
"Client identity is not valid". Close the context to log out.
---
.../tests/realm/RealmInWebAppForEjbRemoteTest.java | 8 ++++++--
.../main/java/org/apache/openejb/util/Pipe.java | 2 +-
.../org/apache/tomee/server/composer/Pipe.java | 22 ++++++++++++++++++++--
3 files changed, 27 insertions(+), 5 deletions(-)
diff --git
a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/RealmInWebAppForEjbRemoteTest.java
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/RealmInWebAppForEjbRemoteTest.java
index 533e72bb99..7e6a94426f 100644
---
a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/RealmInWebAppForEjbRemoteTest.java
+++
b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/RealmInWebAppForEjbRemoteTest.java
@@ -66,7 +66,11 @@ public class RealmInWebAppForEjbRemoteTest
p.put(Context.SECURITY_CREDENTIALS, "ee");
p.put("openejb.authentication.realmName", "realm-test"); // webapp
name to force login using the matching realm
final Context ctx = new InitialContext(p);
- final Simple myBean =
Simple.class.cast(ctx.lookup("java:global/realm-test/SimpleEJB!" +
Simple.class.getName()));
- assertEquals("tom", myBean.name());
+ try {
+ final Simple myBean =
Simple.class.cast(ctx.lookup("java:global/realm-test/SimpleEJB!" +
Simple.class.getName()));
+ assertEquals("tom", myBean.name());
+ } finally {
+ ctx.close(); // logs out
+ }
}
}
diff --git
a/container/openejb-core/src/main/java/org/apache/openejb/util/Pipe.java
b/container/openejb-core/src/main/java/org/apache/openejb/util/Pipe.java
index 6bc42b3e71..cb0a803743 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/Pipe.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/Pipe.java
@@ -58,7 +58,7 @@ public final class Pipe implements Runnable {
try {
int i;
- final byte[] buf = new byte[1];
+ final byte[] buf = new byte[8192];
while ((i = in.read(buf)) != -1) {
out.write(buf, 0, i);
diff --git
a/itests/tomee-server-composer/src/main/java/org/apache/tomee/server/composer/Pipe.java
b/itests/tomee-server-composer/src/main/java/org/apache/tomee/server/composer/Pipe.java
index 0d3dbf5000..1e528c32b1 100644
---
a/itests/tomee-server-composer/src/main/java/org/apache/tomee/server/composer/Pipe.java
+++
b/itests/tomee-server-composer/src/main/java/org/apache/tomee/server/composer/Pipe.java
@@ -17,6 +17,7 @@
package org.apache.tomee.server.composer;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.concurrent.Future;
@@ -49,17 +50,34 @@ public final class Pipe implements Runnable {
}
public synchronized void run() {
+ // read byte by byte (the watchers block a byte[] read until it is
full) but copy per line:
+ // Surefire 3.6+ captures a stack trace for every write to a forked
test JVM's System.out
+ final byte[] buffer = new byte[8192];
+ int length = 0;
try {
int i = -1;
while ((i = in.read()) != -1) {
out.write(i);
- for (final OutputStream stream : cc) {
- stream.write(i);
+ buffer[length++] = (byte) i;
+ if (i == '\n' || length == buffer.length || in.available() ==
0) {
+ copy(buffer, length);
+ length = 0;
}
}
+ copy(buffer, length);
} catch (final Exception e) {
e.printStackTrace();
}
}
+
+ private void copy(final byte[] buffer, final int length) throws
IOException {
+ if (length == 0) {
+ return;
+ }
+ for (final OutputStream stream : cc) {
+ stream.write(buffer, 0, length);
+ stream.flush();
+ }
+ }
}