Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
import com.google.cloud.spanner.jdbc.CloudSpannerJdbcConnection;
import com.google.cloud.spanner.jdbc.JdbcDataSource;
import com.google.cloud.spanner.testing.EmulatorSpannerHelper;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
Expand Down Expand Up @@ -229,7 +230,7 @@ public void testConnectWithDataSourceWithConflictingValues() throws SQLException
public void testConnectWithOAuthToken() throws Exception {
GoogleCredentials credentials;
if (hasValidKeyFile()) {
credentials = GoogleCredentials.fromStream(new FileInputStream(getKeyFile()));
credentials = GoogleCredentials.fromStream(Files.newInputStream(Paths.get(getKeyFile())));
} else {
try {
credentials = GoogleCredentials.getApplicationDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.google.cloud.spanner.jdbc.it;

import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.SPANNER_EMULATOR_HOST;
import static com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
Expand All @@ -34,7 +36,6 @@
import com.google.cloud.spanner.jdbc.ProtoMessageType;
import com.google.cloud.spanner.jdbc.it.SingerProto.Genre;
import com.google.cloud.spanner.jdbc.it.SingerProto.SingerInfo;
import com.google.cloud.spanner.testing.EmulatorSpannerHelper;
import com.google.cloud.spanner.testing.RemoteSpannerHelper;
import java.io.InputStream;
import java.sql.Connection;
Expand Down Expand Up @@ -68,8 +69,6 @@ public static boolean isUsingGraalVm() {

@BeforeClass
public static void setup() throws Exception {
assumeFalse(
"Proto columns is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
assumeFalse("Skipping tests on GraalVM", isUsingGraalVm());
RemoteSpannerHelper testHelper = env.getTestHelper();
final String projectId = testHelper.getInstanceId().getProject();
Expand All @@ -87,7 +86,12 @@ public static void setup() throws Exception {
.setDialect(Dialect.GOOGLE_STANDARD_SQL)
.setProtoDescriptors(in)
.build();
final String host = SpannerTestHost.getHost();
final String host;
if (isUsingEmulator()) {
host = System.getenv(SPANNER_EMULATOR_HOST);
} else {
host = SpannerTestHost.getHost();
}

database =
databaseAdminClient
Expand All @@ -109,6 +113,9 @@ public static void setup() throws Exception {

in.close();
url = "jdbc:cloudspanner://" + host + "/" + database.getId();
if (isUsingEmulator()) {
url += "?autoConfigEmulator=true";
}
}

@AfterClass
Expand All @@ -121,8 +128,6 @@ public static void teardown() {

@Test
public void testNonNullElements() throws Exception {
assumeFalse(
"Proto columns is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
assumeFalse("Skipping tests on GraalVM", isUsingGraalVm());
SingerInfo singerInfo =
SingerInfo.newBuilder()
Expand Down Expand Up @@ -166,8 +171,6 @@ public void testNonNullElements() throws Exception {

@Test
public void testNullElements() throws Exception {
assumeFalse(
"Proto columns is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
assumeFalse("Skipping tests on GraalVM", isUsingGraalVm());
try (Connection connection = DriverManager.getConnection(url);
PreparedStatement ps =
Expand Down Expand Up @@ -201,8 +204,6 @@ public void testNullElements() throws Exception {

@Test
public void testUntypedNullElements() throws Exception {
assumeFalse(
"Proto columns is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
assumeFalse("Skipping tests on GraalVM", isUsingGraalVm());
try (Connection connection = DriverManager.getConnection(url);
PreparedStatement ps =
Expand Down Expand Up @@ -231,8 +232,6 @@ public void testUntypedNullElements() throws Exception {

@Test
public void testInterCompatibility() throws Exception {
assumeFalse(
"Proto columns is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator());
assumeFalse("Skipping tests on GraalVM", isUsingGraalVm());
SingerInfo singerInfo =
SingerInfo.newBuilder()
Expand Down