activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r382083 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/command/ActiveMQMessage.java main/java/org/apache/activemq/command/Message.java test/java/org/apache/activemq/transport/stomp/StompTest.java
Date Wed, 01 Mar 2006 17:05:20 GMT
Author: jstrachan
Date: Wed Mar  1 09:05:17 2006
New Revision: 382083

URL: http://svn.apache.org/viewcvs?rev=382083&view=rev
Log:
test case and patch to ensure that the JMSXGroupID can be specified in Stomp together with
testing for the use of correlation-id

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java?rev=382083&r1=382082&r2=382083&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/ActiveMQMessage.java
Wed Mar  1 09:05:17 2006
@@ -20,6 +20,8 @@
 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;
@@ -322,6 +324,16 @@
             }
         }
     }
+    
+    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 ||

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java?rev=382083&r1=382082&r2=382083&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/command/Message.java
Wed Mar  1 09:05:17 2006
@@ -140,11 +140,7 @@
         properties=null;
     }
 
-    public void setProperties(Map properties) throws IOException {
-        lazyCreateProperties();
-        this.properties.putAll(properties);
-    }
-    
+
     public void setProperty(String name, Object value) throws IOException {
         lazyCreateProperties();
         properties.put(name, value);

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
URL: http://svn.apache.org/viewcvs/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java?rev=382083&r1=382082&r2=382083&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/stomp/StompTest.java
Wed Mar  1 09:05:17 2006
@@ -21,6 +21,7 @@
 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 void testSendMessageWithHeaders() throws Exception {
+    public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
         
         MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
         
@@ -182,6 +183,46 @@
         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 {



Mime
View raw message