You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2005/10/21 17:59:11 UTC

svn commit: r327213 - in /webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine: ThreadingTest.java util/InvokerThread.java

Author: gdaniels
Date: Fri Oct 21 08:59:06 2005
New Revision: 327213

URL: http://svn.apache.org/viewcvs?rev=327213&view=rev
Log:
Threading test was sporadically failing on my machine at work.

* Sleep 100ms in between check loops.  This kind of test should really use locks/semaphores between the active threads, but even barring that we should *never* spin-wait.

* If a thread has an exception, squirrel it away so that the test thread can get at it and be more informative about what went wrong.

Modified:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ThreadingTest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/InvokerThread.java

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ThreadingTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ThreadingTest.java?rev=327213&r1=327212&r2=327213&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ThreadingTest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/ThreadingTest.java Fri Oct 21 08:59:06 2005
@@ -68,8 +68,6 @@
     }
 
     public void testEchoXMLSync() throws Exception {
-
-
         int numberOfThreads = 5;
         InvokerThread[] invokerThreads = new InvokerThread[numberOfThreads];
 
@@ -90,8 +88,9 @@
                     threadsAreRunning = true;
                     break;
                 }
-                if (invokerThreads[i].isExceptionThrown()) {
-                    fail("Exception thrown in thread "+ i + " ....");
+                Exception exception = invokerThreads[i].getThrownException();
+                if (exception != null) {
+                    throw new Exception("Exception thrown in thread "+ i + " ....", exception);
                 }
             }
 
@@ -101,6 +100,7 @@
                 fail("Timing out");
             }
 
+            Thread.sleep(100);
         } while (threadsAreRunning);
 
         assertTrue(true);

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/InvokerThread.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/InvokerThread.java?rev=327213&r1=327212&r2=327213&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/InvokerThread.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/engine/util/InvokerThread.java Fri Oct 21 08:59:06 2005
@@ -39,7 +39,7 @@
                     + "/axis/services/EchoXMLService/echoOMElement");
     protected QName operationName = new QName("echoOMElement");
     protected Log log = LogFactory.getLog(getClass());
-    private boolean isExceptionThrown = false;
+    private Exception thrownException = null;
 
     public InvokerThread(int threadNumber) {
         this.threadNumber = threadNumber;
@@ -63,14 +63,13 @@
             TestingUtils.campareWithCreatedOMElement(result);
             call.close();
             log.info("Finishing Thread number "+ threadNumber + " .....");
-            isExceptionThrown = false;
         } catch (AxisFault axisFault) {
-            isExceptionThrown = true;
+            thrownException = axisFault;
             log.error("Error has occured invoking the service ", axisFault);
         }
     }
 
-    public boolean isExceptionThrown() {
-        return isExceptionThrown;
+    public Exception getThrownException() {
+        return thrownException;
     }
 }