Skip to content

Commit 77ebbfa

Browse files
committed
test: add tests
1 parent cf732e1 commit 77ebbfa

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/test/java/com/google/cloud/spanner/jdbc/JdbcDriverTest.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,14 @@ public void testRegister() throws SQLException {
136136

137137
@Test
138138
public void testConnect() throws SQLException {
139-
try (Connection connection =
140-
DriverManager.getConnection(
141-
String.format(
142-
"jdbc:cloudspanner://localhost:%d/projects/some-company.com:test-project/instances/static-test-instance/databases/test-database;usePlainText=true;credentials=%s",
143-
server.getPort(), TEST_KEY_PATH))) {
144-
assertThat(connection.isClosed()).isFalse();
145-
}
139+
for (String prefix : new String[] {"cloudspanner", "spanner"})
140+
try (Connection connection =
141+
DriverManager.getConnection(
142+
String.format(
143+
"jdbc:%s://localhost:%d/projects/some-company.com:test-project/instances/static-test-instance/databases/test-database;usePlainText=true;credentials=%s",
144+
prefix, server.getPort(), TEST_KEY_PATH))) {
145+
assertThat(connection.isClosed()).isFalse();
146+
}
146147
}
147148

148149
@Test(expected = SQLException.class)
@@ -216,6 +217,17 @@ public void testLenient() throws SQLException {
216217
}
217218
}
218219

220+
@Test
221+
public void testAcceptsURL() throws SQLException {
222+
JdbcDriver driver = JdbcDriver.getRegisteredDriver();
223+
assertTrue(
224+
driver.acceptsURL(
225+
"jdbc:cloudspanner:/projects/my-project/instances/my-instance/databases/my-database"));
226+
assertTrue(
227+
driver.acceptsURL(
228+
"jdbc:spanner:/projects/my-project/instances/my-instance/databases/my-database"));
229+
}
230+
219231
@Test
220232
public void testJdbcExternalHostFormat() {
221233
Matcher matcher =

0 commit comments

Comments
 (0)