From bd7d8bc31ec385142bb100ef0a3f679d23285db1 Mon Sep 17 00:00:00 2001 From: Peter Shipton Date: Tue, 19 Nov 2024 15:04:02 -0500 Subject: [PATCH] Modify OpenJ9DiagnosticMXBean tests to use getDumpOptions Signed-off-by: Peter Shipton --- .../TestOpenJ9DiagnosticsMXBean.java | 29 +++---------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/test/functional/JLM_Tests/src/org/openj9/test/java/lang/management/TestOpenJ9DiagnosticsMXBean.java b/test/functional/JLM_Tests/src/org/openj9/test/java/lang/management/TestOpenJ9DiagnosticsMXBean.java index 76f1d3b5474..0f1a642c0de 100644 --- a/test/functional/JLM_Tests/src/org/openj9/test/java/lang/management/TestOpenJ9DiagnosticsMXBean.java +++ b/test/functional/JLM_Tests/src/org/openj9/test/java/lang/management/TestOpenJ9DiagnosticsMXBean.java @@ -65,7 +65,7 @@ public class TestOpenJ9DiagnosticsMXBean { private ObjectName mxbeanName = null; private OpenJ9DiagnosticsMXBean diagBean = null; private OpenJ9DiagnosticsMXBean diagBeanRemote = null; - List initialDumpOptions = new ArrayList(); + String initialDumpOptions = null; private JMXConnector connector = null; private static ProcessLocking lock; private static String tmpFileName; @@ -80,31 +80,11 @@ public void setUp() throws Exception { Assert.fail("MalformedObjectNameException!"); } - initialDumpOptions = getDumpOptions(); - getLocalMXBean(); getRemoteMXBean(); - } - /** - * Function to get the dump options. - * - */ - private List getDumpOptions() throws IOException { - List list = new ArrayList(); - String javaExec = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; - ProcessBuilder builder = new ProcessBuilder(javaExec, "-Xdump:what", "-version"); - Process process = builder.start(); - builder.redirectErrorStream(true); - - BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); - String line; - while(null != (line = reader.readLine())) { - logger.info(line); - list.add(line); - } - return list; + initialDumpOptions = diagBean.getDumpOptions(); } private void getLocalMXBean() { @@ -527,10 +507,9 @@ private void resetDumpOptions(OpenJ9DiagnosticsMXBean diagBean) throws IOExcepti diagBean.setDumpOptions("java+heap+system:events=vmstop"); diagBean.resetDumpOptions(); - List newDumpOptions = getDumpOptions(); - boolean res = initialDumpOptions.equals(newDumpOptions); + String newDumpOptions = diagBean.getDumpOptions(); - Assert.assertTrue(res, "Reset Dump Options failed"); + Assert.assertEquals(newDumpOptions, initialDumpOptions, "Reset Dump Options failed"); } /**