You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/02/02 22:26:46 UTC

svn commit: r740108 - /cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java

Author: dkulp
Date: Mon Feb  2 21:26:46 2009
New Revision: 740108

URL: http://svn.apache.org/viewvc?rev=740108&view=rev
Log:
If the server fails to start, print out the server output so we don't need to dig into files on disk tofigure out why

Modified:
    cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java

Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java?rev=740108&r1=740107&r2=740108&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java (original)
+++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/ServerLauncher.java Mon Feb  2 21:26:46 2009
@@ -198,7 +198,7 @@
             pb.redirectErrorStream(true);
             process = pb.start();
     
-            launchOutputMonitorThread(process.getInputStream(), System.out);
+            OutputMonitorThread out = launchOutputMonitorThread(process.getInputStream(), System.out);
     
             synchronized (mutex) {
                 do {
@@ -213,6 +213,10 @@
                     }
                 } while (!serverIsReady && !serverLaunchFailed);
             }
+            if (serverLaunchFailed || !serverIsReady) {
+                System.err.println(out.getServerOutput());
+            }
+            
         }
         return serverIsReady && !serverLaunchFailed;
     }
@@ -228,22 +232,27 @@
         return ret;
     }
 
-    private void launchOutputMonitorThread(final InputStream in, final PrintStream out) {
-        Thread t = new OutputMonitorThread(in, out);
+    private OutputMonitorThread launchOutputMonitorThread(final InputStream in, final PrintStream out) {
+        OutputMonitorThread t = new OutputMonitorThread(in, out);
         t.start();
+        return t;
     }
     private class OutputMonitorThread extends Thread {
         InputStream in;
         PrintStream out;
+        StringBuilder serverOutputAll = new StringBuilder();
+
 
         OutputMonitorThread(InputStream i, PrintStream o) {
             in = i;
             out = o;
         }
+        public String getServerOutput() {
+            return serverOutputAll.toString();
+        }
 
         public void run() {
             try {
-                StringBuilder serverOutput = new StringBuilder();
                 String outputDir = System.getProperty("server.output.dir", "target/surefire-reports/");
                 FileOutputStream fos;
                 try {
@@ -262,8 +271,10 @@
                 }
                 PrintStream ps = new PrintStream(fos);
                 boolean running = true;
+                StringBuilder serverOutput = new StringBuilder();
                 for (int ch = in.read(); ch != -1; ch = in.read()) {
                     serverOutput.append((char)ch);
+                    serverOutputAll.append((char)ch);
                     if (debug) {
                         System.err.print((char)ch);
                     }
@@ -282,7 +293,7 @@
                     if (ch == '\n' || !running) {
                         synchronized (out) {
                             ps.print(serverOutput.toString());
-                            serverOutput = new StringBuilder();
+                            serverOutput.setLength(0);
                             ps.flush();
                         }
                     }