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