Skip to content

Commit 218c758

Browse files
authored
test: fix ITJdbcConnectTest for custom server url (#1098)
* test: fix ITJdbcConnectTest for custom server url
1 parent d8d6d47 commit 218c758

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcConnectTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,24 @@ public class ITJdbcConnectTest extends ITAbstractJdbcTest {
6060
@ClassRule public static JdbcIntegrationTestEnv env = new JdbcIntegrationTestEnv();
6161

6262
private Database database;
63+
private SpannerOptions options;
6364

6465
@Before
6566
public void setup() {
6667
database = env.getOrCreateDatabase(Dialect.GOOGLE_STANDARD_SQL, Collections.emptyList());
68+
options = env.getTestHelper().getOptions();
6769
}
6870

6971
private String createBaseUrl() {
7072
StringBuilder url = new StringBuilder("jdbc:cloudspanner:");
7173
if (EmulatorSpannerHelper.isUsingEmulator()) {
7274
url.append("//").append(System.getenv("SPANNER_EMULATOR_HOST"));
7375
}
76+
// Extract "//x.y.googleapis.com" from "https://x.y.googleapis.com" and append it to
77+
// url.
78+
if (options.getHost() != null) {
79+
url.append(options.getHost().substring(options.getHost().indexOf(':') + 1));
80+
}
7481
url.append("/").append(database.getId().getName());
7582
if (EmulatorSpannerHelper.isUsingEmulator()) {
7683
url.append(";usePlainText=true");

0 commit comments

Comments
 (0)