3838import org .junit .jupiter .api .Test ;
3939
4040import com .google .cloud .ServiceOptions ;
41- import com .google .cloud .bigquery .exception .BigQueryJdbcRuntimeException ;
42- import com .google .cloud .bigquery .jdbc .BigQueryConnection ;
4341import com .google .gson .JsonObject ;
4442import com .google .gson .JsonParser ;
4543
@@ -69,15 +67,16 @@ private void validateConnection(String connection_uri) throws SQLException {
6967 Connection connection = DriverManager .getConnection (connection_uri );
7068 assertNotNull (connection );
7169 assertFalse (connection .isClosed ());
72- assertEquals (
73- "GOOGLE_SERVICE_ACCOUNT" ,
74- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
7570 String query =
7671 "SELECT DISTINCT repository_name FROM `bigquery-public-data.samples.github_timeline` LIMIT"
7772 + " 850" ;
7873 Statement statement = connection .createStatement ();
7974 ResultSet jsonResultSet = statement .executeQuery (query );
80- assertTrue (jsonResultSet .getClass ().getName ().contains ("BigQueryJsonResultSet" ));
75+ int totalRows = 0 ;
76+ while (jsonResultSet .next ()){
77+ totalRows += 1 ;
78+ }
79+ assertEquals (totalRows , 850 );
8180 connection .close ();
8281 }
8382
@@ -93,6 +92,7 @@ public void testValidServiceAccountAuthentication() throws SQLException, IOExcep
9392 + "ProjectId="
9493 + authJson .get ("project_id" ).getAsString ()
9594 + ";OAuthType=0;"
95+ + ";OAuthServiceAcctEmail=;"
9696 + "OAuthPvtKeyPath="
9797 + tempFile .toPath ()
9898 + ";" ;
@@ -111,8 +111,8 @@ public void testServiceAccountAuthenticationMissingOAuthPvtKeyPath() throws SQLE
111111 try {
112112 DriverManager .getConnection (connection_uri );
113113 Assertions .fail ();
114- } catch (BigQueryJdbcRuntimeException ex ) {
115- assertTrue (ex .getMessage (). contains ( "No valid credentials provided." ) );
114+ } catch (Exception ex ) {
115+ assertTrue (ex .getMessage () != null );
116116 }
117117 }
118118
@@ -197,9 +197,6 @@ public void testValidGoogleUserAccountAuthentication() throws SQLException {
197197 Connection connection = DriverManager .getConnection (connection_uri );
198198 assertNotNull (connection );
199199 assertFalse (connection .isClosed ());
200- assertEquals (
201- "GOOGLE_USER_ACCOUNT" ,
202- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
203200
204201 Statement statement = connection .createStatement ();
205202 ResultSet resultSet =
@@ -224,9 +221,6 @@ public void testValidExternalAccountAuthentication() throws SQLException {
224221 Connection connection = DriverManager .getConnection (connection_uri );
225222 assertNotNull (connection );
226223 assertFalse (connection .isClosed ());
227- assertEquals (
228- "EXTERNAL_ACCOUNT_AUTH" ,
229- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
230224
231225 Statement statement = connection .createStatement ();
232226 ResultSet resultSet =
@@ -249,9 +243,6 @@ public void testValidExternalAccountAuthenticationFromFile() throws SQLException
249243 Connection connection = DriverManager .getConnection (connection_uri );
250244 assertNotNull (connection );
251245 assertFalse (connection .isClosed ());
252- assertEquals (
253- "EXTERNAL_ACCOUNT_AUTH" ,
254- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
255246
256247 Statement statement = connection .createStatement ();
257248 ResultSet resultSet =
@@ -284,9 +275,6 @@ public void testValidExternalAccountAuthenticationRawJson() throws SQLException
284275 Connection connection = DriverManager .getConnection (connection_uri );
285276 assertNotNull (connection );
286277 assertFalse (connection .isClosed ());
287- assertEquals (
288- "EXTERNAL_ACCOUNT_AUTH" ,
289- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
290278
291279 Statement statement = connection .createStatement ();
292280 ResultSet resultSet =
@@ -309,9 +297,6 @@ public void testValidPreGeneratedAccessTokenAuthentication() throws SQLException
309297 Connection connection = DriverManager .getConnection (connection_uri );
310298 assertNotNull (connection );
311299 assertFalse (connection .isClosed ());
312- assertEquals (
313- "PRE_GENERATED_TOKEN" ,
314- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
315300
316301 Statement statement = connection .createStatement ();
317302 ResultSet resultSet =
@@ -335,9 +320,6 @@ public void testValidRefreshTokenAuthentication() throws SQLException {
335320 Connection connection = DriverManager .getConnection (connection_uri );
336321 assertNotNull (connection );
337322 assertFalse (connection .isClosed ());
338- assertEquals (
339- "PRE_GENERATED_TOKEN" ,
340- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
341323
342324 Statement statement = connection .createStatement ();
343325 ResultSet resultSet =
@@ -355,9 +337,6 @@ public void testValidApplicationDefaultCredentialsAuthentication() throws SQLExc
355337 Connection connection = DriverManager .getConnection (connection_uri );
356338 assertNotNull (connection );
357339 assertFalse (connection .isClosed ());
358- assertEquals (
359- "APPLICATION_DEFAULT_CREDENTIALS" ,
360- ((BigQueryConnection ) connection ).getAuthProperties ().get ("OAuthType" ));
361340 connection .close ();
362341 }
363342
0 commit comments