Skip to content
Open
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
2 changes: 1 addition & 1 deletion java-bigquery-jdbc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
logachev marked this conversation as resolved.

run-it-standalone:
java -cp $(JDBC_JAR):target-it/* org.junit.platform.console.ConsoleLauncher --select-class com.google.cloud.bigquery.jdbc.it.suites.ITDriverAgnosticTests
Expand Down
50 changes: 35 additions & 15 deletions java-bigquery-jdbc/pom-it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<bigquery-jdbc.version>1.2.0-SNAPSHOT</bigquery-jdbc.version><!-- {x-version-update:google-cloud-bigquery-jdbc:current} -->
</properties>

<dependencies>
<!-- Include the test classes from the main project -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigquery-jdbc</artifactId>
<version>1.0.0</version><!-- {x-version-update:google-cloud-bigquery-jdbc:current} -->
<version>${bigquery-jdbc.version}</version>
<type>test-jar</type>
<scope>compile</scope>
</dependency>
Expand Down Expand Up @@ -88,6 +89,20 @@
<build>
<directory>target-it</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -99,21 +114,26 @@
<goal>shade</goal>
</goals>
<configuration>
<!--
We exclude the main bigquery-jdbc framework classes.
This jar should ONLY contain tests and their dependencies (Junit, Mockito, Truth),
plus the test classes themselves. When running, the ACTUAL JDBC driver jar
will be placed on the classpath.
-->
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<excludes>
<exclude>com.google.cloud:google-cloud-bigquery</exclude>
<exclude>com.google.cloud:google-cloud-bigquerystorage</exclude>
<exclude>io.grpc:*</exclude>
<exclude>com.google.protobuf:*</exclude>
</excludes>
</artifactSet>
<!-- Shading everything except junit & integration tests to avoid version conflicts -->
<relocations>
<relocation>
<pattern>com.</pattern>
<shadedPattern>com.google.bqjdbc.shaded.com.</shadedPattern>
<excludes>com.google.cloud.bigquery.jdbc.it.**</excludes>
</relocation>
<relocation>
<pattern>org.</pattern>
<shadedPattern>com.google.bqjdbc.shaded.org.</shadedPattern>
<excludes>
<exclude>org.junit.**</exclude>
</excludes>
</relocation>
<relocation>
<pattern>io.</pattern>
<shadedPattern>com.google.bqjdbc.shaded.io.</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
<artifact>*:*</artifact>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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() {
Expand Down
Loading