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();
}
use of org.springframework.context.support.ClassPathXmlApplicationContext 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;
}
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);
}
use of org.springframework.context.support.ClassPathXmlApplicationContext in project OpenMEAP by OpenMEAP.
the class ModelTestUtils method main.
/**
* I used this mainly to generate the DDL.
* @param argv
*/
public static void main(String[] argv) {
//getPersistenceBean("modelManager");
if (persistenceBeans == null) {
System.setProperty("hibernate.show_sql", "true");
System.setProperty("hibernate.hbm2ddl.auto", "update");
System.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
System.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
System.setProperty("hibernate.connection.url", "jdbc:mysql://localhost:3306/openmeap");
System.setProperty("hibernate.connection.username", "openmeap");
System.setProperty("hibernate.connection.password", "password");
persistenceBeans = new ClassPathXmlApplicationContext(new String[] { "/META-INF/persistenceContext.xml", "/META-INF/test/persistenceContext.xml" });
}
createModel(null);
}
use of org.springframework.context.support.ClassPathXmlApplicationContext in project druid by alibaba.
the class SpringMybatisFilterTest method test_spring.
public void test_spring() throws Exception {
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("com/alibaba/druid/pool/mybatis/spring-config-mybatis.xml");
DataSource dataSource = (DataSource) context.getBean("dataSource");
{
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE sequence_seed (value INTEGER, name VARCHAR(50))");
stmt.close();
conn.close();
}
{
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE t_User (id BIGINT, name VARCHAR(50))");
stmt.close();
conn.close();
}
{
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
Statement stmt = conn.createStatement();
stmt.execute("insert into sequence_seed (value ,name) values (0, 'druid-spring-test')");
stmt.close();
conn.commit();
conn.close();
}
UserMapper userMapper = (UserMapper) context.getBean("userMapper");
{
User user = new User();
user.setName("xx");
userMapper.addUser(user);
}
{
userMapper.errorSelect(1);
}
{
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("DROP TABLE sequence_seed");
stmt.close();
conn.close();
}
{
Connection conn = dataSource.getConnection();
Statement stmt = conn.createStatement();
stmt.execute("DROP TABLE t_User");
stmt.close();
conn.close();
}
context.close();
Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
}
Aggregations