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 2013/08/22 22:46:10 UTC

svn commit: r1516601 - /cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java

Author: dkulp
Date: Thu Aug 22 20:46:10 2013
New Revision: 1516601

URL: http://svn.apache.org/r1516601
Log:
Don't print a stack trace and instead actually propogate the error to the main thread

Modified:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java

Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java?rev=1516601&r1=1516600&r2=1516601&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java Thu Aug 22 20:46:10 2013
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.systest.jaxrs;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.concurrent.ArrayBlockingQueue;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -33,7 +35,6 @@ import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
-import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
 
@@ -124,27 +125,23 @@ public abstract class AbstractJAXRSConti
                                                              new ArrayBlockingQueue<Runnable>(10));
         CountDownLatch startSignal = new CountDownLatch(1);
         CountDownLatch doneSignal = new CountDownLatch(1);
-        
-        executor.execute(new BookWorker("http://localhost:" + port + "/bookstore/" + pathSegment + "/1", 
-                                        "1", 
-                                        "CXF in Action1", startSignal, doneSignal));
-        executor.execute(new BookWorker("http://localhost:" + port + "/bookstore/" + pathSegment + "/2", 
-                                        "2", 
-                                        "CXF in Action2", startSignal, doneSignal));
-        executor.execute(new BookWorker("http://localhost:" + port + "/bookstore/" + pathSegment + "/3", 
-                                        "3", 
-                                        "CXF in Action3", startSignal, doneSignal));
-        executor.execute(new BookWorker("http://localhost:" + port + "/bookstore/" + pathSegment + "/4", 
-                                        "4", 
-                                        "CXF in Action4", startSignal, doneSignal));
-        executor.execute(new BookWorker("http://localhost:" + port + "/bookstore/" + pathSegment + "/5", 
-                                        "5", 
-                                        "CXF in Action5", startSignal, doneSignal));
+        List<BookWorker> workers = new ArrayList<BookWorker>(5);
+        for (int x = 1; x < 6; x++) {
+            workers.add(new BookWorker("http://localhost:" + port + "/bookstore/" + pathSegment + "/" + x, 
+                                       Integer.toString(x), 
+                                       "CXF in Action" + x, startSignal, doneSignal));
+        }
+        for (BookWorker w : workers) {
+            executor.execute(w);
+        }
         
         startSignal.countDown();
         doneSignal.await(60, TimeUnit.SECONDS);
-        executor.shutdownNow();
+        executor.shutdownNow();       
         assertEquals("Not all invocations have completed", 0, doneSignal.getCount());
+        for (BookWorker w : workers) {
+            w.checkError();
+        }
     }
     
     private void checkBook(String address, String id, String expected) throws Exception {
@@ -169,6 +166,7 @@ public abstract class AbstractJAXRSConti
         private String expected;
         private CountDownLatch startSignal;
         private CountDownLatch doneSignal;
+        private Exception error;
         public BookWorker(String address,
                           String id,
                           String expected,
@@ -181,6 +179,12 @@ public abstract class AbstractJAXRSConti
             this.doneSignal = doneSignal;
         }
         
+        public void checkError() throws Exception {
+            if (error != null) {
+                throw error;
+            }
+        }
+
         public void run() {
             
             try {
@@ -190,8 +194,8 @@ public abstract class AbstractJAXRSConti
             } catch (InterruptedException ex) {
                 // ignore
             } catch (Exception ex) {
-                ex.printStackTrace();
-                Assert.fail("Book thread failed for : " + id);
+                ex.fillInStackTrace();
+                error = ex;
             } 
             
         }