Package org.springframework.jms.config

Examples of org.springframework.jms.config.JmsListenerContainerTestFactory


  @Test
  public void simpleMessageListener() {
    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;
    assertNotNull(methodEndpoint.getBean());
View Full Code Here


  @Test
  public void metaAnnotationIsDiscovered() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(
        Config.class, MetaAnnotationTestBean.class);

    JmsListenerContainerTestFactory factory = context.getBean(JmsListenerContainerTestFactory.class);
    assertEquals("one container should have been registered", 1, factory.getListenerContainers().size());
    JmsListenerEndpoint endpoint = factory.getListenerContainers().get(0).getEndpoint();
    assertEquals("metaTestQueue", ((AbstractJmsListenerEndpoint) endpoint).getDestination());
  }
View Full Code Here

      return new JmsListenerEndpointRegistry();
    }

    @Bean
    public JmsListenerContainerTestFactory testFactory() {
      return new JmsListenerContainerTestFactory();
    }
View Full Code Here

  /**
   * Test for {@link SampleBean} discovery. If a factory with the default name
   * is set, an endpoint will use it automatically
   */
  public void testSampleConfiguration(ApplicationContext context) {
    JmsListenerContainerTestFactory defaultFactory =
        context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
    JmsListenerContainerTestFactory simpleFactory =
        context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
    assertEquals(1, defaultFactory.getListenerContainers().size());
    assertEquals(1, simpleFactory.getListenerContainers().size());
  }
View Full Code Here

   * Test for {@link FullBean} discovery. In this case, no default is set because
   * all endpoints provide a default registry. This shows that the default factory
   * is only retrieved if it needs to be.
   */
  public void testFullConfiguration(ApplicationContext context) {
    JmsListenerContainerTestFactory simpleFactory =
        context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
    assertEquals(1, simpleFactory.getListenerContainers().size());
    MethodJmsListenerEndpoint endpoint = (MethodJmsListenerEndpoint)
        simpleFactory.getListenerContainers().get(0).getEndpoint();
    assertEquals("listener1", endpoint.getId());
    assertEquals("queueIn", endpoint.getDestination());
    assertEquals("mySelector", endpoint.getSelector());
    assertEquals("mySubscription", endpoint.getSubscription());
    assertEquals("1-10", endpoint.getConcurrency());
View Full Code Here

   * 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());

View Full Code Here

   * Test for {@link DefaultBean} that does not define the container
   * factory to use as a default is registered with an explicit
   * default.
   */
  public void testExplicitContainerFactoryConfiguration(ApplicationContext context) {
    JmsListenerContainerTestFactory defaultFactory =
        context.getBean("simpleFactory", JmsListenerContainerTestFactory.class);
    assertEquals(1, defaultFactory.getListenerContainers().size());
  }
View Full Code Here

  /**
   * Test for {@link DefaultBean} that does not define the container
   * factory to use as a default is registered with the default name.
   */
  public void testDefaultContainerFactoryConfiguration(ApplicationContext context) {
    JmsListenerContainerTestFactory defaultFactory =
        context.getBean("jmsListenerContainerFactory", JmsListenerContainerTestFactory.class);
    assertEquals(1, defaultFactory.getListenerContainers().size());
  }
View Full Code Here

   * 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));
View Full Code Here

  @Configuration
  static class EnableJmsSampleConfig {

    @Bean
    public JmsListenerContainerTestFactory jmsListenerContainerFactory() {
      return new JmsListenerContainerTestFactory();
    }
View Full Code Here

TOP

Related Classes of org.springframework.jms.config.JmsListenerContainerTestFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.