Ignore test that fails sometimes but adds no value

This commit is contained in:
dsyer
2010-08-02 15:21:05 +00:00
parent 8b96e46500
commit df1783a76e
2 changed files with 19 additions and 5 deletions

View File

@@ -33,8 +33,11 @@ import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionStatus;
@@ -48,11 +51,13 @@ import org.springframework.util.Assert;
*/
public class ConcurrentTransactionAwareProxyTests {
private static Log logger = LogFactory.getLog(ConcurrentTransactionAwareProxyTests.class);
private PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
int outerMax = 10;
int outerMax = 20;
int innerMax = 15;
int innerMax = 30;
private ExecutorService executor;
@@ -84,14 +89,15 @@ public class ConcurrentTransactionAwareProxyTests {
@Test
public void testConcurrentTransactionalAppendOnlyList() throws Exception {
List<String> list = TransactionAwareProxyFactory.createAppendOnlyTransactionalList();
testList(list);
testList(list, false);
}
@Ignore("This fails too often and is a false negative")
@Test
public void testConcurrentTransactionalList() throws Exception {
List<String> list = TransactionAwareProxyFactory.createTransactionalList();
try {
testList(list);
testList(list, true);
fail("Expected ExecutionException or AssertionError (but don't panic if it didn't happen: it probably just means we got lucky for a change)");
}
catch (ExecutionException e) {
@@ -155,7 +161,7 @@ public class ConcurrentTransactionAwareProxyTests {
}
private void testList(final List<String> list) throws Exception {
private void testList(final List<String> list, final boolean mutate) throws Exception {
for (int i = 0; i < outerMax; i++) {
@@ -166,7 +172,14 @@ public class ConcurrentTransactionAwareProxyTests {
String value = "bar" + i;
saveInListAndAssert(list, value);
result.add(value);
// Need to slow it down to allow threads to interleave
Thread.sleep(10L);
if (mutate) {
list.remove(value);
list.add(value);
}
}
logger.info("Added: " + innerMax + " values");
return result;
}
});

View File

@@ -6,4 +6,5 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p %t [%c] - <%m>%n
log4j.category.org.springframework.batch=DEBUG
log4j.category.org.springframework.transaction=INFO
log4j.category.org.springframework.batch.support.transaction.ResourcelessTransactionManager=INFO
log4j.category.org.springframework.jdbc.datasource=INFO