|
27 | 27 | * |
28 | 28 | * @author Phillip Webb |
29 | 29 | * @author Maciej Walkowiak |
| 30 | + * @author Stephane Nicoll |
30 | 31 | */ |
31 | 32 | public class DatabaseDriverTests { |
32 | 33 |
|
@@ -70,25 +71,73 @@ public void unknownOnNullProductName() { |
70 | 71 | public void databaseProductNameLookups() throws Exception { |
71 | 72 | assertThat(DatabaseDriver.fromProductName("newone")) |
72 | 73 | .isEqualTo(DatabaseDriver.UNKNOWN); |
| 74 | + assertThat(DatabaseDriver.fromProductName("Apache Derby")) |
| 75 | + .isEqualTo(DatabaseDriver.DERBY); |
| 76 | + assertThat(DatabaseDriver.fromProductName("H2")) |
| 77 | + .isEqualTo(DatabaseDriver.H2); |
73 | 78 | assertThat(DatabaseDriver.fromProductName("HSQL Database Engine")) |
74 | 79 | .isEqualTo(DatabaseDriver.HSQLDB); |
| 80 | + assertThat(DatabaseDriver.fromProductName("SQLite")) |
| 81 | + .isEqualTo(DatabaseDriver.SQLITE); |
| 82 | + assertThat(DatabaseDriver.fromProductName("MySQL")) |
| 83 | + .isEqualTo(DatabaseDriver.MYSQL); |
75 | 84 | assertThat(DatabaseDriver.fromProductName("Oracle")) |
76 | 85 | .isEqualTo(DatabaseDriver.ORACLE); |
77 | | - assertThat(DatabaseDriver.fromProductName("Apache Derby")) |
78 | | - .isEqualTo(DatabaseDriver.DERBY); |
| 86 | + assertThat(DatabaseDriver.fromProductName("PostgreSQL")) |
| 87 | + .isEqualTo(DatabaseDriver.POSTGRESQL); |
| 88 | + assertThat(DatabaseDriver.fromProductName("SQL SERVER")) |
| 89 | + .isEqualTo(DatabaseDriver.SQLSERVER); |
79 | 90 | assertThat(DatabaseDriver.fromProductName("DB2")).isEqualTo(DatabaseDriver.DB2); |
| 91 | + assertThat(DatabaseDriver.fromProductName("Firebird 2.5.WI")) |
| 92 | + .isEqualTo(DatabaseDriver.FIREBIRD); |
| 93 | + assertThat(DatabaseDriver.fromProductName("Firebird 2.1.LI")) |
| 94 | + .isEqualTo(DatabaseDriver.FIREBIRD); |
80 | 95 | assertThat(DatabaseDriver.fromProductName("DB2/LINUXX8664")) |
81 | 96 | .isEqualTo(DatabaseDriver.DB2); |
82 | 97 | assertThat(DatabaseDriver.fromProductName("DB2 UDB for AS/400")) |
83 | 98 | .isEqualTo(DatabaseDriver.DB2_AS400); |
84 | 99 | assertThat(DatabaseDriver.fromProductName("DB3 XDB for AS/400")) |
85 | 100 | .isEqualTo(DatabaseDriver.DB2_AS400); |
| 101 | + assertThat(DatabaseDriver.fromProductName("Teradata")) |
| 102 | + .isEqualTo(DatabaseDriver.TERADATA); |
86 | 103 | assertThat(DatabaseDriver.fromProductName("Informix Dynamic Server")) |
87 | 104 | .isEqualTo(DatabaseDriver.INFORMIX); |
88 | | - assertThat(DatabaseDriver.fromProductName("Firebird 2.5.WI")) |
89 | | - .isEqualTo(DatabaseDriver.FIREBIRD); |
90 | | - assertThat(DatabaseDriver.fromProductName("Firebird 2.1.LI")) |
| 105 | + } |
| 106 | + |
| 107 | + @Test |
| 108 | + public void databaseJdbcUrlLookups() { |
| 109 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:newone://localhost")) |
| 110 | + .isEqualTo(DatabaseDriver.UNKNOWN); |
| 111 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:derby:sample")) |
| 112 | + .isEqualTo(DatabaseDriver.DERBY); |
| 113 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:h2:~/sample")) |
| 114 | + .isEqualTo(DatabaseDriver.H2); |
| 115 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:hsqldb:hsql://localhost")) |
| 116 | + .isEqualTo(DatabaseDriver.HSQLDB); |
| 117 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:sqlite:sample.db")) |
| 118 | + .isEqualTo(DatabaseDriver.SQLITE); |
| 119 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:mysql://localhost:3306/sample")) |
| 120 | + .isEqualTo(DatabaseDriver.MYSQL); |
| 121 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:oracle:thin:@localhost:1521:orcl")) |
| 122 | + .isEqualTo(DatabaseDriver.ORACLE); |
| 123 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:postgresql://127.0.0.1:5432/sample")) |
| 124 | + .isEqualTo(DatabaseDriver.POSTGRESQL); |
| 125 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:jtds:sqlserver://127.0.0.1:1433/sample")) |
| 126 | + .isEqualTo(DatabaseDriver.JTDS); |
| 127 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:sqlserver://127.0.0.1:1433")) |
| 128 | + .isEqualTo(DatabaseDriver.SQLSERVER); |
| 129 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:firebirdsql://localhost/sample")) |
91 | 130 | .isEqualTo(DatabaseDriver.FIREBIRD); |
| 131 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:db2://localhost:50000/sample ")) |
| 132 | + .isEqualTo(DatabaseDriver.DB2); |
| 133 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:as400://localhost")) |
| 134 | + .isEqualTo(DatabaseDriver.DB2_AS400); |
| 135 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:teradata://localhost/SAMPLE")) |
| 136 | + .isEqualTo(DatabaseDriver.TERADATA); |
| 137 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:informix-sqli://localhost:1533/sample")) |
| 138 | + .isEqualTo(DatabaseDriver.INFORMIX); |
| 139 | + assertThat(DatabaseDriver.fromJdbcUrl("jdbc:informix-direct://sample")) |
| 140 | + .isEqualTo(DatabaseDriver.INFORMIX); |
92 | 141 | } |
93 | 142 |
|
94 | 143 | } |
0 commit comments