mirror of https://github.com/apache/activemq.git
Improved the STOMP test case a little to verify that killed stomp clients redeliver un acked messages
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@566277 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
926f9ce614
commit
90deed42cc
|
@ -20,6 +20,8 @@ import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -60,8 +62,7 @@ public class StompTest extends CombinationTestSupport {
|
||||||
connector = broker.addConnector(bindAddress);
|
connector = broker.addConnector(bindAddress);
|
||||||
broker.start();
|
broker.start();
|
||||||
|
|
||||||
URI connectUri = connector.getConnectUri();
|
stompConnect();
|
||||||
stompConnection.open("127.0.0.1", connectUri.getPort());
|
|
||||||
|
|
||||||
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
|
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory("vm://localhost");
|
||||||
connection = cf.createConnection();
|
connection = cf.createConnection();
|
||||||
|
@ -70,6 +71,11 @@ public class StompTest extends CombinationTestSupport {
|
||||||
connection.start();
|
connection.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stompConnect() throws IOException, URISyntaxException, UnknownHostException {
|
||||||
|
URI connectUri = connector.getConnectUri();
|
||||||
|
stompConnection.open("127.0.0.1", connectUri.getPort());
|
||||||
|
}
|
||||||
|
|
||||||
protected Socket createSocket(URI connectUri) throws IOException {
|
protected Socket createSocket(URI connectUri) throws IOException {
|
||||||
return new Socket();
|
return new Socket();
|
||||||
}
|
}
|
||||||
|
@ -80,10 +86,17 @@ public class StompTest extends CombinationTestSupport {
|
||||||
|
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
connection.close();
|
connection.close();
|
||||||
stompConnection.close();
|
stompDisconnect();
|
||||||
broker.stop();
|
broker.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void stompDisconnect() throws IOException {
|
||||||
|
if (stompConnection != null) {
|
||||||
|
stompConnection.close();
|
||||||
|
stompConnection = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void sendMessage(String msg) throws Exception {
|
public void sendMessage(String msg) throws Exception {
|
||||||
sendMessage(msg, "foo", "xyz");
|
sendMessage(msg, "foo", "xyz");
|
||||||
}
|
}
|
||||||
|
@ -188,8 +201,8 @@ public class StompTest extends CombinationTestSupport {
|
||||||
frame = stompConnection.receiveFrame();
|
frame = stompConnection.receiveFrame();
|
||||||
assertTrue(frame.startsWith("CONNECTED"));
|
assertTrue(frame.startsWith("CONNECTED"));
|
||||||
|
|
||||||
frame = "SEND\n" + "correlation-id:c123\n" + "priority:3\n" + "type:t345\n" + "JMSXGroupID:abc\n" + "foo:abc\n" + "bar:123\n" + "destination:/queue/" + getQueueName()
|
frame = "SEND\n" + "correlation-id:c123\n" + "priority:3\n" + "type:t345\n" + "JMSXGroupID:abc\n" + "foo:abc\n" + "bar:123\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World"
|
||||||
+ "\n\n" + "Hello World" + Stomp.NULL;
|
+ Stomp.NULL;
|
||||||
|
|
||||||
stompConnection.sendFrame(frame);
|
stompConnection.sendFrame(frame);
|
||||||
|
|
||||||
|
@ -238,7 +251,9 @@ public class StompTest extends CombinationTestSupport {
|
||||||
frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n" + Stomp.NULL;
|
frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" + "ack:auto\n\n" + Stomp.NULL;
|
||||||
stompConnection.sendFrame(frame);
|
stompConnection.sendFrame(frame);
|
||||||
|
|
||||||
sendBytesMessage(new byte[] {1, 2, 3, 4, 5});
|
sendBytesMessage(new byte[] {
|
||||||
|
1, 2, 3, 4, 5
|
||||||
|
});
|
||||||
|
|
||||||
frame = stompConnection.receiveFrame();
|
frame = stompConnection.receiveFrame();
|
||||||
assertTrue(frame.startsWith("MESSAGE"));
|
assertTrue(frame.startsWith("MESSAGE"));
|
||||||
|
@ -363,8 +378,7 @@ public class StompTest extends CombinationTestSupport {
|
||||||
frame = stompConnection.receiveFrame();
|
frame = stompConnection.receiveFrame();
|
||||||
assertTrue(frame.startsWith("MESSAGE"));
|
assertTrue(frame.startsWith("MESSAGE"));
|
||||||
|
|
||||||
frame = "DISCONNECT\n" + "\n\n" + Stomp.NULL;
|
stompDisconnect();
|
||||||
stompConnection.sendFrame(frame);
|
|
||||||
|
|
||||||
// message should be received since message was not acknowledged
|
// message should be received since message was not acknowledged
|
||||||
MessageConsumer consumer = session.createConsumer(queue);
|
MessageConsumer consumer = session.createConsumer(queue);
|
||||||
|
|
Loading…
Reference in New Issue