use of org.springframework.orm.jpa.vendor.Database in project spring-boot by spring-projects.
the class CustomHibernateJpaAutoConfigurationTests method testDefaultDatabaseForH2.
@Test
public void testDefaultDatabaseForH2() throws Exception {
EnvironmentTestUtils.addEnvironment(this.context, "spring.datasource.url:jdbc:h2:mem:testdb", "spring.datasource.initialize:false");
this.context.register(TestConfiguration.class, DataSourceAutoConfiguration.class, PropertyPlaceholderAutoConfiguration.class, HibernateJpaAutoConfiguration.class);
this.context.refresh();
HibernateJpaVendorAdapter bean = this.context.getBean(HibernateJpaVendorAdapter.class);
Database database = (Database) ReflectionTestUtils.getField(bean, "database");
assertThat(database).isEqualTo(Database.H2);
}
use of org.springframework.orm.jpa.vendor.Database in project spring-boot by spring-projects.
the class JpaPropertiesTests method determineDatabaseWithUnknownUrl.
@Test
public void determineDatabaseWithUnknownUrl() {
JpaProperties properties = load();
Database database = properties.determineDatabase(mockDataSource("jdbc:unknown://localhost"));
assertThat(database).isEqualTo(Database.DEFAULT);
}
use of org.springframework.orm.jpa.vendor.Database in project spring-boot by spring-projects.
the class JpaPropertiesTests method determineDatabaseWithKnownUrl.
@Test
public void determineDatabaseWithKnownUrl() {
JpaProperties properties = load();
Database database = properties.determineDatabase(mockDataSource("jdbc:h2:mem:testdb"));
assertThat(database).isEqualTo(Database.H2);
}
use of org.springframework.orm.jpa.vendor.Database in project spring-boot by spring-projects.
the class JpaPropertiesTests method determineDatabaseNoCheckIfDatabaseIsSet.
@Test
public void determineDatabaseNoCheckIfDatabaseIsSet() throws SQLException {
JpaProperties properties = load("spring.jpa.database=postgresql");
DataSource dataSource = mockStandaloneDataSource();
Database database = properties.determineDatabase(dataSource);
assertThat(database).isEqualTo(Database.POSTGRESQL);
verify(dataSource, never()).getConnection();
}
use of org.springframework.orm.jpa.vendor.Database in project spring-boot by spring-projects.
the class CustomHibernateJpaAutoConfigurationTests method defaultDatabaseIsSet.
@Test
void defaultDatabaseIsSet() {
this.contextRunner.withPropertyValues("spring.datasource.url:jdbc:h2:mem:testdb", "spring.datasource.initialization-mode:never").run((context) -> {
HibernateJpaVendorAdapter bean = context.getBean(HibernateJpaVendorAdapter.class);
Database database = (Database) ReflectionTestUtils.getField(bean, "database");
assertThat(database).isEqualTo(Database.DEFAULT);
});
}
Aggregations