use of javax.sql.DataSource in project platformlayer by platformlayer.
the class GuiceDataSourceProvider method bindJndi.
public static Provider<? extends DataSource> bindJndi(final String key) {
Provider<DataSource> provider = new Provider<DataSource>() {
@Override
public DataSource get() {
try {
InitialContext context = new InitialContext();
DataSource dataSource = (DataSource) context.lookup(key);
return dataSource;
} catch (NamingException e) {
throw new IllegalStateException("Error getting JDNI connection: " + key, e);
}
}
};
return provider;
}
use of javax.sql.DataSource in project spring-boot by spring-projects.
the class AbstractDevToolsDataSourceAutoConfigurationTests method singleManuallyConfiguredDataSourceIsNotClosed.
@Test
public void singleManuallyConfiguredDataSourceIsNotClosed() throws SQLException {
ConfigurableApplicationContext context = createContext(DataSourcePropertiesConfiguration.class, SingleDataSourceConfiguration.class);
DataSource dataSource = context.getBean(DataSource.class);
Statement statement = configureDataSourceBehaviour(dataSource);
verify(statement, times(0)).execute("SHUTDOWN");
}
use of javax.sql.DataSource in project spring-boot by spring-projects.
the class AbstractDevToolsDataSourceAutoConfigurationTests method emptyFactoryMethodMetadataIgnored.
@Test
public void emptyFactoryMethodMetadataIgnored() {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
DataSource dataSource = mock(DataSource.class);
AnnotatedGenericBeanDefinition beanDefinition = new AnnotatedGenericBeanDefinition(dataSource.getClass());
context.registerBeanDefinition("dataSource", beanDefinition);
context.register(DataSourcePropertiesConfiguration.class);
context.register(DevToolsDataSourceAutoConfiguration.class);
context.refresh();
context.close();
}
use of javax.sql.DataSource in project spring-boot by spring-projects.
the class AbstractDevToolsDataSourceAutoConfigurationTests method multipleDataSourcesAreIgnored.
@Test
public void multipleDataSourcesAreIgnored() throws SQLException {
ConfigurableApplicationContext context = createContext(DataSourcePropertiesConfiguration.class, MultipleDataSourcesConfiguration.class);
Collection<DataSource> dataSources = context.getBeansOfType(DataSource.class).values();
for (DataSource dataSource : dataSources) {
Statement statement = configureDataSourceBehaviour(dataSource);
verify(statement, times(0)).execute("SHUTDOWN");
}
}
use of javax.sql.DataSource in project spring-boot by spring-projects.
the class AtomikosXADataSourceWrapperTests method wrap.
@Test
public void wrap() throws Exception {
XADataSource dataSource = mock(XADataSource.class);
AtomikosXADataSourceWrapper wrapper = new AtomikosXADataSourceWrapper();
DataSource wrapped = wrapper.wrapDataSource(dataSource);
assertThat(wrapped).isInstanceOf(AtomikosDataSourceBean.class);
assertThat(((AtomikosDataSourceBean) wrapped).getXaDataSource()).isSameAs(dataSource);
}
Aggregations