Skip to content

Commit

Permalink
Fix tests wrt updated (2.15.1) max default string value length
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 14, 2023
1 parent f315214 commit d22c2b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ public void testBigString() throws Exception
MappingIterator<List<String>> it = MAPPER
.readerForListOf(String.class)
.with(CsvParser.Feature.WRAP_AS_ARRAY)
.readValues(generateCsv(5001000));
.readValues(generateCsv(20_001_000));
it.readAll();
fail("expected DatabindException");
} catch (DatabindException e) {
assertTrue("unexpected exception message: " + e.getMessage(),
e.getMessage().startsWith("String length (5001000) exceeds the maximum length (5000000)"));
final String message = e.getMessage();
assertTrue("unexpected exception message: " + message, message.startsWith("String length"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length ("));
}
}

Expand All @@ -44,15 +45,15 @@ public void testBiggerString() throws Exception
MappingIterator<List<String>> it = MAPPER
.readerForListOf(String.class)
.with(CsvParser.Feature.WRAP_AS_ARRAY)
.readValues(generateCsv(7_000_000));
.readValues(generateCsv(21_000_000));
it.readAll();
fail("expected DatabindException");
} catch (DatabindException e) {
final String message = e.getMessage();
// this test fails when the TextBuffer is being resized, so we don't yet know just how big the string is
// so best not to assert that the String length value in the message is the full 2000000 value
// so best not to assert that the String length value in the message is the full 20_000_000 value
assertTrue("unexpected exception message: " + message, message.startsWith("String length"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length (5000000)"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length ("));
}
}

Expand All @@ -77,4 +78,4 @@ private String generateCsv(final int len) {
}
return sb.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,27 @@ private TomlMapper newMapperWithUnlimitedStringSizeSupport() {
public void testBigString() throws Exception
{
try {
MAPPER.readValue(generateToml(5001000), StringWrapper.class);
MAPPER.readValue(generateToml(20_001_000), StringWrapper.class);
fail("expected StreamConstraintsException");
} catch (StreamConstraintsException e) {
assertTrue("unexpected exception message: " + e.getMessage(),
e.getMessage().startsWith("String length (5001000) exceeds the maximum length (5000000)"));
final String message = e.getMessage();
assertTrue("unexpected exception message: " + message, message.startsWith("String length"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length ("));
}
}

@Test
public void testBiggerString() throws Exception
{
try {
MAPPER.readValue(generateToml(6000000), StringWrapper.class);
MAPPER.readValue(generateToml(20_100_000), StringWrapper.class);
fail("expected StreamConstraintsException");
} catch (StreamConstraintsException e) {
final String message = e.getMessage();
// this test fails when the TextBuffer is being resized, so we don't yet know just how big the string is
// so best not to assert that the String length value in the message is the full 6000000 value
assertTrue("unexpected exception message: " + message, message.startsWith("String length"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length (5000000)"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length ("));
}
}

Expand Down

0 comments on commit d22c2b0

Please sign in to comment.