11/*
2- * Copyright (c) 2021, 2022 , Oracle and/or its affiliates. All rights reserved.
2+ * Copyright (c) 2021, 2023 , Oracle and/or its affiliates. All rights reserved.
33 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 *
55 * This code is free software; you can redistribute it and/or modify it
2727 * @summary Basic test for com.sun.management.HotSpotDiagnosticMXBean.dumpThreads
2828 * @enablePreview
2929 * @library /test/lib
30- * @run testng /othervm DumpThreads
31- * @run testng /othervm -Djdk.trackAllThreads DumpThreads
32- * @run testng /othervm -Djdk.trackAllThreads=true DumpThreads
33- * @run testng /othervm -Djdk.trackAllThreadds=false DumpThreads
30+ * @run junit /othervm DumpThreads
31+ * @run junit /othervm -Djdk.trackAllThreads DumpThreads
32+ * @run junit /othervm -Djdk.trackAllThreads=true DumpThreads
33+ * @run junit /othervm -Djdk.trackAllThreadds=false DumpThreads
3434 */
3535
3636import java .lang .management .ManagementFactory ;
4747import com .sun .management .HotSpotDiagnosticMXBean .ThreadDumpFormat ;
4848import jdk .test .lib .threaddump .ThreadDump ;
4949
50- import org .testng . annotations .Test ;
51- import static org .testng . Assert .*;
50+ import org .junit . jupiter . api .Test ;
51+ import static org .junit . jupiter . api . Assertions .*;
5252
53- public class DumpThreads {
53+ class DumpThreads {
5454 private static final boolean TRACK_ALL_THREADS ;
5555 static {
5656 String s = System .getProperty ("jdk.trackAllThreads" );
@@ -61,7 +61,7 @@ public class DumpThreads {
6161 * Thread dump in plain text format.
6262 */
6363 @ Test
64- public void testPlainText () throws Exception {
64+ void testPlainText () throws Exception {
6565 var mbean = ManagementFactory .getPlatformMXBean (HotSpotDiagnosticMXBean .class );
6666 Path file = genOutputPath ("txt" );
6767 try (var executor = Executors .newVirtualThreadPerTaskExecutor ()) {
@@ -98,7 +98,7 @@ public void testPlainText() throws Exception {
9898 * Thread dump in JSON format.
9999 */
100100 @ Test
101- public void testJson () throws Exception {
101+ void testJson () throws Exception {
102102 var mbean = ManagementFactory .getPlatformMXBean (HotSpotDiagnosticMXBean .class );
103103 Path file = genOutputPath ("json" );
104104 try (var executor = Executors .newVirtualThreadPerTaskExecutor ()) {
@@ -118,7 +118,7 @@ public void testJson() throws Exception {
118118 ZonedDateTime .parse (threadDump .time ());
119119
120120 // test threadDump/runtimeVersion
121- assertEquals (threadDump . runtimeVersion (), Runtime .version ().toString ());
121+ assertEquals (Runtime .version ().toString (), threadDump . runtimeVersion ());
122122
123123 // test root container
124124 var rootContainer = threadDump .rootThreadContainer ();
@@ -150,7 +150,7 @@ public void testJson() throws Exception {
150150 * Test that dumpThreads throws if the output file already exists.
151151 */
152152 @ Test
153- public void testFileAlreadyExsists () throws Exception {
153+ void testFileAlreadyExsists () throws Exception {
154154 var mbean = ManagementFactory .getPlatformMXBean (HotSpotDiagnosticMXBean .class );
155155 String file = Files .createFile (genOutputPath ("txt" )).toString ();
156156 assertThrows (FileAlreadyExistsException .class ,
@@ -163,7 +163,7 @@ public void testFileAlreadyExsists() throws Exception {
163163 * Test that dumpThreads throws if the file path is relative.
164164 */
165165 @ Test
166- public void testRelativePath () throws Exception {
166+ void testRelativePath () throws Exception {
167167 var mbean = ManagementFactory .getPlatformMXBean (HotSpotDiagnosticMXBean .class );
168168 assertThrows (IllegalArgumentException .class ,
169169 () -> mbean .dumpThreads ("threads.txt" , ThreadDumpFormat .TEXT_PLAIN ));
@@ -175,7 +175,7 @@ public void testRelativePath() throws Exception {
175175 * Test that dumpThreads throws with null parameters.
176176 */
177177 @ Test
178- public void testNull () throws Exception {
178+ void testNull () throws Exception {
179179 var mbean = ManagementFactory .getPlatformMXBean (HotSpotDiagnosticMXBean .class );
180180 assertThrows (NullPointerException .class ,
181181 () -> mbean .dumpThreads (null , ThreadDumpFormat .TEXT_PLAIN ));
0 commit comments