Skip to content

Add integration test for JMX#2066

Draft
Godin wants to merge 4 commits into
jacoco:masterfrom
Godin:jmx
Draft

Add integration test for JMX#2066
Godin wants to merge 4 commits into
jacoco:masterfrom
Godin:jmx

Conversation

@Godin
Copy link
Copy Markdown
Member

@Godin Godin commented Mar 6, 2026

While working on #2052 (comment) I realized that we don't have integration test that will demonstrate behavior of agent when user is affected by https://bugs.openjdk.org/browse/JDK-8287073 And so decided to create one.


During creation of this test also learned how to configure secure JMX connection with SSL and password. So it also can be used to help answer questions such as https://groups.google.com/g/jacoco/c/ilZmw3LcT4E/m/Qojf4m4dBgAJ

@Godin Godin added this to the 0.8.15 milestone Mar 6, 2026
@Godin Godin self-assigned this Mar 6, 2026
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to regenerate keystore.jks to add CN=localhost

@Godin Godin requested a review from marchof March 6, 2026 22:35
@marchof
Copy link
Copy Markdown
Member

marchof commented Mar 9, 2026

FYI, some time ago I had a similar task, basically programatic JMX access via SSL. Here are my observations: https://github.com/mtrail/jmx-over-ssl/

Comment thread org.jacoco.ant.test/src/org/jacoco/ant/JmxTest.java Outdated
public class JmxTest {

public static TestSuite suite() {
if (JavaVersion.current().isBefore("19")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is inverse to SecurityManagerTest where is if block is the actual test. I have no preference here except consistency.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition here is IMO already hard to read, explanatory comment for condition after body of if statement will look even more unreadable and weird, so I'd rather invert if in SecurityManagerTest which IMO will also improve its readability - #2075, and speaking of consistency this will be more consistent with other places where we skip tests - see for example

public void testAnalyzeAll_Pack200() throws IOException {
try {
Class.forName("java.util.jar.Pack200");
} catch (ClassNotFoundException e) {
throw new AssumptionViolatedException(
"this test requires JDK with Pack200");
}

Actually, I should have suggested this back in #1780 😅

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing the test as skipped using a AssumptionViolatedException would definitely my preference. Looks like this is not possible within the suite() method.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing the test as skipped using a AssumptionViolatedException would definitely my preference. Looks like this is not possible within the suite() method.

Unfortunately yes, and this was already noted in past - #1780 (comment)

In #2075 (comment) you proposed AntUnitSuiteFactory.skip shorthand for the empty AntUnitSuite for such cases, and imo #2075 ready to be merged 😉

public class JmxTarget {

public static void main(String[] args) throws Exception {
final JMXServiceURL url = new JMXServiceURL(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a short note that we connect to our own process here?

Co-authored-by: Marc R. Hoffmann <hoffmann@mountainminds.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants