Browse Source

Increase timeout in StompWebSocketIntegrationTests

... with hope of reducing the fragility of these tests on the CI server.
pull/859/head
Sam Brannen 11 years ago
parent
commit
c572d0c469
  1. 36
      spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java

36
spring-websocket/src/test/java/org/springframework/web/socket/messaging/StompWebSocketIntegrationTests.java

@ -16,11 +16,8 @@ @@ -16,11 +16,8 @@
package org.springframework.web.socket.messaging;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CountDownLatch;
@ -71,13 +68,15 @@ import static org.springframework.web.socket.messaging.StompTextMessageBuilder.* @@ -71,13 +68,15 @@ import static org.springframework.web.socket.messaging.StompTextMessageBuilder.*
@RunWith(Parameterized.class)
public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegrationTests {
private static final long TIMEOUT = 10;
@Parameters(name = "server [{0}], client [{1}]")
public static Iterable<Object[]> arguments() {
return Arrays.asList(new Object[][] {
public static Object[][] arguments() {
return new Object[][] {
{new JettyWebSocketTestServer(), new JettyWebSocketClient()},
{new TomcatWebSocketTestServer(), new StandardWebSocketClient()},
{new UndertowTestServer(), new StandardWebSocketClient()}
});
};
}
@ -94,7 +93,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -94,7 +93,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
SimpleController controller = this.wac.getBean(SimpleController.class);
try {
assertTrue(controller.latch.await(10, TimeUnit.SECONDS));
assertTrue(controller.latch.await(TIMEOUT, TimeUnit.SECONDS));
}
finally {
session.close();
@ -112,7 +111,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -112,7 +111,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
WebSocketSession session = doHandshake(clientHandler, "/ws").get();
try {
assertTrue(clientHandler.latch.await(2, TimeUnit.SECONDS));
assertTrue(clientHandler.latch.await(TIMEOUT, TimeUnit.SECONDS));
}
finally {
session.close();
@ -120,7 +119,6 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -120,7 +119,6 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
}
// SPR-10930
@Test
public void sendMessageToBrokerAndReceiveReplyViaTopic() throws Exception {
TextMessage m1 = create(StompCommand.SUBSCRIBE).headers("id:subs1", "destination:/topic/foo").build();
@ -130,7 +128,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -130,7 +128,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
WebSocketSession session = doHandshake(clientHandler, "/ws").get();
try {
assertTrue(clientHandler.latch.await(2, TimeUnit.SECONDS));
assertTrue(clientHandler.latch.await(TIMEOUT, TimeUnit.SECONDS));
String payload = clientHandler.actual.get(0).getPayload();
assertTrue("Expected STOMP MESSAGE, got " + payload, payload.startsWith("MESSAGE\n"));
@ -141,7 +139,6 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -141,7 +139,6 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
}
// SPR-11648
@Test
public void sendSubscribeToControllerAndReceiveReply() throws Exception {
String destHeader = "destination:/app/number";
@ -151,7 +148,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -151,7 +148,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
WebSocketSession session = doHandshake(clientHandler, "/ws").get();
try {
assertTrue(clientHandler.latch.await(2, TimeUnit.SECONDS));
assertTrue(clientHandler.latch.await(TIMEOUT, TimeUnit.SECONDS));
String payload = clientHandler.actual.get(0).getPayload();
assertTrue("Expected STOMP destination=/app/number, got " + payload, payload.contains(destHeader));
assertTrue("Expected STOMP Payload=42, got " + payload, payload.contains("42"));
@ -171,7 +168,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -171,7 +168,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
WebSocketSession session = doHandshake(clientHandler, "/ws").get();
try {
assertTrue(clientHandler.latch.await(2, TimeUnit.SECONDS));
assertTrue(clientHandler.latch.await(TIMEOUT, TimeUnit.SECONDS));
String payload = clientHandler.actual.get(0).getPayload();
assertTrue(payload.startsWith("MESSAGE\n"));
assertTrue(payload.contains("destination:/user/queue/error\n"));
@ -193,7 +190,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -193,7 +190,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
WebSocketSession session = doHandshake(clientHandler, "/ws").get();
try {
assertTrue(clientHandler.latch.await(2, TimeUnit.SECONDS));
assertTrue(clientHandler.latch.await(TIMEOUT, TimeUnit.SECONDS));
String payload = clientHandler.actual.get(0).getPayload();
assertTrue(payload.startsWith("MESSAGE\n"));
assertTrue(payload.contains("destination:/topic/scopedBeanValue\n"));
@ -205,7 +202,6 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -205,7 +202,6 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
}
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Controller
private @interface IntegrationTestController {
@ -217,12 +213,12 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -217,12 +213,12 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
private CountDownLatch latch = new CountDownLatch(1);
@MessageMapping(value="/simple")
@MessageMapping("/simple")
public void handle() {
this.latch.countDown();
}
@MessageMapping(value="/exception")
@MessageMapping("/exception")
public void handleWithError() {
throw new IllegalArgumentException("Bad input");
}
@ -238,7 +234,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -238,7 +234,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
@IntegrationTestController
static class IncrementController {
@MessageMapping(value="/increment")
@MessageMapping("/increment")
public int handle(int i) {
return i + 1;
}
@ -260,7 +256,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -260,7 +256,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
this.scopedBean = scopedBean;
}
@MessageMapping(value="/scopedBeanValue")
@MessageMapping("/scopedBeanValue")
public String getValue() {
return this.scopedBean.getValue();
}
@ -341,7 +337,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration @@ -341,7 +337,7 @@ public class StompWebSocketIntegrationTests extends AbstractWebSocketIntegration
}
@Bean
@Scope(value="websocket", proxyMode=ScopedProxyMode.INTERFACES)
@Scope(scopeName = "websocket", proxyMode = ScopedProxyMode.INTERFACES)
public ScopedBean scopedBean() {
return new ScopedBeanImpl("55");
}

Loading…
Cancel
Save