org.springframework.jms.config.MessageListenerTestContainer Java Examples
The following examples show how to use
org.springframework.jms.config.MessageListenerTestContainer.
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: EnableJmsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void containerAreStartedByDefault() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); MessageListenerTestContainer container = factory.getListenerContainers().get(0); assertTrue(container.isAutoStartup()); assertTrue(container.isStarted()); }
Example #5
Source File: EnableJmsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void containerCanBeStarterViaTheRegistry() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsAutoStartupFalseConfig.class, DefaultBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); MessageListenerTestContainer container = factory.getListenerContainers().get(0); assertFalse(container.isAutoStartup()); assertFalse(container.isStarted()); JmsListenerEndpointRegistry registry = context.getBean(JmsListenerEndpointRegistry.class); registry.start(); assertTrue(container.isStarted()); }
Example #6
Source File: EnableJmsTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void lazyComponent() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class); JmsListenerContainerTestFactory defaultFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); assertEquals(0, defaultFactory.getListenerContainers().size()); context.getBean(LazyBean.class); // trigger lazy resolution assertEquals(1, defaultFactory.getListenerContainers().size()); MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example #7
Source File: EnableJmsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void containerAreStartedByDefault() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsDefaultContainerFactoryConfig.class, DefaultBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); MessageListenerTestContainer container = factory.getListenerContainers().get(0); assertTrue(container.isAutoStartup()); assertTrue(container.isStarted()); }
Example #8
Source File: EnableJmsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void containerCanBeStarterViaTheRegistry() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsAutoStartupFalseConfig.class, DefaultBean.class); JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class); MessageListenerTestContainer container = factory.getListenerContainers().get(0); assertFalse(container.isAutoStartup()); assertFalse(container.isStarted()); JmsListenerEndpointRegistry registry = context.getBean(JmsListenerEndpointRegistry.class); registry.start(); assertTrue(container.isStarted()); }
Example #9
Source File: EnableJmsTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void lazyComponent() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class); JmsListenerContainerTestFactory defaultFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); assertEquals(0, defaultFactory.getListenerContainers().size()); context.getBean(LazyBean.class); // trigger lazy resolution assertEquals(1, defaultFactory.getListenerContainers().size()); MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }
Example #10
Source File: EnableJmsTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void lazyComponent() { ConfigurableApplicationContext context = new AnnotationConfigApplicationContext( EnableJmsDefaultContainerFactoryConfig.class, LazyBean.class); JmsListenerContainerTestFactory defaultFactory = context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class); assertEquals(0, defaultFactory.getListenerContainers().size()); context.getBean(LazyBean.class); // trigger lazy resolution assertEquals(1, defaultFactory.getListenerContainers().size()); MessageListenerTestContainer container = defaultFactory.getListenerContainers().get(0); assertTrue("Should have been started " + container, container.isStarted()); context.close(); // Close and stop the listeners assertTrue("Should have been stopped " + container, container.isStopped()); }