File tree Expand file tree Collapse file tree
java-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,7 +232,11 @@ public void testQueryInterruptGracefullyStopsExplicitJob()
232232 });
233233 t .start ();
234234 // Allow thread to actually initiate the query
235- Thread .sleep (3000 );
235+ // Even when job is created, we might be using `query` API which means if we cancle within first
236+ // 10 seconds,
237+ // it is similar to Optional job cancellation. Need to wait until after we're in "Wait for job
238+ // completion" mode.
239+ Thread .sleep (15000 );
236240 bigQueryStatement .cancel ();
237241 // Wait until background thread is finished
238242 t .join ();
Original file line number Diff line number Diff line change @@ -331,12 +331,10 @@ public void testSetTimeout() throws SQLException {
331331 assertEquals (0 , statement .getQueryTimeout ());
332332 statement .setQueryTimeout (1 );
333333 assertEquals (1 , statement .getQueryTimeout ());
334- try {
335- statement .executeQuery (selectQuery );
336- } catch (SQLException e ) {
337- assertTrue (true );
338- assertEquals ("SQL execution canceled" , e .getMessage ());
339- }
334+ SQLException e = assertThrows (SQLException .class , () -> statement .executeQuery (selectQuery ));
335+ assertEquals (
336+ "BigQueryException during runQuery\n Job execution was cancelled: Job timed out" ,
337+ e .getMessage ());
340338 statement .close ();
341339 connection .close ();
342340 }
You can’t perform that action at this time.
0 commit comments