test.pdfbox.util
Class TestTextStripper

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by test.pdfbox.util.TestTextStripper
All Implemented Interfaces:
junit.framework.Test

public class TestTextStripper
extends junit.framework.TestCase

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

Version:
$Revision: 1.14 $
Author:
Robert Dickinson (bob@brutesquadlabs.com), Ben Litchfield (ben@benlitchfield.com)

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

TestTextStripper

public TestTextStripper(String name)
                 throws IOException
Test class constructor.

Parameters:
name - The name of the test class.
Throws:
IOException - If there is an error creating the test.
Method Detail

setUp

public void setUp()
Test suite setup.

Overrides:
setUp in class junit.framework.TestCase

doTestFile

public void doTestFile(File file,
                       boolean bLogResult)
                throws Exception
Validate text extraction on a single file.

Parameters:
file - The file to validate
bLogResult - Whether to log the extracted text
Throws:
Exception - when there is an exception

testExtract

public void testExtract()
                 throws Exception
Test to validate text extraction of file set.

Throws:
Exception - when there is an exception

suite

public static junit.framework.Test suite()
Set the tests in the suite for this test class.

Returns:
the Suite.

main

public static void main(String[] args)
Command line execution.

Parameters:
args - Command line arguments.


Copyright © 2006-2007 EGIZ - E-Government Innovationszentrum. All Rights Reserved.