Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import java.sql.Statement;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -1378,13 +1379,12 @@ public void testJoinQueryWithJsonType() throws SQLException {
public void testJsonInputOutputWithUdf() throws SQLException {
String personsTable = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("Persons")));
String udfName = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("GetAgeFromJson")));
String udfName = "dbo.GetAgeFromJson";

try (Connection conn = getConnection()) {
try (Statement stmt = conn.createStatement()) {
TestUtils.dropTableIfExists(personsTable, stmt);
TestUtils.dropFunctionIfExists(udfName, stmt);
TestUtils.dropFunctionWithSchemaIfExists(udfName, stmt);
String createUdfSQL = "CREATE FUNCTION " + udfName + " (@json JSON) " +
"RETURNS INT " +
"AS BEGIN " +
Expand Down Expand Up @@ -1439,7 +1439,7 @@ public void testJsonInputOutputWithUdf() throws SQLException {
} finally {
try (Connection conn = getConnection();
Statement stmt = conn.createStatement()) {
TestUtils.dropFunctionIfExists(udfName, stmt);
TestUtils.dropFunctionWithSchemaIfExists(udfName, stmt);
TestUtils.dropTableIfExists(personsTable, stmt);
}
}
Expand All @@ -1456,13 +1456,12 @@ public void testJsonInputOutputWithUdf() throws SQLException {
public void testUdfReturningJson() throws SQLException {
String personsTable = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("Persons")));
String udfName = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("GetPersonJson")));
String udfName = "dbo.GetPersonJson";

try (Connection conn = getConnection()) {
try (Statement stmt = conn.createStatement()) {
TestUtils.dropTableIfExists(personsTable, stmt);
TestUtils.dropFunctionIfExists(udfName, stmt);
TestUtils.dropFunctionWithSchemaIfExists(udfName, stmt);

String createUdfSQL = "CREATE FUNCTION " + udfName + " (@id INT, @name NVARCHAR(100)) " +
"RETURNS JSON " +
Expand Down Expand Up @@ -1501,7 +1500,7 @@ public void testUdfReturningJson() throws SQLException {
} finally {
try (Connection conn = getConnection();
Statement stmt = conn.createStatement()) {
TestUtils.dropFunctionIfExists(udfName, stmt);
TestUtils.dropFunctionWithSchemaIfExists(udfName, stmt);
TestUtils.dropTableIfExists(personsTable, stmt);
}
}
Expand All @@ -1512,6 +1511,7 @@ public void testUdfReturningJson() throws SQLException {
* And verify there is no data loss.
*/
@Test
@Disabled("Disabled due to huge JSON data")
public void testInsert1GBJson() throws SQLException, IOException {
String dstTable = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("dstTableJSON")));
Expand Down Expand Up @@ -1598,6 +1598,7 @@ private boolean filesAreEqual(Path path1, Path path2) throws IOException {
* Note: This test took around 4 mins to run
*/
@Test
@Disabled("Disabled due to huge JSON data")
public void testInsertHugeJsonData() throws SQLException, IOException {
String dstTable = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("dstTableJSON")));
Expand Down Expand Up @@ -1653,6 +1654,7 @@ public void testInsertHugeJsonData() throws SQLException, IOException {
* Expected error -> org.opentest4j.AssertionFailedError: Test failed due to: Attempting to grow LOB beyond maximum allowed size of 216895848447 bytes.
*/
@Test
@Disabled("Disabled due to huge JSON data")
public void testInsert2GBData() throws SQLException, FileNotFoundException, IOException {
String dstTable = TestUtils
.escapeSingleQuotes(AbstractSQLGenerator.escapeIdentifier(RandomUtil.getIdentifier("dstTableJSON")));
Expand Down Expand Up @@ -1812,7 +1814,12 @@ private void generateHugeJsonFile(long targetSize) {
if (!firstElement) {
writer.write(",");
}
String jsonChunk = "{\"value\":\"" + "a".repeat(1000) + "\"}";
// Create a string of 1000 'a' characters - Java 8 compatible
StringBuilder sb = new StringBuilder(1000);
for (int j = 0; j < 1000; j++) {
sb.append('a');
}
String jsonChunk = "{\"value\":\"" + sb.toString() + "\"}";
writer.write(jsonChunk);
currentSize += jsonChunk.length();
firstElement = false;
Expand Down
Loading