|
| 1 | +package tools.jackson.dataformat.cbor.parse; |
| 2 | + |
| 3 | +import java.nio.charset.StandardCharsets; |
| 4 | + |
| 5 | +import org.junit.jupiter.api.Test; |
| 6 | + |
| 7 | +import tools.jackson.core.JsonParser; |
| 8 | +import tools.jackson.core.JsonToken; |
| 9 | +import tools.jackson.core.ObjectReadContext; |
| 10 | +import tools.jackson.dataformat.cbor.CBORFactory; |
| 11 | +import tools.jackson.dataformat.cbor.CBORParser; |
| 12 | +import tools.jackson.dataformat.cbor.CBORTestBase; |
| 13 | + |
| 14 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 15 | + |
| 16 | +public class ParseLongAsciiTextTest extends CBORTestBase |
| 17 | +{ |
| 18 | + private final CBORFactory CBOR_F = cborFactory(); |
| 19 | + |
| 20 | + @Test |
| 21 | + public void testLongNonChunkedAsciiText() throws Exception |
| 22 | + { |
| 23 | + try (JsonParser p = CBOR_F.createParser(ObjectReadContext.empty(), |
| 24 | + this.getClass().getResourceAsStream("/data/macbeth-snippet-non-chunked.cbor"))) { |
| 25 | + assertEquals(JsonToken.VALUE_STRING, p.nextToken()); |
| 26 | + String expected = new String(readResource("/data/macbeth-snippet.txt"), "UTF-8"); |
| 27 | + assertEquals(expected, p.getString()); |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void testLongChunkedAsciiText() throws Exception |
| 33 | + { |
| 34 | + try (JsonParser p = CBOR_F.createParser(ObjectReadContext.empty(), |
| 35 | + this.getClass().getResourceAsStream("/data/macbeth-snippet-chunked.cbor"))) { |
| 36 | + assertEquals(JsonToken.VALUE_STRING, p.nextToken()); |
| 37 | + String expected = new String(readResource("/data/macbeth-snippet.txt"), StandardCharsets.UTF_8); |
| 38 | + assertEquals(expected, p.getString()); |
| 39 | + } |
| 40 | + } |
| 41 | +} |
0 commit comments