File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
io/src/test/java/com/itextpdf/io/font Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -44,23 +44,26 @@ This file is part of the iText (R) project.
44
44
45
45
import com .itextpdf .test .annotations .type .UnitTest ;
46
46
import org .junit .Assert ;
47
+ import org .junit .Rule ;
47
48
import org .junit .Test ;
48
49
import org .junit .experimental .categories .Category ;
50
+ import org .junit .rules .ExpectedException ;
49
51
50
52
import java .io .IOException ;
51
53
import com .itextpdf .io .util .MessageFormatUtil ;
52
54
53
55
@ Category (UnitTest .class )
54
56
public class FontProgramTest {
57
+ private static final String notExistingFont = "some-font.ttf" ;
58
+
59
+ @ Rule
60
+ public ExpectedException junitExpectedException = ExpectedException .none ();
55
61
56
62
@ Test
57
63
public void exceptionMessageTest () throws IOException {
58
- String font = "some-font.ttf" ;
59
- try {
60
- FontProgramFactory .createFont (font );
61
- } catch (com .itextpdf .io .IOException ex ) {
62
- Assert .assertEquals (MessageFormatUtil .format (com .itextpdf .io .IOException .FontFile1NotFound , font ), ex .getMessage ());
63
- }
64
+ junitExpectedException .expect (java .io .IOException .class );
65
+ junitExpectedException .expectMessage (MessageFormatUtil .format ("{0} not found as file or resource" , notExistingFont ));
66
+ FontProgramFactory .createFont (notExistingFont );
64
67
}
65
68
66
69
@ Test
You can’t perform that action at this time.
0 commit comments