activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1344907 - in /activemq/trunk: activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
Date Thu, 31 May 2012 20:57:33 GMT
Author: tabish
Date: Thu May 31 20:57:32 2012
New Revision: 1344907

URL: http://svn.apache.org/viewvc?rev=1344907&view=rev
Log:
apply patch for: https://issues.apache.org/jira/browse/AMQ-3857

Modified:
    activemq/trunk/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java
    activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java

Modified: activemq/trunk/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java?rev=1344907&r1=1344906&r2=1344907&view=diff
==============================================================================
--- activemq/trunk/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java (original)
+++ activemq/trunk/activemq-web-demo/src/test/java/org/apache/activemq/web/RestTest.java Thu
May 31 20:57:32 2012
@@ -24,6 +24,7 @@ import javax.management.ObjectName;
 import org.apache.commons.lang.RandomStringUtils;
 import org.eclipse.jetty.client.ContentExchange;
 import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.http.HttpFields;
 import org.eclipse.jetty.http.HttpStatus;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -153,4 +154,28 @@ public class RestTest extends JettyTestS
         contentExchange2.waitForDone();
         assertTrue("success status", HttpStatus.isSuccess(contentExchange2.getResponseStatus()));
     }
+
+    // test for https://issues.apache.org/activemq/browse/AMQ-3857
+    public void testProperties() throws Exception {
+        HttpClient httpClient = new HttpClient();
+        httpClient.start();
+        ContentExchange contentExchange = new ContentExchange();
+        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
+        contentExchange.setMethod("POST");
+        contentExchange.setURL("http://localhost:8080/message/testPost?type=queue&property=value");
+        httpClient.send(contentExchange);
+
+        contentExchange.waitForDone();
+        assertTrue("success status", HttpStatus.isSuccess(contentExchange.getResponseStatus()));
+
+        ContentExchange contentExchange2 = new ContentExchange(true);
+        contentExchange2.setURL("http://localhost:8080/message/testPost?readTimeout=1000&type=Queue");
+        httpClient.send(contentExchange2);
+        contentExchange2.waitForDone();
+        assertTrue("success status", HttpStatus.isSuccess(contentExchange2.getResponseStatus()));
+
+        HttpFields fields = contentExchange2.getResponseFields();
+        assertNotNull("Headers Exist", fields);
+        assertEquals("header value", "value", fields.getStringField("property"));
+    }
 }

Modified: activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java?rev=1344907&r1=1344906&r2=1344907&view=diff
==============================================================================
--- activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
(original)
+++ activemq/trunk/activemq-web/src/main/java/org/apache/activemq/web/MessageServlet.java
Thu May 31 20:57:32 2012
@@ -19,6 +19,7 @@ package org.apache.activemq.web;
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.Enumeration;
 import java.util.HashMap;
 
 import javax.jms.Destination;
@@ -48,8 +49,6 @@ import org.slf4j.LoggerFactory;
  * the servlet or as request parameters. <p/> For reading messages you can
  * specify a readTimeout parameter to determine how long the servlet should
  * block for.
- *
- *
  */
 public class MessageServlet extends MessageServletSupport {
 
@@ -319,9 +318,16 @@ public class MessageServlet extends Mess
         return null;
     }
 
+    @SuppressWarnings("rawtypes")
     protected void setResponseHeaders(HttpServletResponse response, Message message) throws
JMSException {
         response.setHeader("destination", message.getJMSDestination().toString());
         response.setHeader("id", message.getJMSMessageID());
+
+        // Return JMS properties as header values.
+        for(Enumeration names = message.getPropertyNames(); names.hasMoreElements();) {
+            String name = (String) names.nextElement();
+            response.setHeader(name , message.getObjectProperty(name).toString());
+        }
     }
 
     /**



Mime
View raw message