openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r729134 - /openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java
Date Tue, 23 Dec 2008 21:49:49 GMT
Author: ppoddar
Date: Tue Dec 23 13:49:49 2008
New Revision: 729134

URL: http://svn.apache.org/viewvc?rev=729134&view=rev
Log:
Timeout multithreaded tests if they hang

Modified:
    openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java

Modified: openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java?rev=729134&r1=729133&r2=729134&view=diff
==============================================================================
--- openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java
(original)
+++ openjpa/trunk/openjpa-slice/src/test/java/org/apache/openjpa/slice/TestQueryMultiThreaded.java
Tue Dec 23 13:49:49 2008
@@ -32,10 +32,13 @@
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import javax.persistence.EntityManager;
 import javax.persistence.Query;
 
+import com.sun.org.apache.bcel.internal.generic.GETSTATIC;
+
 /**
  * Tests when multiple user threads enter the same EntityManager and executes 
  * query. 
@@ -303,16 +306,21 @@
 		try {
 			for (Future f : futures)
 				try {
-					f.get();
+					f.get(60, TimeUnit.SECONDS);
+				} catch (TimeoutException te) {
+				    fail("Failed " + te + "\r\n" + getStackDump(te));
 				} catch (ExecutionException e) {
-					Throwable t = e.getCause();
-					StringWriter writer = new StringWriter();
-					t.printStackTrace(new PrintWriter(writer));
-					fail("Failed " + writer.toString());
+					fail("Failed " + "\r\n" + getStackDump(e.getCause()));
 				}
 		} catch (InterruptedException e) {
 
 		}
 	}
+	
+	String getStackDump(Throwable t) {
+        StringWriter writer = new StringWriter();
+        t.printStackTrace(new PrintWriter(writer));
+        return writer.toString();
+	}
 
 }



Mime
View raw message