use of org.apache.cxf.transport.jms.JMSConfiguration in project cxf by apache.
the class JMSUtilTest method testJMSMessageMarshal.
@Test
public void testJMSMessageMarshal() throws IOException, JMSException {
String testMsg = "Test Message";
// TODO encoding
final byte[] testBytes = testMsg.getBytes(Charset.defaultCharset().name());
JMSConfiguration jmsConfig = new JMSConfiguration();
jmsConfig.setConnectionFactory(new ActiveMQConnectionFactory("vm://tesstMarshal?broker.persistent=false"));
try (ResourceCloser closer = new ResourceCloser()) {
Connection connection = JMSFactory.createConnection(jmsConfig);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
javax.jms.Message jmsMessage = JMSUtil.createAndSetPayload(testBytes, session, JMSConstants.BYTE_MESSAGE_TYPE);
assertTrue("Message should have been of type BytesMessage ", jmsMessage instanceof BytesMessage);
}
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project cxf by apache.
the class JMSClientServerTest method testReplyAndReplyToDestinations.
@Test(expected = SOAPFaultException.class)
public void testReplyAndReplyToDestinations() throws Exception {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setWsdlLocation("classpath:/wsdl/jms_test.wsdl");
factory.setServiceName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldService"));
factory.setEndpointName(new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort"));
factory.setAddress("jms://");
JMSConfigFeature feature = new JMSConfigFeature();
JMSConfiguration config = new JMSConfiguration();
config.setConnectionFactory(new ActiveMQConnectionFactory(broker.getBrokerURL()));
config.setRequestURI("test.jmstransport.text");
config.setTargetDestination("test.jmstransport.text");
// replyDestination and replyToDestination intentionally differ in this test scenario
// replyDestination = Destination name to listen on for reply messages
config.setReplyDestination("test.jmstransport.text.reply");
// replyToDestination = Destination name to send out as replyTo address in the message
config.setReplyToDestination("test.jmstransport.text.replyTo");
config.setReceiveTimeout(1000L);
feature.setJmsConfig(config);
factory.getFeatures().add(feature);
HelloWorldPortType greeter = factory.create(HelloWorldPortType.class);
try {
greeter.greetMe("FooBar");
// Timeout exception should be thrown
} finally {
((java.io.Closeable) greeter).close();
}
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.
the class JmsConfigurator method create.
public static JmsConfigurator create(Endpoint endpoint) {
if (!(endpoint instanceof EndpointImpl)) {
return null;
}
final EndpointImpl ep = (EndpointImpl) endpoint;
final QName serviceName = ep.getServiceName();
if (serviceName == null) {
return null;
}
final QName endpointName = ep.getEndpointName();
final String portName = endpointName == null ? null : endpointName.getLocalPart();
JmsConfigurator result = new JmsConfigurator();
result.setConfigurationPrefix(portName);
result.setJmsConfiguration(new JMSConfiguration());
result.setServiceName(serviceName);
return result;
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.
the class JmsConfigurator method create.
public static JmsConfigurator create(Dispatch<?> dispatch) {
if (!(dispatch instanceof DispatchImpl<?>)) {
return null;
}
DispatchImpl<?> dsp = (DispatchImpl<?>) dispatch;
Client cl = dsp.getClient();
final QName serviceName;
try {
serviceName = cl.getEndpoint().getService().getName();
} catch (Exception e) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(Level.FINER, "Exception caught: ", e);
}
return null;
}
if (serviceName == null) {
return null;
}
QName endpointName;
try {
endpointName = cl.getEndpoint().getEndpointInfo().getName();
} catch (Exception e) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.log(Level.FINER, "Exception caught: ", e);
}
endpointName = null;
}
final String portName = endpointName == null ? null : endpointName.getLocalPart();
JmsConfigurator result = new JmsConfigurator();
result.setConfigurationPrefix(portName);
result.setJmsConfiguration(new JMSConfiguration());
result.setServiceName(serviceName);
return result;
}
use of org.apache.cxf.transport.jms.JMSConfiguration in project tesb-rt-se by Talend.
the class DurableSubscriptionFeatureTest method testDurableSubscriptionFeature.
@Test
public void testDurableSubscriptionFeature() throws Exception {
DurableSubscriptionFeature f = new DurableSubscriptionFeature();
f.setDurableSubscriptionName("durableSubscriptionName");
f.setDurableSubscriptionClientId("durableSubscriptionClientId");
JMSConfiguration jmsConfig = new JMSConfiguration();
JMSConduit conduit = createMock(JMSConduit.class);
expect(conduit.getJmsConfig()).andReturn(jmsConfig).anyTimes();
replay(conduit);
Client client = createMock(Client.class);
expect(client.getConduit()).andReturn(conduit).anyTimes();
replay(client);
Bus bus = createNiceMock(Bus.class);
f.initialize(client, bus);
assertSame("durableSubscriptionName", jmsConfig.getDurableSubscriptionName());
assertSame("durableSubscriptionClientId", jmsConfig.getDurableSubscriptionClientId());
}
Aggregations