JpdfUnit is a framework for testing a generated pdf document with the JUnit test framework so JPdfUnit is a high level api. The
framework is designed for an easy access to the PDFBox library. This functionality provides the user a lot of
possibilities in pdf document handling. For instance you can test the meta data of the pdf document like the author or the
creation date or search for content via Strings, fragments of words or even regular expressions. Different simple ready-to-use
assertions allow the user to compare the expected data to the concrete data of the pdf document. JPdfUnit is developed to test
one pdf document. You have got three different kinds of using the framework i.e. you can inherit our DocumentTestCase
shown in the example or you can work with our DocumentTester class to avoid inheritance from our framework.
Here is a small example :
public class OioTest extends DocumentTestCase {
public OioTest(String name) {
super(name);
}
protected DocumentDataSource getDataSource() {
DocumentDataSource datasource = new PdfDataSource("etc/testing-pdfs/DocumentInformationTest.pdf");
return datasource;
}
public void testAssertAuthorsNameEquals() {
assertAuthorsNameEquals("Benjamin Bratkus");
}
}