Search in sources :

Example 61 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext 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 62 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext 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 63 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project sharding-jdbc by dangdangdotcom.

the class SpringNamespaceWithMasterSlaveMain method main.

// CHECKSTYLE:OFF
public static void main(final String[] args) throws SQLException {
    // CHECKSTYLE:ON
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/applicationContextWithMasterSlave.xml");
    OrderService orderService = applicationContext.getBean(OrderService.class);
    orderService.insert();
    orderService.select();
    orderService.delete();
    orderService.select();
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) OrderService(com.dangdang.ddframe.rdb.sharding.example.config.spring.masterslave.service.OrderService)

Example 64 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project cas by apereo.

the class JdbcDataSourceMonitorTests method setUp.

@Before
public void setUp() {
    final ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("classpath:/jpaTestApplicationContext.xml");
    this.dataSource = ctx.getBean("dataSource", DataSource.class);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) DataSource(javax.sql.DataSource) Before(org.junit.Before)

Example 65 with ClassPathXmlApplicationContext

use of org.springframework.context.support.ClassPathXmlApplicationContext in project OpenMEAP by OpenMEAP.

the class ModelTestUtils method getPersistenceBean.

public static synchronized Object getPersistenceBean(String name) {
    if (persistenceBeans == null) {
        System.setProperty("hibernate.show_sql", "true");
        System.setProperty("hibernate.hbm2ddl.auto", "update");
        System.setProperty("hibernate.dialect", "org.hibernate.dialect.SQLite3Dialect");
        System.setProperty("hibernate.connection.driver_class", "org.sqlite.JDBC");
        System.setProperty("hibernate.connection.url", "jdbc:sqlite:" + OPENMEAP_TEST_DB);
        persistenceBeans = new ClassPathXmlApplicationContext(new String[] { "/META-INF/persistenceContext.xml", "/META-INF/test/persistenceContext.xml" });
    }
    return persistenceBeans.getBean(name);
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext)

Aggregations

ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)561 Test (org.junit.Test)265 ApplicationContext (org.springframework.context.ApplicationContext)167 Before (org.junit.Before)53 ConfigurableMessenger (org.springframework.scripting.ConfigurableMessenger)33 ITestBean (org.springframework.tests.sample.beans.ITestBean)30 Messenger (org.springframework.scripting.Messenger)29 CamelContext (org.apache.camel.CamelContext)25 Refreshable (org.springframework.aop.target.dynamic.Refreshable)23 AbstractXmlApplicationContext (org.springframework.context.support.AbstractXmlApplicationContext)22 DataSource (javax.sql.DataSource)18 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)16 AbstractApplicationContext (org.springframework.context.support.AbstractApplicationContext)16 Bus (org.apache.cxf.Bus)14 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)14 ArrayList (java.util.ArrayList)13 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)12 DemoService (com.alibaba.dubbo.config.spring.api.DemoService)11 IOException (java.io.IOException)10 ProducerTemplate (org.apache.camel.ProducerTemplate)10