Commit 9c7e041d authored by Madhura Bhave's avatar Madhura Bhave

Merge pull request #23565 from desainidhi99

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

Closes gh-23565
parents 65c7cd43 7c22e717
...@@ -52,7 +52,7 @@ class DataSourceHealthIndicatorTests { ...@@ -52,7 +52,7 @@ class DataSourceHealthIndicatorTests {
@BeforeEach @BeforeEach
void init() { void init() {
EmbeddedDatabaseConnection db = EmbeddedDatabaseConnection.HSQL; EmbeddedDatabaseConnection db = EmbeddedDatabaseConnection.HSQLDB;
this.dataSource = new SingleConnectionDataSource(db.getUrl("testdb") + ";shutdown=true", "sa", "", false); this.dataSource = new SingleConnectionDataSource(db.getUrl("testdb") + ";shutdown=true", "sa", "", false);
this.dataSource.setDriverClassName(db.getDriverClassName()); this.dataSource.setDriverClassName(db.getDriverClassName());
} }
......
...@@ -163,7 +163,7 @@ class LiquibaseEndpointTests { ...@@ -163,7 +163,7 @@ class LiquibaseEndpointTests {
private DataSource createEmbeddedDatabase() { private DataSource createEmbeddedDatabase() {
return new EmbeddedDatabaseBuilder().generateUniqueName(true) return new EmbeddedDatabaseBuilder().generateUniqueName(true)
.setType(EmbeddedDatabaseConnection.HSQL.getType()).build(); .setType(EmbeddedDatabaseConnection.HSQLDB.getType()).build();
} }
private SpringLiquibase createSpringLiquibase(String changeLog, DataSource dataSource) { private SpringLiquibase createSpringLiquibase(String changeLog, DataSource dataSource) {
......
...@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
@JdbcTest @JdbcTest
@AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.AUTO_CONFIGURED, @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.AUTO_CONFIGURED,
connection = EmbeddedDatabaseConnection.HSQL) connection = EmbeddedDatabaseConnection.HSQLDB)
class JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests { class JdbcTestWithAutoConfigureTestDatabaseReplaceAutoConfiguredIntegrationTests {
@Autowired @Autowired
......
...@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -37,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@JdbcTest @JdbcTest
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQL) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQLDB)
class JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests { class JdbcTestWithAutoConfigureTestDatabaseReplaceExplicitIntegrationTests {
@Autowired @Autowired
......
...@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -38,7 +38,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@JdbcTest @JdbcTest
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQL) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQLDB)
@TestPropertySource(properties = "spring.test.database.replace=ANY") @TestPropertySource(properties = "spring.test.database.replace=ANY")
class JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests { class JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAnyIntegrationTests {
......
...@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat; ...@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@JdbcTest @JdbcTest
@AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQL) @AutoConfigureTestDatabase(connection = EmbeddedDatabaseConnection.HSQLDB)
@TestPropertySource(properties = "spring.test.database.replace=AUTO_CONFIGURED") @TestPropertySource(properties = "spring.test.database.replace=AUTO_CONFIGURED")
class JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests { class JdbcTestWithAutoConfigureTestDatabaseReplacePropertyAutoConfiguredIntegrationTests {
......
...@@ -35,6 +35,7 @@ import org.springframework.util.ClassUtils; ...@@ -35,6 +35,7 @@ import org.springframework.util.ClassUtils;
* @author Phillip Webb * @author Phillip Webb
* @author Dave Syer * @author Dave Syer
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Nidhi Desai
* @since 1.0.0 * @since 1.0.0
* @see #get(ClassLoader) * @see #get(ClassLoader)
*/ */
...@@ -58,8 +59,16 @@ public enum EmbeddedDatabaseConnection { ...@@ -58,8 +59,16 @@ public enum EmbeddedDatabaseConnection {
/** /**
* HSQL Database Connection. * HSQL Database Connection.
* @deprecated since 2.4.0 in favor of {@link EmbeddedDatabaseConnection#HSQLDB}.
*/ */
@Deprecated
HSQL(EmbeddedDatabaseType.HSQL, DatabaseDriver.HSQLDB.getDriverClassName(), "org.hsqldb.jdbcDriver", 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"); "jdbc:hsqldb:mem:%s");
private final EmbeddedDatabaseType type; private final EmbeddedDatabaseType type;
...@@ -114,8 +123,8 @@ public enum EmbeddedDatabaseConnection { ...@@ -114,8 +123,8 @@ public enum EmbeddedDatabaseConnection {
* @return true if the driver class is one of the embedded types * @return true if the driver class is one of the embedded types
*/ */
public static boolean isEmbedded(String driverClass) { public static boolean isEmbedded(String driverClass) {
return driverClass != null return driverClass != null && (matches(HSQL, driverClass) || matches(H2, driverClass)
&& (matches(HSQL, driverClass) || matches(H2, driverClass) || matches(DERBY, driverClass)); || matches(DERBY, driverClass) || matches(HSQLDB, driverClass));
} }
private static boolean matches(EmbeddedDatabaseConnection candidate, String driverClass) { private static boolean matches(EmbeddedDatabaseConnection candidate, String driverClass) {
......
...@@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException ...@@ -25,6 +25,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
* Tests for {@link EmbeddedDatabaseConnection}. * Tests for {@link EmbeddedDatabaseConnection}.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Nidhi Desai
*/ */
class EmbeddedDatabaseConnectionTests { class EmbeddedDatabaseConnectionTests {
...@@ -41,20 +42,40 @@ class EmbeddedDatabaseConnectionTests { ...@@ -41,20 +42,40 @@ class EmbeddedDatabaseConnectionTests {
} }
@Test @Test
@Deprecated
void hsqlCustomDatabaseName() { void hsqlCustomDatabaseName() {
assertThat(EmbeddedDatabaseConnection.HSQL.getUrl("myhsql")).isEqualTo("jdbc:hsqldb:mem:myhsql"); assertThat(EmbeddedDatabaseConnection.HSQL.getUrl("myhsql")).isEqualTo("jdbc:hsqldb:mem:myhsql");
} }
@Test @Test
@Deprecated
void getUrlWithNullDatabaseName() { void getUrlWithNullDatabaseName() {
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(null)) assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(null))
.withMessageContaining("DatabaseName must not be empty"); .withMessageContaining("DatabaseName must not be empty");
} }
@Test @Test
@Deprecated
void getUrlWithEmptyDatabaseName() { void getUrlWithEmptyDatabaseName() {
assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(" ")) assertThatIllegalArgumentException().isThrownBy(() -> EmbeddedDatabaseConnection.HSQL.getUrl(" "))
.withMessageContaining("DatabaseName must not be empty"); .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");
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment