|
21 | 21 | import static org.junit.jupiter.api.Assertions.assertNotEquals; |
22 | 22 | import static org.junit.jupiter.api.Assertions.assertThrows; |
23 | 23 | import static org.junit.jupiter.api.Assertions.assertTrue; |
24 | | -import static org.junit.jupiter.api.Assertions.fail; |
25 | 24 |
|
26 | 25 | import java.io.ByteArrayOutputStream; |
27 | 26 | import java.io.IOException; |
@@ -88,23 +87,18 @@ private void writePDFTests(String expected, COSString testSubj) throws IOExcepti |
88 | 87 |
|
89 | 88 | /** |
90 | 89 | * Test parseHex() - tests that the proper String is created from a hex string input. |
| 90 | + * |
| 91 | + * @throws IOException |
91 | 92 | */ |
92 | 93 | @Test |
93 | | - void testFromHex() |
| 94 | + void testFromHex() throws IOException |
94 | 95 | { |
95 | 96 | String expected = "Quick and simple test"; |
96 | 97 | String hexForm = createHex(expected); |
97 | | - try |
98 | | - { |
99 | | - COSString test1 = COSString.parseHex(hexForm); |
100 | | - writePDFTests("(" + expected + ")", test1); |
101 | | - COSString test2 = COSString.parseHex(createHex(ESC_CHAR_STRING)); |
102 | | - writePDFTests("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", test2); |
103 | | - } |
104 | | - catch (IOException e) |
105 | | - { |
106 | | - fail("IOException thrown: " + e.getMessage()); |
107 | | - } |
| 98 | + COSString test1 = COSString.parseHex(hexForm); |
| 99 | + writePDFTests("(" + expected + ")", test1); |
| 100 | + COSString test2 = COSString.parseHex(createHex(ESC_CHAR_STRING)); |
| 101 | + writePDFTests("(" + ESC_CHAR_STRING_PDF_FORMAT + ")", test2); |
108 | 102 | assertThrows(IOException.class, () -> COSString.parseHex(hexForm + "xx"), |
109 | 103 | "Should have thrown an IOException here"); |
110 | 104 | } |
@@ -137,30 +131,25 @@ void testGetHex() |
137 | 131 |
|
138 | 132 | /** |
139 | 133 | * Test testGetString() - ensure getString() are returned in the correct format. |
| 134 | + * |
| 135 | + * @throws IOException |
140 | 136 | */ |
141 | 137 | @Test |
142 | | - void testGetString() |
| 138 | + void testGetString() throws IOException |
143 | 139 | { |
144 | | - try |
145 | | - { |
146 | | - String testStr = "Test subject for getString()"; |
147 | | - COSString test1 = new COSString(testStr); |
148 | | - assertEquals(testStr, test1.getString()); |
| 140 | + String testStr = "Test subject for getString()"; |
| 141 | + COSString test1 = new COSString(testStr); |
| 142 | + assertEquals(testStr, test1.getString()); |
149 | 143 |
|
150 | | - COSString hexStr = COSString.parseHex(createHex(testStr)); |
151 | | - assertEquals(testStr, hexStr.getString()); |
| 144 | + COSString hexStr = COSString.parseHex(createHex(testStr)); |
| 145 | + assertEquals(testStr, hexStr.getString()); |
152 | 146 |
|
153 | | - COSString escapedString = new COSString(ESC_CHAR_STRING); |
154 | | - assertEquals(ESC_CHAR_STRING, escapedString.getString()); |
| 147 | + COSString escapedString = new COSString(ESC_CHAR_STRING); |
| 148 | + assertEquals(ESC_CHAR_STRING, escapedString.getString()); |
155 | 149 |
|
156 | | - testStr = "Line1\nLine2\nLine3\n"; |
157 | | - COSString lineFeedString = new COSString(testStr); |
158 | | - assertEquals(testStr, lineFeedString.getString()); |
159 | | - } |
160 | | - catch (IOException e) |
161 | | - { |
162 | | - fail("IOException thrown: " + e.getMessage()); |
163 | | - } |
| 150 | + testStr = "Line1\nLine2\nLine3\n"; |
| 151 | + COSString lineFeedString = new COSString(testStr); |
| 152 | + assertEquals(testStr, lineFeedString.getString()); |
164 | 153 | } |
165 | 154 |
|
166 | 155 | /** |
|
0 commit comments