Merge pull request #23565 from desainidhi99

* pr/23565:
  Polish "Deprecate EmbeddedDatabaseConnection#HSQL"
  Deprecate EmbeddedDatabaseConnection#HSQL in favor of HSQLDB

Closes gh-23565
pull/23571/head
Madhura Bhave 4 years ago
commit 9c7e041d41

@ -52,7 +52,7 @@ class DataSourceHealthIndicatorTests {
@BeforeEach
void init() {
EmbeddedDatabaseConnection db = EmbeddedDatabaseConnection.HSQL;
EmbeddedDatabaseConnection db = EmbeddedDatabaseConnection.HSQLDB;
this.dataSource = new SingleConnectionDataSource(db.getUrl("testdb") + ";shutdown=true", "sa", "", false);
this.dataSource.setDriverClassName(db.getDriverClassName());
}

@ -163,7 +163,7 @@ class LiquibaseEndpointTests {
private DataSource createEmbeddedDatabase() {
return new EmbeddedDatabaseBuilder().generateUniqueName(true)
.setType(EmbeddedDatabaseConnection.HSQL.getType()).build();
.setType(EmbeddedDatabaseConnection.HSQLDB.getType()).build();
}
private SpringLiquibase createSpringLiquibase(String changeLog, DataSource dataSource) {

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/
@JdbcTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.AUTO_CONFIGURED,
connection = EmbeddedDatabaseConnection.HSQL)
connection = EmbeddedDatabaseConnection.HSQLDB)
class JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests {
@Autowired

@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@JdbcTest
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQL)
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQLDB)
class JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests {
@Autowired

@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@JdbcTest
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQL)
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQLDB)
@TestPropertySource(properties = "spring.test.database.replace=ANY")
class JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests {

@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll
*/
@JdbcTest
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQL)
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQLDB)
@TestPropertySource(properties = "spring.test.database.replace=AUTO_CONFIGURED")
class JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests {

@ -35,6 +35,7 @@ import org.springframework.util.ClassUtils;
* @author Phillip Webb
* @author Dave Syer
* @author Stephane Nicoll
* @author Nidhi Desai
* @since 1.0.0
* @see #get(ClassLoader)
*/
@ -58,8 +59,16 @@ public enum EmbeddedDatabaseConnection {
/**
* HSQL Database Connection.
* @deprecated since 2.4.0 in favor of {@link EmbeddedDatabaseConnection#HSQLDB}.
*/
@Deprecated
HSQL(EmbeddedDatabaseType.HSQL, DatabaseDriver.HSQLDB.getDriverClassName(), "org.hsqldb.jdbcDriver",
"jdbc:hsqldb:mem:%s"),
/**
* HSQL Database Connection.
*/
HSQLDB(EmbeddedDatabaseType.HSQL, DatabaseDriver.HSQLDB.getDriverClassName(), "org.hsqldb.jdbcDriver",
"jdbc:hsqldb:mem:%s");
private final EmbeddedDatabaseType type;
@ -114,8 +123,8 @@ public enum EmbeddedDatabaseConnection {
* @return true if the driver class is one of the embedded types
*/
public static boolean isEmbedded(String driverClass) {
return driverClass != null
&& (matches(HSQL, driverClass) || matches(H2, driverClass) || matches(DERBY, driverClass));
return driverClass != null && (matches(HSQL, driverClass) || matches(H2, driverClass)
|| matches(DERBY, driverClass) || matches(HSQLDB, driverClass));
}
private static boolean matches(EmbeddedDatabaseConnection candidate, String driverClass) {

@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* Tests for {@link EmbeddedDatabaseConnection}.
*
* @author Stephane Nicoll
* @author Nidhi Desai
*/
class EmbeddedDatabaseConnectionTests {
@ -41,20 +42,40 @@ class EmbeddedDatabaseConnectionTests {
}
@Test
@Deprecated
void hsqlCustomDatabaseName() {
assertThat(EmbeddedDatabaseConnection.HSQL.getUrl("myhsql")).isEqualTo("jdbc:hsqldb:mem:myhsql");
}
@Test
@Deprecated
void getUrlWithNullDatabaseName() {
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(null))
.withMessageContaining("DatabaseName must not be empty");
}
@Test
@Deprecated
void getUrlWithEmptyDatabaseName() {
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(" "))
.withMessageContaining("DatabaseName must not be empty");
}
@Test
void hsqldbCustomDatabaseName() {
assertThat(EmbeddedDatabaseConnection.HSQLDB.getUrl("myhsqldb")).isEqualTo("jdbc:hsqldb:mem:myhsqldb");
}
@Test
void getUrlWithNullDatabaseNameForHsqldb() {
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQLDB.getUrl(null))
.withMessageContaining("DatabaseName must not be empty");
}
@Test
void getUrlWithEmptyDatabaseNameForHsqldb() {
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQLDB.getUrl(" "))
.withMessageContaining("DatabaseName must not be empty");
}
}

Loading…
Cancel
Save