INT-3786: Fix Several Sporadic Test Failures
JIRA: https://jira.spring.io/browse/INT-3786 * Increase `receiveTimeout` for several `QueueChannel` and `CountDownLatch` based tests * Fix `FileSplitterTests` for Windows compatibility - `UTF-8` for bytes conversion * Make some STOMP tests as `LongRunning` The next fixing phase
This commit is contained in:
committed by
Gary Russell
parent
3c9b0e4e82
commit
ec12b289c2
@@ -41,6 +41,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
/**
|
||||
* @author Iwein Fuld
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@@ -87,7 +88,7 @@ public class FileReadingMessageSourceIntegrationTests {
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanoutInputDir() throws Exception {
|
||||
public void cleanupInputDir() throws Exception {
|
||||
File[] listFiles = inputDir.listFiles();
|
||||
for (int i = 0; i < listFiles.length; i++) {
|
||||
listFiles[i].delete();
|
||||
@@ -140,11 +141,12 @@ public class FileReadingMessageSourceIntegrationTests {
|
||||
assertNull(pollableFileSource.receive());
|
||||
}
|
||||
|
||||
@Test(timeout = 6000)
|
||||
@Test
|
||||
@Repeat(5)
|
||||
public void concurrentProcessing() throws Exception {
|
||||
CountDownLatch go = new CountDownLatch(1);
|
||||
Runnable succesfulConsumer = new Runnable() {
|
||||
Runnable successfulConsumer = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Message<File> received = pollableFileSource.receive();
|
||||
@@ -154,8 +156,10 @@ public class FileReadingMessageSourceIntegrationTests {
|
||||
}
|
||||
pollableFileSource.onSend(received);
|
||||
}
|
||||
|
||||
};
|
||||
Runnable failingConsumer = new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Message<File> received = pollableFileSource.receive();
|
||||
@@ -163,12 +167,13 @@ public class FileReadingMessageSourceIntegrationTests {
|
||||
pollableFileSource.onFailure(received);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
CountDownLatch succesfulDone = doConcurrently(3, succesfulConsumer, go);
|
||||
CountDownLatch successfulDone = doConcurrently(3, successfulConsumer, go);
|
||||
CountDownLatch failingDone = doConcurrently(10, failingConsumer, go);
|
||||
go.countDown();
|
||||
try {
|
||||
succesfulDone.await();
|
||||
successfulDone.await();
|
||||
failingDone.await();
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
@@ -187,7 +192,8 @@ public class FileReadingMessageSourceIntegrationTests {
|
||||
*
|
||||
* @param numberOfThreads how many threads to spawn
|
||||
* @param runnable the runnable that should be run by all the threads
|
||||
* @param start the {@link java.util.concurrent.CountDownLatch} instance telling it when to assume everything works
|
||||
* @param start the {@link java.util.concurrent.CountDownLatch} instance
|
||||
* telling it when to assume everything works
|
||||
* @return a latch that will be counted down once all threads have run their
|
||||
* runnable.
|
||||
*/
|
||||
@@ -210,8 +216,10 @@ public class FileReadingMessageSourceIntegrationTests {
|
||||
runnable.run();
|
||||
done.countDown();
|
||||
}
|
||||
|
||||
}).start();
|
||||
}
|
||||
return done;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
xmlns:int-file="http://www.springframework.org/schema/integration/file"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd">
|
||||
http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">
|
||||
|
||||
<int:splitter input-channel="input1" output-channel="output">
|
||||
<bean class="org.springframework.integration.file.splitter.FileSplitter">
|
||||
<constructor-arg value="false"/>
|
||||
</bean>
|
||||
</int:splitter>
|
||||
<int-file:splitter input-channel="input1" output-channel="output" iterator="false" charset="UTF-8"/>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user