3232
3333import org .junit .jupiter .api .Test ;
3434import org .junit .jupiter .api .BeforeAll ;
35+ import org .junit .jupiter .api .Disabled ;
3536import org .junit .jupiter .api .DisplayName ;
3637import org .junit .platform .runner .JUnitPlatform ;
3738import org .junit .runner .RunWith ;
@@ -1383,8 +1384,7 @@ public void testJsonInputOutputWithUdf() throws SQLException {
13831384 try (Connection conn = getConnection ()) {
13841385 try (Statement stmt = conn .createStatement ()) {
13851386 TestUtils .dropTableIfExists (personsTable , stmt );
1386- String dropUdfSQL = "IF OBJECT_ID('" + udfName + "', 'FN') IS NOT NULL DROP FUNCTION " + udfName ;
1387- stmt .execute (dropUdfSQL );
1387+ TestUtils .dropFunctionWithSchemaIfExists (udfName , stmt );
13881388 String createUdfSQL = "CREATE FUNCTION " + udfName + " (@json JSON) " +
13891389 "RETURNS INT " +
13901390 "AS BEGIN " +
@@ -1439,7 +1439,7 @@ public void testJsonInputOutputWithUdf() throws SQLException {
14391439 } finally {
14401440 try (Connection conn = getConnection ();
14411441 Statement stmt = conn .createStatement ()) {
1442- TestUtils .dropFunctionIfExists (udfName , stmt );
1442+ TestUtils .dropFunctionWithSchemaIfExists (udfName , stmt );
14431443 TestUtils .dropTableIfExists (personsTable , stmt );
14441444 }
14451445 }
@@ -1461,8 +1461,7 @@ public void testUdfReturningJson() throws SQLException {
14611461 try (Connection conn = getConnection ()) {
14621462 try (Statement stmt = conn .createStatement ()) {
14631463 TestUtils .dropTableIfExists (personsTable , stmt );
1464- String dropUdfSQL = "IF OBJECT_ID('" + udfName + "', 'FN') IS NOT NULL DROP FUNCTION " + udfName ;
1465- stmt .execute (dropUdfSQL );
1464+ TestUtils .dropFunctionWithSchemaIfExists (udfName , stmt );
14661465
14671466 String createUdfSQL = "CREATE FUNCTION " + udfName + " (@id INT, @name NVARCHAR(100)) " +
14681467 "RETURNS JSON " +
@@ -1501,7 +1500,7 @@ public void testUdfReturningJson() throws SQLException {
15011500 } finally {
15021501 try (Connection conn = getConnection ();
15031502 Statement stmt = conn .createStatement ()) {
1504- TestUtils .dropFunctionIfExists (udfName , stmt );
1503+ TestUtils .dropFunctionWithSchemaIfExists (udfName , stmt );
15051504 TestUtils .dropTableIfExists (personsTable , stmt );
15061505 }
15071506 }
@@ -1512,6 +1511,7 @@ public void testUdfReturningJson() throws SQLException {
15121511 * And verify there is no data loss.
15131512 */
15141513 @ Test
1514+ @ Disabled ("Disabled due to huge JSON data" )
15151515 public void testInsert1GBJson () throws SQLException , IOException {
15161516 String dstTable = TestUtils
15171517 .escapeSingleQuotes (AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("dstTable" )));
@@ -1598,6 +1598,7 @@ private boolean filesAreEqual(Path path1, Path path2) throws IOException {
15981598 * Note: This test took around 4 mins to run
15991599 */
16001600 @ Test
1601+ @ Disabled ("Disabled due to huge JSON data" )
16011602 public void testInsertHugeJsonData () throws SQLException , IOException {
16021603 String dstTable = TestUtils
16031604 .escapeSingleQuotes (AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("dstTable" )));
@@ -1653,6 +1654,7 @@ public void testInsertHugeJsonData() throws SQLException, IOException {
16531654 * Expected error -> org.opentest4j.AssertionFailedError: Test failed due to: Attempting to grow LOB beyond maximum allowed size of 216895848447 bytes.
16541655 */
16551656 @ Test
1657+ @ Disabled ("Disabled due to huge JSON data" )
16561658 public void testInsert2GBData () throws SQLException , FileNotFoundException , IOException {
16571659 String dstTable = TestUtils
16581660 .escapeSingleQuotes (AbstractSQLGenerator .escapeIdentifier (RandomUtil .getIdentifier ("dstTable" )));
@@ -1812,7 +1814,12 @@ private void generateHugeJsonFile(long targetSize) {
18121814 if (!firstElement ) {
18131815 writer .write ("," );
18141816 }
1815- String jsonChunk = "{\" value\" :\" " + "a" .repeat (1000 ) + "\" }" ;
1817+ // Create a string of 1000 'a' characters - Java 8 compatible
1818+ StringBuilder sb = new StringBuilder (1000 );
1819+ for (int j = 0 ; j < 1000 ; j ++) {
1820+ sb .append ('a' );
1821+ }
1822+ String jsonChunk = "{\" value\" :\" " + sb .toString () + "\" }" ;
18161823 writer .write (jsonChunk );
18171824 currentSize += jsonChunk .length ();
18181825 firstElement = false ;
0 commit comments