Skip to content
Permalink
Browse files
CXF-5543 Fix JAXRSJMSTest
git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1565203 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cschneider committed Feb 6, 2014
1 parent e87711a commit 155751283fd85ce63d83d1636ac06f094280e82d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
@@ -333,10 +333,13 @@ public void doReplyMessage(Exchange exchange, javax.jms.Message jmsMessage) thro

LOG.log(Level.FINE, "client received reply: ", jmsMessage);
try {
Message inMessage = JMSMessageUtils.asCXFMessage(jmsMessage, JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
Message inMessage = JMSMessageUtils.asCXFMessage(jmsMessage,
JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
SecurityContext securityContext = JMSMessageUtils.buildSecurityContext(jmsMessage, jmsConfig);
inMessage.put(SecurityContext.class, securityContext);
exchange.setInMessage(inMessage);
Object responseCode = inMessage.get(org.apache.cxf.message.Message.RESPONSE_CODE);
exchange.put(org.apache.cxf.message.Message.RESPONSE_CODE, responseCode);

if (exchange.isSynchronous()) {
synchronized (exchange) {
@@ -64,11 +64,9 @@ final class JMSMessageUtils {
private JMSMessageUtils() {

}

public static org.apache.cxf.message.Message asCXFMessage(Message message, String headerType)
throws UnsupportedEncodingException, JMSException {

org.apache.cxf.message.Message inMessage = new MessageImpl();
org.apache.cxf.message.Message inMessage = new MessageImpl();
populateIncomingContext(message, inMessage, headerType);
retrieveAndSetPayload(inMessage, message);
return inMessage;
@@ -150,8 +148,7 @@ private static void populateIncomingContext(javax.jms.Message message,
inMessage.put(org.apache.cxf.message.Message.ENCODING, getEncoding(val));
}
if (name.equals(org.apache.cxf.message.Message.RESPONSE_CODE)) {
inMessage.getExchange().put(org.apache.cxf.message.Message.RESPONSE_CODE,
Integer.valueOf(val));
inMessage.put(org.apache.cxf.message.Message.RESPONSE_CODE, Integer.valueOf(val));
}
}
inMessage.put(org.apache.cxf.message.Message.PROTOCOL_HEADERS, protHeaders);
@@ -72,7 +72,7 @@ public Object fromMessage(Message message) throws JMSException {
StreamMessage streamMessage = (StreamMessage)message;
return streamMessage.readObject();
} else {
throw new IllegalArgumentException("Unsupported message type " + nullSafeClassName(message));
return new byte[]{};
}
}

@@ -70,7 +70,7 @@ public static void startServers() throws Exception {
assertTrue("server did not launch correctly",
launchServer(EmbeddedJMSBrokerLauncher.class, props, null));
assertTrue("server did not launch correctly",
launchServer(JMSServer.class));
launchServer(JMSServer.class, true));
serversStarted = true;
}

@@ -241,7 +241,10 @@ public void testOneWayBook() throws Exception {
private void checkBookInResponse(Session session, Destination replyToDestination,
long bookId, String bookName) throws Exception {
MessageConsumer consumer = session.createConsumer(replyToDestination);
BytesMessage jmsMessage = (BytesMessage)consumer.receive(300000);
BytesMessage jmsMessage = (BytesMessage)consumer.receive(5000);
if (jmsMessage == null) {
throw new RuntimeException("No response recieved on " + replyToDestination);
}
byte[] bytes = new byte[(int)jmsMessage.getBodyLength()];
jmsMessage.readBytes(bytes);
InputStream is = new ByteArrayInputStream(bytes);
@@ -262,7 +265,7 @@ private Context getContext() throws Exception {
private void postGetMessage(Session session, Destination destination, Destination replyTo)
throws Exception {
MessageProducer producer = session.createProducer(destination);
Message message = session.createMessage();
Message message = session.createBytesMessage();
message.setJMSReplyTo(replyTo);
message.setStringProperty("Accept", "application/xml");
message.setStringProperty(org.apache.cxf.message.Message.REQUEST_URI, "/bookstore/books/123");
@@ -20,11 +20,17 @@
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jms="http://cxf.apache.org/transports/jms" xmlns:p="http://www.springframework.org/schema/p" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://cxf.apache.org/transports/jms http://cxf.apache.org/schemas/configuration/jms.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory" p:brokerURL="tcp://localhost:${testutil.ports.EmbeddedJMSBrokerLauncher}"/>
<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"
p:brokerURL="tcp://localhost:${testutil.ports.EmbeddedJMSBrokerLauncher}"/>
<bean id="singleConnectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory" destroy-method="destroy">
<property name="targetConnectionFactory" ref="jmsConnectionFactory"/>
</bean>
<bean id="jmsConfig" class="org.apache.cxf.transport.jms.JMSConfiguration" p:connectionFactory-ref="singleConnectionFactory" p:timeToLive="500000" p:concurrentConsumers="1" p:maxSuspendedContinuations="0" p:maxConcurrentConsumers="1"/>
<bean id="jmsConfig" class="org.apache.cxf.transport.jms.JMSConfiguration"
p:connectionFactory-ref="singleConnectionFactory"
p:timeToLive="500000"
p:concurrentConsumers="1"
p:maxSuspendedContinuations="0"
p:maxConcurrentConsumers="1"/>
<jms:destination name="{http://books.com}BookService.jms-destination">
<jms:address jndiConnectionFactoryName="ConnectionFactory" jndiDestinationName="dynamicQueues/test.jmstransport.text">
<jms:JMSNamingProperty name="java.naming.factory.initial" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory"/>

0 comments on commit 1557512

Please sign in to comment.