Skip to content

Commit 6f81a4e

Browse files
committed
Minor change to align with higher max string value length limit
1 parent df541d3 commit 6f81a4e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ void setString(String string) {
3232
/**********************************************************************
3333
*/
3434

35+
private final static int TOO_LONG_STRING_VALUE = 20_100_000;
36+
3537
private final ObjectMapper MAPPER = newJsonMapper();
3638

3739
private ObjectMapper newJsonMapperWithUnlimitedStringSizeSupport() {
@@ -44,31 +46,32 @@ private ObjectMapper newJsonMapperWithUnlimitedStringSizeSupport() {
4446
public void testBigString() throws Exception
4547
{
4648
try {
47-
MAPPER.readValue(generateJson("string", 5001000), StringWrapper.class);
48-
fail("expected JsonMappingException");
49+
MAPPER.readValue(generateJson("string", TOO_LONG_STRING_VALUE), StringWrapper.class);
50+
fail("expected DatabindException");
4951
} catch (DatabindException e) {
50-
assertTrue("unexpected exception message: " + e.getMessage(),
51-
e.getMessage().startsWith("String length (5001000) exceeds the maximum length (5000000)"));
52+
final String message = e.getMessage();
53+
assertTrue("unexpected exception message: " + message, message.startsWith("String length"));
54+
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length ("));
5255
}
5356
}
5457

5558
public void testBiggerString() throws Exception
5659
{
5760
try {
58-
MAPPER.readValue(generateJson("string", 6_000_000), StringWrapper.class);
61+
MAPPER.readValue(generateJson("string", TOO_LONG_STRING_VALUE), StringWrapper.class);
5962
fail("expected JsonMappingException");
6063
} catch (DatabindException e) {
6164
final String message = e.getMessage();
6265
// this test fails when the TextBuffer is being resized, so we don't yet know just how big the string is
6366
// so best not to assert that the String length value in the message is the full 6000000 value
6467
assertTrue("unexpected exception message: " + message, message.startsWith("String length"));
65-
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length (5000000)"));
68+
assertTrue("unexpected exception message: " + message, message.contains("exceeds the maximum length ("));
6669
}
6770
}
6871

6972
public void testUnlimitedString() throws Exception
7073
{
71-
final int len = 5_001_000;
74+
final int len = TOO_LONG_STRING_VALUE;
7275
StringWrapper sw = newJsonMapperWithUnlimitedStringSizeSupport()
7376
.readValue(generateJson("string", len), StringWrapper.class);
7477
assertEquals(len, sw.string.length());

0 commit comments

Comments
 (0)