Skip to content

Commit df1783a

Browse files
author
dsyer
committed
Ignore test that fails sometimes but adds no value
1 parent 8b96e46 commit df1783a

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

spring-batch-infrastructure/src/test/java/org/springframework/batch/support/transaction/ConcurrentTransactionAwareProxyTests.java

+18-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@
3333
import java.util.concurrent.ExecutorService;
3434
import java.util.concurrent.Executors;
3535

36+
import org.apache.commons.logging.Log;
37+
import org.apache.commons.logging.LogFactory;
3638
import org.junit.After;
3739
import org.junit.Before;
40+
import org.junit.Ignore;
3841
import org.junit.Test;
3942
import org.springframework.transaction.PlatformTransactionManager;
4043
import org.springframework.transaction.TransactionStatus;
@@ -48,11 +51,13 @@
4851
*/
4952
public class ConcurrentTransactionAwareProxyTests {
5053

54+
private static Log logger = LogFactory.getLog(ConcurrentTransactionAwareProxyTests.class);
55+
5156
private PlatformTransactionManager transactionManager = new ResourcelessTransactionManager();
5257

53-
int outerMax = 10;
58+
int outerMax = 20;
5459

55-
int innerMax = 15;
60+
int innerMax = 30;
5661

5762
private ExecutorService executor;
5863

@@ -84,14 +89,15 @@ public void testConcurrentTransactionalAppendOnlySet() throws Exception {
8489
@Test
8590
public void testConcurrentTransactionalAppendOnlyList() throws Exception {
8691
List<String> list = TransactionAwareProxyFactory.createAppendOnlyTransactionalList();
87-
testList(list);
92+
testList(list, false);
8893
}
8994

95+
@Ignore("This fails too often and is a false negative")
9096
@Test
9197
public void testConcurrentTransactionalList() throws Exception {
9298
List<String> list = TransactionAwareProxyFactory.createTransactionalList();
9399
try {
94-
testList(list);
100+
testList(list, true);
95101
fail("Expected ExecutionException or AssertionError (but don't panic if it didn't happen: it probably just means we got lucky for a change)");
96102
}
97103
catch (ExecutionException e) {
@@ -155,7 +161,7 @@ public List<String> call() throws Exception {
155161

156162
}
157163

158-
private void testList(final List<String> list) throws Exception {
164+
private void testList(final List<String> list, final boolean mutate) throws Exception {
159165

160166
for (int i = 0; i < outerMax; i++) {
161167

@@ -166,7 +172,14 @@ public List<String> call() throws Exception {
166172
String value = "bar" + i;
167173
saveInListAndAssert(list, value);
168174
result.add(value);
175+
// Need to slow it down to allow threads to interleave
176+
Thread.sleep(10L);
177+
if (mutate) {
178+
list.remove(value);
179+
list.add(value);
180+
}
169181
}
182+
logger.info("Added: " + innerMax + " values");
170183
return result;
171184
}
172185
});

spring-batch-infrastructure/src/test/resources/log4j.properties

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ log4j.appender.stdout.layout.ConversionPattern=%d %p %t [%c] - <%m>%n
66

77
log4j.category.org.springframework.batch=DEBUG
88
log4j.category.org.springframework.transaction=INFO
9+
log4j.category.org.springframework.batch.support.transaction.ResourcelessTransactionManager=INFO
910
log4j.category.org.springframework.jdbc.datasource=INFO

0 commit comments

Comments
 (0)