diff --git a/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java b/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java index 5c6d9db9e0..d229367032 100644 --- a/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java +++ b/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java @@ -73,13 +73,13 @@ public class AjaxTest extends JettyTestSupport { assertEquals( "Expected number of elements is not correct.", expected, occurrences ); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling() throws Exception { LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling ***" ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); // client 1 subscribes to a queue LOG.debug( "SENDING LISTEN" ); @@ -132,17 +132,18 @@ public class AjaxTest extends JettyTestSupport { assertContains( "msg1", fullResponse ); assertContains( "msg2", fullResponse ); assertContains( "msg3", fullResponse ); - assertResponseCount( 3, fullResponse ); - } - @Test(timeout = 60 * 1000) + httpClient.stop(); +} + + @Test(timeout = 15 * 1000) public void testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling() throws Exception { LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling ***" ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); // client 1 subscribes to a queue LOG.debug( "SENDING LISTEN" ); @@ -197,9 +198,11 @@ public class AjaxTest extends JettyTestSupport { assertContains( "msg2", fullResponse ); assertContains( "msg3", fullResponse ); assertResponseCount( 3, fullResponse ); + + httpClient.stop(); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testAjaxClientReceivesMessagesWhichAreQueuedBeforeClientSubscribes() throws Exception { LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreQueuedBeforeClientSubscribes ***" ); // send messages to queue://test @@ -208,8 +211,8 @@ public class AjaxTest extends JettyTestSupport { producer.send( session.createTextMessage("test three") ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); // client 1 subscribes to queue LOG.debug( "SENDING LISTEN" ); @@ -238,15 +241,17 @@ public class AjaxTest extends JettyTestSupport { assertContains( "test two", response ); assertContains( "test three", response ); assertResponseCount( 3, response ); + + httpClient.stop(); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testStompMessagesAreReceivedByAjaxClient() throws Exception { LOG.debug( "*** testStompMessagesAreRecievedByAjaxClient ***" ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); // client 1 subscribes to a queue LOG.debug( "SENDING LISTEN" ); @@ -307,15 +312,17 @@ public class AjaxTest extends JettyTestSupport { assertContains( "message4", fullResponse ); assertContains( "message5", fullResponse ); assertResponseCount( 5, fullResponse ); + + httpClient.stop(); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testAjaxMessagesAreReceivedByStompClient() throws Exception { LOG.debug( "*** testAjaxMessagesAreReceivedByStompClient ***" ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); AjaxTestContentExchange contentExchange = new AjaxTestContentExchange(); contentExchange.setMethod( "POST" ); @@ -349,9 +356,11 @@ public class AjaxTest extends JettyTestSupport { assertContains( "msg2", allMessageBodies ); assertContains( "msg3", allMessageBodies ); assertContains( "msg4", allMessageBodies ); + + httpClient.stop(); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testAjaxClientMayUseSelectors() throws Exception { LOG.debug( "*** testAjaxClientMayUseSelectors ***" ); @@ -364,10 +373,10 @@ public class AjaxTest extends JettyTestSupport { producer.send( msg ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); - // client ubscribes to queue + // client subscribes to queue LOG.debug( "SENDING LISTEN" ); AjaxTestContentExchange contentExchange = new AjaxTestContentExchange(); contentExchange.setMethod( "POST" ); @@ -392,12 +401,12 @@ public class AjaxTest extends JettyTestSupport { LOG.debug( poll.getResponseContent() ); String expected = "test two"; - assertContains( expected, poll.getResponseContent() ); + httpClient.stop(); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testMultipleAjaxClientsMayExistInTheSameSession() throws Exception { LOG.debug( "*** testMultipleAjaxClientsMayExistInTheSameSession ***" ); @@ -410,8 +419,8 @@ public class AjaxTest extends JettyTestSupport { producerB.send( session.createTextMessage("B2") ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); // clientA subscribes to /queue/testA LOG.debug( "SENDING LISTEN" ); @@ -470,17 +479,18 @@ public class AjaxTest extends JettyTestSupport { LOG.debug( "clientB response : " + poll.getResponseContent() ); expected1 = "B1"; expected2 = "B2"; - assertContains( expected1, poll.getResponseContent() ); assertContains( expected2, poll.getResponseContent() ); + + httpClient.stop(); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testAjaxClientReceivesMessagesForMultipleTopics() throws Exception { LOG.debug( "*** testAjaxClientReceivesMessagesForMultipleTopics ***" ); HttpClient httpClient = new HttpClient(); - httpClient.start(); httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); LOG.debug( "SENDING LISTEN FOR /topic/topicA" ); AjaxTestContentExchange contentExchange = new AjaxTestContentExchange(); @@ -545,5 +555,7 @@ public class AjaxTest extends JettyTestSupport { assertContains( "A2", fullResponse ); assertContains( "B2", fullResponse ); assertResponseCount( 4, fullResponse ); + + httpClient.stop(); } } diff --git a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java index a9223bd46b..13488f02a9 100644 --- a/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java +++ b/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java @@ -92,8 +92,12 @@ public class RestTest extends JettyTestSupport { } // test for https://issues.apache.org/activemq/browse/AMQ-2827 - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testCorrelation() throws Exception { + HttpClient httpClient = new HttpClient(); + httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); + httpClient.start(); + for (int i = 0; i < 200; i++) { String correlId = "RESTY" + RandomStringUtils.randomNumeric(10); @@ -102,13 +106,9 @@ public class RestTest extends JettyTestSupport { message.setJMSCorrelationID(correlId); LOG.info("Sending: " + correlId); - producer.send(message); - HttpClient httpClient = new HttpClient(); - httpClient.start(); ContentExchange contentExchange = new ContentExchange(); - httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue&clientId=test"); httpClient.send(contentExchange); contentExchange.waitForDone(); @@ -116,9 +116,10 @@ public class RestTest extends JettyTestSupport { assertEquals(200, contentExchange.getResponseStatus()); assertEquals(correlId, contentExchange.getResponseContent()); } + httpClient.stop(); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testDisconnect() throws Exception { producer.send(session.createTextMessage("test")); @@ -144,7 +145,7 @@ public class RestTest extends JettyTestSupport { assertEquals("Consumers not closed", 0 , subs.size()); } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testPost() throws Exception { HttpClient httpClient = new HttpClient(); httpClient.start(); @@ -165,7 +166,7 @@ public class RestTest extends JettyTestSupport { } // test for https://issues.apache.org/activemq/browse/AMQ-3857 - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testProperties() throws Exception { HttpClient httpClient = new HttpClient(); httpClient.start(); @@ -190,7 +191,7 @@ public class RestTest extends JettyTestSupport { } - @Test(timeout = 60 * 1000) + @Test(timeout = 15 * 1000) public void testAuth() throws Exception { HttpClient httpClient = new HttpClient(); httpClient.start();