test case and patch to ensure that the JMSXGroupID can be specified in Stomp together with testing for the use of correlation-id

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@382083 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-03-01 17:05:17 +00:00
parent 7f1b4644af
commit b5bba09207
3 changed files with 55 additions and 6 deletions

View File

@ -20,6 +20,8 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
import javax.jms.DeliveryMode;
@ -323,6 +325,16 @@ public class ActiveMQMessage extends Message implements javax.jms.Message {
}
}
public void setProperties(Map properties) throws JMSException {
for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
Map.Entry entry = (Map.Entry) iter.next();
// Lets use the object property method as we may contain standard extension headers like JMSXGroupID
setObjectProperty((String) entry.getKey(), entry.getValue());
}
}
private void checkValidObject(Object value) throws MessageFormatException {
if(!(value instanceof Boolean || value instanceof Byte || value instanceof Short || value instanceof Integer ||
value instanceof Long || value instanceof Float || value instanceof Double || value instanceof String ||

View File

@ -140,10 +140,6 @@ abstract public class Message extends BaseCommand implements MarshallAware, Mess
properties=null;
}
public void setProperties(Map properties) throws IOException {
lazyCreateProperties();
this.properties.putAll(properties);
}
public void setProperty(String name, Object value) throws IOException {
lazyCreateProperties();

View File

@ -21,6 +21,7 @@ import org.apache.activemq.CombinationTestSupport;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.TransportConnector;
import org.apache.activemq.command.ActiveMQQueue;
import org.apache.activemq.command.ActiveMQTextMessage;
import javax.jms.Connection;
import javax.jms.JMSException;
@ -155,7 +156,7 @@ public class StompTest extends CombinationTestSupport {
}
public void testSendMessageWithHeaders() throws Exception {
public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
@ -182,6 +183,46 @@ public class StompTest extends CombinationTestSupport {
TextMessage message = (TextMessage) consumer.receive(1000);
assertNotNull(message);
assertEquals("Hello World", message.getText());
assertEquals("foo", "abc", message.getStringProperty("foo"));
assertEquals("bar", "123", message.getStringProperty("bar"));
}
public void testSendMessageWithStandardHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
String frame =
"CONNECT\n" +
"login: brianm\n" +
"passcode: wombats\n\n"+
Stomp.NULL;
sendFrame(frame);
frame = receiveFrame(10000);
assertTrue(frame.startsWith("CONNECTED"));
frame =
"SEND\n" +
"correlation-id:c123\n" +
"JMSXGroupID:abc\n" +
"foo:abc\n" +
"bar:123\n" +
"destination:/queue/" + getQueueName() + "\n\n" +
"Hello World" +
Stomp.NULL;
sendFrame(frame);
TextMessage message = (TextMessage) consumer.receive(1000);
assertNotNull(message);
assertEquals("Hello World", message.getText());
assertEquals("JMSCorrelationID", "c123", message.getJMSCorrelationID());
assertEquals("foo", "abc", message.getStringProperty("foo"));
assertEquals("bar", "123", message.getStringProperty("bar"));
assertEquals("JMSXGroupID", "abc", message.getStringProperty("JMSXGroupID"));
ActiveMQTextMessage amqMessage = (ActiveMQTextMessage) message;
assertEquals("GroupID", "abc", amqMessage.getGroupID());
}
public void testSubscribeWithAutoAck() throws Exception {