11package com .lowagie .text .pdf .parser ;
22
3- import static org .hamcrest .MatcherAssert .assertThat ;
4- import static org .hamcrest .Matchers .containsString ;
5- import static org .hamcrest .Matchers .emptyString ;
6- import static org .hamcrest .Matchers .equalToCompressingWhiteSpace ;
7- import static org .hamcrest .Matchers .is ;
8- import static org .hamcrest .Matchers .not ;
3+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4+ import static org .junit .jupiter .api .Assertions .assertFalse ;
95import static org .junit .jupiter .api .Assertions .assertNotNull ;
106import static org .junit .jupiter .api .Assertions .assertTrue ;
117
2622import java .io .InputStream ;
2723import java .net .URL ;
2824import java .nio .file .Files ;
29- import org .junit .jupiter .api .Assertions ;
3025import org .junit .jupiter .api .Test ;
3126
3227
@@ -68,12 +63,12 @@ protected static byte[] readDocument(final File file) throws IOException {
6863
6964 @ Test
7065 void testPageExceeded () throws Exception {
71- assertThat ( getString ("HelloWorldMeta.pdf" , 5 ), is ( emptyString () ));
66+ assertEquals ( "" , getString ("HelloWorldMeta.pdf" , 5 ));
7267 }
7368
7469 @ Test
7570 void testInvalidPageNumber () throws Exception {
76- assertThat ( getString ("HelloWorldMeta.pdf" , 0 ), is ( emptyString () ));
71+ assertEquals ( "" , getString ("HelloWorldMeta.pdf" , 0 ));
7772 }
7873
7974 @ Test
@@ -88,7 +83,7 @@ void testZapfDingbatsFont() throws Exception {
8883 document .add (new Chunk ("Greek" , new Font (Font .ZAPFDINGBATS )));
8984 document .close ();
9085 PdfTextExtractor pdfTextExtractor = new PdfTextExtractor (new PdfReader (byteArrayOutputStream .toByteArray ()));
91- Assertions . assertEquals ("✧❒❅❅❋" , pdfTextExtractor .getTextFromPage (1 ));
86+ assertEquals ("✧❒❅❅❋" , pdfTextExtractor .getTextFromPage (1 ));
9287 Document .compress = true ;
9388 }
9489
@@ -105,7 +100,7 @@ void testSymbolFont() throws Exception {
105100 document .add (selector .process ("ετε" ));
106101 document .close ();
107102 PdfTextExtractor pdfTextExtractor = new PdfTextExtractor (new PdfReader (byteArrayOutputStream .toByteArray ()));
108- Assertions . assertEquals ("ετε" , pdfTextExtractor .getTextFromPage (1 ));
103+ assertEquals ("ετε" , pdfTextExtractor .getTextFromPage (1 ));
109104 Document .compress = true ;
110105 }
111106
@@ -129,7 +124,7 @@ void whenTrunkedWordsInChunks_expectsFullWordAsExtraction() throws IOException {
129124 // when
130125 final String extracted = new PdfTextExtractor (new PdfReader (pdfBytes )).getTextFromPage (1 );
131126 // then
132- assertThat ( extracted , is ( "trunked" ) );
127+ assertEquals ( "trunked" , extracted );
133128 }
134129
135130 @ Test
@@ -142,7 +137,7 @@ void getTextFromPageWithPhrases_expectsNoAddedSpace() throws IOException {
142137 // when
143138 final String extracted = new PdfTextExtractor (new PdfReader (pdfBytes )).getTextFromPage (1 );
144139 // then
145- assertThat ( extracted , is ( "Phrase begin. Phrase End." ) );
140+ assertEquals ( "Phrase begin. Phrase End." , extracted );
146141 }
147142
148143 @ Test
@@ -159,8 +154,9 @@ void getTextFromPageWithParagraphs_expectsTextHasNoMultipleSpaces() throws IOExc
159154 // when
160155 final String extracted = new PdfTextExtractor (new PdfReader (pdfBytes )).getTextFromPage (1 );
161156 // then
162- assertThat (extracted , equalToCompressingWhiteSpace (expected ));
163- assertThat (extracted , not (containsString (" " )));
157+ assertFalse (extracted .contains (" " ));
158+ // ignore all white spaces
159+ assertEquals (expected .replaceAll ("\\ s+" , "" ), extracted .replaceAll ("\\ s+" , "" ));
164160 }
165161
166162 @ Test
@@ -175,7 +171,7 @@ void getTextFromPageInTablesWithSingleWords_expectsWordsAreSeparatedBySpaces()
175171 // when
176172 final String extracted = new PdfTextExtractor (new PdfReader (pdfBytes )).getTextFromPage (1 );
177173 // then
178- assertThat ( extracted , is ( "One Two Three" ) );
174+ assertEquals ( "One Two Three" , extracted );
179175 }
180176
181177 private String getString (String fileName , int pageNumber ) throws Exception {
0 commit comments