|
|
@ -1,5 +1,5 @@
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Copyright 2012-2016 the original author or authors.
|
|
|
|
* Copyright 2012-2017 the original author or authors.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
@ -133,28 +133,27 @@ public class JpaPropertiesTests {
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void determineDatabaseWithKnownUrl() {
|
|
|
|
public void determineDatabaseWithKnownUrl() {
|
|
|
|
JpaProperties properties = load();
|
|
|
|
JpaProperties properties = load();
|
|
|
|
Database database = properties.determineDatabase(
|
|
|
|
Database database = properties
|
|
|
|
mockDataSource("jdbc:h2:mem:testdb"));
|
|
|
|
.determineDatabase(mockDataSource("jdbc:h2:mem:testdb"));
|
|
|
|
assertThat(database).isEqualTo(Database.H2);
|
|
|
|
assertThat(database).isEqualTo(Database.H2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void determineDatabaseWithKnownUrlAndUserConfig() {
|
|
|
|
public void determineDatabaseWithKnownUrlAndUserConfig() {
|
|
|
|
JpaProperties properties = load("spring.jpa.database=mysql");
|
|
|
|
JpaProperties properties = load("spring.jpa.database=mysql");
|
|
|
|
Database database = properties.determineDatabase(
|
|
|
|
Database database = properties
|
|
|
|
mockDataSource("jdbc:h2:mem:testdb"));
|
|
|
|
.determineDatabase(mockDataSource("jdbc:h2:mem:testdb"));
|
|
|
|
assertThat(database).isEqualTo(Database.MYSQL);
|
|
|
|
assertThat(database).isEqualTo(Database.MYSQL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void determineDatabaseWithUnknownUrl() {
|
|
|
|
public void determineDatabaseWithUnknownUrl() {
|
|
|
|
JpaProperties properties = load();
|
|
|
|
JpaProperties properties = load();
|
|
|
|
Database database = properties.determineDatabase(
|
|
|
|
Database database = properties
|
|
|
|
mockDataSource("jdbc:unknown://localhost"));
|
|
|
|
.determineDatabase(mockDataSource("jdbc:unknown://localhost"));
|
|
|
|
assertThat(database).isEqualTo(Database.DEFAULT);
|
|
|
|
assertThat(database).isEqualTo(Database.DEFAULT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
|
|
|
private DataSource mockStandaloneDataSource() throws SQLException {
|
|
|
|
private DataSource mockStandaloneDataSource() throws SQLException {
|
|
|
|
DataSource ds = mock(DataSource.class);
|
|
|
|
DataSource ds = mock(DataSource.class);
|
|
|
|
given(ds.getConnection()).willThrow(SQLException.class);
|
|
|
|
given(ds.getConnection()).willThrow(SQLException.class);
|
|
|
|