< prev index next >
test/serviceability/dcmd/compiler/CompilerQueueTest.java
Print this page
rev 7754 : 8071908: Port internal Diagnostic Command tests and test framework to jtreg
Reviewed-by:
@@ -22,21 +22,26 @@
*/
/*
* @test CompilerQueueTest
* @bug 8054889
- * @library ..
+ * @library /testlibrary
* @ignore 8069160
- * @build DcmdUtil CompilerQueueTest
- * @run main CompilerQueueTest
- * @run main/othervm -XX:-TieredCompilation CompilerQueueTest
- * @run main/othervm -Xint CompilerQueueTest
+ * @build com.oracle.java.testlibrary.*
+ * @build com.oracle.java.testlibrary.dcmd.*
+ * @run testng CompilerQueueTest
+ * @run testng/othervm -XX:-TieredCompilation CompilerQueueTest
+ * @run testng/othervm -Xint CompilerQueueTest
* @summary Test of diagnostic command Compiler.queue
*/
-import java.io.BufferedReader;
-import java.io.StringReader;
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.dcmd.CommandExecutor;
+import com.oracle.java.testlibrary.dcmd.JMXExecutor;
+import org.testng.annotations.Test;
+
+import java.util.Iterator;
public class CompilerQueueTest {
/**
* This test calls Jcmd (diagnostic command tool) Compiler.queue and
@@ -58,54 +63,57 @@
* Empty
* ----------------------------
*
**/
- public static void main(String arg[]) throws Exception {
+ public void run(CommandExecutor executor) {
// Get output from dcmd (diagnostic command)
- String result = DcmdUtil.executeDcmd("Compiler.queue");
- BufferedReader r = new BufferedReader(new StringReader(result));
-
- String str = r.readLine();
+ OutputAnalyzer output = executor.execute("Compiler.queue");
+ Iterator<String> lines = output.asLines().iterator();
- while (str != null) {
+ while (lines.hasNext()) {
+ String str = lines.next();
if (str.startsWith("Contents of C")) {
- match(r.readLine(), "----------------------------");
- str = r.readLine();
+ match(lines.next(), "----------------------------");
+ str = lines.next();
if (!str.equals("Empty")) {
while (str.charAt(0) != '-') {
validateMethodLine(str);
- str = r.readLine();
+ str = lines.next();
}
} else {
- str = r.readLine();
+ str = lines.next();
}
match(str,"----------------------------");
- str = r.readLine();
} else {
- throw new Exception("Failed parsing dcmd queue, line: " + str);
+ throw new RuntimeException("Failed parsing dcmd queue, line: " + str);
}
}
}
- private static void validateMethodLine(String str) throws Exception {
+ private static void validateMethodLine(String str) {
// Skip until package/class name begins. Trim to remove whitespace that
// may differ.
String name = str.substring(14).trim();
int sep = name.indexOf("::");
if (sep == -1) {
- throw new Exception("Failed dcmd queue, didn't find separator :: in: " + name);
+ throw new RuntimeException("Failed dcmd queue, didn't find separator :: in: " + name);
}
try {
Class.forName(name.substring(0, sep));
} catch (ClassNotFoundException e) {
- throw new Exception("Failed dcmd queue, Class for name: " + str);
+ throw new RuntimeException("Failed dcmd queue, Class for name: " + str);
}
}
- public static void match(String line, String str) throws Exception {
+ public static void match(String line, String str) {
if (!line.equals(str)) {
- throw new Exception("String equals: " + line + ", " + str);
+ throw new RuntimeException("String equals: " + line + ", " + str);
}
}
+
+ @Test
+ public void jmx() {
+ run(new JMXExecutor());
+ }
}
< prev index next >