mirror of https://github.com/apache/activemq.git
Converted to JUnit 4 and added timeouts. See AMQ-5013
This commit is contained in:
parent
da3775302c
commit
bdf7aa4823
|
@ -31,9 +31,12 @@ import org.eclipse.jetty.client.ContentExchange;
|
|||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class AjaxTest extends JettyTestSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AjaxTest.class);
|
||||
|
||||
|
@ -70,6 +73,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertEquals( "Expected number of <response> elements is not correct.", expected, occurrences );
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling ***" );
|
||||
|
||||
|
@ -132,6 +136,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertResponseCount( 3, fullResponse );
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling ***" );
|
||||
|
||||
|
@ -194,6 +199,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertResponseCount( 3, fullResponse );
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testAjaxClientReceivesMessagesWhichAreQueuedBeforeClientSubscribes() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreQueuedBeforeClientSubscribes ***" );
|
||||
// send messages to queue://test
|
||||
|
@ -234,6 +240,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertResponseCount( 3, response );
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testStompMessagesAreReceivedByAjaxClient() throws Exception {
|
||||
LOG.debug( "*** testStompMessagesAreRecievedByAjaxClient ***" );
|
||||
|
||||
|
@ -302,6 +309,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertResponseCount( 5, fullResponse );
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testAjaxMessagesAreReceivedByStompClient() throws Exception {
|
||||
LOG.debug( "*** testAjaxMessagesAreReceivedByStompClient ***" );
|
||||
|
||||
|
@ -343,6 +351,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertContains( "msg4", allMessageBodies );
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testAjaxClientMayUseSelectors() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientMayUseSelectors ***" );
|
||||
|
||||
|
@ -388,6 +397,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testMultipleAjaxClientsMayExistInTheSameSession() throws Exception {
|
||||
LOG.debug( "*** testMultipleAjaxClientsMayExistInTheSameSession ***" );
|
||||
|
||||
|
@ -465,6 +475,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertContains( expected2, poll.getResponseContent() );
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testAjaxClientReceivesMessagesForMultipleTopics() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesForMultipleTopics ***" );
|
||||
HttpClient httpClient = new HttpClient();
|
||||
|
|
|
@ -24,7 +24,6 @@ import javax.jms.MessageProducer;
|
|||
import javax.jms.Session;
|
||||
import javax.net.SocketFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.util.Wait;
|
||||
|
@ -32,10 +31,14 @@ import org.eclipse.jetty.server.Connector;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.nio.SelectChannelConnector;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class JettyTestSupport extends TestCase {
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class JettyTestSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JettyTestSupport.class);
|
||||
|
||||
BrokerService broker;
|
||||
|
@ -52,7 +55,8 @@ public class JettyTestSupport extends TestCase {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
broker = new BrokerService();
|
||||
broker.setBrokerName("amq-broker");
|
||||
broker.setPersistent(isPersistent());
|
||||
|
@ -86,7 +90,9 @@ public class JettyTestSupport extends TestCase {
|
|||
producer = session.createProducer(session.createQueue("test"));
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
session.close();
|
||||
connection.close();
|
||||
server.stop();
|
||||
|
|
|
@ -22,6 +22,9 @@ import org.eclipse.jetty.client.ContentExchange;
|
|||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class RestPersistentTest extends JettyTestSupport {
|
||||
|
||||
|
@ -31,10 +34,13 @@ public class RestPersistentTest extends JettyTestSupport {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testPostAndGetWithQueue() throws Exception {
|
||||
postAndGet("queue");
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
@Ignore("Needs a JIRA")
|
||||
public void testPostAndGetWithTopic() throws Exception {
|
||||
// TODO: problems with topics
|
||||
// postAndGet("topic");
|
||||
|
|
|
@ -26,12 +26,16 @@ import org.eclipse.jetty.client.ContentExchange;
|
|||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class RestTest extends JettyTestSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RestTest.class);
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testConsume() throws Exception {
|
||||
producer.send(session.createTextMessage("test"));
|
||||
LOG.info("message sent");
|
||||
|
@ -46,6 +50,7 @@ public class RestTest extends JettyTestSupport {
|
|||
assertEquals("test", contentExchange.getResponseContent());
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testSubscribeFirst() throws Exception {
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
|
@ -63,6 +68,7 @@ public class RestTest extends JettyTestSupport {
|
|||
assertEquals("test", contentExchange.getResponseContent());
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testSelector() throws Exception {
|
||||
TextMessage msg1 = session.createTextMessage("test1");
|
||||
msg1.setIntProperty("test", 1);
|
||||
|
@ -86,6 +92,7 @@ public class RestTest extends JettyTestSupport {
|
|||
}
|
||||
|
||||
// test for https://issues.apache.org/activemq/browse/AMQ-2827
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testCorrelation() throws Exception {
|
||||
for (int i = 0; i < 200; i++) {
|
||||
String correlId = "RESTY" + RandomStringUtils.randomNumeric(10);
|
||||
|
@ -111,6 +118,7 @@ public class RestTest extends JettyTestSupport {
|
|||
}
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testDisconnect() throws Exception {
|
||||
|
||||
producer.send(session.createTextMessage("test"));
|
||||
|
@ -136,6 +144,7 @@ public class RestTest extends JettyTestSupport {
|
|||
assertEquals("Consumers not closed", 0 , subs.size());
|
||||
}
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testPost() throws Exception {
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
|
@ -156,6 +165,7 @@ public class RestTest extends JettyTestSupport {
|
|||
}
|
||||
|
||||
// test for https://issues.apache.org/activemq/browse/AMQ-3857
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testProperties() throws Exception {
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
|
@ -179,6 +189,8 @@ public class RestTest extends JettyTestSupport {
|
|||
assertEquals("header value", "value", fields.getStringField("property"));
|
||||
}
|
||||
|
||||
|
||||
@Test(timeout = 60 * 1000)
|
||||
public void testAuth() throws Exception {
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
|
|
Loading…
Reference in New Issue