8060120: Improve diagnostic output of StartManagementAgent test
authorjbachorik
Fri, 10 Oct 2014 14:35:53 +0200
changeset 27041 c0f17f42fad3
parent 27040 5ac8a08e338f
child 27047 05b228626582
8060120: Improve diagnostic output of StartManagementAgent test Reviewed-by: dfuchs
jdk/test/com/sun/tools/attach/StartManagementAgent.java
--- a/jdk/test/com/sun/tools/attach/StartManagementAgent.java	Tue Oct 14 15:20:41 2014 +0900
+++ b/jdk/test/com/sun/tools/attach/StartManagementAgent.java	Fri Oct 10 14:35:53 2014 +0200
@@ -53,7 +53,9 @@
     public static void main(String[] args) throws Throwable {
         ProcessThread processThread = null;
         try {
+            System.out.println("Starting test application");
             processThread = RunnerUtil.startApplication();
+            System.out.println("Application started");
             runTests(processThread.getPid());
         } catch (Throwable t) {
             System.out.println("StartManagementAgent got unexpected exception: " + t);
@@ -70,6 +72,7 @@
         // Try calling with null argument
         boolean exception = false;
         try {
+            System.out.println("Starting management agent with null");
             vm.startManagementAgent(null);
         } catch (NullPointerException e) {
             exception = true;
@@ -86,6 +89,7 @@
         }
         p.put("com.sun.management.config.file", f.getAbsolutePath());
         try {
+            System.out.println("Starting management agent with bogus port");
             vm.startManagementAgent(p);
         } catch(AttachOperationFailedException ex) {
             // We expect parsing of "apa" above to fail, but if the file path
@@ -93,6 +97,9 @@
             if (!ex.getMessage().contains("Invalid com.sun.management.jmxremote.port number")) {
                 throw ex;
             }
+            ex.printStackTrace(System.err);
+        } catch (Throwable t) {
+            t.printStackTrace(System.err);
         }
     }
 
@@ -134,14 +141,19 @@
     }
 
     public static void testLocalAgent(VirtualMachine vm) throws Exception {
+        System.out.println("Getting VM properties");
         Properties agentProps = vm.getAgentProperties();
         String address = (String) agentProps.get(LOCAL_CONNECTOR_ADDRESS_PROP);
         if (address != null) {
             throw new Exception("Local management agent already started");
         }
 
+        System.out.println("Starting local agent");
+
         String result = vm.startLocalManagementAgent();
 
+        System.out.println("Agent started");
+
         // try to parse the return value as a JMXServiceURL
         new JMXServiceURL(result);