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
@@ -23,8 +23,6 @@ import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -55,8 +53,6 @@ import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.simp.stomp.Reactor2TcpStompClient;
|
||||
import org.springframework.messaging.simp.stomp.StompCommand;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ConcurrentTaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
@@ -81,11 +77,13 @@ public class StompServerIntegrationTests {
|
||||
activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5);
|
||||
activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5);
|
||||
activeMQBroker.start();
|
||||
|
||||
stompClient = new Reactor2TcpStompClient("127.0.0.1", port);
|
||||
stompClient.setMessageConverter(new PassThruMessageConverter());
|
||||
ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
|
||||
taskScheduler.afterPropertiesSet();
|
||||
stompClient.setTaskScheduler(taskScheduler);
|
||||
stompClient.setReceiptTimeLimit(5000);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
||||
@@ -59,6 +59,7 @@ import org.springframework.messaging.simp.broker.SubscriptionRegistry;
|
||||
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
import org.springframework.messaging.simp.stomp.StompCommand;
|
||||
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
|
||||
import org.springframework.messaging.simp.stomp.StompHeaders;
|
||||
import org.springframework.messaging.support.AbstractSubscribableChannel;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
@@ -209,7 +210,6 @@ public class StompInboundChannelAdapterWebSocketIntegrationTests {
|
||||
public WebSocketStompClient stompClient(TaskScheduler taskScheduler) {
|
||||
WebSocketStompClient webSocketStompClient = new WebSocketStompClient(webSocketClient());
|
||||
webSocketStompClient.setMessageConverter(new MappingJackson2MessageConverter());
|
||||
webSocketStompClient.setDefaultHeartbeat(new long[]{100, 100});
|
||||
webSocketStompClient.setTaskScheduler(taskScheduler);
|
||||
return webSocketStompClient;
|
||||
}
|
||||
@@ -219,6 +219,9 @@ public class StompInboundChannelAdapterWebSocketIntegrationTests {
|
||||
WebSocketStompSessionManager webSocketStompSessionManager =
|
||||
new WebSocketStompSessionManager(stompClient, server().getWsBaseUrl() + "/ws");
|
||||
webSocketStompSessionManager.setAutoReceipt(true);
|
||||
StompHeaders stompHeaders = new StompHeaders();
|
||||
stompHeaders.setHeartbeat(new long[] {10000, 10000});
|
||||
webSocketStompSessionManager.setConnectHeaders(stompHeaders);
|
||||
return webSocketStompSessionManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -53,6 +54,7 @@ import org.springframework.integration.stomp.WebSocketStompSessionManager;
|
||||
import org.springframework.integration.stomp.event.StompExceptionEvent;
|
||||
import org.springframework.integration.stomp.event.StompIntegrationEvent;
|
||||
import org.springframework.integration.stomp.event.StompReceiptEvent;
|
||||
import org.springframework.integration.test.support.LongRunningIntegrationTest;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.integration.websocket.TomcatWebSocketTestServer;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -95,6 +97,9 @@ import org.springframework.web.socket.sockjs.client.WebSocketTransport;
|
||||
@DirtiesContext
|
||||
public class StompMessageHandlerWebSocketIntegrationTests {
|
||||
|
||||
@ClassRule
|
||||
public static LongRunningIntegrationTest longTests = new LongRunningIntegrationTest();
|
||||
|
||||
@Value("#{server.serverContext}")
|
||||
private ApplicationContext serverContext;
|
||||
|
||||
@@ -113,10 +118,10 @@ public class StompMessageHandlerWebSocketIntegrationTests {
|
||||
@Test
|
||||
public void testStompMessageHandler() throws InterruptedException {
|
||||
int n = 0;
|
||||
while (TestUtils.getPropertyValue(this.stompMessageHandler, "stompSession") == null && n++ < 10) {
|
||||
Thread.sleep(50);
|
||||
while (TestUtils.getPropertyValue(this.stompMessageHandler, "stompSession") == null && n++ < 100) {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
assertTrue(n < 10);
|
||||
assertTrue(n < 100);
|
||||
|
||||
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SEND);
|
||||
headers.setDestination("/app/simple");
|
||||
@@ -180,7 +185,7 @@ public class StompMessageHandlerWebSocketIntegrationTests {
|
||||
public WebSocketStompClient stompClient(TaskScheduler taskScheduler) {
|
||||
WebSocketStompClient webSocketStompClient = new WebSocketStompClient(webSocketClient());
|
||||
webSocketStompClient.setTaskScheduler(taskScheduler);
|
||||
webSocketStompClient.setReceiptTimeLimit(200);
|
||||
webSocketStompClient.setReceiptTimeLimit(5000);
|
||||
webSocketStompClient.setMessageConverter(new StringMessageConverter());
|
||||
return webSocketStompClient;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user