git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1344907 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-05-31 20:57:32 +00:00
parent eb887f1545
commit 3c1b477523
2 changed files with 33 additions and 2 deletions

View File

@ -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 JettyTestSupport {
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"));
}
}

View File

@ -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 MessageServletSupport {
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());
}
}
/**