Repository: activemq
Updated Branches:
  refs/heads/trunk c34f8426a -> df0c19594


Fix OOME errors in tests


Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/df0c1959
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/df0c1959
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/df0c1959

Branch: refs/heads/trunk
Commit: df0c195941537589d7cb224443f40899e2cda5bb
Parents: c34f842
Author: Hadrian Zbarcea <[email protected]>
Authored: Wed Mar 5 12:32:46 2014 -0500
Committer: Hadrian Zbarcea <[email protected]>
Committed: Wed Mar 5 12:32:46 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/activemq/web/AjaxTest.java  | 54 ++++++++++++--------
 .../java/org/apache/activemq/web/RestTest.java  | 19 +++----
 2 files changed, 43 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/df0c1959/activemq-web-demo/src/test/java/org/apache/activemq/web/AjaxTest.java
----------------------------------------------------------------------
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 5c6d9db..d229367 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 <response> 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( "<response id='handler' destination='queue://test' 
>msg1</response>", fullResponse );
         assertContains( "<response id='handler' destination='queue://test' 
>msg2</response>", fullResponse );
         assertContains( "<response id='handler' destination='queue://test' 
>msg3</response>", 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( "<response id='handler' destination='topic://test' 
>msg2</response>", fullResponse );
         assertContains( "<response id='handler' destination='topic://test' 
>msg3</response>", 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( "<response id='handler' destination='queue://test' 
>test two</response>", response );
         assertContains( "<response id='handler' destination='queue://test' 
>test three</response>", 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( "<response id='handler' destination='queue://test' 
>message4</response>", fullResponse );
         assertContains( "<response id='handler' destination='queue://test' 
>message5</response>", 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 = "<response id='handler' destination='queue://test' 
>test two</response>";
-
         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 =  "<response id='handlerB' destination='queue://testB' 
>B1</response>";
         expected2 = "<response id='handlerB' destination='queue://testB' 
>B2</response>";
-
         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( "<response id='handlerA' destination='topic://topicA' 
>A2</response>", fullResponse );
         assertContains( "<response id='handlerB' destination='topic://topicB' 
>B2</response>", fullResponse );
         assertResponseCount( 4, fullResponse );
+
+        httpClient.stop();
      }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/df0c1959/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java
----------------------------------------------------------------------
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 a9223bd..13488f0 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();

Reply via email to