Search in sources :

Example 11 with MessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessageListenerAdapter in project spring-framework by spring-projects.

the class JmsNamespaceHandlerTests method testJcaContainerConfiguration.

@Test
public void testJcaContainerConfiguration() throws Exception {
    Map<String, JmsMessageEndpointManager> containers = context.getBeansOfType(JmsMessageEndpointManager.class);
    assertTrue("listener3 not found", containers.containsKey("listener3"));
    JmsMessageEndpointManager listener3 = containers.get("listener3");
    assertEquals("Wrong resource adapter", context.getBean("testResourceAdapter"), listener3.getResourceAdapter());
    assertEquals("Wrong activation spec factory", context.getBean("testActivationSpecFactory"), new DirectFieldAccessor(listener3).getPropertyValue("activationSpecFactory"));
    Object endpointFactory = new DirectFieldAccessor(listener3).getPropertyValue("endpointFactory");
    Object messageListener = new DirectFieldAccessor(endpointFactory).getPropertyValue("messageListener");
    assertEquals("Wrong message listener", MessageListenerAdapter.class, messageListener.getClass());
    MessageListenerAdapter adapter = (MessageListenerAdapter) messageListener;
    DirectFieldAccessor adapterFieldAccessor = new DirectFieldAccessor(adapter);
    assertEquals("Message converter not set properly", context.getBean("testMessageConverter"), adapterFieldAccessor.getPropertyValue("messageConverter"));
    assertEquals("Wrong delegate", context.getBean("testBean1"), adapterFieldAccessor.getPropertyValue("delegate"));
    assertEquals("Wrong method name", "setName", adapterFieldAccessor.getPropertyValue("defaultListenerMethod"));
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter) JmsMessageEndpointManager(org.springframework.jms.listener.endpoint.JmsMessageEndpointManager) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) Test(org.junit.Test)

Example 12 with MessageListenerAdapter

use of org.springframework.jms.listener.adapter.MessageListenerAdapter in project spring-framework by spring-projects.

the class JmsNamespaceHandlerTests method createDummyEndpoint.

private JmsListenerEndpoint createDummyEndpoint() {
    SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
    endpoint.setMessageListener(new MessageListenerAdapter());
    endpoint.setDestination("testQueue");
    return endpoint;
}
Also used : MessageListenerAdapter(org.springframework.jms.listener.adapter.MessageListenerAdapter)

Aggregations

MessageListenerAdapter (org.springframework.jms.listener.adapter.MessageListenerAdapter)12 Test (org.junit.Test)11 MessageListener (javax.jms.MessageListener)8 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)4 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 SimpleMessageListenerContainer (org.springframework.jms.listener.SimpleMessageListenerContainer)3 JmsMessageEndpointManager (org.springframework.jms.listener.endpoint.JmsMessageEndpointManager)3 MessageListenerContainer (org.springframework.jms.listener.MessageListenerContainer)1 JmsActivationSpecConfig (org.springframework.jms.listener.endpoint.JmsActivationSpecConfig)1 StubJmsActivationSpecFactory (org.springframework.jms.listener.endpoint.StubJmsActivationSpecFactory)1 BackOff (org.springframework.util.backoff.BackOff)1 FixedBackOff (org.springframework.util.backoff.FixedBackOff)1