diff --git a/java-bigquery-jdbc/Makefile b/java-bigquery-jdbc/Makefile
index 827cbcd94058..d3c1f014eff4 100644
--- a/java-bigquery-jdbc/Makefile
+++ b/java-bigquery-jdbc/Makefile
@@ -70,7 +70,7 @@ package:
cp target/google-cloud-bigquery-jdbc-*-all.jar $(PACKAGE_DESTINATION)/
build-it-standalone:
- mvn -Dmaven.test.skip=true package -f pom-it.xml
+ mvn -Dmaven.test.skip=true package -f pom-it.xml -Dbigquery-jdbc.version=$(JDBC_DRIVER_VERSION)
run-it-standalone:
java -cp $(JDBC_JAR):target-it/* org.junit.platform.console.ConsoleLauncher --select-class com.google.cloud.bigquery.jdbc.it.suites.ITDriverAgnosticTests
diff --git a/java-bigquery-jdbc/pom-it.xml b/java-bigquery-jdbc/pom-it.xml
index 3b6ae457bcee..75c8e3016fae 100644
--- a/java-bigquery-jdbc/pom-it.xml
+++ b/java-bigquery-jdbc/pom-it.xml
@@ -14,6 +14,7 @@
UTF-8
8
8
+ 1.2.0-SNAPSHOT
@@ -21,7 +22,7 @@
com.google.cloud
google-cloud-bigquery-jdbc
- 1.0.0
+ ${bigquery-jdbc.version}
test-jar
compile
@@ -88,6 +89,20 @@
target-it
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ default-compile
+ none
+
+
+ default-testCompile
+ none
+
+
+
org.apache.maven.plugins
maven-shade-plugin
@@ -99,21 +114,26 @@
shade
-
false
-
-
- com.google.cloud:google-cloud-bigquery
- com.google.cloud:google-cloud-bigquerystorage
- io.grpc:*
- com.google.protobuf:*
-
-
+
+
+
+ com.
+ com.google.bqjdbc.shaded.com.
+ com.google.cloud.bigquery.jdbc.it.**
+
+
+ org.
+ com.google.bqjdbc.shaded.org.
+
+ org.junit.**
+
+
+
+ io.
+ com.google.bqjdbc.shaded.io.
+
+
*:*
diff --git a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBaseTest.java b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBaseTest.java
index 8be466e8178c..2529c1bff75a 100644
--- a/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBaseTest.java
+++ b/java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/BigQueryJdbcBaseTest.java
@@ -17,10 +17,12 @@
package com.google.cloud.bigquery.jdbc;
import com.google.cloud.bigquery.BigQuery;
+import com.google.cloud.bigquery.BigQueryOptions;
import com.google.cloud.bigquery.jdbc.utils.TestUtilities;
import com.google.cloud.bigquery.jdbc.utils.URIBuilder;
+import java.lang.reflect.Method;
+import java.sql.Connection;
import java.sql.DriverManager;
-import java.sql.SQLException;
public class BigQueryJdbcBaseTest {
@@ -48,12 +50,18 @@ public class BigQueryJdbcBaseTest {
protected static BigQuery getBigQuery(String connectionUrl) {
try {
- return DriverManager.getConnection(connectionUrl)
- .unwrap(BigQueryConnection.class)
- .getBigQuery();
- } catch (SQLException e) {
- throw new RuntimeException("Failed to initialize BigQuery client", e);
+ Class> bqConnClass = Class.forName("com.google.cloud.bigquery.jdbc.BigQueryConnection");
+ Connection conn = DriverManager.getConnection(connectionUrl);
+ Object unwrapped = conn.unwrap(bqConnClass);
+ if (unwrapped != null) {
+ Method method = bqConnClass.getDeclaredMethod("getBigQuery");
+ method.setAccessible(true);
+ return (BigQuery) method.invoke(unwrapped);
+ }
+ } catch (Throwable e) {
+ // ignore for some set of tests; Proxy/TPC tests will fail if it doesn't work.
}
+ return BigQueryOptions.getDefaultInstance().getService();
}
protected static URIBuilder getBaseUri() {