Skip to content

Commit eccf453

Browse files
committed
add some tests
Signed-off-by: Michael Sprauer <[email protected]>
1 parent f0d13fa commit eccf453

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616

1717
package org.springframework.boot.jdbc;
1818

19+
import org.springframework.util.Assert;
20+
import org.springframework.util.StringUtils;
21+
1922
import java.util.Arrays;
2023
import java.util.Collection;
2124
import java.util.Collections;
2225
import java.util.Locale;
2326

24-
import org.springframework.util.Assert;
25-
import org.springframework.util.StringUtils;
26-
2727
/**
2828
* Enumeration of common database drivers.
2929
*
@@ -51,11 +51,6 @@ public enum DatabaseDriver {
5151
* H2.
5252
*/
5353
H2("H2", "org.h2.Driver", "org.h2.jdbcx.JdbcDataSource", "SELECT 1"),
54-
55-
/**
56-
* HDB - SAP Hana Database.
57-
*/
58-
HDB("HDB", "com.sap.db.jdbc.Driver", "com.sap.db.jdbcext.XADataSourceSAP", "SELECT 1 FROM DUMMY"),
5954

6055
/**
6156
* HyperSQL DataBase.
@@ -104,6 +99,12 @@ public String getId() {
10499
POSTGRESQL("PostgreSQL", "org.postgresql.Driver", "org.postgresql.xa.PGXADataSource",
105100
"SELECT 1"),
106101

102+
/**
103+
* SAP - SAP Hana Database - HDB
104+
*/
105+
SAP("HDB", "com.sap.db.jdbc.Driver", "com.sap.db.jdbcext.XADataSourceSAP",
106+
"SELECT 1 FROM DUMMY"),
107+
107108
/**
108109
* jTDS. As it can be used for several databases, there isn't a single product name we
109110
* could rely on.

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DatabaseDriverTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public void databaseProductNameLookups() {
7474
assertThat(DatabaseDriver.fromProductName("Apache Derby"))
7575
.isEqualTo(DatabaseDriver.DERBY);
7676
assertThat(DatabaseDriver.fromProductName("H2")).isEqualTo(DatabaseDriver.H2);
77+
assertThat(DatabaseDriver.fromProductName("HDB")).isEqualTo(DatabaseDriver.SAP);
7778
assertThat(DatabaseDriver.fromProductName("HSQL Database Engine"))
7879
.isEqualTo(DatabaseDriver.HSQLDB);
7980
assertThat(DatabaseDriver.fromProductName("SQLite"))
@@ -113,6 +114,8 @@ public void databaseJdbcUrlLookups() {
113114
.isEqualTo(DatabaseDriver.DERBY);
114115
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:h2:~/sample"))
115116
.isEqualTo(DatabaseDriver.H2);
117+
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:sap:localhost"))
118+
.isEqualTo(DatabaseDriver.SAP);
116119
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:hsqldb:hsql://localhost"))
117120
.isEqualTo(DatabaseDriver.HSQLDB);
118121
assertThat(DatabaseDriver.fromJdbcUrl("jdbc:sqlite:sample.db"))

0 commit comments

Comments
 (0)