Author: bstansberry(a)jboss.com
Date: 2008-02-27 13:36:29 -0500 (Wed, 27 Feb 2008)
New Revision: 14372
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticInvalidatedTransactionalTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticReadOnlyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticInvalidatedTransactionalTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticReadOnlyTestCase.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/OptimisticBulkOperationsTest.java
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestUtil.java
Log:
Factor out usage of createFailureExpectedTestSuite
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/AbstractJBossCacheTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,13 +23,7 @@
*/
package org.hibernate.test.cache.jbc2;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Set;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
import org.hibernate.cache.RegionFactory;
import org.hibernate.junit.UnitTestCase;
@@ -102,44 +96,4 @@
protected void avoidConcurrentFlush() {
testSupport.avoidConcurrentFlush();
}
-
-
- /**
- * Supports easy creation of a TestSuite where a subclass'
"FailureExpected"
- * version of a base test is included in the suite, while the base test
- * is excluded. E.g. test class FooTestCase includes method testBar(), while test
- * class SubFooTestCase extends FooTestCase includes method
testBarFailureExcluded().
- * Passing SubFooTestCase.class to this method will return a suite that
- * does not include testBar().
- *
- * FIXME Move this to UnitTestCase
- */
- public static TestSuite createFailureExpectedSuite(Class testClass) {
-
- TestSuite allTests = new TestSuite(testClass);
- Set failureExpected = new HashSet();
- Enumeration tests = allTests.tests();
- while (tests.hasMoreElements()) {
- Test t = (Test) tests.nextElement();
- if (t instanceof TestCase) {
- String name = ((TestCase) t).getName();
- if (name.endsWith("FailureExpected"))
- failureExpected.add(name);
- }
- }
-
- TestSuite result = new TestSuite();
- tests = allTests.tests();
- while (tests.hasMoreElements()) {
- Test t = (Test) tests.nextElement();
- if (t instanceof TestCase) {
- String name = ((TestCase) t).getName();
- if (!failureExpected.contains(name + "FailureExpected")) {
- result.addTest(t);
- }
- }
- }
-
- return result;
- }
}
\ No newline at end of file
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.collection;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -45,7 +47,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite =
createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
return getTestSetup(suite, "optimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/OptimisticReadOnlyTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.collection;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -44,7 +46,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite = createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
return getTestSetup(suite, "optimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticInvalidatedTransactionalTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.collection;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -44,7 +46,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite =
createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
return getTestSetup(suite, "pessimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticReadOnlyTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticReadOnlyTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/PessimisticReadOnlyTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.collection;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -44,7 +46,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite = createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
return getTestSetup(suite, "pessimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.entity;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -44,7 +46,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite =
createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
return getTestSetup(suite, "optimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/OptimisticReadOnlyTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.entity;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -44,7 +46,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite = createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
return getTestSetup(suite, "optimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticInvalidatedTransactionalTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticInvalidatedTransactionalTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.entity;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -44,7 +46,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite =
createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
return getTestSetup(suite, "pessimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticReadOnlyTestCase.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticReadOnlyTestCase.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/PessimisticReadOnlyTestCase.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,6 +23,8 @@
*/
package org.hibernate.test.cache.jbc2.entity;
+import org.hibernate.test.util.CacheTestUtil;
+
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -44,7 +46,7 @@
}
public static Test suite() throws Exception {
- TestSuite suite = createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
+ TestSuite suite =
CacheTestUtil.createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
return getTestSetup(suite, "pessimistic-entity");
}
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/OptimisticBulkOperationsTest.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/OptimisticBulkOperationsTest.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/bulk/OptimisticBulkOperationsTest.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -22,7 +22,12 @@
package org.hibernate.test.cache.jbc2.functional.bulk;
+import junit.framework.Test;
+import
org.hibernate.test.cache.jbc2.collection.OptimisticInvalidatedTransactionalTestCase;
+import org.hibernate.test.util.CacheTestUtil;
+
+
/**
* Optimistic version of BulkOperationsUnitTestCase.
*
@@ -32,6 +37,10 @@
public class OptimisticBulkOperationsTest
extends PessimisticBulkOperationsTest
{
+
+ public static Test suite() throws Exception {
+ return
CacheTestUtil.createFailureExpectedSuite(OptimisticBulkOperationsTest.class);
+ }
/**
* @param name
Modified:
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestUtil.java
===================================================================
---
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestUtil.java 2008-02-27
18:06:19 UTC (rev 14371)
+++
core/trunk/cache-jbosscache2/src/test/java/org/hibernate/test/util/CacheTestUtil.java 2008-02-27
18:36:29 UTC (rev 14372)
@@ -23,8 +23,15 @@
*/
package org.hibernate.test.util;
+import java.util.Enumeration;
+import java.util.HashSet;
import java.util.Properties;
+import java.util.Set;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
import org.hibernate.cache.jbc2.JBossCacheRegionFactory;
import org.hibernate.cache.jbc2.SharedJBossCacheRegionFactory;
import org.hibernate.cache.jbc2.builder.SharedCacheInstanceManager;
@@ -113,4 +120,43 @@
private CacheTestUtil() {
}
+ /**
+ * Supports easy creation of a TestSuite where a subclass'
"FailureExpected"
+ * version of a base test is included in the suite, while the base test
+ * is excluded. E.g. test class FooTestCase includes method testBar(), while test
+ * class SubFooTestCase extends FooTestCase includes method
testBarFailureExcluded().
+ * Passing SubFooTestCase.class to this method will return a suite that
+ * does not include testBar().
+ *
+ * FIXME Move this to UnitTestCase
+ */
+ public static TestSuite createFailureExpectedSuite(Class testClass) {
+
+ TestSuite allTests = new TestSuite(testClass);
+ Set failureExpected = new HashSet();
+ Enumeration tests = allTests.tests();
+ while (tests.hasMoreElements()) {
+ Test t = (Test) tests.nextElement();
+ if (t instanceof TestCase) {
+ String name = ((TestCase) t).getName();
+ if (name.endsWith("FailureExpected"))
+ failureExpected.add(name);
+ }
+ }
+
+ TestSuite result = new TestSuite();
+ tests = allTests.tests();
+ while (tests.hasMoreElements()) {
+ Test t = (Test) tests.nextElement();
+ if (t instanceof TestCase) {
+ String name = ((TestCase) t).getName();
+ if (!failureExpected.contains(name + "FailureExpected")) {
+ result.addTest(t);
+ }
+ }
+ }
+
+ return result;
+ }
+
}