Skip to content

Commit

Permalink
Update stream constraints test wrt jackson-core changes to allow long…
Browse files Browse the repository at this point in the history
…er String values
  • Loading branch information
cowtowncoder committed Mar 22, 2023
1 parent acb3143 commit be7c8e1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,31 @@ private ObjectMapper newJsonMapperWithUnlimitedStringSizeSupport() {
public void testBigString() throws Exception
{
try {
MAPPER.readValue(generateJson("string", 1001000), StringWrapper.class);
MAPPER.readValue(generateJson("string", 5001000), StringWrapper.class);
fail("expected JsonMappingException");
} catch (DatabindException e) {
assertTrue("unexpected exception message: " + e.getMessage(),
e.getMessage().startsWith("String length (1001000) exceeds the maximum length (1000000)"));
e.getMessage().startsWith("String length (5001000) exceeds the maximum length (5000000)"));
}
}

public void testBiggerString() throws Exception
{
try {
MAPPER.readValue(generateJson("string", 2_000_000), StringWrapper.class);
MAPPER.readValue(generateJson("string", 6_000_000), StringWrapper.class);
fail("expected JsonMappingException");
} 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 6000000 value
assertTrue("unexpected exception message: " + message, message.startsWith("String length"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length (1000000)"));
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length (5000000)"));
}
}

public void testUnlimitedString() throws Exception
{
final int len = 1_001_000;
final int len = 5_001_000;
StringWrapper sw = newJsonMapperWithUnlimitedStringSizeSupport()
.readValue(generateJson("string", len), StringWrapper.class);
assertEquals(len, sw.string.length());
Expand Down

0 comments on commit be7c8e1

Please sign in to comment.