|
5 | 5 |
|
6 | 6 | import com.fasterxml.jackson.core.JsonGenerator;
|
7 | 7 | import com.fasterxml.jackson.core.JsonToken;
|
| 8 | +import com.fasterxml.jackson.core.StreamReadConstraints; |
8 | 9 | import com.fasterxml.jackson.dataformat.smile.SmileFactory;
|
9 | 10 | import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
|
10 | 11 | import com.fasterxml.jackson.dataformat.smile.SmileParser;
|
@@ -109,6 +110,36 @@ public void testLongAsciiStrings() throws IOException
|
109 | 110 | _testStrings(f, input, data, 1, 1);
|
110 | 111 | }
|
111 | 112 |
|
| 113 | + public void testLongAsciiStringsLowStringLimit() throws IOException |
| 114 | + { |
| 115 | + final String[] input = new String[] { |
| 116 | + // ~100 chars for long(er) content |
| 117 | + String.format("%s %s %s %s %s %s %s %s %s %s %s %s", |
| 118 | + str0to9,str0to9,"...",str0to9,"/", str0to9, |
| 119 | + str0to9,"",str0to9,str0to9,"...",str0to9), |
| 120 | + LONG_ASCII |
| 121 | + }; |
| 122 | + SmileFactory f = SmileFactory.builder() |
| 123 | + .streamReadConstraints(StreamReadConstraints.builder().maxStringLength(10).build()) |
| 124 | + .enable(SmileParser.Feature.REQUIRE_HEADER) |
| 125 | + .enable(SmileGenerator.Feature.CHECK_SHARED_NAMES) |
| 126 | + .enable(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES) |
| 127 | + .build(); |
| 128 | + byte[] data = _stringDoc(f, input); |
| 129 | + |
| 130 | + AsyncReaderWrapper r = asyncForBytes(f, 1, data, 0); |
| 131 | + // start with "no token" |
| 132 | + assertNull(r.currentToken()); |
| 133 | + assertToken(JsonToken.START_ARRAY, r.nextToken()); |
| 134 | + assertToken(JsonToken.VALUE_STRING, r.nextToken()); |
| 135 | + try { |
| 136 | + r.currentText(); |
| 137 | + fail("expected IllegalStateException"); |
| 138 | + } catch (IllegalStateException ise) { |
| 139 | + assertEquals("String length (98) exceeds the maximum length (10)", ise.getMessage()); |
| 140 | + } |
| 141 | + } |
| 142 | + |
112 | 143 | public void testLongUnicodeStrings() throws IOException
|
113 | 144 | {
|
114 | 145 | // ~100 chars for long(er) content
|
|
0 commit comments