Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -72,8 +72,7 @@ public void checkStateChanged(CheckStateChangedEvent event) {
if (element instanceof TriggerRule) {
setRuleChecked((TriggerRule) element, event.getChecked());
} else if (element instanceof RuleGroup) {
RuleGroup group = ((RuleGroup) element);
group.getRules().forEach(rule -> setRuleChecked(rule, event.getChecked()));
((RuleGroup) element).getRules().forEach(rule -> setRuleChecked(rule, event.getChecked()));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -170,6 +170,8 @@ private void createClient(FormToolkit toolkit) {
tree.setData("name", "triggers.RulesTree"); //$NON-NLS-1$ //$NON-NLS-2$
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
m_viewer = createViewer(toolkit, tree, client);
tree.setData("org.eclipse.jface.viewer", m_viewer); //$NON-NLS-1$
tree.setData("viewer", m_viewer); //$NON-NLS-1$

tree.setLayoutData(gd);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2025, Kantega AS. All rights reserved.
* Copyright (c) 2024, 2026, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2024, 2026, Kantega AS. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -112,16 +112,25 @@ public void testReadAttributesOverJolokia() throws MalformedURLException, IOExce
.getAttributes()) {
String attributeName = attributeInfo.getName();
if (!unsafeAttributes.contains(attributeName)) {
Object attribute = getJolokiaMBeanConnector().getAttribute(objectName, attributeName);
fetched++;
if (attribute instanceof String || attribute instanceof Boolean) { // Assume strings and booleans are safe to compare directly
try {
Object locallyRetrievedAttribute = localConnection.getAttribute(objectName, attributeName);
compared++;
Assert.assertEquals("Comparing returned value of " + objectName + "." + attributeName,
locallyRetrievedAttribute, attribute);
} catch (InstanceNotFoundException e) {
unavailable++;
try {
Object attribute = getJolokiaMBeanConnector().getAttribute(objectName, attributeName);
fetched++;
if (attribute instanceof String || attribute instanceof Boolean) { // Assume strings and booleans are safe to compare directly
try {
Object locallyRetrievedAttribute = localConnection.getAttribute(objectName,
attributeName);
compared++;
Assert.assertEquals("Comparing returned value of " + objectName + "." + attributeName,
locallyRetrievedAttribute, attribute);
} catch (InstanceNotFoundException e) {
unavailable++;
}
}
} catch (RuntimeException e) {
if (isParsingFailure(e)) {
// Skip attributes that cause parsing errors (e.g., NaN values)
} else {
throw e;
}
}
}
Expand Down Expand Up @@ -160,13 +169,12 @@ private static MBeanServerConnection getJolokiaMBeanConnector() throws IOExcepti
@Test
public void testDiscover() {
boolean isMacOs = "macosx".equals(System.getProperty("osgi.os"));
boolean isCiRun = "true".equals(System.getenv("GITHUB_ACTIONS"));
boolean shouldTestMacOS = "true".equals(System.getenv("JOLOKIA_TEST_DISCOVERY_ON_MAC"));
if (isMacOs && isCiRun && !shouldTestMacOS) {
//This does not work in the JMC CI pipeline for Mac
if (isMacOs && !shouldTestMacOS) {
//Multicast discovery does not work on macOS due to network stack limitations
// 'D> --> Couldnt send discovery message from /127.0.0.1: java.net.BindException: Can't assign requested address
// D> --> Exception during lookup: java.util.concurrent.ExecutionException:
// org.jolokia.service.discovery.MulticastUtil$CouldntSendDiscoveryPacketException:
// D> --> Exception during lookup: java.util.concurrent.ExecutionException:
// org.jolokia.service.discovery.MulticastUtil$CouldntSendDiscoveryPacketException:
// Can't send discovery UDP packet from /127.0.0.1: Can't assign requested address'
// We get test coverage on both Linux and Windows
return;
Expand All @@ -192,6 +200,21 @@ public void onDescriptorRemoved(String descriptorId) {
Awaitility.await().atMost(Duration.ofSeconds(5)).until(() -> foundVms.get() > 0);
}

private static boolean isParsingFailure(RuntimeException e) {
Throwable current = e;
while (current != null) {
if (current instanceof NumberFormatException) {
return true;
}
String message = current.getMessage();
if (message != null && (message.contains("NaN") || message.contains("NumberFormatException"))) {
return true;
}
current = current.getCause();
}
return false;
}

@After
public void stopListener() throws Exception {
if (discoveryListener != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -132,7 +132,7 @@ public void testImportNonExistantFile() {
*/
@Test
public void testSetMasterPassword() {
MC.jvmBrowser.createConnection("localhost", "0", "username", "Password@123", true, "PasswordConnection");
MC.jvmBrowser.createConnection("localhost", "0", "username", "Password1!", true, "PasswordConnection");
MC.jvmBrowser.deleteItem("PasswordConnection");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Require-Bundle: org.eclipse.ui,
org.openjdk.jmc.rjmx,
org.openjdk.jmc.rjmx.ui,
org.openjdk.jmc.console.ui.mbeanbrowser,
org.openjdk.jmc.alert,
org.junit
Bundle-RequiredExecutionEnvironment: JavaSE-21
Bundle-ActivationPolicy: lazy
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -41,6 +41,7 @@
import org.junit.ClassRule;
import org.junit.Test;
import org.openjdk.jmc.test.jemmy.MCJemmyTestBase;
import org.openjdk.jmc.test.jemmy.misc.base.wrappers.MCJemmyBase;
import org.openjdk.jmc.test.jemmy.MCUITestRule;
import org.openjdk.jmc.test.jemmy.misc.helpers.ConnectionHelper;
import org.openjdk.jmc.test.jemmy.misc.wrappers.JmxConsole;
Expand Down Expand Up @@ -87,6 +88,10 @@ public void testTableColumnSorting() {
if (mbeanAttributesTree.getColumnIndex("Type", false) != -1) {
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Visible Columns", "Type");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
Assert.assertTrue("The tree contains the \"Type\" column!",
mbeanAttributesTree.getColumnIndex("Type", false) == -1);
}
Expand All @@ -95,16 +100,28 @@ public void testTableColumnSorting() {
// grouped by type)
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Visible Columns", "Type");
mbeanAttributesTree.getColumnIndex("Type");
int typeColumnIndex = mbeanAttributesTree.waitForColumnIndex("Type", 5000);
if (typeColumnIndex == -1) {
Assert.fail("Could not find the column with header \"Type\". Columns: "
+ mbeanAttributesTree.getColumnHeaders());
}

// Select an item in the tree and sort on Name - Ascending
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Sort Columns", "Name", "Ascending");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
List<String> namesColumnAscending = getColumn(mbeanAttributesTree.getAllItemTexts(), getColumnIndex("Name"));

// Select an item in the tree and sort on Name - Descending
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Sort Columns", "Name", "Descending");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
List<String> namesColumnDescending = getColumn(mbeanAttributesTree.getAllItemTexts(), getColumnIndex("Name"));

// Verify that resorting has happened.
Expand All @@ -118,13 +135,21 @@ public void testTableColumnSorting() {
// Select an item in the tree and sort on Value - Ascending
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Sort Columns", "Value", "Ascending");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
Map<String, List<String>> valueColumnAscending = getColumnGroupedByType(mbeanAttributesTree.getAllItemTexts(),
getColumnIndex("Value"), getColumnIndex("Type"));

if (!ConnectionHelper.is9u0EAorLater(TEST_CONNECTION)) {
// Select an item in the tree and sort on Value - Descending
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Sort Columns", "Value", "Descending");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
Map<String, List<String>> valueColumnDescending = getColumnGroupedByType(
mbeanAttributesTree.getAllItemTexts(), getColumnIndex("Value"), getColumnIndex("Type"));

Expand All @@ -142,6 +167,10 @@ public void testTableColumnSorting() {
// Select an item in the tree and sort on Type - Ascending
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Sort Columns", "Type", "Ascending");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
List<String> typeColumnAscending = getColumn(mbeanAttributesTree.getAllItemTexts(), getColumnIndex("Type"));
// Verify sorting by Type
Assert.assertTrue("Type column not correctly sorted ascending: " + formatForPrinting(typeColumnAscending),
Expand All @@ -150,12 +179,20 @@ public void testTableColumnSorting() {
// Remove the Type column and verify that the table doesn't contain that column (again)
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Visible Columns", "Type");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
Assert.assertTrue("The tree still contains the \"Type\" column!",
mbeanAttributesTree.getColumnIndex("Type", false) == -1);

// Resort on Name column again, ascending
mbeanAttributesTree.select("VmVendor");
mbeanAttributesTree.contextChoose("Sort Columns", "Name", "Ascending");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
namesColumnAscending = getColumn(mbeanAttributesTree.getAllItemTexts(), getColumnIndex("Name"));
Assert.assertTrue("Name column not sorted ascending: " + formatForPrinting(namesColumnAscending),
listIsSorted(namesColumnAscending, true));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -292,6 +292,10 @@ public void testTwoThreadsAtaTime() {
MCTree paramsTree = MCTree.getByItem("p0");
paramsTree.select("p0");
paramsTree.enterText("2");
MCJemmyBase.waitForIdle();
if (MCJemmyBase.isOSX()) {
sleep(500);
}
for (int i = 0; i < 2; i++) {
paramsTree.select("p0", "[" + i + "]");
paramsTree.enterText(Long.toString(threadIds[i]));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -135,6 +135,9 @@ public void intermittentMBeanTest() {
// de-register the MBean
mBean2Runner.unregisterMBean(MBEAN_PATH);

// Wait for the subscription to fully stop before checking
sleep(sleepTime);

// verify that the chart isn't updated now
Assert.assertFalse(
"Chart " + NEW_CHART_DEFAULT_NAME + " is still updated with new data after de-registration of MBean",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2026, Oracle and/or its affiliates. All rights reserved.
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -72,6 +72,11 @@ public class TriggersTabTest extends MCJemmyTestBase {

@Rule
public MCUITestRule testRule = new MCUITestRule(verboseRuleOutput) {
@Override
public void before() {
org.openjdk.jmc.alert.AlertPlugin.getDefault().setPopup(true);
}

@Override
public void after() {
MCTriggersPage.resetTriggerRules();
Expand All @@ -97,7 +102,7 @@ public void testApplicationAlert() {
Assume.assumeTrue("This feature is only valid on JDK7u4 or later.",
ConnectionHelper.is7u4orLater(TEST_CONNECTION));

MCTriggersPage.createTriggerRule(null, null, "1 s", ALERT_ACTION_NAME, null, ALERT_RULE_GROUP_NAME,
MCTriggersPage.createTriggerRule("1 %", "0 s", "1 s", ALERT_ACTION_NAME, null, ALERT_RULE_GROUP_NAME,
ALERT_RULE_NAME + "Application Alert", ALERT_ATTRIBUTE_PATH);

// Activate the new rule
Expand All @@ -121,7 +126,7 @@ public void testDiagnosticCommand() {
actionParams.put(DIAGNOSTIC_COMMAND_LOG_FILE_TOOLTIP, filename);
actionParams.put(DIAGNOSTIC_COMMAND_TOOLTIP, DIAGNOSTIC_COMMAND);

MCTriggersPage.createTriggerRule(null, null, "1 s", DIAGNOSTIC_COMMAND_ACTION_NAME, actionParams,
MCTriggersPage.createTriggerRule("1 %", "0 s", "1 s", DIAGNOSTIC_COMMAND_ACTION_NAME, actionParams,
ALERT_RULE_GROUP_NAME, ALERT_RULE_NAME + "Diagnostic Command", ALERT_ATTRIBUTE_PATH);

// Activate the new rule
Expand Down Expand Up @@ -210,4 +215,5 @@ private boolean verifyFileUpdated(String path, long baseline, int maxWait) {
}
return updated;
}

}
Loading