Fixes for Sporadic Test Failures
* `ClientWebSocketContainer`: add some synchronization to avoid race conditions: https://build.spring.io/browse/INT-B41-492 * `TomcatWebSocketTestServer`: convert to `0` port to rely on the OS resolution for `localPort` * Add `LogAdjustingTestSupport` for STOMP test * `SftpServerTests`: use `0` port to rely on the OS resolution for `localPort` * `ImapMailReceiver`, `OutboundGatewayFunctionTests` (JMS), `CachingClientConnectionFactoryTests`, `AsyncGatewayTests`, `AsyncMessagingTemplateTests`, `GatewayParserTests`, `PriorityChannelTests`, `AggregatorIntegrationTests`: increase timeout * `EnableIntegrationTests`: use `LogAdjustingTestSupport` * `FileOutboundChannelAdapterParserTests`: rework `Thread.sleep()` with `CountDownLatch` * `ConnectionToConnectionTests`: increase timeout and count iteration. Previously with `1sec` we may lose some events. And we can't just rely on the `10sec`, because the last iteration will be so long * `TcpOutboundGatewayTests`: `500ms` is so big timeout to wait for the `Exception` that in the high load environment we can yield to other Thread so long. Like in our case to `server` Thread to send the reply for us. Therefore decrease the Exception timeout to the `50ms` and increase server delay to `2sec` * `StompInboundChannelAdapterWebSocketIntegrationTests`: remove `@Qualifier("taskScheduler")` as a potential candidate to test against latest SF changes. We're fine with `SF-4.2.2` and it is just a test-case. So, I don't see reason to wait for their fix here. STOMP: `session = null` in adapters for any transportError Polishing
This commit is contained in:
committed by
Gary Russell
parent
e45bb36be2
commit
9d8e2b61f6
@@ -93,13 +93,25 @@
|
||||
<si:channel id="usageChannelConcurrent">
|
||||
<si:dispatcher task-executor="executor"/>
|
||||
</si:channel>
|
||||
|
||||
|
||||
<file:outbound-channel-adapter channel="usageChannelConcurrent"
|
||||
filename-generator-expression="'fileToAppendConcurrent.txt'"
|
||||
mode="APPEND"
|
||||
directory="test"/>
|
||||
directory="test">
|
||||
<file:request-handler-advice-chain>
|
||||
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
|
||||
<property name="onSuccessExpression" value="@fileWriteLatch.countDown()"/>
|
||||
</bean>
|
||||
</file:request-handler-advice-chain>
|
||||
</file:outbound-channel-adapter>
|
||||
|
||||
<bean id="customFileNameGenerator" class="org.springframework.integration.file.config.CustomFileNameGenerator"/>
|
||||
|
||||
<bean id="fileWriteLatch" class="java.util.concurrent.CountDownLatch">
|
||||
<constructor-arg value="2"/>
|
||||
</bean>
|
||||
|
||||
<context:property-placeholder/>
|
||||
|
||||
<task:executor id="executor" pool-size="100"/>
|
||||
|
||||
@@ -25,6 +25,8 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -33,15 +35,15 @@ import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
@@ -55,6 +57,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Tony Falabella
|
||||
* @author Artem Bilan
|
||||
*
|
||||
*/
|
||||
@ContextConfiguration
|
||||
@@ -100,6 +103,9 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
@Autowired
|
||||
MessageChannel usageChannelConcurrent;
|
||||
|
||||
@Autowired
|
||||
CountDownLatch fileWriteLatch;
|
||||
|
||||
private volatile static int adviceCalled;
|
||||
|
||||
@Test
|
||||
@@ -313,7 +319,8 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
usageChannelConcurrent.send(new GenericMessage<String>(bString));
|
||||
}
|
||||
|
||||
Thread.sleep(2000);
|
||||
assertTrue(this.fileWriteLatch.await(10, TimeUnit.SECONDS));
|
||||
|
||||
String actualFileContent = new String(FileCopyUtils.copyToByteArray(testFile));
|
||||
int beginningIndex = 0;
|
||||
for (int i = 0; i < 2; i++) {
|
||||
|
||||
Reference in New Issue
Block a user