Factor out usage of createFailureExpectedTestSuite
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14372 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
7c0305487f
commit
9b8bd0c9ff
|
@ -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 @@ public abstract class AbstractJBossCacheTestCase extends UnitTestCase {
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -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 class OptimisticInvalidatedTransactionalTestCase
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
|
||||
return getTestSetup(suite, "optimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class OptimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase {
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
|
||||
return getTestSetup(suite, "optimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class PessimisticInvalidatedTransactionalTestCase extends AbstractTransac
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
|
||||
return getTestSetup(suite, "pessimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class PessimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
|
||||
return getTestSetup(suite, "pessimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class OptimisticInvalidatedTransactionalTestCase extends AbstractTransact
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticInvalidatedTransactionalTestCase.class);
|
||||
return getTestSetup(suite, "optimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class OptimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase {
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(OptimisticReadOnlyTestCase.class);
|
||||
return getTestSetup(suite, "optimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class PessimisticInvalidatedTransactionalTestCase extends AbstractTransac
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticInvalidatedTransactionalTestCase.class);
|
||||
return getTestSetup(suite, "pessimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class PessimisticReadOnlyTestCase extends AbstractReadOnlyAccessTestCase
|
|||
}
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
TestSuite suite = createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
|
||||
TestSuite suite = CacheTestUtil.createFailureExpectedSuite(PessimisticReadOnlyTestCase.class);
|
||||
return getTestSetup(suite, "pessimistic-entity");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
|
||||
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.
|
||||
|
@ -33,6 +38,10 @@ public class OptimisticBulkOperationsTest
|
|||
extends PessimisticBulkOperationsTest
|
||||
{
|
||||
|
||||
public static Test suite() throws Exception {
|
||||
return CacheTestUtil.createFailureExpectedSuite(OptimisticBulkOperationsTest.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,14 @@
|
|||
*/
|
||||
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;
|
||||
|
@ -113,4 +120,43 @@ public class CacheTestUtil {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue