Example usage for org.springframework.jdbc.datasource.embedded DataSourceFactory getDataSource

List of usage examples for org.springframework.jdbc.datasource.embedded DataSourceFactory getDataSource

Introduction

In this page you can find the example usage for org.springframework.jdbc.datasource.embedded DataSourceFactory getDataSource.

Prototype

DataSource getDataSource();

Source Link

Document

Get the DataSource with the #getConnectionProperties connection properties applied.

Usage

From source file:com.gopivotal.cloudfoundry.test.core.DataSourceUtilsTest.java

@Test
public void embeddedDataSourceUrl() {
    BoneCPDataSource targetDataSource = new BoneCPDataSource();
    targetDataSource.setJdbcUrl(TEST_URL);
    DataSourceFactory dataSourceFactory = mock(DataSourceFactory.class);
    when(dataSourceFactory.getDataSource()).thenReturn(targetDataSource);

    EmbeddedDatabaseFactory embeddedDatabaseFactory = new EmbeddedDatabaseFactory();
    embeddedDatabaseFactory.setDataSourceFactory(dataSourceFactory);
    embeddedDatabaseFactory.setDatabaseConfigurer(mock(EmbeddedDatabaseConfigurer.class));
    EmbeddedDatabase dataSource = embeddedDatabaseFactory.getDatabase();
    assertEquals(TEST_URL, this.dataSourceUtils.getUrl(dataSource));
}