Java Code Examples for org.springframework.jms.config.MethodJmsListenerEndpoint#setupListenerContainer()
The following examples show how to use
org.springframework.jms.config.MethodJmsListenerEndpoint#setupListenerContainer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JmsListenerAnnotationBeanPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void simpleMessageListener() throws Exception { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( Config.class, SimpleMessageListenerTestBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); assertEquals("One container should have been registered", 1, factory.getListenerContainers().size()); MessageListenerTestContainer container = factory.getListenerContainers().get(0); JmsListenerEndpoint endpoint = container.getEndpoint(); assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass()); MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint; assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod()); SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); methodEndpoint.setupListenerContainer(listenerContainer); assertNotNull(listenerContainer.getMessageListener()); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example 2
Source File: JmsListenerAnnotationBeanPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void simpleMessageListener() throws Exception { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( Config.class, SimpleMessageListenerTestBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); assertEquals("One container should have been registered", 1, factory.getListenerContainers().size()); MessageListenerTestContainer container = factory.getListenerContainers().get(0); JmsListenerEndpoint endpoint = container.getEndpoint(); assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass()); MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint; assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod()); SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); methodEndpoint.setupListenerContainer(listenerContainer); assertNotNull(listenerContainer.getMessageListener()); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example 3
Source File: JmsListenerAnnotationBeanPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void simpleMessageListener() throws Exception { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( Config.class, SimpleMessageListenerTestBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); assertEquals("One container should have been registered", 1, factory.getListenerContainers().size()); MessageListenerTestContainer container = factory.getListenerContainers().get(0); JmsListenerEndpoint endpoint = container.getEndpoint(); assertEquals("Wrong endpoint type", MethodJmsListenerEndpoint.class, endpoint.getClass()); MethodJmsListenerEndpoint methodEndpoint = (MethodJmsListenerEndpoint) endpoint; assertEquals(SimpleMessageListenerTestBean.class, methodEndpoint.getBean().getClass()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMethod()); assertEquals(SimpleMessageListenerTestBean.class.getMethod("handleIt", String.class), methodEndpoint.getMostSpecificMethod()); SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(); methodEndpoint.setupListenerContainer(listenerContainer); assertNotNull(listenerContainer.getMessageListener()); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example 4
Source File: AbstractJmsAnnotationDrivenTests.java From spring-analysis-note with MIT License | 5 votes |
/** * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}. * * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} */ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); endpoint.setupListenerContainer(container); MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener(); listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class)); }
Example 5
Source File: AbstractJmsAnnotationDrivenTests.java From java-technology-stack with MIT License | 5 votes |
/** * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}. * * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} */ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); endpoint.setupListenerContainer(container); MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener(); listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class)); }
Example 6
Source File: AbstractJmsAnnotationDrivenTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Test for {@link ValidationBean} with a validator ({@link TestValidator}) specified * in a custom {@link org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory}. * * The test should throw a {@link org.springframework.jms.listener.adapter.ListenerExecutionFailedException} */ public void testJmsHandlerMethodFactoryConfiguration(ApplicationContext context) throws JMSException { JmsListenerContainerTestFactory simpleFactory = context.getBean("defaultFactory", JmsListenerContainerTestFactory.class); assertEquals(1, simpleFactory.getListenerContainers().size()); MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint) simpleFactory.getListenerContainers().get(0).getEndpoint(); SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); endpoint.setupListenerContainer(container); MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener(); listener.onMessage(new StubTextMessage("failValidation"), mock(Session.class)); }