Search in sources :

Example 1 with JDBCXADataSource

use of org.hsqldb.jdbc.pool.JDBCXADataSource in project spring-boot by spring-projects.

the class XADataSourceAutoConfigurationTests method createFromUrl.

@Test
public void createFromUrl() throws Exception {
    ApplicationContext context = createContext(FromProperties.class, "spring.datasource.url:jdbc:hsqldb:mem:test", "spring.datasource.username:un");
    context.getBean(DataSource.class);
    MockXADataSourceWrapper wrapper = context.getBean(MockXADataSourceWrapper.class);
    JDBCXADataSource dataSource = (JDBCXADataSource) wrapper.getXaDataSource();
    assertThat(dataSource).isNotNull();
    assertThat(dataSource.getUrl()).isEqualTo("jdbc:hsqldb:mem:test");
    assertThat(dataSource.getUser()).isEqualTo("un");
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) JDBCXADataSource(org.hsqldb.jdbc.pool.JDBCXADataSource) Test(org.junit.Test)

Example 2 with JDBCXADataSource

use of org.hsqldb.jdbc.pool.JDBCXADataSource in project spring-boot by spring-projects.

the class XADataSourceAutoConfigurationTests method createFromClass.

@Test
public void createFromClass() throws Exception {
    ApplicationContext context = createContext(FromProperties.class, "spring.datasource.xa.data-source-class-name:org.hsqldb.jdbc.pool.JDBCXADataSource", "spring.datasource.xa.properties.database-name:test");
    context.getBean(DataSource.class);
    MockXADataSourceWrapper wrapper = context.getBean(MockXADataSourceWrapper.class);
    JDBCXADataSource dataSource = (JDBCXADataSource) wrapper.getXaDataSource();
    assertThat(dataSource).isNotNull();
    assertThat(dataSource.getDatabaseName()).isEqualTo("test");
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) JDBCXADataSource(org.hsqldb.jdbc.pool.JDBCXADataSource) Test(org.junit.Test)

Aggregations

JDBCXADataSource (org.hsqldb.jdbc.pool.JDBCXADataSource)2 Test (org.junit.Test)2 ApplicationContext (org.springframework.context.ApplicationContext)2 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)2