Search in sources :

Example 56 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.

the class EnableJmsTests method fullConfigurableConfiguration.

@Override
public void fullConfigurableConfiguration() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableJmsFullConfigurableConfig.class, FullConfigurableBean.class);
    testFullConfiguration(context);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext)

Example 57 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.

the class EnableJmsTests method jmsListeners.

@Override
@Test
public void jmsListeners() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableJmsDefaultContainerFactoryConfig.class, JmsListenersBean.class);
    testJmsListenerRepeatable(context);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 58 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.

the class EnableJmsTests method sampleConfiguration.

@Override
@Test
public void sampleConfiguration() {
    ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(EnableJmsSampleConfig.class, SampleBean.class);
    testSampleConfiguration(context);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) Test(org.junit.Test)

Example 59 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.

the class JmsListenerAnnotationBeanPostProcessorTests method simpleMessageListener.

@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());
    // Close and stop the listeners
    context.close();
    assertTrue("Should have been stopped " + container, container.isStopped());
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) AbstractJmsListenerEndpoint(org.springframework.jms.config.AbstractJmsListenerEndpoint) JmsListenerEndpoint(org.springframework.jms.config.JmsListenerEndpoint) MethodJmsListenerEndpoint(org.springframework.jms.config.MethodJmsListenerEndpoint) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) MessageListenerTestContainer(org.springframework.jms.config.MessageListenerTestContainer) SimpleMessageListenerContainer(org.springframework.jms.listener.SimpleMessageListenerContainer) JmsListenerContainerTestFactory(org.springframework.jms.config.JmsListenerContainerTestFactory) MethodJmsListenerEndpoint(org.springframework.jms.config.MethodJmsListenerEndpoint) Test(org.junit.Test)

Example 60 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-framework by spring-projects.

the class DestroyMethodInferenceTests method xml.

@Test
public void xml() {
    ConfigurableApplicationContext ctx = new GenericXmlApplicationContext(getClass(), "DestroyMethodInferenceTests-context.xml");
    WithLocalCloseMethod x1 = ctx.getBean("x1", WithLocalCloseMethod.class);
    WithLocalCloseMethod x2 = ctx.getBean("x2", WithLocalCloseMethod.class);
    WithLocalCloseMethod x3 = ctx.getBean("x3", WithLocalCloseMethod.class);
    WithNoCloseMethod x4 = ctx.getBean("x4", WithNoCloseMethod.class);
    WithInheritedCloseMethod x8 = ctx.getBean("x8", WithInheritedCloseMethod.class);
    assertThat(x1.closed, is(false));
    assertThat(x2.closed, is(false));
    assertThat(x3.closed, is(false));
    assertThat(x4.closed, is(false));
    ctx.close();
    assertThat(x1.closed, is(false));
    assertThat(x2.closed, is(true));
    assertThat(x3.closed, is(true));
    assertThat(x4.closed, is(false));
    assertThat(x8.closed, is(false));
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) GenericXmlApplicationContext(org.springframework.context.support.GenericXmlApplicationContext) Test(org.junit.Test)

Aggregations

ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)177 Test (org.junit.Test)110 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)42 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)17 ApplicationContext (org.springframework.context.ApplicationContext)17 SpringApplication (org.springframework.boot.SpringApplication)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)13 DataSource (javax.sql.DataSource)8 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)7 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)7 MBeanServer (javax.management.MBeanServer)6 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)6 Statement (java.sql.Statement)5 ArrayList (java.util.ArrayList)5 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)5 RootBeanDefinition (org.springframework.beans.factory.support.RootBeanDefinition)5 GenericApplicationContext (org.springframework.context.support.GenericApplicationContext)5 GenericXmlApplicationContext (org.springframework.context.support.GenericXmlApplicationContext)5 ObjectName (javax.management.ObjectName)4