Skip to content

Conversation

Copy link

Copilot AI commented Oct 27, 2025

Enables redirecting Open Test Reporting XML events to a socket instead of a file, using the Writer-based API introduced in open-test-reporting 0.2.5.

Configuration

  • New parameter: junit.platform.reporting.open.xml.socket=<port>
  • When set, connects to localhost:<port> and streams XML events to the socket
  • Falls back to file-based output when not configured

Implementation

  • createDocumentWriter() method checks for socket config and delegates to appropriate Events.createDocumentWriter() overload
  • Uses OutputStreamWriter with UTF-8 encoding for socket output
  • Socket lifecycle tied to DocumentWriter lifecycle (closes automatically)
  • Validates port as integer with descriptive error on parse failure

Example Usage

<!-- Gradle -->
<properties>
    <configurationParameters>
        junit.platform.reporting.open.xml.enabled = true
        junit.platform.reporting.open.xml.socket = 8080
    </configurationParameters>
</properties>
# Console Launcher
java -jar junit-platform-console-standalone.jar \
  --config=junit.platform.reporting.open.xml.enabled=true \
  --config=junit.platform.reporting.open.xml.socket=8080

Testing

  • Added writesXmlReportToSocket() test verifying end-to-end socket output
  • Uses daemon thread with try-with-resources for proper cleanup

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • checkstyle.org
    • Triggering command: /opt/hostedtoolcache/CodeQL/2.23.1/x64/codeql/tools/linux64/java/bin/java -jar /opt/hostedtoolcache/CodeQL/2.23.1/x64/codeql/xml/tools/xml-extractor.jar --fileList=/home/REDACTED/work/junit-framework/.codeql-scratch/dbs/java/working/files-to-index17571054916578602831.list --sourceArchiveDir=/home/REDACTED/work/junit-framework/.codeql-scratch/dbs/java/src --outputDir=/home/REDACTED/work/junit-framework/.codeql-scratch/dbs/java/trap/java (dns block)
  • ge.junit.org
    • Triggering command: /usr/lib/jvm/temurin-25-jdk-amd64/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.prefs/java.util.prefs=ALL-UNNAMED --add-opens=java.base/java.nio.charset=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.util.concurrent=ALL-UNNAMED --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED --add-opens=java.xml/javax.xml.namespace=ALL-UNNAMED --add-opens=java.base/java.time=ALL-UNNAMED --enable-native-access=ALL-UNNAMED -XX:MaxMetaspaceSize=512m -XX:&#43;HeapDumpOnOutOfMemoryError -Xmx1g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -cp /home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/gradle-daemon-main-9.1.0.jar -javaagent:/home/REDACTED/.gradle/wrapper/dists/gradle-9.1.0-bin/9agqghryom9wkf8r80qlhnts3/gradle-9.1.0/lib/agents/gradle-instrumentation-agent-9.1.0.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 9.1.0 (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)
  • junit.org
    • Triggering command: /usr/lib/jvm/temurin-25-jdk-amd64/bin/java @/tmp/options3707181241615664813 -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager -Djunit.platform.discovery.issue.severity.critical=info -Djunit.platform.execution.dryRun.enabled=false -Djunit.platform.output.capture.stderr=true -Djunit.platform.output.capture.stdout=true -Djunit.platform.reporting.open.xml.enabled=true -Djunit.platform.reporting.open.xml.git.enabled=true -Djunit.platform.reporting.output.dir=/home/REDACTED/work/junit-framework/junit-framework/platform-tests/build/test-results/test/junit-{uniqueNumber} -Dlog4j2.disableJmx=true -Dlog4j2.julLoggerAdapter=org.apache.logging.log4j.jul.CoreLoggerAdapter -Dnet.bytebuddy.experimental=true -Dnet.bytebuddy.safe=true -Xshare:off -javaagent:/home/REDACTED/work/junit-framework/junit-framework/platform-tests/build/tmp/.cache/expanded/zip_27729b840c216bdc69a9315e04b27ab1/jacocoagent.jar=destfile=build/jacoco/test.exec,append=true,inclnolocationclasses=false,dumponexit=true,output=file,jmx=false -javaagent:/home/REDACTED/.gradle/caches/modules-2/files-2.1/org.mockito/mockito-core/5.20.0/a32f446f38acf636363c5693db6498047731b9e0/mockito-core-5.20.0.jar -Xmx1g -Dfile.encoding=UTF-8 -Duser.country -Duser.language=en -Duser.variant -ea -Dorg.gradle.test.worker=1 com.gradle.enterprise.testdistribution.launcher.forked.LauncherMain 43439 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

OpenTestReportGeneratingListener should get an option to redirect event to a socket

Recently an option to redirect the events not only to a file was added to the ota4j lib here

ota4j-team/open-test-reporting#728

The version was already released and updated in junit

junit-team@40db534

Now OpenTestReportGeneratingListener can be enhanced to support this as well:

  • if the config contains a key "junit.platform.reporting.open.xml.socket" take this as an integer for a port value
  • in this case don't create a file based writer but one that uses a writer and this writer should send everything to a socket opened to the local port given by the configuration
  • as closing the eventsFileWriter will close the writer according to the javadoc, and a sockt getc closed by closing its stream we can then be safe to not need to further keep the socket around as it will be implicitly closed
  • all documentation and possibly the release notes need to be updated for this new feature
  • make sure rules in the CONTRIBUTING.md are followed especially the formating of files should be ensure by calling 'gradle spotlessApply'

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits October 27, 2025 05:59
- Add SOCKET_PROPERTY_NAME constant for junit.platform.reporting.open.xml.socket
- Implement createDocumentWriter method to support both file and socket outputs
- When socket property is set, connect to localhost:<port> and write XML to socket
- Add comprehensive test for socket-based reporting
- Update documentation to describe socket configuration parameter
- Update release notes with new feature

Co-authored-by: laeubi <[email protected]>
- Add specific NumberFormatException handling with descriptive error message for invalid port
- Use try-with-resources for ServerSocket in test
- Make server thread daemon and handle interruption gracefully
- Use try-with-resources for client socket and reader in test

Co-authored-by: laeubi <[email protected]>
Copilot AI changed the title [WIP] Add option to redirect events to a socket in OpenTestReportGeneratingListener Add socket output support to OpenTestReportGeneratingListener Oct 27, 2025
Copilot AI requested a review from laeubi October 27, 2025 06:10
Copilot finished work on behalf of laeubi October 27, 2025 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants