Skip to content

Commit 76b2613

Browse files
Fix expected exception for FontProgramTest#exceptionMessageTest
Changes are caused by [279206f] "Get rid of the pre-check for the font file path" commit.
1 parent e0f1a33 commit 76b2613

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

io/src/test/java/com/itextpdf/io/font/FontProgramTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,26 @@ This file is part of the iText (R) project.
4444

4545
import com.itextpdf.test.annotations.type.UnitTest;
4646
import org.junit.Assert;
47+
import org.junit.Rule;
4748
import org.junit.Test;
4849
import org.junit.experimental.categories.Category;
50+
import org.junit.rules.ExpectedException;
4951

5052
import java.io.IOException;
5153
import com.itextpdf.io.util.MessageFormatUtil;
5254

5355
@Category(UnitTest.class)
5456
public class FontProgramTest {
57+
private static final String notExistingFont = "some-font.ttf";
58+
59+
@Rule
60+
public ExpectedException junitExpectedException = ExpectedException.none();
5561

5662
@Test
5763
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);
6467
}
6568

6669
@Test

0 commit comments

Comments
 (0)