mirror of https://github.com/apache/activemq.git
resolve the dependency on fixed ports 61616 and 61613.
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1075051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72a0fd1a43
commit
9308db8b75
|
@ -40,11 +40,11 @@ import javax.jms.TextMessage;
|
|||
|
||||
public class AjaxTest extends JettyTestSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(AjaxTest.class);
|
||||
|
||||
|
||||
private class AjaxTestContentExchange extends ContentExchange {
|
||||
private HashMap<String,String> headers;
|
||||
private String responseContent;
|
||||
|
||||
|
||||
AjaxTestContentExchange() {
|
||||
super(true);
|
||||
this.headers = new HashMap<String,String>();
|
||||
|
@ -65,7 +65,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
return responseContent;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void assertContains( String expected, String actual ) {
|
||||
assertTrue( "'"+actual+"' does not contain expected fragment '"+expected+"'", actual.indexOf( expected ) != -1 );
|
||||
}
|
||||
|
@ -73,14 +73,14 @@ public class AjaxTest extends JettyTestSupport {
|
|||
int occurrences = StringUtils.countMatches( actual, "<response" );
|
||||
assertEquals( "Expected number of <response> elements is not correct.", expected, occurrences );
|
||||
}
|
||||
|
||||
|
||||
public void testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreSentToQueueWhileClientIsPolling ***" );
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
// client 1 subscribes to a queue
|
||||
LOG.debug( "SENDING LISTEN" );
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -91,7 +91,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
String jsessionid = contentExchange.getJsessionId();
|
||||
|
||||
|
||||
// client 1 polls for messages
|
||||
LOG.debug( "SENDING POLL" );
|
||||
AjaxTestContentExchange poll = new AjaxTestContentExchange();
|
||||
|
@ -99,7 +99,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setURL("http://localhost:8080/amq?timeout=5000");
|
||||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
|
||||
|
||||
// while client 1 is polling, client 2 sends messages to the queue
|
||||
LOG.debug( "SENDING MESSAGES" );
|
||||
contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -114,11 +114,11 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
LOG.debug( "DONE POSTING MESSAGES" );
|
||||
|
||||
|
||||
// wait for poll to finish
|
||||
poll.waitForDone();
|
||||
String response = poll.getResponseContent();
|
||||
|
||||
|
||||
// messages might not all be delivered during the 1st poll. We need to check again.
|
||||
poll = new AjaxTestContentExchange();
|
||||
poll.setMethod( "GET" );
|
||||
|
@ -126,23 +126,23 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
poll.waitForDone();
|
||||
|
||||
|
||||
String fullResponse = response + poll.getResponseContent();
|
||||
LOG.debug( "full response : " + fullResponse );
|
||||
|
||||
|
||||
assertContains( "<response id='handler' destination='queue://test' >msg1</response>\n", fullResponse );
|
||||
assertContains( "<response id='handler' destination='queue://test' >msg2</response>\n", fullResponse );
|
||||
assertContains( "<response id='handler' destination='queue://test' >msg3</response>\n", fullResponse );
|
||||
assertResponseCount( 3, fullResponse );
|
||||
}
|
||||
|
||||
|
||||
public void testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreSentToTopicWhileClientIsPolling ***" );
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
// client 1 subscribes to a queue
|
||||
LOG.debug( "SENDING LISTEN" );
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -153,7 +153,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
String jsessionid = contentExchange.getJsessionId();
|
||||
|
||||
|
||||
// client 1 polls for messages
|
||||
LOG.debug( "SENDING POLL" );
|
||||
AjaxTestContentExchange poll = new AjaxTestContentExchange();
|
||||
|
@ -161,7 +161,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setURL("http://localhost:8080/amq?timeout=5000");
|
||||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
|
||||
|
||||
// while client 1 is polling, client 2 sends messages to the queue
|
||||
LOG.debug( "SENDING MESSAGES" );
|
||||
contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -176,11 +176,11 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
LOG.debug( "DONE POSTING MESSAGES" );
|
||||
|
||||
|
||||
// wait for poll to finish
|
||||
poll.waitForDone();
|
||||
String response = poll.getResponseContent();
|
||||
|
||||
|
||||
// not all messages might be delivered during the 1st poll. We need to check again.
|
||||
poll = new AjaxTestContentExchange();
|
||||
poll.setMethod( "GET" );
|
||||
|
@ -188,27 +188,27 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
poll.waitForDone();
|
||||
|
||||
|
||||
String fullResponse = response + poll.getResponseContent();
|
||||
LOG.debug( "full response : " + fullResponse );
|
||||
|
||||
|
||||
assertContains( "<response id='handler' destination='topic://test' >msg1</response>\n", fullResponse );
|
||||
assertContains( "<response id='handler' destination='topic://test' >msg2</response>\n", fullResponse );
|
||||
assertContains( "<response id='handler' destination='topic://test' >msg3</response>\n", fullResponse );
|
||||
assertResponseCount( 3, fullResponse );
|
||||
}
|
||||
|
||||
|
||||
public void testAjaxClientReceivesMessagesWhichAreQueuedBeforeClientSubscribes() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesWhichAreQueuedBeforeClientSubscribes ***" );
|
||||
// send messages to queue://test
|
||||
producer.send( session.createTextMessage("test one") );
|
||||
producer.send( session.createTextMessage("test two") );
|
||||
producer.send( session.createTextMessage("test three") );
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
// client 1 subscribes to queue
|
||||
LOG.debug( "SENDING LISTEN" );
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -219,7 +219,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
String jsessionid = contentExchange.getJsessionId();
|
||||
|
||||
|
||||
// client 1 polls for messages
|
||||
LOG.debug( "SENDING POLL" );
|
||||
AjaxTestContentExchange poll = new AjaxTestContentExchange();
|
||||
|
@ -227,24 +227,24 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setURL("http://localhost:8080/amq?timeout=5000");
|
||||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
|
||||
|
||||
// wait for poll to finish
|
||||
poll.waitForDone();
|
||||
String response = poll.getResponseContent();
|
||||
|
||||
|
||||
assertContains( "<response id='handler' destination='queue://test' >test one</response>\n", response );
|
||||
assertContains( "<response id='handler' destination='queue://test' >test two</response>\n", response );
|
||||
assertContains( "<response id='handler' destination='queue://test' >test three</response>\n", response );
|
||||
assertResponseCount( 3, response );
|
||||
}
|
||||
|
||||
|
||||
public void testStompMessagesAreReceivedByAjaxClient() throws Exception {
|
||||
LOG.debug( "*** testStompMessagesAreRecievedByAjaxClient ***" );
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
// client 1 subscribes to a queue
|
||||
LOG.debug( "SENDING LISTEN" );
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -255,7 +255,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
String jsessionid = contentExchange.getJsessionId();
|
||||
|
||||
|
||||
// client 1 polls for messages
|
||||
LOG.debug( "SENDING POLL" );
|
||||
AjaxTestContentExchange poll = new AjaxTestContentExchange();
|
||||
|
@ -263,10 +263,10 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setURL("http://localhost:8080/amq?timeout=5000");
|
||||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
|
||||
|
||||
// stomp client queues some messages
|
||||
StompConnection connection = new StompConnection();
|
||||
connection.open("localhost", 61613);
|
||||
connection.open(stompUri.getHost(), stompUri.getPort());
|
||||
connection.connect("user", "password");
|
||||
HashMap<String, String> headers = new HashMap<String, String>();
|
||||
headers.put( "amq-msg-type", "text" );
|
||||
|
@ -276,11 +276,11 @@ public class AjaxTest extends JettyTestSupport {
|
|||
connection.send( "/queue/test", "message4", (String)null, headers );
|
||||
connection.send( "/queue/test", "message5", (String)null, headers );
|
||||
connection.disconnect();
|
||||
|
||||
|
||||
// wait for poll to finish
|
||||
poll.waitForDone();
|
||||
String response = poll.getResponseContent();
|
||||
|
||||
|
||||
// not all messages might be delivered during the 1st poll. We need to check again.
|
||||
poll = new AjaxTestContentExchange();
|
||||
poll.setMethod( "GET" );
|
||||
|
@ -288,9 +288,9 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
poll.waitForDone();
|
||||
|
||||
|
||||
String fullResponse = response + poll.getResponseContent();
|
||||
|
||||
|
||||
assertContains( "<response id='handler' destination='queue://test' >message1</response>\n", fullResponse );
|
||||
assertContains( "<response id='handler' destination='queue://test' >message2</response>\n", fullResponse );
|
||||
assertContains( "<response id='handler' destination='queue://test' >message3</response>\n", fullResponse );
|
||||
|
@ -298,14 +298,14 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertContains( "<response id='handler' destination='queue://test' >message5</response>\n", fullResponse );
|
||||
assertResponseCount( 5, fullResponse );
|
||||
}
|
||||
|
||||
|
||||
public void testAjaxMessagesAreReceivedByStompClient() throws Exception {
|
||||
LOG.debug( "*** testAjaxMessagesAreReceivedByStompClient ***" );
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
contentExchange.setMethod( "POST" );
|
||||
contentExchange.setURL("http://localhost:8080/amq");
|
||||
|
@ -317,12 +317,12 @@ public class AjaxTest extends JettyTestSupport {
|
|||
contentExchange.setRequestContentType( "application/x-www-form-urlencoded; charset=UTF-8" );
|
||||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
|
||||
|
||||
StompConnection connection = new StompConnection();
|
||||
connection.open("localhost", 61613);
|
||||
connection.open(stompUri.getHost(), stompUri.getPort());
|
||||
connection.connect("user", "password");
|
||||
connection.subscribe( "/queue/test" );
|
||||
|
||||
|
||||
StompFrame message;
|
||||
String allMessageBodies = "";
|
||||
try {
|
||||
|
@ -331,18 +331,18 @@ public class AjaxTest extends JettyTestSupport {
|
|||
allMessageBodies = allMessageBodies +"\n"+ message.getBody();
|
||||
}
|
||||
} catch (SocketTimeoutException e) {}
|
||||
|
||||
|
||||
LOG.debug( "All message bodies : " + allMessageBodies );
|
||||
|
||||
|
||||
assertContains( "msg1", allMessageBodies );
|
||||
assertContains( "msg2", allMessageBodies );
|
||||
assertContains( "msg3", allMessageBodies );
|
||||
assertContains( "msg4", allMessageBodies );
|
||||
}
|
||||
|
||||
|
||||
public void testAjaxClientMayUseSelectors() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientMayUseSelectors ***" );
|
||||
|
||||
|
||||
// send 2 messages to the same queue w/ different 'filter' values.
|
||||
Message msg = session.createTextMessage("test one");
|
||||
msg.setStringProperty( "filter", "one" );
|
||||
|
@ -350,11 +350,11 @@ public class AjaxTest extends JettyTestSupport {
|
|||
msg = session.createTextMessage("test two");
|
||||
msg.setStringProperty( "filter", "two" );
|
||||
producer.send( msg );
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
// client ubscribes to queue
|
||||
LOG.debug( "SENDING LISTEN" );
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -367,7 +367,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
String jsessionid = contentExchange.getJsessionId();
|
||||
|
||||
|
||||
// client 1 polls for messages
|
||||
LOG.debug( "SENDING POLL" );
|
||||
AjaxTestContentExchange poll = new AjaxTestContentExchange();
|
||||
|
@ -376,19 +376,19 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
poll.waitForDone();
|
||||
|
||||
|
||||
LOG.debug( poll.getResponseContent() );
|
||||
|
||||
|
||||
String expected = "<ajax-response>\n" +
|
||||
"<response id='handler' destination='queue://test' >test two</response>\n" +
|
||||
"</ajax-response>\n";
|
||||
assertEquals( "Poll response is not correct.", expected, poll.getResponseContent() );
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testMultipleAjaxClientsMayExistInTheSameSession() throws Exception {
|
||||
LOG.debug( "*** testMultipleAjaxClientsMayExistInTheSameSession ***" );
|
||||
|
||||
|
||||
// send messages to queues testA and testB.
|
||||
MessageProducer producerA = session.createProducer(session.createQueue("testA"));
|
||||
MessageProducer producerB = session.createProducer(session.createQueue("testB"));
|
||||
|
@ -396,11 +396,11 @@ public class AjaxTest extends JettyTestSupport {
|
|||
producerA.send( session.createTextMessage("A2") );
|
||||
producerB.send( session.createTextMessage("B1") );
|
||||
producerB.send( session.createTextMessage("B2") );
|
||||
|
||||
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
// clientA subscribes to /queue/testA
|
||||
LOG.debug( "SENDING LISTEN" );
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -416,7 +416,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
String jsessionid = contentExchange.getJsessionId();
|
||||
|
||||
|
||||
// clientB subscribes to /queue/testB using the same JSESSIONID.
|
||||
contentExchange = new AjaxTestContentExchange();
|
||||
contentExchange.setMethod( "POST" );
|
||||
|
@ -431,7 +431,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
contentExchange.setRequestContentType( "application/x-www-form-urlencoded; charset=UTF-8" );
|
||||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
|
||||
|
||||
// clientA polls for messages
|
||||
AjaxTestContentExchange poll = new AjaxTestContentExchange();
|
||||
poll.setMethod( "GET" );
|
||||
|
@ -439,14 +439,14 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
poll.waitForDone();
|
||||
|
||||
|
||||
LOG.debug( "clientA response : " + poll.getResponseContent() );
|
||||
String expected = "<ajax-response>\n" +
|
||||
"<response id='handlerA' destination='queue://testA' >A1</response>\n" +
|
||||
"<response id='handlerA' destination='queue://testA' >A2</response>\n" +
|
||||
"</ajax-response>\n";
|
||||
assertEquals( "Poll response is not correct.", expected, poll.getResponseContent() );
|
||||
|
||||
|
||||
// clientB polls for messages
|
||||
poll = new AjaxTestContentExchange();
|
||||
poll.setMethod( "GET" );
|
||||
|
@ -454,7 +454,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
poll.waitForDone();
|
||||
|
||||
|
||||
LOG.debug( "clientB response : " + poll.getResponseContent() );
|
||||
expected = "<ajax-response>\n" +
|
||||
"<response id='handlerB' destination='queue://testB' >B1</response>\n" +
|
||||
|
@ -462,13 +462,13 @@ public class AjaxTest extends JettyTestSupport {
|
|||
"</ajax-response>\n";
|
||||
assertEquals( "Poll response is not correct.", expected, poll.getResponseContent() );
|
||||
}
|
||||
|
||||
|
||||
public void testAjaxClientReceivesMessagesForMultipleTopics() throws Exception {
|
||||
LOG.debug( "*** testAjaxClientReceivesMessagesForMultipleTopics ***" );
|
||||
HttpClient httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
|
||||
|
||||
LOG.debug( "SENDING LISTEN FOR /topic/topicA" );
|
||||
AjaxTestContentExchange contentExchange = new AjaxTestContentExchange();
|
||||
contentExchange.setMethod( "POST" );
|
||||
|
@ -478,7 +478,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
String jsessionid = contentExchange.getJsessionId();
|
||||
|
||||
|
||||
LOG.debug( "SENDING LISTEN FOR /topic/topicB" );
|
||||
contentExchange = new AjaxTestContentExchange();
|
||||
contentExchange.setMethod( "POST" );
|
||||
|
@ -488,7 +488,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
contentExchange.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
|
||||
|
||||
// client 1 polls for messages
|
||||
LOG.debug( "SENDING POLL" );
|
||||
AjaxTestContentExchange poll = new AjaxTestContentExchange();
|
||||
|
@ -496,7 +496,7 @@ public class AjaxTest extends JettyTestSupport {
|
|||
poll.setURL("http://localhost:8080/amq?timeout=5000");
|
||||
poll.setRequestHeader( "Cookie", jsessionid );
|
||||
httpClient.send( poll );
|
||||
|
||||
|
||||
// while client 1 is polling, client 2 sends messages to the topics
|
||||
LOG.debug( "SENDING MESSAGES" );
|
||||
contentExchange = new AjaxTestContentExchange();
|
||||
|
@ -512,11 +512,11 @@ public class AjaxTest extends JettyTestSupport {
|
|||
httpClient.send(contentExchange);
|
||||
contentExchange.waitForDone();
|
||||
LOG.debug( "DONE POSTING MESSAGES" );
|
||||
|
||||
|
||||
// wait for poll to finish
|
||||
poll.waitForDone();
|
||||
String response = poll.getResponseContent();
|
||||
|
||||
|
||||
// not all messages might be delivered during the 1st poll. We need to check again.
|
||||
poll = new AjaxTestContentExchange();
|
||||
poll.setMethod( "GET" );
|
||||
|
@ -533,5 +533,5 @@ public class AjaxTest extends JettyTestSupport {
|
|||
assertContains( "<response id='handlerB' destination='topic://topicB' >B2</response>\n", fullResponse );
|
||||
assertResponseCount( 4, fullResponse );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.activemq.web;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import javax.jms.Connection;
|
||||
|
@ -38,23 +39,26 @@ import org.eclipse.jetty.webapp.WebAppContext;
|
|||
|
||||
public class JettyTestSupport extends TestCase {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JettyTestSupport.class);
|
||||
|
||||
|
||||
BrokerService broker;
|
||||
Server server;
|
||||
ActiveMQConnectionFactory factory;
|
||||
Connection connection;
|
||||
Session session;
|
||||
MessageProducer producer;
|
||||
|
||||
|
||||
URI tcpUri;
|
||||
URI stompUri;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
broker = new BrokerService();
|
||||
broker.setPersistent(false);
|
||||
broker.setUseJmx(true);
|
||||
broker.addConnector("tcp://localhost:61616");
|
||||
broker.addConnector("stomp://localhost:61613");
|
||||
tcpUri = broker.addConnector("tcp://localhost:61616").getConnectUri();
|
||||
stompUri = broker.addConnector("stomp://localhost:61613").getConnectUri();
|
||||
broker.start();
|
||||
broker.waitUntilStarted();
|
||||
|
||||
|
||||
server = new Server();
|
||||
SelectChannelConnector connector = new SelectChannelConnector();
|
||||
connector.setPort(8080);
|
||||
|
@ -70,8 +74,8 @@ public class JettyTestSupport extends TestCase {
|
|||
});
|
||||
server.start();
|
||||
waitForJettySocketToAccept("http://localhost:8080");
|
||||
|
||||
factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
|
||||
|
||||
factory = new ActiveMQConnectionFactory(tcpUri);
|
||||
connection = factory.createConnection();
|
||||
connection.start();
|
||||
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
|
||||
|
@ -102,5 +106,5 @@ public class JettyTestSupport extends TestCase {
|
|||
return canConnect;
|
||||
}}, 60 * 1000));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue