Search in sources :

Example 1 with SimpleJmsListenerEndpoint

use of org.springframework.jms.config.SimpleJmsListenerEndpoint in project spring-framework by spring-projects.

the class AbstractJmsAnnotationDrivenTests method testCustomConfiguration.

/**
	 * Test for {@link CustomBean} and an manually endpoint registered
	 * with "myCustomEndpointId". The custom endpoint does not provide
	 * any factory so it's registered with the default one
	 */
public void testCustomConfiguration(ApplicationContext context) {
    JmsListenerContainerTestFactory defaultFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
    JmsListenerContainerTestFactory customFactory = context.getBean("customFactory", JmsListenerContainerTestFactory.class);
    assertEquals(1, defaultFactory.getListenerContainers().size());
    assertEquals(1, customFactory.getListenerContainers().size());
    JmsListenerEndpoint endpoint = defaultFactory.getListenerContainers().get(0).getEndpoint();
    assertEquals("Wrong endpoint type", SimpleJmsListenerEndpoint.class, endpoint.getClass());
    assertEquals("Wrong listener set in custom endpoint", context.getBean("simpleMessageListener"), ((SimpleJmsListenerEndpoint) endpoint).getMessageListener());
    JmsListenerEndpointRegistry customRegistry = context.getBean("customRegistry", JmsListenerEndpointRegistry.class);
    assertEquals("Wrong number of containers in the registry", 2, customRegistry.getListenerContainerIds().size());
    assertEquals("Wrong number of containers in the registry", 2, customRegistry.getListenerContainers().size());
    assertNotNull("Container with custom id on the annotation should be found", customRegistry.getListenerContainer("listenerId"));
    assertNotNull("Container created with custom id should be found", customRegistry.getListenerContainer("myCustomEndpointId"));
}
Also used : JmsListenerEndpointRegistry(org.springframework.jms.config.JmsListenerEndpointRegistry) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) MethodJmsListenerEndpoint(org.springframework.jms.config.MethodJmsListenerEndpoint) SimpleJmsListenerEndpoint(org.springframework.jms.config.SimpleJmsListenerEndpoint) JmsListenerContainerTestFactory(org.springframework.jms.config.JmsListenerContainerTestFactory)

Aggregations

JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)1 JmsListenerEndpoint (org.springframework.jms.config.JmsListenerEndpoint)1 JmsListenerEndpointRegistry (org.springframework.jms.config.JmsListenerEndpointRegistry)1 MethodJmsListenerEndpoint (org.springframework.jms.config.MethodJmsListenerEndpoint)1 SimpleJmsListenerEndpoint (org.springframework.jms.config.SimpleJmsListenerEndpoint)1