|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
test.pdfbox.util.TestTextStripper
public class TestTextStripper
Test suite for PDFTextStripper. FILE SET VALIDATION This test suite is designed to test PDFTextStripper using a set of PDF files and known good output for each. The default mode of testAll() is to process each *.pdf file in "test/input". An output file is created in "test/output" with the same name as the PDF file, plus an additional ".txt" suffix. The output file is then tested against a known good result file from the input directory (again, with the same name as the tested PDF file, but with the additional ".txt" suffix). So for the file "test/input/hello.pdf", an output file will be generated named "test/output/hello.pdf.txt". Then that file will be compared to the known good file "test/input/hello.pdf.txt", if it exists. Any errors are logged, and at the end of processing all *.pdf files, if there were any errors, the test fails. The logging is at INFO, as the general goal is overall validation, and on failure, the indication of which file or files failed. When processing new PDF files, you may use testAll() to generate output, verify the output manually, then move the output file to the test input directory to use as the basis for future validations. SINGLE FILE VALIDATION To further research individual failures, the test.pdfbox.util.TextStripper.file system property may be set with the name of a single file in the "test/input" directory. In this mode, testAll() will evaluate only that file, and will do so with DEBUG level logging. You can set this property from ant by defining "file", as in: ant testextract -Dfile=hello.pdf
Constructor Summary | |
---|---|
TestTextStripper(String name)
Test class constructor. |
Method Summary | |
---|---|
void |
doTestFile(File file,
boolean bLogResult)
Validate text extraction on a single file. |
static void |
main(String[] args)
Command line execution. |
void |
setUp()
Test suite setup. |
static junit.framework.Test |
suite()
Set the tests in the suite for this test class. |
void |
testExtract()
Test to validate text extraction of file set. |
Methods inherited from class junit.framework.TestCase |
---|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString |
Methods inherited from class junit.framework.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TestTextStripper(String name) throws IOException
name
- The name of the test class.
IOException
- If there is an error creating the test.Method Detail |
---|
public void setUp()
setUp
in class junit.framework.TestCase
public void doTestFile(File file, boolean bLogResult) throws Exception
file
- The file to validatebLogResult
- Whether to log the extracted text
Exception
- when there is an exceptionpublic void testExtract() throws Exception
Exception
- when there is an exceptionpublic static junit.framework.Test suite()
public static void main(String[] args)
args
- Command line arguments.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |