cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1517572 - /cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
Date Mon, 26 Aug 2013 15:51:46 GMT
Author: dkulp
Date: Mon Aug 26 15:51:46 2013
New Revision: 1517572

URL: http://svn.apache.org/r1517572
Log:
Merged revisions 1516601 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1516601 | dkulp | 2013-08-22 16:46:10 -0400 (Thu, 22 Aug 2013) | 2 lines

  Don't print a stack trace and instead actually propogate the error to the main thread

........

Modified:
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java?rev=1517572&r1=1517571&r2=1517572&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AbstractJAXRSContinuationsTest.java
Mon Aug 26 15:51:46 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;
 
@@ -107,28 +108,25 @@ public abstract class AbstractJAXRSConti
         ThreadPoolExecutor executor = new ThreadPoolExecutor(5, 5, 0, TimeUnit.SECONDS,
                                                              new ArrayBlockingQueue<Runnable>(10));
         CountDownLatch startSignal = new CountDownLatch(1);
-        CountDownLatch doneSignal = new CountDownLatch(5);
-        
-        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));
+
+        CountDownLatch doneSignal = new CountDownLatch(1);
+        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 {
@@ -153,6 +151,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,
@@ -165,6 +164,12 @@ public abstract class AbstractJAXRSConti
             this.doneSignal = doneSignal;
         }
         
+        public void checkError() throws Exception {
+            if (error != null) {
+                throw error;
+            }
+        }
+
         public void run() {
             
             try {
@@ -174,8 +179,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;
             } 
             
         }



Mime
View raw message