12.6.  Verifying the Configuration

Verifying with a Script

The installation of PDFUnit can be checked using a special program, started with the script verifyInstallation.bat or verifyInstallation.sh:

::
:: Verify the installation of PDFUnit
::

set CURRENTDIR=%~dp0
set PDFUNIT_HOME=%CURRENTDIR%

::
:: Change the installation directories depending on your situation:
::
set ASPECTJ_HOME=%PDFUNIT_HOME%/lib/aspectj-1.8.7
set BOUNCYCASTLE_HOME=%PDFUNIT_HOME%/lib/bouncycastle-jdk15on-153
set JAVASSIST_HOME=%PDFUNIT_HOME%/lib-ext/javassist-3.20.0-GA
set JUNIT_HOME=%PDFUNIT_HOME%/lib/junit-4.12
set COMMONSCOLLECTIONS_HOME=%PDFUNIT_HOME%/lib/commons-collections4-4.1
set COMMONSLOGGING_HOME=%PDFUNIT_HOME%/lib/commons-logging-1.2
set PDFBOX_HOME=%PDFUNIT_HOME%/lib/pdfbox-2.0.0
set TESS4J_HOME=%PDFUNIT_HOME%/lib/tess4j-3.1.0
set VIP_HOME=%PDFUNIT_HOME%/lib/vip-1.0.0
set ZXING_HOME=%PDFUNIT_HOME%/lib/zxing-core-3.2.1

set CLASSPATH=
set CLASSPATH=%ASPECTJ_HOME%/*;%CLASSPATH%
set CLASSPATH=%BOUNCYCASTLE_HOME%/*;%CLASSPATH%
set CLASSPATH=%COMMONSCOLLECTIONS_HOME%/*;%CLASSPATH%
set CLASSPATH=%COMMONSLOGGING_HOME%/*;%CLASSPATH%
set CLASSPATH=%JAVASSIST_HOME%/*;%CLASSPATH%
set CLASSPATH=%JUNIT_HOME%/*;%CLASSPATH%
set CLASSPATH=%PDFBOX_HOME%/*;%CLASSPATH%
set CLASSPATH=%TESS4J_HOME%/*;%CLASSPATH%
set CLASSPATH=%TESS4J_HOME%/lib/*;%CLASSPATH%
set CLASSPATH=%VIP_HOME%/*;%CLASSPATH%
set CLASSPATH=%ZXING_HOME%/*;%CLASSPATH%

:: The folder of PDFUnit-Java:
set CLASSPATH=%PDFUNIT_HOME%/build_ant/classes;%CLASSPATH%
:: The JAR files of PDFUnit-Java:
set CLASSPATH=%PDFUNIT_HOME%*;%CLASSPATH%


:: Run installation verification:
java org.verifyinstallation.VIPMain  --in   pdfunit_development.vip  
                                     --out  verifyInstallation_result.html
                                     --xslt ./lib/vip-1.0.0/vip-java_simple.xslt 

You have do edit the paths depending on your installation.

The stylesheet option is provided to use individual stylesheets. If you don't use a stylesheet, a simple one is used automatically.

The script produces the following output on the console:

Checking installation ...
... finished. Report created, see 'verifyInstallation_result.html'.

The resulting report file shows errors and information about the classpath, environment variables and other runtime related data:

Verifying as a Unit Test

The verification of the installation can also be done as a unit test. That makes it possible to visualize the system environment of the current tests in the context of ANT, Maven or Jenkins.

Within a simple unit test you can use a special method:

/*
 * The method verifies that all required libraries and files are found on the 
 * classpath. Additionally it logs some system properties and writes 
 * all to System.out.
 */
@Test
public void verifyRequriedFilesAndLibraries() throws Exception {
  AssertThat.installationIsClean("pdfunit_development.vip");
}

The method performs the same internal checks as the script described above. If a configuration error exists, the test is red and the error message points to the created HTML file:

The report file contains the same data as when it was created by a shell script.