Search in sources :

Example 1 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project cucumber-jvm by cucumber.

the class CucumberTestContextManager method createFallbackContext.

@SuppressWarnings("resource")
private ConfigurableListableBeanFactory createFallbackContext() {
    ConfigurableApplicationContext applicationContext;
    if (getClass().getClassLoader().getResource("cucumber.xml") != null) {
        applicationContext = new ClassPathXmlApplicationContext("cucumber.xml");
    } else {
        applicationContext = new GenericApplicationContext();
    }
    applicationContext.registerShutdownHook();
    ConfigurableListableBeanFactory beanFactory = applicationContext.getBeanFactory();
    beanFactory.registerScope(GlueCodeScope.NAME, new GlueCodeScope());
    for (Class<?> stepClass : stepClasses) {
        registerStepClassBeanDefinition(beanFactory, stepClass);
    }
    return beanFactory;
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) GenericApplicationContext(org.springframework.context.support.GenericApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ConfigurableListableBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory)

Example 2 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project spring-cloud-microservice-example by kbastani.

the class Application method main.

public static void main(String[] args) {
    ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args);
    RepositoryRestConfiguration restConfiguration = ctx.getBean("config", RepositoryRestConfiguration.class);
    restConfiguration.exposeIdsFor(User.class);
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) RepositoryRestConfiguration(org.springframework.data.rest.core.config.RepositoryRestConfiguration)

Example 3 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project redisson by redisson.

the class SpringNamespaceWikiTest method testMasterSlave.

@Test
public void testMasterSlave() throws Exception {
    RedisRunner.RedisProcess master = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").nosave().randomDir().run();
    RedisRunner.RedisProcess slave1 = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").masterauth("do_not_use_if_it_is_not_set").port(6380).nosave().randomDir().slaveof("127.0.0.1", 6379).run();
    RedisRunner.RedisProcess slave2 = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").masterauth("do_not_use_if_it_is_not_set").port(6381).nosave().randomDir().slaveof("127.0.0.1", 6379).run();
    try {
        ((ConfigurableApplicationContext) new ClassPathXmlApplicationContext("classpath:org/redisson/spring/support/namespace_wiki_master_slave.xml")).close();
    } finally {
        master.stop();
        slave1.stop();
        slave2.stop();
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) RedisRunner(org.redisson.RedisRunner) Test(org.junit.Test)

Example 4 with ConfigurableApplicationContext

use of org.springframework.context.ConfigurableApplicationContext in project redisson by redisson.

the class SpringNamespaceWikiTest method testSentinel.

@Test
public void testSentinel() throws Exception {
    RedisRunner.RedisProcess master = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").nosave().randomDir().run();
    RedisRunner.RedisProcess slave1 = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").masterauth("do_not_use_if_it_is_not_set").port(6380).nosave().randomDir().slaveof("127.0.0.1", 6379).run();
    RedisRunner.RedisProcess slave2 = new RedisRunner().requirepass("do_not_use_if_it_is_not_set").masterauth("do_not_use_if_it_is_not_set").port(6381).nosave().randomDir().slaveof("127.0.0.1", 6379).run();
    RedisRunner.RedisProcess sentinel1 = new RedisRunner().nosave().randomDir().port(26379).sentinel().sentinelMonitor("myMaster", "127.0.0.1", 6379, 2).sentinelAuthPass("myMaster", "do_not_use_if_it_is_not_set").run();
    RedisRunner.RedisProcess sentinel2 = new RedisRunner().nosave().randomDir().port(26380).sentinel().sentinelMonitor("myMaster", "127.0.0.1", 6379, 2).sentinelAuthPass("myMaster", "do_not_use_if_it_is_not_set").run();
    RedisRunner.RedisProcess sentinel3 = new RedisRunner().nosave().randomDir().port(26381).sentinel().sentinelMonitor("myMaster", "127.0.0.1", 6379, 2).sentinelAuthPass("myMaster", "do_not_use_if_it_is_not_set").run();
    try {
        ((ConfigurableApplicationContext) new ClassPathXmlApplicationContext("classpath:org/redisson/spring/support/namespace_wiki_sentinel.xml")).close();
    } finally {
        master.stop();
        slave1.stop();
        slave2.stop();
        sentinel1.stop();
        sentinel2.stop();
        sentinel3.stop();
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) RedisRunner(org.redisson.RedisRunner) Test(org.junit.Test)

Example 5 with ConfigurableApplicationContext

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

the class LocalDevToolsAutoConfigurationTests method initializeAndRun.

private ConfigurableApplicationContext initializeAndRun(Class<?> config, Map<String, Object> properties, String... args) {
    Restarter.initialize(new String[0], false, new MockRestartInitializer(), false);
    SpringApplication application = new SpringApplication(config);
    application.setDefaultProperties(getDefaultProperties(properties));
    ConfigurableApplicationContext context = application.run(args);
    return context;
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) SpringApplication(org.springframework.boot.SpringApplication) MockRestartInitializer(org.springframework.boot.devtools.restart.MockRestartInitializer)

Aggregations

ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)162 Test (org.junit.Test)108 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)42 SpringApplicationBuilder (org.springframework.boot.builder.SpringApplicationBuilder)17 ApplicationContext (org.springframework.context.ApplicationContext)15 SpringApplication (org.springframework.boot.SpringApplication)14 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)12 DataSource (javax.sql.DataSource)8 JmsListenerContainerTestFactory (org.springframework.jms.config.JmsListenerContainerTestFactory)7 MBeanServer (javax.management.MBeanServer)6 ConfigurableEnvironment (org.springframework.core.env.ConfigurableEnvironment)6 Statement (java.sql.Statement)5 ConfigurableListableBeanFactory (org.springframework.beans.factory.config.ConfigurableListableBeanFactory)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 RedisRunner (org.redisson.RedisRunner)4 BeanDefinition (org.springframework.beans.factory.config.BeanDefinition)4