use of org.apache.cxf.transport.jms.util.TestReceiver in project cxf by apache.
the class MessageIdAsCorrelationIdJMSConduitTest method sendAndReceive.
public void sendAndReceive(boolean synchronous, String replyDestination) throws Exception {
BusFactory bf = BusFactory.newInstance();
Bus bus = bf.createBus();
BusFactory.setDefaultBus(bus);
EndpointReferenceType target = new EndpointReferenceType();
connectionFactory = new PooledConnectionFactory(BROKER_URI);
TestReceiver receiver = new TestReceiver(connectionFactory, SERVICE_QUEUE, true);
receiver.runAsync();
JMSConfiguration jmsConfig = new JMSConfiguration();
jmsConfig.setTargetDestination(SERVICE_QUEUE);
jmsConfig.setConnectionFactory(connectionFactory);
jmsConfig.setUseConduitIdSelector(false);
jmsConfig.setReplyDestination(replyDestination);
JMSConduit conduit = new JMSConduit(target, jmsConfig, bus);
Exchange exchange = new ExchangeImpl();
exchange.setSynchronous(synchronous);
Message message = new MessageImpl();
exchange.setOutMessage(message);
conduit.sendExchange(exchange, "Request");
waitForAsyncReply(exchange);
receiver.close();
if (exchange.getInMessage() == null) {
throw new RuntimeException("No reply received within 2 seconds");
}
JMSMessageHeadersType inHeaders = (JMSMessageHeadersType) exchange.getInMessage().get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
Assert.assertEquals(receiver.getRequestMessageId(), inHeaders.getJMSCorrelationID());
conduit.close();
bus.shutdown(true);
}
use of org.apache.cxf.transport.jms.util.TestReceiver in project cxf by apache.
the class URIConfiguredConduitTest method sendAndReceive.
public void sendAndReceive(SyncType syncType, String address) throws Exception {
// Register bean locator for cf lookup
TestReceiver receiver = new TestReceiver(cf, SERVICE_QUEUE, false);
receiver.runAsync();
EndpointInfo ei = new EndpointInfo();
ei.setAddress(address);
Bus bus = BusFactory.getDefaultBus();
JMSConfiguration jmsConfig = JMSConfigFactory.createFromEndpointInfo(bus, ei, null);
jmsConfig.setConnectionFactory(cf);
JMSConduit conduit = new JMSConduit(new EndpointReferenceType(), jmsConfig, bus);
Exchange exchange = new ExchangeImpl();
exchange.setSynchronous(syncType == SyncType.sync);
Message message = new MessageImpl();
exchange.setOutMessage(message);
conduit.sendExchange(exchange, "Request");
waitForAsyncReply(exchange);
receiver.close();
if (exchange.getInMessage() == null) {
throw new RuntimeException("No reply received within 2 seconds");
}
JMSMessageHeadersType inHeaders = (JMSMessageHeadersType) exchange.getInMessage().get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
Assert.assertEquals(receiver.getRequestMessageId(), inHeaders.getJMSCorrelationID());
conduit.close();
}
use of org.apache.cxf.transport.jms.util.TestReceiver in project cxf by apache.
the class JMSClientServerTest method testReplyToConfig.
@Test
public void testReplyToConfig() throws Exception {
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(broker.getBrokerURL());
TestReceiver receiver = new TestReceiver(cf, "SoapService7.replyto.queue", false);
receiver.setStaticReplyQueue("SoapService7.reply.queue");
receiver.runAsync();
QName serviceName = new QName("http://apache.org/hello_world_doc_lit", "SOAPService7");
QName portName = new QName("http://apache.org/hello_world_doc_lit", "SoapPort7");
URL wsdl = getWSDLURL("/wsdl/hello_world_doc_lit.wsdl");
SOAPService7 service = new SOAPService7(wsdl, serviceName);
Greeter greeter = service.getPort(portName, Greeter.class);
String name = "FooBar";
String reply = greeter.greetMe(name);
Assert.assertEquals("Hello " + name, reply);
((Closeable) greeter).close();
}
Aggregations