mirror of https://github.com/apache/activemq.git
Fixed test that was wrong
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1414727 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1877a14a60
commit
fa250bf1bf
|
@ -16,15 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.activemq.camel.component;
|
package org.apache.activemq.camel.component;
|
||||||
|
|
||||||
import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent;
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
|
||||||
import static org.hamcrest.Matchers.hasEntry;
|
|
||||||
import static org.hamcrest.Matchers.hasKey;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.jms.Destination;
|
import javax.jms.Destination;
|
||||||
|
|
||||||
import org.apache.camel.CamelContext;
|
import org.apache.camel.CamelContext;
|
||||||
|
@ -33,13 +26,15 @@ import org.apache.camel.Headers;
|
||||||
import org.apache.camel.Message;
|
import org.apache.camel.Message;
|
||||||
import org.apache.camel.Processor;
|
import org.apache.camel.Processor;
|
||||||
import org.apache.camel.builder.RouteBuilder;
|
import org.apache.camel.builder.RouteBuilder;
|
||||||
import org.apache.camel.component.mock.AssertionClause;
|
|
||||||
import org.apache.camel.component.mock.MockEndpoint;
|
|
||||||
import org.apache.camel.test.junit4.CamelTestSupport;
|
import org.apache.camel.test.junit4.CamelTestSupport;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import static org.apache.activemq.camel.component.ActiveMQComponent.activeMQComponent;
|
||||||
|
import static org.hamcrest.Matchers.hasEntry;
|
||||||
|
import static org.hamcrest.Matchers.hasKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -52,28 +47,13 @@ public class InvokeRequestReplyUsingJmsReplyToHeaderTest extends CamelTestSuppor
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPerformRequestReplyOverJms() throws Exception {
|
public void testPerformRequestReplyOverJms() throws Exception {
|
||||||
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
|
|
||||||
|
|
||||||
resultEndpoint.expectedBodiesReceived("Hello James");
|
|
||||||
AssertionClause firstMessage = resultEndpoint.message(0);
|
|
||||||
firstMessage.header("JMSCorrelationID").isEqualTo(correlationID);
|
|
||||||
/*
|
|
||||||
TODO - allow JMS headers to be copied?
|
|
||||||
|
|
||||||
firstMessage.header("cheese").isEqualTo(123);
|
|
||||||
firstMessage.header("JMSXGroupID").isEqualTo(groupID);
|
|
||||||
firstMessage.header("JMSReplyTo").isEqualTo(ActiveMQConverter.toDestination(replyQueueName));
|
|
||||||
*/
|
|
||||||
|
|
||||||
Map<String, Object> headers = new HashMap<String, Object>();
|
Map<String, Object> headers = new HashMap<String, Object>();
|
||||||
headers.put("cheese", 123);
|
headers.put("cheese", 123);
|
||||||
headers.put("JMSReplyTo", replyQueueName);
|
headers.put("JMSReplyTo", replyQueueName);
|
||||||
headers.put("JMSCorrelationID", correlationID);
|
headers.put("JMSCorrelationID", correlationID);
|
||||||
headers.put("JMSXGroupID", groupID);
|
headers.put("JMSXGroupID", groupID);
|
||||||
|
|
||||||
|
Exchange reply = template.request("activemq:test.server?replyTo=queue:test.reply", new Processor() {
|
||||||
// Camel 2.0 ignores JMSReplyTo, so we're using replyTo MEP property
|
|
||||||
template.request("activemq:test.server?replyTo=queue:test.reply", new Processor() {
|
|
||||||
public void process(Exchange exchange) {
|
public void process(Exchange exchange) {
|
||||||
exchange.getIn().setBody("James");
|
exchange.getIn().setBody("James");
|
||||||
Map<String, Object> headers = new HashMap<String, Object>();
|
Map<String, Object> headers = new HashMap<String, Object>();
|
||||||
|
@ -85,29 +65,15 @@ public class InvokeRequestReplyUsingJmsReplyToHeaderTest extends CamelTestSuppor
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
resultEndpoint.assertIsSatisfied();
|
Message in = reply.getIn();
|
||||||
|
|
||||||
List<Exchange> list = resultEndpoint.getReceivedExchanges();
|
|
||||||
Exchange exchange = list.get(0);
|
|
||||||
Message in = exchange.getIn();
|
|
||||||
Object replyTo = in.getHeader("JMSReplyTo");
|
Object replyTo = in.getHeader("JMSReplyTo");
|
||||||
LOG.info("Reply to is: " + replyTo);
|
LOG.info("Reply to is: " + replyTo);
|
||||||
|
|
||||||
LOG.info("Received headers: " + in.getHeaders());
|
LOG.info("Received headers: " + in.getHeaders());
|
||||||
LOG.info("Received body: " + in.getBody());
|
LOG.info("Received body: " + in.getBody());
|
||||||
|
|
||||||
assertMessageHeader(in, "JMSCorrelationID", correlationID);
|
assertMessageHeader(in, "JMSCorrelationID", correlationID);
|
||||||
|
|
||||||
/*
|
|
||||||
TODO
|
|
||||||
Destination destination = assertIsInstanceOf(Destination.class, replyTo);
|
|
||||||
assertEquals("ReplyTo", replyQueueName, destination.toString());
|
|
||||||
assertMessageHeader(in, "cheese", 123);
|
|
||||||
assertMessageHeader(in, "JMSXGroupID", groupID);
|
|
||||||
*/
|
|
||||||
|
|
||||||
Map<String,Object> receivedHeaders = myBean.getHeaders();
|
Map<String,Object> receivedHeaders = myBean.getHeaders();
|
||||||
|
|
||||||
assertThat(receivedHeaders, hasKey("JMSReplyTo"));
|
assertThat(receivedHeaders, hasKey("JMSReplyTo"));
|
||||||
assertThat(receivedHeaders, hasEntry("JMSXGroupID", groupID));
|
assertThat(receivedHeaders, hasEntry("JMSXGroupID", groupID));
|
||||||
assertThat(receivedHeaders, hasEntry("JMSCorrelationID", correlationID));
|
assertThat(receivedHeaders, hasEntry("JMSCorrelationID", correlationID));
|
||||||
|
@ -116,8 +82,6 @@ public class InvokeRequestReplyUsingJmsReplyToHeaderTest extends CamelTestSuppor
|
||||||
LOG.info("Reply to is: " + replyTo);
|
LOG.info("Reply to is: " + replyTo);
|
||||||
Destination destination = assertIsInstanceOf(Destination.class, replyTo);
|
Destination destination = assertIsInstanceOf(Destination.class, replyTo);
|
||||||
assertEquals("ReplyTo", replyQueueName, destination.toString());
|
assertEquals("ReplyTo", replyQueueName, destination.toString());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CamelContext createCamelContext() throws Exception {
|
protected CamelContext createCamelContext() throws Exception {
|
||||||
|
@ -134,8 +98,6 @@ public class InvokeRequestReplyUsingJmsReplyToHeaderTest extends CamelTestSuppor
|
||||||
return new RouteBuilder() {
|
return new RouteBuilder() {
|
||||||
public void configure() throws Exception {
|
public void configure() throws Exception {
|
||||||
from("activemq:test.server").bean(myBean);
|
from("activemq:test.server").bean(myBean);
|
||||||
|
|
||||||
from("activemq:test.reply").to("mock:result");
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue