mirror of https://github.com/apache/activemq.git
Removes the dependence on the fixed ports, should prevent needless test failures.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1185804 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6c82480a10
commit
f3e9ec0b81
|
@ -18,9 +18,7 @@ package org.apache.activemq.web;
|
|||
|
||||
import org.apache.activemq.transport.stomp.StompConnection;
|
||||
import org.apache.activemq.transport.stomp.StompFrame;
|
||||
import org.apache.activemq.transport.stomp.Stomp;
|
||||
|
||||
import java.lang.Thread;
|
||||
import java.net.SocketTimeoutException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
@ -31,12 +29,10 @@ import java.util.*;
|
|||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.client.ContentExchange;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.eclipse.jetty.http.HttpFields;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
|
||||
import javax.jms.MessageProducer;
|
||||
import javax.jms.Message;
|
||||
import javax.jms.TextMessage;
|
||||
|
||||
public class AjaxTest extends JettyTestSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AjaxTest.class);
|
||||
|
@ -533,5 +529,4 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertContains( "<response id='handlerB' destination='topic://topicB' >B2</response>\n", fullResponse );
|
||||
assertResponseCount( 4, fullResponse );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
/**
|
||||
* A simple bootstrap class for starting Jetty in your IDE using the local web
|
||||
* application.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class JettyServer {
|
||||
|
||||
|
@ -46,8 +46,8 @@ public final class JettyServer {
|
|||
BrokerService broker = new BrokerService();
|
||||
broker.setPersistent(false);
|
||||
broker.setUseJmx(true);
|
||||
broker.addConnector("tcp://localhost:61616");
|
||||
broker.addConnector("stomp://localhost:61613");
|
||||
broker.addConnector("tcp://localhost:0");
|
||||
broker.addConnector("stomp://localhost:0");
|
||||
broker.start();
|
||||
|
||||
// lets publish some messages so that there is some stuff to browse
|
||||
|
|
|
@ -54,8 +54,8 @@ public class JettyTestSupport extends TestCase {
|
|||
broker = new BrokerService();
|
||||
broker.setPersistent(false);
|
||||
broker.setUseJmx(true);
|
||||
tcpUri = broker.addConnector("tcp://localhost:61616").getConnectUri();
|
||||
stompUri = broker.addConnector("stomp://localhost:61613").getConnectUri();
|
||||
tcpUri = new URI(broker.addConnector("tcp://localhost:0").getPublishableConnectString());
|
||||
stompUri = new URI(broker.addConnector("stomp://localhost:0").getPublishableConnectString());
|
||||
broker.start();
|
||||
broker.waitUntilStarted();
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.activemq.web;
|
|||
import javax.jms.TextMessage;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.broker.jmx.DestinationViewMBean;
|
||||
import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -31,11 +29,11 @@ import java.util.Set;
|
|||
|
||||
public class RestTest extends JettyTestSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RestTest.class);
|
||||
|
||||
|
||||
public void testConsume() throws Exception {
|
||||
producer.send(session.createTextMessage("test"));
|
||||
LOG.info("message sent");
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
ContentExchange contentExchange = new ContentExchange();
|
||||
|
@ -43,9 +41,9 @@ public class RestTest extends JettyTestSupport {
|
|||
contentExchange.setURL("http://localhost:8080/message/test?readTimeout=1000&type=queue");
|
||||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
assertEquals("test", contentExchange.getResponseContent());
|
||||
assertEquals("test", contentExchange.getResponseContent());
|
||||
}
|
||||
|
||||
|
||||
public void testSubscribeFirst() throws Exception {
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
|
@ -53,27 +51,27 @@ public class RestTest extends JettyTestSupport {
|
|||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
contentExchange.setURL("http://localhost:8080/message/test?readTimeout=5000&type=queue");
|
||||
httpClient.send(contentExchange);
|
||||
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
|
||||
producer.send(session.createTextMessage("test"));
|
||||
LOG.info("message sent");
|
||||
|
||||
|
||||
contentExchange.waitForDone();
|
||||
assertEquals("test", contentExchange.getResponseContent());
|
||||
assertEquals("test", contentExchange.getResponseContent());
|
||||
}
|
||||
|
||||
|
||||
public void testSelector() throws Exception {
|
||||
TextMessage msg1 = session.createTextMessage("test1");
|
||||
msg1.setIntProperty("test", 1);
|
||||
producer.send(msg1);
|
||||
LOG.info("message 1 sent");
|
||||
|
||||
|
||||
TextMessage msg2 = session.createTextMessage("test2");
|
||||
msg2.setIntProperty("test", 2);
|
||||
producer.send(msg2);
|
||||
LOG.info("message 2 sent");
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
ContentExchange contentExchange = new ContentExchange();
|
||||
|
@ -84,20 +82,20 @@ public class RestTest extends JettyTestSupport {
|
|||
contentExchange.waitForDone();
|
||||
assertEquals("test2", contentExchange.getResponseContent());
|
||||
}
|
||||
|
||||
|
||||
// test for https://issues.apache.org/activemq/browse/AMQ-2827
|
||||
public void testCorrelation() throws Exception {
|
||||
for (int i = 0; i < 200; i++) {
|
||||
String correlId = "RESTY" + RandomStringUtils.randomNumeric(10);
|
||||
|
||||
|
||||
TextMessage message = session.createTextMessage(correlId);
|
||||
message.setStringProperty("correlationId", correlId);
|
||||
message.setJMSCorrelationID(correlId);
|
||||
|
||||
|
||||
LOG.info("Sending: " + correlId);
|
||||
|
||||
|
||||
producer.send(message);
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
ContentExchange contentExchange = new ContentExchange();
|
||||
|
@ -131,12 +129,8 @@ public class RestTest extends JettyTestSupport {
|
|||
|
||||
httpClient.stop();
|
||||
|
||||
|
||||
|
||||
ObjectName name = new ObjectName("org.apache.activemq" + ":BrokerName=localhost,Type=Queue,Destination=test");
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Subscription,destinationType=Queue,destinationName=test,*");
|
||||
Set subs = broker.getManagementContext().queryNames(query, null);
|
||||
Set<ObjectName> subs = broker.getManagementContext().queryNames(query, null);
|
||||
assertEquals("Consumers not closed", 0 , subs.size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue