diff --git a/pom.xml b/pom.xml index bdc93668..91f31802 100644 --- a/pom.xml +++ b/pom.xml @@ -119,15 +119,15 @@ test - com.google.code.gson - gson - 2.9.0 + org.junit.jupiter + junit-jupiter + 5.11.1 test - junit - junit - 4.13.1 + com.google.code.gson + gson + 2.9.0 test diff --git a/src/test/java/com/google/api/services/bigquery/MinifiedBigqueryTest.java b/src/test/java/com/google/api/services/bigquery/MinifiedBigqueryTest.java index 7ce68497..562ba33f 100644 --- a/src/test/java/com/google/api/services/bigquery/MinifiedBigqueryTest.java +++ b/src/test/java/com/google/api/services/bigquery/MinifiedBigqueryTest.java @@ -4,7 +4,7 @@ import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.json.MockJsonFactory; import org.assertj.core.api.Assertions; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class MinifiedBigqueryTest { diff --git a/src/test/java/net/starschema/clouddb/jdbc/BQForwardOnlyResultSetFunctionTest.java b/src/test/java/net/starschema/clouddb/jdbc/BQForwardOnlyResultSetFunctionTest.java index 5ffaa53f..8000e1fa 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/BQForwardOnlyResultSetFunctionTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/BQForwardOnlyResultSetFunctionTest.java @@ -20,6 +20,8 @@ */ package net.starschema.clouddb.jdbc; +import static org.junit.jupiter.api.Assertions.*; + import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpResponse; import com.google.api.services.bigquery.model.Job; @@ -45,11 +47,10 @@ import java.util.Map; import java.util.Properties; import java.util.TimeZone; -import junit.framework.Assert; import org.assertj.core.api.Assertions; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -72,22 +73,22 @@ private Connection connect(final String extraUrl) throws SQLException, IOExcepti return ConnectionFromResources.connect("installedaccount1.properties", extraUrl); } - @Before + @BeforeEach public void setConnection() throws SQLException, IOException { connection = connect("&useLegacySql=true"); } - @Before + @BeforeEach public void setStandardSqlConnection() throws SQLException, IOException { standardSqlConnection = connect("&useLegacySql=false"); } - @After + @AfterEach public void closeConnection() throws SQLException { connection.close(); } - @After + @AfterEach public void closeStandardSqlConnection() throws SQLException { standardSqlConnection.close(); } @@ -105,42 +106,42 @@ public void ChainedCursorFunctionTest() { this.QueryLoad(); this.logger.info("ChainedFunctionTest"); try { - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("you", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("you", resultForTest.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { resultForTest.absolute(10); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); } try { for (int i = 0; i < 9; i++) { - Assert.assertTrue(resultForTest.next()); + assertTrue(resultForTest.next()); } - Assert.assertFalse(resultForTest.next()); + assertFalse(resultForTest.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", resultForTest.getString(1)); + assertEquals("", resultForTest.getString(1)); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); } QueryLoad(); try { resultForTest.next(); - Assert.assertEquals("you", resultForTest.getString(1)); + assertEquals("you", resultForTest.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } this.logger.info("chainedfunctiontest end"); } @@ -156,10 +157,10 @@ public void databaseMetaDataGetTables() { .getColumns(null, "starschema_net__clouddb", "OUTLET_LOOKUP", null); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(); + fail(); } try { - Assert.assertTrue(result.first()); + assertTrue(result.first()); while (!result.isAfterLast()) { String toprint = ""; toprint += result.getString(1) + " , "; @@ -177,7 +178,7 @@ public void databaseMetaDataGetTables() { } } catch (SQLException e) { e.printStackTrace(); - Assert.fail(); + fail(); } } @@ -186,21 +187,21 @@ public void databaseMetaDataGetTables() { public void isClosedValidtest() { this.QueryLoad(); try { - Assert.assertEquals(true, connection.isValid(0)); + assertEquals(true, connection.isValid(0)); } catch (SQLException e) { - Assert.fail("Got an exception" + e.toString()); + fail("Got an exception" + e.toString()); e.printStackTrace(); } try { - Assert.assertEquals(true, connection.isValid(10)); + assertEquals(true, connection.isValid(10)); } catch (SQLException e) { - Assert.fail("Got an exception" + e.toString()); + fail("Got an exception" + e.toString()); e.printStackTrace(); } try { connection.isValid(-10); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); // e.printStackTrace(); } @@ -210,7 +211,7 @@ public void isClosedValidtest() { e.printStackTrace(); } try { - Assert.assertTrue(connection.isClosed()); + assertTrue(connection.isClosed()); } catch (SQLException e1) { e1.printStackTrace(); } @@ -218,7 +219,7 @@ public void isClosedValidtest() { try { connection.isValid(0); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); e.printStackTrace(); } } @@ -242,9 +243,9 @@ public void QueryLoad() { resultForTest = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(resultForTest); + assertNotNull(resultForTest); } @Test @@ -256,7 +257,7 @@ public void ResultSetMetadata() { } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); } - Assert.assertTrue(true); + assertTrue(true); } @Test @@ -265,7 +266,7 @@ public void TestResultIndexOutofBound() { try { this.logger.debug("{}", resultForTest.getBoolean(99)); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); this.logger.error("SQLexception" + e.toString()); } } @@ -276,10 +277,10 @@ public void TestResultSetFirst() { try { // Assert.assertTrue(resultForTest.first()); resultForTest.next(); - Assert.assertTrue(resultForTest.isFirst()); + assertTrue(resultForTest.isFirst()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @@ -287,11 +288,11 @@ public void TestResultSetFirst() { public void TestResultSetgetBoolean() { this.QueryLoad(); try { - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals(Boolean.parseBoolean("42"), resultForTest.getBoolean(2)); + assertTrue(resultForTest.next()); + assertEquals(Boolean.parseBoolean("42"), resultForTest.getBoolean(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @@ -299,11 +300,11 @@ public void TestResultSetgetBoolean() { public void TestResultSetgetFloat() { this.QueryLoad(); try { - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals(42f, resultForTest.getFloat(2)); + assertTrue(resultForTest.next()); + assertEquals(42f, resultForTest.getFloat(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @@ -311,11 +312,11 @@ public void TestResultSetgetFloat() { public void TestResultSetgetInteger() { this.QueryLoad(); try { - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals(42, resultForTest.getInt(2)); + assertTrue(resultForTest.next()); + assertEquals(42, resultForTest.getInt(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @@ -323,10 +324,10 @@ public void TestResultSetgetInteger() { public void TestResultSetgetRow() { this.QueryLoad(); try { - Assert.assertTrue(resultForTest.next()); + assertTrue(resultForTest.next()); resultForTest.getRow(); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); } } @@ -334,11 +335,11 @@ public void TestResultSetgetRow() { public void TestResultSetgetString() { this.QueryLoad(); try { - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("you", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("you", resultForTest.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @@ -353,35 +354,35 @@ public void TestResultSetNext() { this.QueryLoad(); try { // Assert.assertTrue(resultForTest.first()); - Assert.assertTrue(resultForTest.next()); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("yet", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("would", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("world", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("without", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("with", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("will", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("why", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("whose", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("whom", resultForTest.getString(1)); - Assert.assertFalse(resultForTest.next()); + assertTrue(resultForTest.next()); + assertTrue(resultForTest.next()); + assertEquals("yet", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("would", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("world", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("without", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("with", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("will", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("why", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("whose", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("whom", resultForTest.getString(1)); + assertFalse(resultForTest.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", resultForTest.getString(1)); + assertEquals("", resultForTest.getString(1)); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); } } @@ -391,35 +392,35 @@ public void TestResultSetNextWhenFetchSizeExceeded() throws SQLException { resultForTest.setFetchSize(2); try { // Assert.assertTrue(resultForTest.first()); - Assert.assertTrue(resultForTest.next()); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("yet", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("would", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("world", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("without", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("with", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("will", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("why", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("whose", resultForTest.getString(1)); - Assert.assertTrue(resultForTest.next()); - Assert.assertEquals("whom", resultForTest.getString(1)); - Assert.assertFalse(resultForTest.next()); + assertTrue(resultForTest.next()); + assertTrue(resultForTest.next()); + assertEquals("yet", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("would", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("world", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("without", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("with", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("will", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("why", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("whose", resultForTest.getString(1)); + assertTrue(resultForTest.next()); + assertEquals("whom", resultForTest.getString(1)); + assertFalse(resultForTest.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", resultForTest.getString(1)); + assertEquals("", resultForTest.getString(1)); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); } } @@ -442,10 +443,10 @@ public void testResultSetTypesInGetString() throws SQLException { result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(result); - Assert.assertTrue(result.next()); + assertNotNull(result); + assertTrue(result.next()); HashMap hello = new HashMap() { @@ -462,29 +463,29 @@ public void testResultSetTypesInGetString() throws SQLException { } }; - Assert.assertEquals( + assertEquals( hello, new Gson() .fromJson(result.getString(1), new TypeToken>() {}.getType())); - Assert.assertEquals("[\"a\",\"b\",\"c\"]", result.getString(2)); + assertEquals("[\"a\",\"b\",\"c\"]", result.getString(2)); Map[] arrayOfMapsActual = new Gson() .fromJson(result.getString(3), new TypeToken[]>() {}.getType()); - Assert.assertEquals(2, arrayOfMapsActual.length); - Assert.assertEquals(hello, arrayOfMapsActual[0]); - Assert.assertEquals(goodbye, arrayOfMapsActual[1]); + assertEquals(2, arrayOfMapsActual.length); + assertEquals(hello, arrayOfMapsActual[0]); + assertEquals(goodbye, arrayOfMapsActual[1]); Map mixedBagActual = new Gson().fromJson(result.getString(4), new TypeToken>() {}.getType()); - Assert.assertEquals(2, mixedBagActual.size()); - Assert.assertEquals("1", mixedBagActual.get("a")); - Assert.assertEquals( + assertEquals(2, mixedBagActual.size()); + assertEquals("1", mixedBagActual.get("a")); + assertEquals( new Gson().toJson(new String[] {"an", "array"}), new Gson().toJson(mixedBagActual.get("b"))); - Assert.assertEquals("2012-01-01 00:00:03 UTC", result.getString(5)); + assertEquals("2012-01-01 00:00:03 UTC", result.getString(5)); } @Test @@ -499,28 +500,28 @@ public void testResultSetDateTimeType() throws SQLException, ParseException { ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setQueryTimeout(500); ResultSet result = stmt.executeQuery(sql); - Assert.assertTrue(result.next()); + assertTrue(result.next()); Timestamp resultTimestamp = result.getTimestamp(1); Object resultObject = result.getObject(1); String resultString = result.getString(1); // getObject() and getTimestamp() should behave the same for DATETIME. - Assert.assertEquals(resultTimestamp, resultObject); + assertEquals(resultTimestamp, resultObject); // getTimestamp().toString() should be equivalent to getString(), with full microsecond support. - Assert.assertEquals("2012-01-01 01:02:03.04567", resultTimestamp.toString()); - Assert.assertEquals("2012-01-01T01:02:03.045670", resultString); + assertEquals("2012-01-01 01:02:03.04567", resultTimestamp.toString()); + assertEquals("2012-01-01T01:02:03.045670", resultString); // If a different calendar is used, the string representation should be adjusted. Timestamp adjustedTimestamp = result.getTimestamp(1, istCalendar); // Render it from the perspective of UTC. // Since it was created for IST, it should be adjusted by -5:30. String adjustedString = utcDateFormatter.format(adjustedTimestamp); - Assert.assertEquals("2011-12-31 19:32:03.045", adjustedString); + assertEquals("2011-12-31 19:32:03.045", adjustedString); // SimpleDateFormat does not support microseconds, // but they should be correct on the adjusted timestamp. - Assert.assertEquals(45670000, adjustedTimestamp.getNanos()); + assertEquals(45670000, adjustedTimestamp.getNanos()); } @Test @@ -532,23 +533,23 @@ public void testResultSetTimestampType() throws SQLException, ParseException { ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); stmt.setQueryTimeout(500); ResultSet result = stmt.executeQuery(sql); - Assert.assertTrue(result.next()); + assertTrue(result.next()); Timestamp resultTimestamp = result.getTimestamp(1); Object resultObject = result.getObject(1); String resultString = result.getString(1); // getObject() and getTimestamp() should behave the same for TIMESTAMP. - Assert.assertEquals(resultTimestamp, resultObject); + assertEquals(resultTimestamp, resultObject); // getString() should be the string representation in UTC+0. - Assert.assertEquals("2012-01-01 01:02:03.04567 UTC", resultString); + assertEquals("2012-01-01 01:02:03.04567 UTC", resultString); // getTimestamp() should have the right number of milliseconds elapsed since epoch. // 1325379723045 milliseconds after epoch, the time is 2012-01-01 01:02:03.045 in UTC+0. - Assert.assertEquals(1325379723045L, resultTimestamp.getTime()); + assertEquals(1325379723045L, resultTimestamp.getTime()); // The microseconds should also be correct, but nanoseconds are not supported by BigQuery. - Assert.assertEquals(45670000, resultTimestamp.getNanos()); + assertEquals(45670000, resultTimestamp.getNanos()); } @Test @@ -567,18 +568,18 @@ public void testResultSetTypesInGetObject() throws SQLException, ParseException result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(result); - Assert.assertTrue(result.next()); + assertNotNull(result); + assertTrue(result.next()); - Assert.assertEquals(new BigDecimal("2312412432423423334.234234234"), result.getObject(1)); + assertEquals(new BigDecimal("2312412432423423334.234234234"), result.getObject(1)); SimpleDateFormat dateDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date parsedDateDate = new java.sql.Date(dateDateFormat.parse("2011-04-03").getTime()); - Assert.assertEquals(parsedDateDate, result.getObject(2)); + assertEquals(parsedDateDate, result.getObject(2)); - Assert.assertEquals(Double.NaN, result.getObject(3)); + assertEquals(Double.NaN, result.getObject(3)); } @Test @@ -594,25 +595,25 @@ public void testResultSetArraysInGetObject() throws SQLException, ParseException result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLException" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(result); - Assert.assertTrue(result.next()); + assertNotNull(result); + assertTrue(result.next()); // for arrays, getObject() and getString() should behave identically, allowing consumers // to interpret/convert types as needed String expected = "[\"1\",\"2\",\"3\"]"; Object resultObject = result.getObject(1); String resultString = result.getString(1); - Assert.assertEquals(expected, (String) resultObject); - Assert.assertEquals(expected, resultString); + assertEquals(expected, (String) resultObject); + assertEquals(expected, resultString); // timestamp conversion should occur consumer-side for arrays String expectedTwo = "[\"1.2838986E9\"]"; Object resultObjectTwo = result.getObject(2); String resultStringTwo = result.getString(2); - Assert.assertEquals(expectedTwo, (String) resultObjectTwo); - Assert.assertEquals(expectedTwo, resultStringTwo); + assertEquals(expectedTwo, (String) resultObjectTwo); + assertEquals(expectedTwo, resultStringTwo); } @Test @@ -628,20 +629,20 @@ public void testResultSetTimeType() throws SQLException, ParseException { result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(result); - Assert.assertTrue(result.next()); + assertNotNull(result); + assertTrue(result.next()); java.sql.Time resultTime = result.getTime(1); Object resultObject = result.getObject(1); String resultString = result.getString(1); // getObject() and getTime() should behave the same for TIME. - Assert.assertEquals(resultTime, resultObject); + assertEquals(resultTime, resultObject); // getTime().toString() should be equivalent to getString() without milliseconds. - Assert.assertTrue(resultString.startsWith(resultTime.toString())); + assertTrue(resultString.startsWith(resultTime.toString())); // getTime() should have milliseconds, though. They're just not included in toString(). // Get whole milliseconds (modulo whole seconds) from resultTime. @@ -649,25 +650,25 @@ public void testResultSetTimeType() throws SQLException, ParseException { // Get whole milliseconds from resultString. int decimalPlace = resultString.lastIndexOf('.'); long stringMillis = Long.parseLong(resultString.substring(decimalPlace + 1, decimalPlace + 4)); - Assert.assertEquals(timeMillis, stringMillis); + assertEquals(timeMillis, stringMillis); // Check that explicit casts to TIME work as expected. Time fixedTime = result.getTime(2); - Assert.assertEquals("00:00:02", fixedTime.toString()); + assertEquals("00:00:02", fixedTime.toString()); // The object should have milliseconds even though they're hidden by toString(). // AFAICT [java.sql.Time] does not support microseconds. - Assert.assertEquals(123, fixedTime.getTime() % 1000); + assertEquals(123, fixedTime.getTime() % 1000); // getString() should show microseconds. - Assert.assertEquals("00:00:02.123450", result.getString(2)); + assertEquals("00:00:02.123450", result.getString(2)); } @Test public void TestResultSetTotalBytesProcessedCacheHit() { QueryLoad(); - Assert.assertTrue(resultForTest instanceof BQForwardOnlyResultSet); + assertTrue(resultForTest instanceof BQForwardOnlyResultSet); BQForwardOnlyResultSet results = (BQForwardOnlyResultSet) resultForTest; final Boolean processedNoBytes = new Long(0L).equals(results.getTotalBytesProcessed()); - Assert.assertEquals(processedNoBytes, results.getCacheHit()); + assertEquals(processedNoBytes, results.getCacheHit()); } @Test @@ -684,7 +685,7 @@ public void testResultSetProcedures() throws SQLException, ParseException { result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } finally { String cleanupSql = "DROP PROCEDURE looker_test.procedure_test;\n"; Statement stmt = @@ -717,7 +718,7 @@ protected long getSyncTimeoutMillis() { stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } finally { String cleanupSql = "DROP PROCEDURE looker_test.long_procedure;\n"; Statement stmt = @@ -744,9 +745,9 @@ public void testBQForwardOnlyResultSetDoesntThrowNPE() throws Exception { bq.close(); try { new BQForwardOnlyResultSet(bq.getBigquery(), bq.getProjectId(), ref, null, stmt); - Assert.fail("Initalizing BQForwardOnlyResultSet should throw something other than a NPE."); + fail("Initalizing BQForwardOnlyResultSet should throw something other than a NPE."); } catch (SQLException e) { - Assert.assertEquals(e.getMessage(), "Failed to fetch results. Connection is closed."); + assertEquals(e.getMessage(), "Failed to fetch results. Connection is closed."); } } @@ -755,7 +756,7 @@ public void testHandlesAllNullResponseFields() throws Exception { try { mockResponse("{}"); } catch (BQSQLException e) { - Assert.assertTrue(e.getMessage().contains("without a job reference")); + assertTrue(e.getMessage().contains("without a job reference")); return; } throw new AssertionError("Expected graceful failure due to lack of job reference"); diff --git a/src/test/java/net/starschema/clouddb/jdbc/BQResultSetFunctionTest.java b/src/test/java/net/starschema/clouddb/jdbc/BQResultSetFunctionTest.java index 4af5204e..b818e937 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/BQResultSetFunctionTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/BQResultSetFunctionTest.java @@ -20,14 +20,15 @@ */ package net.starschema.clouddb.jdbc; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import junit.framework.Assert; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,14 +46,14 @@ public class BQResultSetFunctionTest { Logger logger = LoggerFactory.getLogger(BQResultSetFunctionTest.class); - @Before + @BeforeEach public void setConnection() throws SQLException, IOException { connection = ConnectionFromResources.connect("installedaccount1.properties", "&useLegacySql=true"); QueryLoad(); } - @After + @AfterEach public void closeConnection() throws SQLException { connection.close(); } @@ -96,20 +97,20 @@ public void QueryLoad() { result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(result); + assertNotNull(result); this.logger.debug(description); this.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -120,84 +121,84 @@ public void ChainedCursorFunctionTest() { this.logger.info("ChainedFunctionTest"); try { result.beforeFirst(); - Assert.assertTrue(result.next()); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.next()); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.absolute(10)); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.absolute(10)); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertFalse(result.next()); + assertFalse(result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } try { - Assert.assertTrue(result.first()); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.first()); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.isFirst()); - Assert.assertFalse(result.previous()); + assertTrue(result.isFirst()); + assertFalse(result.previous()); result.afterLast(); - Assert.assertTrue(result.isAfterLast()); - Assert.assertTrue(result.absolute(-1)); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.isAfterLast()); + assertTrue(result.absolute(-1)); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.relative(-5)); - Assert.assertEquals("without", result.getString(1)); + assertTrue(result.relative(-5)); + assertEquals("without", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertFalse(result.relative(6)); + assertFalse(result.relative(6)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("without", result.getString(1)); + assertEquals("without", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } this.logger.info("chainedfunctiontest end"); @@ -223,10 +224,10 @@ public void databaseMetaDataGetTables() { // ALIAS , ) } catch (SQLException e) { e.printStackTrace(); - Assert.fail(); + fail(); } try { - Assert.assertTrue(result.first()); + assertTrue(result.first()); while (!result.isAfterLast()) { String toprint = ""; toprint += result.getString(1) + " , "; @@ -244,7 +245,7 @@ public void databaseMetaDataGetTables() { } } catch (SQLException e) { e.printStackTrace(); - Assert.fail(); + fail(); } } @@ -271,21 +272,21 @@ private boolean comparer(String[][] expected, String[][] reality) { @Test public void isClosedValidtest() { try { - Assert.assertEquals(true, connection.isValid(0)); + assertEquals(true, connection.isValid(0)); } catch (SQLException e) { - Assert.fail("Got an exception" + e.toString()); + fail("Got an exception" + e.toString()); e.printStackTrace(); } try { - Assert.assertEquals(true, connection.isValid(10)); + assertEquals(true, connection.isValid(10)); } catch (SQLException e) { - Assert.fail("Got an exception" + e.toString()); + fail("Got an exception" + e.toString()); e.printStackTrace(); } try { connection.isValid(-10); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); // e.printStackTrace(); } @@ -295,7 +296,7 @@ public void isClosedValidtest() { e.printStackTrace(); } try { - Assert.assertTrue(connection.isClosed()); + assertTrue(connection.isClosed()); } catch (SQLException e1) { e1.printStackTrace(); } @@ -303,7 +304,7 @@ public void isClosedValidtest() { try { connection.isValid(0); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); e.printStackTrace(); } } @@ -316,7 +317,7 @@ public void ResultSetMetadata() { } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); } - Assert.assertTrue(true); + assertTrue(true); } @Test @@ -324,7 +325,7 @@ public void TestResultIndexOutofBound() { try { this.logger.debug("{}", result.getBoolean(99)); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); this.logger.error("SQLexception" + e.toString()); } } @@ -332,54 +333,54 @@ public void TestResultIndexOutofBound() { @Test public void TestResultSetAbsolute() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals("you", result.getString(1)); - Assert.assertTrue(result.absolute(2)); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.absolute(3)); - Assert.assertEquals("would", result.getString(1)); - Assert.assertTrue(result.absolute(4)); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.absolute(5)); - Assert.assertEquals("without", result.getString(1)); - Assert.assertTrue(result.absolute(6)); - Assert.assertEquals("with", result.getString(1)); - Assert.assertTrue(result.absolute(7)); - Assert.assertEquals("will", result.getString(1)); - Assert.assertTrue(result.absolute(8)); - Assert.assertEquals("why", result.getString(1)); - Assert.assertTrue(result.absolute(9)); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.absolute(10)); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.absolute(1)); + assertEquals("you", result.getString(1)); + assertTrue(result.absolute(2)); + assertEquals("yet", result.getString(1)); + assertTrue(result.absolute(3)); + assertEquals("would", result.getString(1)); + assertTrue(result.absolute(4)); + assertEquals("world", result.getString(1)); + assertTrue(result.absolute(5)); + assertEquals("without", result.getString(1)); + assertTrue(result.absolute(6)); + assertEquals("with", result.getString(1)); + assertTrue(result.absolute(7)); + assertEquals("will", result.getString(1)); + assertTrue(result.absolute(8)); + assertEquals("why", result.getString(1)); + assertTrue(result.absolute(9)); + assertEquals("whose", result.getString(1)); + assertTrue(result.absolute(10)); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertFalse(result.absolute(0)); - Assert.assertEquals("", result.getString(1)); + assertFalse(result.absolute(0)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } try { - Assert.assertFalse(result.absolute(11)); - Assert.assertEquals("", result.getString(1)); + assertFalse(result.absolute(11)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -388,23 +389,23 @@ public void TestResultSetAbsolute() { public void TestResultSetAfterlast() { try { result.afterLast(); - Assert.assertTrue(result.previous()); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.previous()); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { result.afterLast(); - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -413,23 +414,23 @@ public void TestResultSetAfterlast() { public void TestResultSetBeforeFirst() { try { result.beforeFirst(); - Assert.assertTrue(result.next()); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.next()); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { result.beforeFirst(); - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -437,44 +438,44 @@ public void TestResultSetBeforeFirst() { @Test public void TestResultSetFirst() { try { - Assert.assertTrue(result.first()); - Assert.assertTrue(result.isFirst()); + assertTrue(result.first()); + assertTrue(result.isFirst()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetBoolean() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(Boolean.parseBoolean("42"), result.getBoolean(2)); + assertTrue(result.absolute(1)); + assertEquals(Boolean.parseBoolean("42"), result.getBoolean(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetFloat() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(new Float(42), result.getFloat(2)); + assertTrue(result.absolute(1)); + assertEquals(new Float(42), result.getFloat(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetInteger() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(42, result.getInt(2)); + assertTrue(result.absolute(1)); + assertEquals(42, result.getInt(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @@ -482,86 +483,86 @@ public void TestResultSetgetInteger() { public void TestResultSetgetRow() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(1, result.getRow()); - Assert.assertTrue(result.absolute(10)); - Assert.assertEquals(10, result.getRow()); + assertTrue(result.absolute(1)); + assertEquals(1, result.getRow()); + assertTrue(result.absolute(10)); + assertEquals(10, result.getRow()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { result.beforeFirst(); - Assert.assertEquals(0, result.getRow()); + assertEquals(0, result.getRow()); result.afterLast(); - Assert.assertEquals(0, result.getRow()); + assertEquals(0, result.getRow()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetString() { try { - Assert.assertTrue(result.first()); - Assert.assertEquals("you", result.getString(1)); - Assert.assertTrue(result.last()); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.first()); + assertEquals("you", result.getString(1)); + assertTrue(result.last()); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetLast() { try { - Assert.assertTrue(result.last()); - Assert.assertTrue(result.isLast()); + assertTrue(result.last()); + assertTrue(result.isLast()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetNext() { try { - Assert.assertTrue(result.first()); - Assert.assertTrue(result.next()); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("would", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("without", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("with", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("will", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("why", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("whom", result.getString(1)); - Assert.assertFalse(result.next()); + assertTrue(result.first()); + assertTrue(result.next()); + assertEquals("yet", result.getString(1)); + assertTrue(result.next()); + assertEquals("would", result.getString(1)); + assertTrue(result.next()); + assertEquals("world", result.getString(1)); + assertTrue(result.next()); + assertEquals("without", result.getString(1)); + assertTrue(result.next()); + assertEquals("with", result.getString(1)); + assertTrue(result.next()); + assertEquals("will", result.getString(1)); + assertTrue(result.next()); + assertEquals("why", result.getString(1)); + assertTrue(result.next()); + assertEquals("whose", result.getString(1)); + assertTrue(result.next()); + assertEquals("whom", result.getString(1)); + assertFalse(result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -569,39 +570,39 @@ public void TestResultSetNext() { @Test public void TestResultSetPrevious() { try { - Assert.assertTrue(result.last()); - Assert.assertTrue(result.previous()); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("why", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("will", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("with", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("without", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("would", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("you", result.getString(1)); - Assert.assertFalse(result.previous()); + assertTrue(result.last()); + assertTrue(result.previous()); + assertEquals("whose", result.getString(1)); + assertTrue(result.previous()); + assertEquals("why", result.getString(1)); + assertTrue(result.previous()); + assertEquals("will", result.getString(1)); + assertTrue(result.previous()); + assertEquals("with", result.getString(1)); + assertTrue(result.previous()); + assertEquals("without", result.getString(1)); + assertTrue(result.previous()); + assertEquals("world", result.getString(1)); + assertTrue(result.previous()); + assertEquals("would", result.getString(1)); + assertTrue(result.previous()); + assertEquals("yet", result.getString(1)); + assertTrue(result.previous()); + assertEquals("you", result.getString(1)); + assertFalse(result.previous()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -609,49 +610,49 @@ public void TestResultSetPrevious() { @Test public void TestResultSetRelative() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals("you", result.getString(1)); - Assert.assertTrue(result.relative(1)); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.relative(2)); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.relative(5)); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.relative(-5)); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.relative(-2)); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.relative(-1)); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.absolute(1)); + assertEquals("you", result.getString(1)); + assertTrue(result.relative(1)); + assertEquals("yet", result.getString(1)); + assertTrue(result.relative(2)); + assertEquals("world", result.getString(1)); + assertTrue(result.relative(5)); + assertEquals("whose", result.getString(1)); + assertTrue(result.relative(-5)); + assertEquals("world", result.getString(1)); + assertTrue(result.relative(-2)); + assertEquals("yet", result.getString(1)); + assertTrue(result.relative(-1)); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.first()); - Assert.assertFalse(result.relative(-1)); - Assert.assertEquals("", result.getString(1)); + assertTrue(result.first()); + assertFalse(result.relative(-1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } try { - Assert.assertTrue(result.last()); - Assert.assertFalse(result.relative(1)); - Assert.assertEquals("", result.getString(1)); + assertTrue(result.last()); + assertFalse(result.relative(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } diff --git a/src/test/java/net/starschema/clouddb/jdbc/BQSQLExceptionTest.java b/src/test/java/net/starschema/clouddb/jdbc/BQSQLExceptionTest.java index aea16f68..070348c4 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/BQSQLExceptionTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/BQSQLExceptionTest.java @@ -5,8 +5,8 @@ import com.google.api.client.http.HttpHeaders; import com.google.api.client.http.HttpResponseException; import java.io.IOException; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class BQSQLExceptionTest { @@ -16,7 +16,7 @@ public void exceptionCauseEnrichmentIOExceptionTest() { BQSQLException exception = new BQSQLException("Oops! Something went wrong:", ioException); String actualMessage = exception.getMessage(); - Assert.assertEquals( + Assertions.assertEquals( "Oops! Something went wrong: - java.io.IOException: Read timed out!", actualMessage); } @@ -31,7 +31,7 @@ public void exceptionCauseEnrichmentGoogleJsonResponseExceptionTest() { BQSQLException exception = new BQSQLException("Oops! Something went wrong:", cause); String actualMessage = exception.getMessage(); - Assert.assertEquals("Oops! Something went wrong: - You don't have access", actualMessage); + Assertions.assertEquals("Oops! Something went wrong: - You don't have access", actualMessage); } @Test @@ -40,7 +40,7 @@ public void exceptionCauseEnrichmentOtherRuntimeExceptionTest() { BQSQLException sqlException = new BQSQLException("Oops! Something went wrong:", exception); String actualMessage = sqlException.getMessage(); - Assert.assertEquals( + Assertions.assertEquals( "Oops! Something went wrong: - java.lang.RuntimeException: something went horribly wrong", actualMessage); } diff --git a/src/test/java/net/starschema/clouddb/jdbc/BQScrollableResultSetFunctionTest.java b/src/test/java/net/starschema/clouddb/jdbc/BQScrollableResultSetFunctionTest.java index 81b7762f..e6fb2a4f 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/BQScrollableResultSetFunctionTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/BQScrollableResultSetFunctionTest.java @@ -20,6 +20,8 @@ */ package net.starschema.clouddb.jdbc; +import static org.junit.jupiter.api.Assertions.*; + import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpResponse; import java.io.IOException; @@ -28,12 +30,11 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.Properties; -import junit.framework.Assert; import org.assertj.core.api.Assertions; -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,84 +55,84 @@ public void ChainedCursorFunctionTest() { this.logger.info("ChainedFunctionTest"); try { result.beforeFirst(); - Assert.assertTrue(result.next()); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.next()); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.absolute(10)); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.absolute(10)); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertFalse(result.next()); + assertFalse(result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } try { - Assert.assertTrue(result.first()); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.first()); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.isFirst()); - Assert.assertFalse(result.previous()); + assertTrue(result.isFirst()); + assertFalse(result.previous()); result.afterLast(); - Assert.assertTrue(result.isAfterLast()); - Assert.assertTrue(result.absolute(-1)); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.isAfterLast()); + assertTrue(result.absolute(-1)); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.relative(-5)); - Assert.assertEquals("without", result.getString(1)); + assertTrue(result.relative(-5)); + assertEquals("without", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertFalse(result.relative(6)); + assertFalse(result.relative(6)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("without", result.getString(1)); + assertEquals("without", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } this.logger.info("chainedfunctiontest end"); @@ -157,10 +158,10 @@ public void databaseMetaDataGetTables() { // ALIAS , ) } catch (SQLException e) { e.printStackTrace(); - Assert.fail(); + fail(); } try { - Assert.assertTrue(result.first()); + assertTrue(result.first()); while (!result.isAfterLast()) { String toprint = ""; toprint += result.getString(1) + " , "; @@ -178,7 +179,7 @@ public void databaseMetaDataGetTables() { } } catch (SQLException e) { e.printStackTrace(); - Assert.fail(); + fail(); } } @@ -205,21 +206,21 @@ private boolean comparer(String[][] expected, String[][] reality) { @Test public void isClosedValidtest() { try { - Assert.assertEquals(true, connection.isValid(0)); + assertEquals(true, connection.isValid(0)); } catch (SQLException e) { - Assert.fail("Got an exception" + e.toString()); + fail("Got an exception" + e.toString()); e.printStackTrace(); } try { - Assert.assertEquals(true, connection.isValid(10)); + assertEquals(true, connection.isValid(10)); } catch (SQLException e) { - Assert.fail("Got an exception" + e.toString()); + fail("Got an exception" + e.toString()); e.printStackTrace(); } try { connection.isValid(-10); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); // e.printStackTrace(); } @@ -229,7 +230,7 @@ public void isClosedValidtest() { e.printStackTrace(); } try { - Assert.assertTrue(connection.isClosed()); + assertTrue(connection.isClosed()); } catch (SQLException e1) { e1.printStackTrace(); } @@ -237,7 +238,7 @@ public void isClosedValidtest() { try { connection.isValid(0); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); e.printStackTrace(); } } @@ -246,13 +247,13 @@ private Connection connect(final String extraUrl) throws SQLException, IOExcepti return ConnectionFromResources.connect("installedaccount1.properties", extraUrl); } - @Before + @BeforeEach public void setConnection() throws SQLException, IOException { connection = connect("&useLegacySql=true"); QueryLoad(); } - @After + @AfterEach public void closeConnection() throws SQLException { connection.close(); } @@ -278,20 +279,20 @@ public void QueryLoad() { result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(result); + assertNotNull(result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -303,7 +304,7 @@ public void ResultSetMetadata() { } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); } - Assert.assertTrue(true); + assertTrue(true); } @Test @@ -311,7 +312,7 @@ public void TestResultIndexOutofBound() { try { this.logger.debug("{}", result.getBoolean(99)); } catch (SQLException e) { - Assert.assertTrue(true); + assertTrue(true); this.logger.error("SQLexception" + e.toString()); } } @@ -319,54 +320,54 @@ public void TestResultIndexOutofBound() { @Test public void TestResultSetAbsolute() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals("you", result.getString(1)); - Assert.assertTrue(result.absolute(2)); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.absolute(3)); - Assert.assertEquals("would", result.getString(1)); - Assert.assertTrue(result.absolute(4)); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.absolute(5)); - Assert.assertEquals("without", result.getString(1)); - Assert.assertTrue(result.absolute(6)); - Assert.assertEquals("with", result.getString(1)); - Assert.assertTrue(result.absolute(7)); - Assert.assertEquals("will", result.getString(1)); - Assert.assertTrue(result.absolute(8)); - Assert.assertEquals("why", result.getString(1)); - Assert.assertTrue(result.absolute(9)); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.absolute(10)); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.absolute(1)); + assertEquals("you", result.getString(1)); + assertTrue(result.absolute(2)); + assertEquals("yet", result.getString(1)); + assertTrue(result.absolute(3)); + assertEquals("would", result.getString(1)); + assertTrue(result.absolute(4)); + assertEquals("world", result.getString(1)); + assertTrue(result.absolute(5)); + assertEquals("without", result.getString(1)); + assertTrue(result.absolute(6)); + assertEquals("with", result.getString(1)); + assertTrue(result.absolute(7)); + assertEquals("will", result.getString(1)); + assertTrue(result.absolute(8)); + assertEquals("why", result.getString(1)); + assertTrue(result.absolute(9)); + assertEquals("whose", result.getString(1)); + assertTrue(result.absolute(10)); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertFalse(result.absolute(0)); - Assert.assertEquals("", result.getString(1)); + assertFalse(result.absolute(0)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } try { - Assert.assertFalse(result.absolute(11)); - Assert.assertEquals("", result.getString(1)); + assertFalse(result.absolute(11)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -375,23 +376,23 @@ public void TestResultSetAbsolute() { public void TestResultSetAfterlast() { try { result.afterLast(); - Assert.assertTrue(result.previous()); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.previous()); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { result.afterLast(); - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -400,23 +401,23 @@ public void TestResultSetAfterlast() { public void TestResultSetBeforeFirst() { try { result.beforeFirst(); - Assert.assertTrue(result.next()); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.next()); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { result.beforeFirst(); - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -424,44 +425,44 @@ public void TestResultSetBeforeFirst() { @Test public void TestResultSetFirst() { try { - Assert.assertTrue(result.first()); - Assert.assertTrue(result.isFirst()); + assertTrue(result.first()); + assertTrue(result.isFirst()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetBoolean() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(Boolean.parseBoolean("42"), result.getBoolean(2)); + assertTrue(result.absolute(1)); + assertEquals(Boolean.parseBoolean("42"), result.getBoolean(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetFloat() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(new Float(42), result.getFloat(2)); + assertTrue(result.absolute(1)); + assertEquals(new Float(42), result.getFloat(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetInteger() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(42, result.getInt(2)); + assertTrue(result.absolute(1)); + assertEquals(42, result.getInt(2)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @@ -469,86 +470,86 @@ public void TestResultSetgetInteger() { public void TestResultSetgetRow() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals(1, result.getRow()); - Assert.assertTrue(result.absolute(10)); - Assert.assertEquals(10, result.getRow()); + assertTrue(result.absolute(1)); + assertEquals(1, result.getRow()); + assertTrue(result.absolute(10)); + assertEquals(10, result.getRow()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { result.beforeFirst(); - Assert.assertEquals(0, result.getRow()); + assertEquals(0, result.getRow()); result.afterLast(); - Assert.assertEquals(0, result.getRow()); + assertEquals(0, result.getRow()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetgetString() { try { - Assert.assertTrue(result.first()); - Assert.assertEquals("you", result.getString(1)); - Assert.assertTrue(result.last()); - Assert.assertEquals("whom", result.getString(1)); + assertTrue(result.first()); + assertEquals("you", result.getString(1)); + assertTrue(result.last()); + assertEquals("whom", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetLast() { try { - Assert.assertTrue(result.last()); - Assert.assertTrue(result.isLast()); + assertTrue(result.last()); + assertTrue(result.isLast()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } @Test public void TestResultSetNext() { try { - Assert.assertTrue(result.first()); - Assert.assertTrue(result.next()); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("would", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("without", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("with", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("will", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("why", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.next()); - Assert.assertEquals("whom", result.getString(1)); - Assert.assertFalse(result.next()); + assertTrue(result.first()); + assertTrue(result.next()); + assertEquals("yet", result.getString(1)); + assertTrue(result.next()); + assertEquals("would", result.getString(1)); + assertTrue(result.next()); + assertEquals("world", result.getString(1)); + assertTrue(result.next()); + assertEquals("without", result.getString(1)); + assertTrue(result.next()); + assertEquals("with", result.getString(1)); + assertTrue(result.next()); + assertEquals("will", result.getString(1)); + assertTrue(result.next()); + assertEquals("why", result.getString(1)); + assertTrue(result.next()); + assertEquals("whose", result.getString(1)); + assertTrue(result.next()); + assertEquals("whom", result.getString(1)); + assertFalse(result.next()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -556,39 +557,39 @@ public void TestResultSetNext() { @Test public void TestResultSetPrevious() { try { - Assert.assertTrue(result.last()); - Assert.assertTrue(result.previous()); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("why", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("will", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("with", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("without", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("would", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.previous()); - Assert.assertEquals("you", result.getString(1)); - Assert.assertFalse(result.previous()); + assertTrue(result.last()); + assertTrue(result.previous()); + assertEquals("whose", result.getString(1)); + assertTrue(result.previous()); + assertEquals("why", result.getString(1)); + assertTrue(result.previous()); + assertEquals("will", result.getString(1)); + assertTrue(result.previous()); + assertEquals("with", result.getString(1)); + assertTrue(result.previous()); + assertEquals("without", result.getString(1)); + assertTrue(result.previous()); + assertEquals("world", result.getString(1)); + assertTrue(result.previous()); + assertEquals("would", result.getString(1)); + assertTrue(result.previous()); + assertEquals("yet", result.getString(1)); + assertTrue(result.previous()); + assertEquals("you", result.getString(1)); + assertFalse(result.previous()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertEquals("", result.getString(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @@ -596,59 +597,59 @@ public void TestResultSetPrevious() { @Test public void TestResultSetRelative() { try { - Assert.assertTrue(result.absolute(1)); - Assert.assertEquals("you", result.getString(1)); - Assert.assertTrue(result.relative(1)); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.relative(2)); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.relative(5)); - Assert.assertEquals("whose", result.getString(1)); - Assert.assertTrue(result.relative(-5)); - Assert.assertEquals("world", result.getString(1)); - Assert.assertTrue(result.relative(-2)); - Assert.assertEquals("yet", result.getString(1)); - Assert.assertTrue(result.relative(-1)); - Assert.assertEquals("you", result.getString(1)); + assertTrue(result.absolute(1)); + assertEquals("you", result.getString(1)); + assertTrue(result.relative(1)); + assertEquals("yet", result.getString(1)); + assertTrue(result.relative(2)); + assertEquals("world", result.getString(1)); + assertTrue(result.relative(5)); + assertEquals("whose", result.getString(1)); + assertTrue(result.relative(-5)); + assertEquals("world", result.getString(1)); + assertTrue(result.relative(-2)); + assertEquals("yet", result.getString(1)); + assertTrue(result.relative(-1)); + assertEquals("you", result.getString(1)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } try { - Assert.assertTrue(result.first()); - Assert.assertFalse(result.relative(-1)); - Assert.assertEquals("", result.getString(1)); + assertTrue(result.first()); + assertFalse(result.relative(-1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } try { - Assert.assertTrue(result.last()); - Assert.assertFalse(result.relative(1)); - Assert.assertEquals("", result.getString(1)); + assertTrue(result.last()); + assertFalse(result.relative(1)); + assertEquals("", result.getString(1)); } catch (SQLException e) { boolean ct = e.toString().contains("Cursor is not in a valid Position"); if (ct == true) { - Assert.assertTrue(ct); + assertTrue(ct); } else { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } } } @Test public void TestResultSetTotalBytesProcessedCacheHit() { - Assert.assertTrue(result instanceof BQScrollableResultSet); + assertTrue(result instanceof BQScrollableResultSet); BQScrollableResultSet results = (BQScrollableResultSet) result; final Boolean processedNoBytes = new Long(0L).equals(results.getTotalBytesProcessed()); - Assert.assertEquals(processedNoBytes, results.getCacheHit()); + assertEquals(processedNoBytes, results.getCacheHit()); } @Test @@ -656,7 +657,7 @@ public void testHandlesAllNullResponseFields() throws Exception { try { mockResponse("{}"); } catch (BQSQLException e) { - Assert.assertTrue(e.getMessage().contains("without a job reference")); + assertTrue(e.getMessage().contains("without a job reference")); return; } throw new AssertionError("Expected graceful failure due to lack of job reference"); @@ -724,21 +725,21 @@ protected Statement createStatementForCommonTests(Connection connection) throws @Override @Test - @Ignore( + @Disabled( "Contradiction between BQSCrollableResultSet and BQForwardOnlyResultSet " + "dates and times: b/317107706") public void testGetTimeByLabel() throws SQLException {} @Override @Test - @Ignore( + @Disabled( "Contradiction between BQSCrollableResultSet and BQForwardOnlyResultSet " + "dates and times: b/317107706") public void testGetDateByLabel() throws SQLException {} @Override @Test - @Ignore( + @Disabled( "Contradiction between BQSCrollableResultSet and BQForwardOnlyResultSet " + "dates and times: b/317107706") public void testGetTimestampByLabel() throws SQLException {} diff --git a/src/test/java/net/starschema/clouddb/jdbc/CancelTest.java b/src/test/java/net/starschema/clouddb/jdbc/CancelTest.java index 8388cef3..81fb9dfd 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/CancelTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/CancelTest.java @@ -1,7 +1,6 @@ package net.starschema.clouddb.jdbc; -import static junit.framework.Assert.*; -import static org.junit.Assert.assertThrows; +import static org.junit.jupiter.api.Assertions.*; import com.google.api.services.bigquery.model.Job; import com.google.api.services.bigquery.model.JobReference; @@ -16,9 +15,9 @@ import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import junit.framework.Assert; -import org.junit.After; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** Created by steven on 11/2/15. */ public class CancelTest { @@ -37,7 +36,7 @@ private BQConnection conn() throws SQLException, IOException { return new BQConnection(url, new Properties()); } - @After + @AfterEach public void teardown() throws Throwable { if (this.unexpectedDiedWith.get() != null) { throw this.unexpectedDiedWith.get(); @@ -112,7 +111,7 @@ public void syncQueryCancel() throws SQLException, InterruptedException, IOExcep stmt.cancel(); backgroundThread.join(); SQLException exception = expectedSqlException.get(); - Assert.assertEquals( + Assertions.assertEquals( "Job execution was cancelled: User requested cancellation", ((com.google.api.client.googleapis.json.GoogleJsonResponseException) exception.getCause()) .getDetails() @@ -133,7 +132,7 @@ public void syncQueryCancel2() throws SQLException, InterruptedException, IOExce stmt.cancel(); backgroundThread.join(); SQLException exception = expectedSqlException.get(); - Assert.assertEquals( + Assertions.assertEquals( "Job execution was cancelled: User requested cancellation", ((com.google.api.client.googleapis.json.GoogleJsonResponseException) exception.getCause()) .getDetails() @@ -166,8 +165,8 @@ public void connectionCancelWorks() throws SQLException, InterruptedException, I Thread backgroundThread2 = getAndRunBackgroundQuery(stmt2); stmt1.waitForTestPoint(); stmt2.waitForTestPoint(); - assertTrue("Must see both running queries", bq.getNumberRunningQueries() == 2); - assertTrue("Must not fail to cancel queries", bq.cancelRunningQueries() == 0); + assertTrue(bq.getNumberRunningQueries() == 2, "Must see both running queries"); + assertTrue(bq.cancelRunningQueries() == 0, "Must not fail to cancel queries"); backgroundThread1.join(); backgroundThread2.join(); } @@ -223,7 +222,7 @@ public void handlesLoggingBQJobStatus() throws IOException { .setStatistics(new JobStatistics().setCreationTime(12345567789L)) .setJobReference(new JobReference().setJobId("Job Id")); String result = BQSupportFuncts.logAndGetQueryState(testJob); - Assert.assertEquals(result, "PENDING"); + Assertions.assertEquals(result, "PENDING"); } @Test @@ -237,19 +236,16 @@ public void handlesNullCreationTime() throws IOException { .setJobReference(new JobReference().setJobId("Job Id")); Throwable exception = assertThrows( - IllegalStateException.class, - () -> { - BQSupportFuncts.logAndGetQueryState(testJob); - }); + IllegalStateException.class, () -> BQSupportFuncts.logAndGetQueryState(testJob)); assertEquals("Failed to fetch start or creation time.", exception.getMessage()); } private void assertPollJobException(Exception exception) { - Assert.assertTrue( + Assertions.assertTrue( exception.getMessage().contains("Something went wrong getting results for the job")); - Assert.assertEquals(exception.getClass(), BQSQLException.class); - Assert.assertEquals(exception.getCause().getMessage(), "Failed to fetch query state."); - Assert.assertEquals(exception.getCause().getClass(), IOException.class); + Assertions.assertEquals(exception.getClass(), BQSQLException.class); + Assertions.assertEquals(exception.getCause().getMessage(), "Failed to fetch query state."); + Assertions.assertEquals(exception.getCause().getClass(), IOException.class); } private static class TestableBQStatementWithBadPollJobs extends TestableBQStatement { diff --git a/src/test/java/net/starschema/clouddb/jdbc/CommonTestsForResultSets.java b/src/test/java/net/starschema/clouddb/jdbc/CommonTestsForResultSets.java index a3b80a92..dbeb63c4 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/CommonTestsForResultSets.java +++ b/src/test/java/net/starschema/clouddb/jdbc/CommonTestsForResultSets.java @@ -18,9 +18,9 @@ import java.util.Date; import java.util.stream.Collectors; import org.assertj.core.api.Assertions; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * An abstract class that contains tests common to {@link ResultSet} implementations. Its name @@ -33,13 +33,13 @@ public abstract class CommonTestsForResultSets { private Connection connection; - @Before + @BeforeEach public void connectForCommonTests() throws SQLException, IOException { connection = ConnectionFromResources.connect("installedaccount1.properties", "&useLegacySql=false"); } - @After + @AfterEach public void closeConnectionForCommonTests() throws SQLException { connection.close(); } diff --git a/src/test/java/net/starschema/clouddb/jdbc/JdbcUrlTest.java b/src/test/java/net/starschema/clouddb/jdbc/JdbcUrlTest.java index d9653505..c2b720a6 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/JdbcUrlTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/JdbcUrlTest.java @@ -1,5 +1,7 @@ package net.starschema.clouddb.jdbc; +import static org.junit.jupiter.api.Assertions.*; + import com.google.api.client.testing.http.MockHttpTransport; import com.google.api.client.testing.http.MockLowLevelHttpRequest; import com.google.api.client.testing.http.MockLowLevelHttpResponse; @@ -13,13 +15,12 @@ import java.sql.SQLException; import java.util.Map; import java.util.Properties; -import junit.framework.Assert; import net.starschema.clouddb.jdbc.BQConnection.JobCreationMode; import org.assertj.core.api.Assertions; -import org.junit.Before; import org.junit.Rule; -import org.junit.Test; import org.junit.contrib.java.lang.system.EnvironmentVariables; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** Created by steven on 10/21/15. */ public class JdbcUrlTest { @@ -32,7 +33,7 @@ public class JdbcUrlTest { @Rule public final EnvironmentVariables environmentVariables = new EnvironmentVariables(); - @Before + @BeforeEach public void setup() throws SQLException, IOException { properties = getProperties("/installedaccount.properties"); URL = getUrl("/installedaccount.properties", null) + "&useLegacySql=true"; @@ -43,7 +44,7 @@ public void setup() throws SQLException, IOException { @Test public void urlWithDefaultDatasetShouldWork() throws SQLException { - Assert.assertEquals(properties.getProperty("dataset"), bq.getDataSet()); + assertEquals(properties.getProperty("dataset"), bq.getDataSet()); } @Test @@ -51,8 +52,8 @@ public void projectWithColons() throws SQLException { String urlWithColonContainingProject = URL.replace(bq.getProjectId(), "example.com:project"); try { BQConnection bqWithColons = new BQConnection(urlWithColonContainingProject, new Properties()); - Assert.assertEquals("example.com:project", bqWithColons.getProjectId()); - Assert.assertEquals("example.com:project", bqWithColons.getCatalog()); + assertEquals("example.com:project", bqWithColons.getProjectId()); + assertEquals("example.com:project", bqWithColons.getCatalog()); } catch (SQLException e) { throw new AssertionError(e); } @@ -65,8 +66,8 @@ public void mungedProjectName() throws SQLException { try { BQConnection bqWithUnderscores = new BQConnection(urlWithUnderscoreContainingProject, new Properties()); - Assert.assertEquals("example.com:project", bqWithUnderscores.getProjectId()); - Assert.assertEquals("example.com:project", bqWithUnderscores.getCatalog()); + assertEquals("example.com:project", bqWithUnderscores.getProjectId()); + assertEquals("example.com:project", bqWithUnderscores.getCatalog()); } catch (SQLException e) { throw new AssertionError(e); } @@ -78,7 +79,7 @@ public void urlWithTimeouts() throws SQLException { String url1 = URL + "&readTimeout=foo"; new BQConnection(url1, new Properties()); } catch (SQLException e) { - Assert.assertEquals( + assertEquals( "could not parse readTimeout parameter. - java.lang.NumberFormatException: For input" + " string: \"foo\"", e.getMessage()); @@ -88,7 +89,7 @@ public void urlWithTimeouts() throws SQLException { String url1 = URL + "&connectTimeout=foo"; new BQConnection(url1, new Properties()); } catch (SQLException e) { - Assert.assertEquals( + assertEquals( "could not parse connectTimeout parameter. - java.lang.NumberFormatException: For input" + " string: \"foo\"", e.getMessage()); @@ -98,14 +99,14 @@ public void urlWithTimeouts() throws SQLException { String url1 = URL + "&readTimeout=-1000"; new BQConnection(url1, new Properties()); } catch (SQLException e) { - Assert.assertEquals("readTimeout must be positive.", e.getMessage()); + assertEquals("readTimeout must be positive.", e.getMessage()); } try { String url1 = URL + "&connectTimeout=-1000"; new BQConnection(url1, new Properties()); } catch (SQLException e) { - Assert.assertEquals("connectTimeout must be positive.", e.getMessage()); + assertEquals("connectTimeout must be positive.", e.getMessage()); } } @@ -289,7 +290,7 @@ public void impersonatingServiceAccountWithLimitedPermissionsWorksAsExpected() stmt.executeQuery("SELECT * FROM bigquery-public-data.baseball.schedules limit 1"); try { stmt.executeQuery("SELECT * FROM orders limit 1"); - Assert.fail("The impersonated service account should not have access to the orders table"); + fail("The impersonated service account should not have access to the orders table"); } catch (SQLException e) { Assertions.assertThat(e.getCause().getMessage()) .contains("User does not have permission to query table"); @@ -332,7 +333,7 @@ public void delegationsThrowWithBadDelegationChain() throws IOException, SQLExce BQStatement stmt = new BQStatement(bqConn.getProjectId(), bqConn); try { stmt.executeQuery("SELECT * FROM bigquery-public-data.baseball.schedules limit 1"); - Assert.fail("I should have failed when trying to execute the query."); + fail("I should have failed when trying to execute the query."); } catch (SQLException e) { Assertions.assertThat(e.getCause().getMessage()).contains("Error requesting access token"); } @@ -344,10 +345,9 @@ public void gettingUrlComponentsWorks() throws IOException { Properties protectedProperties = getProperties("/protectedaccount.properties"); Properties components = BQSupportFuncts.getUrlQueryComponents(url, new Properties()); - Assert.assertEquals(protectedProperties.getProperty("user"), components.getProperty("user")); - Assert.assertEquals( - protectedProperties.getProperty("password"), components.getProperty("password")); - Assert.assertEquals(protectedProperties.getProperty("path"), components.getProperty("path")); + assertEquals(protectedProperties.getProperty("user"), components.getProperty("user")); + assertEquals(protectedProperties.getProperty("password"), components.getProperty("password")); + assertEquals(protectedProperties.getProperty("path"), components.getProperty("path")); } @Test @@ -355,11 +355,11 @@ public void connectionUseLegacySqlValueFromProperties() throws IOException, SQLE String url = getUrl("/protectedaccount.properties", null); BQConnection bqConn = new BQConnection(url, new Properties()); // default true - Assert.assertEquals(bqConn.getUseLegacySql(), false); + assertEquals(bqConn.getUseLegacySql(), false); String newUrl = url + "&useLegacySql=false"; BQConnection bqConn2 = new BQConnection(newUrl, new Properties()); - Assert.assertEquals(bqConn2.getUseLegacySql(), false); + assertEquals(bqConn2.getUseLegacySql(), false); } @Test @@ -367,11 +367,11 @@ public void connectionMaxBillingBytesFromProperties() throws IOException, SQLExc String url = getUrl("/protectedaccount.properties", null); BQConnection bqConn = new BQConnection(url, new Properties()); // default null - Assert.assertNull(bqConn.getMaxBillingBytes()); + assertNull(bqConn.getMaxBillingBytes()); String newUrl = url + "&maxbillingbytes=1000000000"; BQConnection bqConn2 = new BQConnection(newUrl, new Properties()); - Assert.assertEquals((long) bqConn2.getMaxBillingBytes(), 1000000000); + assertEquals((long) bqConn2.getMaxBillingBytes(), 1000000000); } @Test @@ -391,13 +391,13 @@ public void maxBillingBytesOverrideWorks() throws IOException, SQLException { try { stmt.executeQuery(sqlStmt, false); } catch (SQLException e) { - Assert.assertTrue( - "Expected query to fail because it exceeds maximum billing bytes.", - e.toString().contains("Query exceeded limit for bytes billed: 1.")); + assertTrue( + e.toString().contains("Query exceeded limit for bytes billed: 1."), + "Expected query to fail because it exceeds maximum billing bytes."); didFailAsExpected = true; } - Assert.assertTrue("Query did not fail as expected.", didFailAsExpected); + assertTrue(didFailAsExpected, "Query did not fail as expected."); // unlimited-bytes query should succeed stmt.executeQuery(sqlStmt, true); @@ -429,8 +429,7 @@ public void rootUrlOverrideWorks() throws IOException, SQLException { stmt.executeQuery(sqlStmt); MockLowLevelHttpRequest request = mockTransport.getLowLevelHttpRequest(); - Assert.assertTrue( - request.getUrl().startsWith("https://restricted.googleapis.com/bigquery/v2/")); + assertTrue(request.getUrl().startsWith("https://restricted.googleapis.com/bigquery/v2/")); } @Test @@ -438,12 +437,12 @@ public void timeoutMsRejectsBadValues() throws Exception { try { new BQConnection(URL + "&timeoutMs=-1", new Properties()); } catch (BQSQLException e) { - Assert.assertEquals(e.getMessage().contains("timeoutMs must be positive."), true); + assertEquals(e.getMessage().contains("timeoutMs must be positive."), true); } try { new BQConnection(URL + "&timeoutMs=NotANumber", new Properties()); } catch (BQSQLException e) { - Assert.assertEquals(e.getMessage().contains("could not parse timeoutMs parameter."), true); + assertEquals(e.getMessage().contains("could not parse timeoutMs parameter."), true); } } @@ -453,27 +452,26 @@ public void timeoutMsWorks() throws Exception { this.URL += "&timeoutMs=1"; this.bq = new BQConnection(URL, new Properties()); // ensure that the url string was parsed properly - Assert.assertEquals(this.bq.getTimeoutMs(), Integer.valueOf(1)); + assertEquals(this.bq.getTimeoutMs(), Integer.valueOf(1)); // this query takes about 50 second to complete normally String sqlStmt = "SELECT * from publicdata:samples.wikipedia"; BQStatement stmt = new BQStatement(this.properties.getProperty("projectid"), this.bq); try { stmt.executeQuery(sqlStmt); - Assert.fail("Query job should have timed out"); + fail("Query job should have timed out"); } catch (BQSQLException e) { - Assert.assertEquals( - e.getMessage().contains("Query run took more than the specified timeout"), true); + assertEquals(e.getMessage().contains("Query run took more than the specified timeout"), true); } } @Test public void queryCacheIsOnByDefault() throws Exception { // Sanity check to make sure the queryCache param is not set. - Assert.assertFalse(this.URL.toLowerCase().contains("querycache")); + assertFalse(this.URL.toLowerCase().contains("querycache")); // It's possible that this may fail for unforeseeable reasons, // but we expect it to be true the vast majority of the time. - Assert.assertTrue(runSimpleQueryTwiceAndReturnLastCacheHit()); + assertTrue(runSimpleQueryTwiceAndReturnLastCacheHit()); } @Test @@ -482,7 +480,7 @@ public void queryCacheOverrideWorks() throws Exception { this.bq = new BQConnection(URL, new Properties()); // This should never fail. - Assert.assertFalse(runSimpleQueryTwiceAndReturnLastCacheHit()); + assertFalse(runSimpleQueryTwiceAndReturnLastCacheHit()); } private boolean runSimpleQueryTwiceAndReturnLastCacheHit() throws Exception { @@ -512,11 +510,11 @@ public void setLabelsTest() throws Exception { stmt.executeQuery("SELECT * FROM orders LIMIT 1"); sentLabels = stmt.getLabelsFromMostRecentQuery(this.bq); - Assert.assertEquals(4, sentLabels.size()); - Assert.assertEquals("connection-label", sentLabels.get("this")); - Assert.assertEquals("another-connection-label", sentLabels.get("that")); - Assert.assertEquals("query-label", sentLabels.get("the-other")); - Assert.assertEquals("another-query-label", sentLabels.get("and-then")); + assertEquals(4, sentLabels.size()); + assertEquals("connection-label", sentLabels.get("this")); + assertEquals("another-connection-label", sentLabels.get("that")); + assertEquals("query-label", sentLabels.get("the-other")); + assertEquals("another-query-label", sentLabels.get("and-then")); } @Test @@ -529,11 +527,11 @@ public void setLabelsTestForStatementRoot() throws Exception { stmt.executeUpdate("SELECT * FROM orders LIMIT 1"); sentLabels = stmt.getLabelsFromMostRecentQuery(this.bq); - Assert.assertEquals(4, sentLabels.size()); - Assert.assertEquals("connection-label", sentLabels.get("this")); - Assert.assertEquals("another-connection-label", sentLabels.get("that")); - Assert.assertEquals("query-label", sentLabels.get("the-other")); - Assert.assertEquals("another-query-label", sentLabels.get("and-then")); + assertEquals(4, sentLabels.size()); + assertEquals("connection-label", sentLabels.get("this")); + assertEquals("another-connection-label", sentLabels.get("that")); + assertEquals("query-label", sentLabels.get("the-other")); + assertEquals("another-query-label", sentLabels.get("and-then")); } private BQStatement prepareStatementWithLabels() throws Exception { diff --git a/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java b/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java index b8fcb142..ba5d397f 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java +++ b/src/test/java/net/starschema/clouddb/jdbc/PreparedStatementTests.java @@ -30,9 +30,9 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * This Junit test runs query with preparedstatement, while changing the number of results @@ -68,7 +68,7 @@ private boolean comparer(String[][] expected, String[][] reality) { * Makes a new Bigquery Connection to Hardcoded URL and gives back the Connection to static con * member. */ - @Before + @BeforeEach public void Connect() throws Exception { try { Class.forName("net.starschema.clouddb.jdbc.BQDriver"); @@ -98,7 +98,7 @@ public void outOfRangeTest() { stm.setBigDecimal(2, BigDecimal.valueOf((double) limit)); stm.setString(3, first); } catch (SQLException e) { - Assert.assertTrue(true); + Assertions.assertTrue(true); } try { con.close(); @@ -115,9 +115,9 @@ public void ParameterlessTest() { try { PreparedStatement stm = PreparedStatementTests.con.prepareStatement(sql); java.sql.ResultSet theResult = stm.executeQuery(); - Assert.assertNotNull(theResult); + Assertions.assertNotNull(theResult); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -175,23 +175,23 @@ public void ResultSetMetadataFunctionTestTypes() { String expectedStringValue = queries[i][1]; java.sql.ResultSet theResult = stm.executeQuery(); - Assert.assertNotNull(theResult); - Assert.assertEquals( - "Expected type was not returned in metadata", + Assertions.assertNotNull(theResult); + Assertions.assertEquals( expectedType[i], - theResult.getMetaData().getColumnType(1)); + theResult.getMetaData().getColumnType(1), + "Expected type was not returned in metadata"); while (theResult.next()) { // should only be one row for each of these, but lets validate that we can read the object // and string - Assert.assertNotNull(theResult.getObject(1)); + Assertions.assertNotNull(theResult.getObject(1)); if (expectedStringValue != null) { - Assert.assertEquals(expectedStringValue, theResult.getString(1)); + Assertions.assertEquals(expectedStringValue, theResult.getString(1)); } else { theResult.getString(1); } } } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } } @@ -222,7 +222,7 @@ public void setBigDecimalTest() { stm.setBigDecimal(2, BigDecimal.valueOf((double) limit)); theResult = stm.executeQuery(); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { ResultSetMetaData metadata = theResult.getMetaData(); @@ -238,7 +238,7 @@ public void setBigDecimalTest() { Line = ""; for (int i = 0; i < ColumnCount; i++) { if (i == 0) { - Assert.assertEquals(second, theResult.getString(i + 1)); + Assertions.assertEquals(second, theResult.getString(i + 1)); } Line += String.format("%-32s", theResult.getString(i + 1)); } @@ -246,7 +246,7 @@ public void setBigDecimalTest() { } } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -254,7 +254,7 @@ public void setBigDecimalTest() { e.printStackTrace(); } con = null; - Assert.assertTrue(limit >= actual); + Assertions.assertTrue(limit >= actual); } @Test @@ -270,7 +270,7 @@ public void SetByteTest() { stm.setByte(1, COUNT); theResult = stm.executeQuery(); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { // Count Column Values @@ -278,7 +278,7 @@ public void SetByteTest() { Actual++; } } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -288,7 +288,7 @@ public void SetByteTest() { con = null; Byte Act = Byte.parseByte(Integer.toString(Actual)); - Assert.assertEquals(COUNT, Act); + Assertions.assertEquals(COUNT, Act); } @Test @@ -307,16 +307,16 @@ public void SetCharacterStreamTest() { PreparedStatement stm = PreparedStatementTests.con.prepareStatement(sql); stm.setCharacterStream(1, reader); Result = stm.executeQuery(); - Assert.assertNotNull(Result); + Assertions.assertNotNull(Result); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + Assertions.assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -341,7 +341,7 @@ public void setDateTest() { try { date = formatter.parse(first); } catch (ParseException e2) { - Assert.fail(); + Assertions.fail(); e2.printStackTrace(); } java.sql.ResultSet theResult = null; @@ -354,7 +354,7 @@ public void setDateTest() { stm.setBoolean(3, istrue); theResult = stm.executeQuery(); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { ResultSetMetaData metadata = theResult.getMetaData(); @@ -379,7 +379,7 @@ public void setDateTest() { } } } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -387,7 +387,7 @@ public void setDateTest() { e.printStackTrace(); } con = null; - Assert.assertTrue(true); + Assertions.assertTrue(true); } @Test @@ -403,9 +403,9 @@ public void SetDoubleTest() { stm.setInt(1, 2); stm.setDouble(2, number); Result = stm.executeQuery(); - Assert.assertNotNull(Result); + Assertions.assertNotNull(Result); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { Result.first(); @@ -417,11 +417,11 @@ public void SetDoubleTest() { } } try { - Assert.assertTrue( - "The result was not as expected: " + Result.getString(1), - Result.getString(1).equals("tamingoftheshrew")); + Assertions.assertTrue( + Result.getString(1).equals("tamingoftheshrew"), + "The result was not as expected: " + Result.getString(1)); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -444,9 +444,9 @@ public void SetFloatTest() { stm.setInt(1, 2); stm.setFloat(2, number); Result = stm.executeQuery(); - Assert.assertNotNull(Result); + Assertions.assertNotNull(Result); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { Result.first(); @@ -457,11 +457,11 @@ public void SetFloatTest() { } } try { - Assert.assertTrue( - "The result was not as expected: " + Result.getString(1), - Result.getString(1).equals("tamingoftheshrew")); + Assertions.assertTrue( + Result.getString(1).equals("tamingoftheshrew"), + "The result was not as expected: " + Result.getString(1)); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -488,7 +488,7 @@ public void setIntTest() { stm.setInt(1, COUNT); theResult = stm.executeQuery(); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { ResultSetMetaData metadata = theResult.getMetaData(); @@ -508,7 +508,7 @@ public void setIntTest() { Actual++; } } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -516,7 +516,7 @@ public void setIntTest() { e.printStackTrace(); } con = null; - Assert.assertEquals(COUNT, Actual); + Assertions.assertEquals(COUNT, Actual); } @Test @@ -531,10 +531,10 @@ public void SetLongTest() { PreparedStatement stm = PreparedStatementTests.con.prepareStatement(sql); stm.setLong(1, number); Result = stm.executeQuery(); - Assert.assertNotNull(Result); + Assertions.assertNotNull(Result); } catch (SQLException e) { // BIGQUERY Can only store long as a string - Assert.assertTrue(e.toString().contains("Argument type mismatch in function GREATER")); + Assertions.assertTrue(e.toString().contains("Argument type mismatch in function GREATER")); } try { con.close(); @@ -574,7 +574,7 @@ public void setStringTest() { stm.setInt(2, limit); theResult = stm.executeQuery(); } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { ResultSetMetaData metadata = theResult.getMetaData(); @@ -590,14 +590,14 @@ public void setStringTest() { Line = ""; for (int i = 0; i < ColumnCount; i++) { if (i == 0) { - Assert.assertEquals(second, theResult.getString(i + 1)); + Assertions.assertEquals(second, theResult.getString(i + 1)); } Line += String.format("%-32s", theResult.getString(i + 1)); } actual++; } } catch (SQLException e) { - Assert.fail(e.toString()); + Assertions.fail(e.toString()); } try { con.close(); @@ -605,7 +605,7 @@ public void setStringTest() { e.printStackTrace(); } con = null; - Assert.assertTrue(limit >= actual); + Assertions.assertTrue(limit >= actual); } @Test diff --git a/src/test/java/net/starschema/clouddb/jdbc/QueryResultTest.java b/src/test/java/net/starschema/clouddb/jdbc/QueryResultTest.java index 8e23ffd0..ae5c6edd 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/QueryResultTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/QueryResultTest.java @@ -20,16 +20,17 @@ */ package net.starschema.clouddb.jdbc; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Arrays; -import junit.framework.Assert; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,22 +72,22 @@ private Connection connect(final String extraUrl) throws SQLException, IOExcepti return ConnectionFromResources.connect("installedaccount1.properties", extraUrl); } - @Before + @BeforeEach public void setConnection() throws SQLException, IOException { connection = connect("&useLegacySql=true"); } - @Before + @BeforeEach public void setStandardSqlConnection() throws SQLException, IOException { standardSqlConnection = connect("&useLegacySql=false"); } - @After + @AfterEach public void closeConnection() throws SQLException { connection.close(); } - @After + @AfterEach public void closeStandardSqlConnection() throws SQLException { standardSqlConnection.close(); } @@ -94,10 +95,10 @@ public void closeStandardSqlConnection() throws SQLException { @Test public void QueryResultTestWithDataset() throws SQLException { standardSqlConnection.setSchema("foobar"); - Assert.assertEquals("foobar", standardSqlConnection.getSchema()); + assertEquals("foobar", standardSqlConnection.getSchema()); standardSqlConnection.setSchema("tokyo_star"); - Assert.assertEquals("tokyo_star", standardSqlConnection.getSchema()); + assertEquals("tokyo_star", standardSqlConnection.getSchema()); final String sql = "SELECT meaning FROM meaning_of_life GROUP BY ROLLUP(meaning);"; String[][] expectation = new String[][] {{null, "42"}}; @@ -112,20 +113,20 @@ public void QueryResultTestWithDataset() throws SQLException { Result = s.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); HelperFunctions.printer(expectation); try { String[][] res = BQSupportMethods.GetQueryResult(Result); - Assert.assertTrue( - "Comparing failed in the String[][] array " + Arrays.deepToString(res), - this.comparer(expectation, res)); + assertTrue( + this.comparer(expectation, res), + "Comparing failed in the String[][] array " + Arrays.deepToString(res)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -147,23 +148,22 @@ public void QueryResultTest01() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } - Assert.assertTrue( - Result instanceof BQForwardOnlyResultSet || Result instanceof BQScrollableResultSet); + assertTrue(Result instanceof BQForwardOnlyResultSet || Result instanceof BQScrollableResultSet); long totalBytesProcessed; boolean cacheHit; @@ -177,7 +177,7 @@ public void QueryResultTest01() { cacheHit = bqScrollableResultSet.getCacheHit(); } - Assert.assertEquals(cacheHit, totalBytesProcessed == 0); + assertEquals(cacheHit, totalBytesProcessed == 0); } @Test @@ -197,19 +197,19 @@ public void QueryResultTest02() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -235,8 +235,7 @@ public void QueryResultTest03() { result = stmt.executeQuery(sql); } catch (SQLException e) { this.logger.debug("SQLexception" + e.toString()); - Assert.assertTrue( - e.toString().contains("Access Denied: Table guid754187384106:m_lab.2010_01")); + assertTrue(e.toString().contains("Access Denied: Table guid754187384106:m_lab.2010_01")); } } @@ -259,19 +258,19 @@ public void QueryResultTest04() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -291,16 +290,16 @@ public void QueryResultTest05() { this.logger.debug("{}", Result.getMetaData().getColumnCount()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); try { - if (Result.getType() != ResultSet.TYPE_FORWARD_ONLY) Assert.assertFalse(Result.first()); + if (Result.getType() != ResultSet.TYPE_FORWARD_ONLY) assertFalse(Result.first()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -326,19 +325,19 @@ public void QueryResultTest06() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -364,21 +363,21 @@ public void QueryResultTest07() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -405,21 +404,21 @@ public void QueryResultTest08() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -443,21 +442,21 @@ public void QueryResultTest09() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -484,7 +483,7 @@ public void QueryResultTest10() { stmt.executeQuery(sql); } catch (SQLException e) { this.logger.info("SQLexception" + e.toString()); - Assert.assertTrue(true); + assertTrue(true); } } @@ -498,7 +497,7 @@ public void QueryResultTest11() { connection.getMetaData().getSchemas(); } catch (SQLException e) { this.logger.warn("SQLexception" + e.toString()); - Assert.fail("schema problem"); + fail("schema problem"); } } @@ -518,9 +517,9 @@ public void QueryResultTest12() { Result = stm.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); try { /* int j = 0; @@ -531,10 +530,10 @@ public void QueryResultTest12() { Assert.assertTrue(Result.next()); }*/ Result.absolute(limitNum); - Assert.assertTrue(true); + assertTrue(true); } catch (SQLException e) { e.printStackTrace(); - Assert.fail(); + fail(); } } @@ -566,19 +565,19 @@ public void QueryResultTestSyncQuery() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -595,19 +594,19 @@ public void QueryResultTestTokyo01() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -626,20 +625,20 @@ public void QueryResultTestTokyoForceFetchMoreRowsPath() { Result = s.executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); HelperFunctions.printer(expectation); try { String[][] res = BQSupportMethods.GetQueryResult(Result); - Assert.assertTrue( - "Comparing failed in the String[][] array " + Arrays.deepToString(res), - this.comparer(expectation, res)); + assertTrue( + this.comparer(expectation, res), + "Comparing failed in the String[][] array " + Arrays.deepToString(res)); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } } diff --git a/src/test/java/net/starschema/clouddb/jdbc/StatelessQuery.java b/src/test/java/net/starschema/clouddb/jdbc/StatelessQuery.java index f36dfb30..9304f21f 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/StatelessQuery.java +++ b/src/test/java/net/starschema/clouddb/jdbc/StatelessQuery.java @@ -2,7 +2,7 @@ import com.google.common.collect.ImmutableSet; import java.util.Set; -import org.junit.Assume; +import org.junit.jupiter.api.Assumptions; /** Helpers for tests that require projects with stateless queries enabled */ public final class StatelessQuery { @@ -19,7 +19,7 @@ private StatelessQuery() {} * @param project the project to check - get it from {@link BQConnection#getCatalog() } */ public static void assumeStatelessQueriesEnabled(String project) { - Assume.assumeTrue(ENABLED_PROJECTS.contains(project)); + Assumptions.assumeTrue(ENABLED_PROJECTS.contains(project)); } /** diff --git a/src/test/java/net/starschema/clouddb/jdbc/TimeoutTest.java b/src/test/java/net/starschema/clouddb/jdbc/TimeoutTest.java index 8b5c476d..dca68e72 100644 --- a/src/test/java/net/starschema/clouddb/jdbc/TimeoutTest.java +++ b/src/test/java/net/starschema/clouddb/jdbc/TimeoutTest.java @@ -20,13 +20,14 @@ */ package net.starschema.clouddb.jdbc; +import static org.junit.jupiter.api.Assertions.*; + import java.io.IOException; import java.sql.ResultSet; import java.sql.SQLException; -import junit.framework.Assert; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,13 +55,13 @@ private boolean comparer(String[][] expected, String[][] reality) { return true; } - @Before + @BeforeEach public void setConnection() throws SQLException, IOException { connection = ConnectionFromResources.connect("installedaccount1.properties", "&useLegacySql=true"); } - @After + @AfterEach public void closeConnection() throws SQLException { connection.close(); } @@ -68,7 +69,7 @@ public void closeConnection() throws SQLException { @Test public void isvalidtest() { try { - Assert.assertTrue(connection.isValid(0)); + assertTrue(connection.isValid(0)); } catch (SQLException e) { } @@ -92,21 +93,21 @@ public void QueryResultTest01() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -127,21 +128,21 @@ public void QueryResultTest02() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -165,8 +166,7 @@ public void QueryResultTest03() { } catch (SQLException e) { this.logger.debug("SQLexception" + e.toString()); // fail("SQLException" + e.toString()); - Assert.assertTrue( - e.toString().contains("Access Denied: Table guid754187384106:m_lab.2010_01")); + assertTrue(e.toString().contains("Access Denied: Table guid754187384106:m_lab.2010_01")); } } @@ -189,21 +189,21 @@ public void QueryResultTest04() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -223,16 +223,16 @@ public void QueryResultTest05() { this.logger.debug("{}", Result.getMetaData().getColumnCount()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); try { - if (Result.getType() != ResultSet.TYPE_FORWARD_ONLY) Assert.assertFalse(Result.first()); + if (Result.getType() != ResultSet.TYPE_FORWARD_ONLY) assertFalse(Result.first()); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -258,21 +258,21 @@ public void QueryResultTest06() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -298,21 +298,21 @@ public void QueryResultTest07() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -339,21 +339,21 @@ public void QueryResultTest08() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } @@ -377,20 +377,20 @@ public void QueryResultTest09() { Result = connection.createStatement().executeQuery(sql); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail("SQLException" + e.toString()); + fail("SQLException" + e.toString()); } - Assert.assertNotNull(Result); + assertNotNull(Result); this.logger.debug(description); HelperFunctions.printer(expectation); try { - Assert.assertTrue( - "Comparing failed in the String[][] array", - this.comparer(expectation, BQSupportMethods.GetQueryResult(Result))); + assertTrue( + this.comparer(expectation, BQSupportMethods.GetQueryResult(Result)), + "Comparing failed in the String[][] array"); } catch (SQLException e) { this.logger.error("SQLexception" + e.toString()); - Assert.fail(e.toString()); + fail(e.toString()); } } }