4040import static org .hamcrest .Matchers .equalTo ;
4141import static org .hamcrest .Matchers .instanceOf ;
4242import static org .hamcrest .Matchers .startsWith ;
43- import static org .junit .jupiter .api .Assertions .fail ;
43+ import static org .junit .jupiter .api .Assertions .assertThrows ;
4444
4545public class TikaParseTest extends CamelTestSupport {
4646
@@ -58,13 +58,11 @@ public boolean matches(Exchange exchange) {
5858 assertThat (body , instanceOf (String .class ));
5959
6060 Charset detectedCharset = null ;
61- try {
61+ assertThrows ( IOException . class , () -> {
6262 InputStream bodyIs = new ByteArrayInputStream (body .getBytes ());
6363 UniversalEncodingDetector encodingDetector = new UniversalEncodingDetector ();
6464 detectedCharset = encodingDetector .detect (bodyIs , new Metadata ());
65- } catch (IOException e1 ) {
66- fail ();
67- }
65+ });
6866
6967 assertThat (detectedCharset , equalTo (StandardCharsets .ISO_8859_1 ));
7068 assertThat (body , containsString ("<body/>" ));
@@ -89,13 +87,11 @@ public boolean matches(Exchange exchange) {
8987 assertThat (body , instanceOf (String .class ));
9088
9189 Charset detectedCharset = null ;
92- try {
90+ assertThrows ( IOException . class , () -> {
9391 InputStream bodyIs = new ByteArrayInputStream (((String ) body ).getBytes (StandardCharsets .UTF_16 ));
9492 UniversalEncodingDetector encodingDetector = new UniversalEncodingDetector ();
9593 detectedCharset = encodingDetector .detect (bodyIs , new Metadata ());
96- } catch (IOException e1 ) {
97- fail ();
98- }
94+ });
9995
10096 assertThat (detectedCharset .name (), startsWith (StandardCharsets .UTF_16 .name ()));
10197 assertThat (headerMap .get (Exchange .CONTENT_TYPE ), equalTo ("application/vnd.oasis.opendocument.text" ));
0 commit comments