|
From: <tho...@us...> - 2014-09-06 17:40:42
|
Revision: 8644
http://sourceforge.net/p/bigdata/code/8644
Author: thompsonbry
Date: 2014-09-06 17:40:34 +0000 (Sat, 06 Sep 2014)
Log Message:
-----------
enabling thread count checks in CI.
Modified Paths:
--------------
branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/ProxyBigdataSailTestCase.java
branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/ProxyTestCase.java
Modified: branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/ProxyBigdataSailTestCase.java
===================================================================
--- branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/ProxyBigdataSailTestCase.java 2014-09-06 17:39:26 UTC (rev 8643)
+++ branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/ProxyBigdataSailTestCase.java 2014-09-06 17:40:34 UTC (rev 8644)
@@ -37,7 +37,6 @@
import junit.extensions.proxy.IProxyTest;
import junit.framework.Test;
-import org.apache.log4j.Logger;
import org.openrdf.model.Resource;
import org.openrdf.query.Binding;
import org.openrdf.query.BindingSet;
@@ -157,18 +156,77 @@
* proxy is created for each test, while one instance of the delegate serves
* an entire suite of tests.)
*/
+
+ private int startupActiveThreads = 0;
+ @Override
protected void setUp() throws Exception {
- getOurDelegate().setUp(this);
+
+ startupActiveThreads = Thread.currentThread().getThreadGroup().activeCount();
+
+ getOurDelegate().setUp(this);
+
}
+ private static boolean s_checkThreads = true;
+
+ @Override
protected void tearDown() throws Exception {
+
getOurDelegate().tearDown(this);
+
+ if (s_checkThreads) {
+
+ final ThreadGroup grp = Thread.currentThread().getThreadGroup();
+ final int tearDownActiveThreads = grp.activeCount();
+ if (startupActiveThreads != tearDownActiveThreads) {
+ final Thread[] threads = new Thread[tearDownActiveThreads];
+ grp.enumerate(threads);
+ final StringBuilder info = new StringBuilder();
+ boolean first = true;
+ for (Thread t : threads) {
+ if (t == null)
+ continue;
+ if (!first)
+ info.append(',');
+ info.append("[" + t.getName() + "]");
+ first = false;
+ }
+
+ final String failMessage = "Threads left active after task"
+ + ": test="
+ + getName()//
+ + ", delegate=" + getOurDelegate().getClass().getName()
+ + ", startupCount=" + startupActiveThreads
+ + ", teardownCount=" + tearDownActiveThreads
+ + ", thisThread=" + Thread.currentThread().getName()
+ + ", threads: " + info;
+
+ if (grp.activeCount() != startupActiveThreads)
+ log.error(failMessage);
+
+ /*
+ * Wait up to 2 seconds for threads to die off so the next test
+ * will run more cleanly.
+ */
+ for (int i = 0; i < 20; i++) {
+ Thread.sleep(100);
+ if (grp.activeCount() != startupActiveThreads)
+ break;
+ }
+
+ }
+
+ }
+
+ super.tearDown();
+
}
/**
* The properties as configured by the delegate.
*/
+ @Override
public Properties getProperties() {
return getOurDelegate().getProperties();
}
Modified: branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/ProxyTestCase.java
===================================================================
--- branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/ProxyTestCase.java 2014-09-06 17:39:26 UTC (rev 8643)
+++ branches/SESAME_2_7/bigdata-sails/src/test/com/bigdata/rdf/sail/webapp/ProxyTestCase.java 2014-09-06 17:40:34 UTC (rev 8644)
@@ -155,68 +155,73 @@
* an entire suite of tests.)
*/
-// private int startupActiveThreads = 0;
+ private int startupActiveThreads = 0;
+ @Override
public void setUp() throws Exception {
-// startupActiveThreads = Thread.currentThread().getThreadGroup().activeCount();
+ startupActiveThreads = Thread.currentThread().getThreadGroup().activeCount();
getOurDelegate().setUp(this);
}
-// private static boolean s_checkThreads = true;
-
+ private static boolean s_checkThreads = true;
+
+ @Override
public void tearDown() throws Exception {
getOurDelegate().tearDown(this);
-// if (s_checkThreads) {
-//
-// final ThreadGroup grp = Thread.currentThread().getThreadGroup();
-// final int tearDownActiveThreads = grp.activeCount();
-// if (startupActiveThreads != tearDownActiveThreads) {
-// final Thread[] threads = new Thread[tearDownActiveThreads];
-// grp.enumerate(threads);
-// final StringBuilder info = new StringBuilder();
-// boolean first = true;
-// for (Thread t : threads) {
-// if (t == null)
-// continue;
-// if(!first)
-// info.append(',');
-// info.append("[" + t.getName() + "]");
-// first = false;
-// }
-//
-// final String failMessage = "Threads left active after task"
-// +": test=" + getName()//
-// + ", delegate="+getOurDelegate().getClass().getName()
-// + ", startupCount=" + startupActiveThreads
-// + ", teardownCount=" + tearDownActiveThreads
-// + ", thisThread="+Thread.currentThread().getName()
-// + ", threads: " + info;
-//
-// if (grp.activeCount() != startupActiveThreads)
-// log.error(failMessage);
-//
-// /*
-// * Wait up to 2 seconds for threads to die off so the next test
-// * will run more cleanly.
-// */
-// for (int i = 0; i < 20; i++) {
-// Thread.sleep(100);
-// if (grp.activeCount() != startupActiveThreads)
-// break;
-// }
-//
-// }
-//
-// }
-
- super.tearDown();
+ if (s_checkThreads) {
+
+ final ThreadGroup grp = Thread.currentThread().getThreadGroup();
+ final int tearDownActiveThreads = grp.activeCount();
+ if (startupActiveThreads != tearDownActiveThreads) {
+ final Thread[] threads = new Thread[tearDownActiveThreads];
+ grp.enumerate(threads);
+ final StringBuilder info = new StringBuilder();
+ boolean first = true;
+ for (Thread t : threads) {
+ if (t == null)
+ continue;
+ if (!first)
+ info.append(',');
+ info.append("[" + t.getName() + "]");
+ first = false;
+ }
+
+ final String failMessage = "Threads left active after task"
+ + ": test="
+ + getName()//
+ + ", delegate=" + getOurDelegate().getClass().getName()
+ + ", startupCount=" + startupActiveThreads
+ + ", teardownCount=" + tearDownActiveThreads
+ + ", thisThread=" + Thread.currentThread().getName()
+ + ", threads: " + info;
+
+ if (grp.activeCount() != startupActiveThreads)
+ log.error(failMessage);
+
+ /*
+ * Wait up to 2 seconds for threads to die off so the next test
+ * will run more cleanly.
+ */
+ for (int i = 0; i < 20; i++) {
+ Thread.sleep(100);
+ if (grp.activeCount() != startupActiveThreads)
+ break;
+ }
+
+ }
+
+ }
+
+ super.tearDown();
+
}
+ @Override
public Properties getProperties() {
return getOurDelegate().getProperties();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|