de.oio.jpdfunit
Class DocumentTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by de.oio.jpdfunit.DocumentTestCase
All Implemented Interfaces:
junit.framework.Test

public abstract class DocumentTestCase
extends junit.framework.TestCase

The DocumentTestCase class is the basic class for your own tests. For implementing own tests extending the DocumentTestCase class you have to provide a getDataSource() method where you return your DocumentDataSource ie. a "PdfDataSource".

Author:
bbratkus

Constructor Summary
DocumentTestCase(String name)
           
 
Method Summary
 void assertAllFontNamesInDocument(String[] expected)
           
 void assertAllFontNamesOnPage(String[] expected, int page)
           
 void assertAllFontTypesInDocument(String[] expected)
           
 void assertAllFontTypesOnPage(String[] expected, int page)
           
 void assertAuthorsNameEquals(String expected)
          The method compares the supposed authors name to the authors name of the pdf document.
 void assertBookmarkExists(String bookmarkName)
           
 void assertBookmarksAre(String[] bookmarks)
           
 void assertContentContainsText(String text, TextSearchType type)
          This assert method checks if the supposed parameters are contained in the document.
 void assertContentContainsTextMultipleTimes(String text, TextSearchType type)
          This assert method checks if the supposed parameters are contained in the document.
 void assertContentContainsTextOnPage(String text, int page, TextSearchType type)
          This assert method checks if the supposed parameters are contained in the document.
 void assertContentDoesNotContainText(String text, TextSearchType type)
          This assert method checks if the supposed parameters are not contained in the document.
 void assertContentDoesNotContainTextMultipleTimes(String text, TextSearchType type)
          This assert method checks if the supposed parameters are not contained in the document.
 void assertContentDoesNotContainTextOnPage(String text, int page, TextSearchType type)
          This assert method checks if the supposed parameters are not contained in the document.
 void assertCreationDateEquals(Calendar expected)
          The method comapares the supposed creation date to the creation date of the document.
 void assertCreatorEquals(String expected)
          The method compares the supposed creator to the creator of the document.
 void assertDecryptWithOwnerPasswd(String expected)
          The method compares the supposed owner password with the owner password if it exists of the document and trys to decrypt the document.
 void assertDecryptWithUserPasswd(String expected)
          The method compares the supposed user password with the user password if it exists of the document and trys to decrypt the document.
 void assertDocumentTitleEquals(String exspected)
          The method comapares the supposed document title of the document informations with the document title of the document.
 void assertEncryptionLenghthEquals(int exspected)
          The method compares the supposed encryption length with the encryption length of the document if it is encrypted else it returns 0.
 void assertFontNameInDocument(String expected)
           
 void assertFontNameOnPage(String expected, int page)
           
 void assertFontTypeInDocument(String expected)
           
 void assertFontTypeOnPage(String expected, int page)
           
 void assertIsDocumentEncrypted(boolean expected)
          The method checks if the current document is encrypted and comapares it to the parameter.
 void assertIsOwnerPasswd(String expected)
          The method compares the supposed owner password with the owner password if it exists of the document.
 void assertIsUserPasswd(String expected)
          The method compares the supposed user password with the user password if it exists of the document.
 void assertKeywordsEquals(String exspected)
          The method compares the supposed keywords to the keywords of the document informations of the document.
 void assertNumberOfBookmarks(int numberOfBookmarks)
           
 void assertPageCount(int exspected)
          The method compares the supposed page number to the page number of the document.
 void assertSubjectEquals(String expected)
          The method compares the supposed subject to the subject of the document.
 void assertVersionEquals(float expected)
          The method compares the supposed version to the version of the document.
protected abstract  DocumentDataSource getDataSource()
          A must have if you want to extend the DocumentTestCase therefore you need a DocumentDataSource.
 DocumentTester getTester()
          The method returns the used DocumentTester of the DocumentTestCase.
protected  void onSetup()
          If you would like to perform some additional steps.
protected  void setUp()
          The setUp method of the JUnit framework.
protected  void setUpTestingDocument(DocumentDataSource source)
          The method instanciates the DocumentTester for the DocumentTestCase.
protected  void tearDown()
          A must have for a testcase.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, 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

DocumentTestCase

public DocumentTestCase(String name)
Parameters:
name - Constructs a test case with the given name.
Method Detail

assertAuthorsNameEquals

public void assertAuthorsNameEquals(String expected)
The method compares the supposed authors name to the authors name of the pdf document.

Parameters:
expected - The expected authors name, the methods checks if the expected value equals the authors name of the file.

assertContentContainsText

public void assertContentContainsText(String text,
                                      TextSearchType type)
This assert method checks if the supposed parameters are contained in the document. The method matches the first time the text was found in the document.

Parameters:
text - The text to search within the document for. Even a regular expression is a valid parameter.
type - The TextSearchtype but remember that this is relative to the single pages of the document.

assertContentContainsTextOnPage

public void assertContentContainsTextOnPage(String text,
                                            int page,
                                            TextSearchType type)
This assert method checks if the supposed parameters are contained in the document. The method trys to match the text on a certain page in the document.

Parameters:
text - The text to search within the document for. Even a regular expression is a valid parameter.
page - The supposed page to search for the text. The page count is 1-based.
type - The TextSearchtype but remember that this is relative to the single pages of the document.

assertContentContainsTextMultipleTimes

public void assertContentContainsTextMultipleTimes(String text,
                                                   TextSearchType type)
This assert method checks if the supposed parameters are contained in the document. The method trys to match all the time the text was found in the document.

Parameters:
text - The text to search within the document for. Even a regular expression is a valid parameter.
type - The TextSearchtype but remember that this is relative to the single pages of the document.

assertContentDoesNotContainText

public void assertContentDoesNotContainText(String text,
                                            TextSearchType type)
This assert method checks if the supposed parameters are not contained in the document. The method matches the first time the text was found in the document.

Parameters:
text - The text to search within the document for. Even a regular expression is a valid parameter.
type - The TextSearchtype but remember that this is relative to the single pages of the document.

assertContentDoesNotContainTextOnPage

public void assertContentDoesNotContainTextOnPage(String text,
                                                  int page,
                                                  TextSearchType type)
This assert method checks if the supposed parameters are not contained in the document. The method trys to match the text on a certain page in the document.

Parameters:
text - The text to search within the document for. Even a regular expression is a valid parameter.
page - The supposed page to search for the text. The page count is 1-based.
type - The TextSearchtype but remember that this is relative to the single pages of the document.

assertContentDoesNotContainTextMultipleTimes

public void assertContentDoesNotContainTextMultipleTimes(String text,
                                                         TextSearchType type)
This assert method checks if the supposed parameters are not contained in the document. The method trys to match all the time the text was found in the document.

Parameters:
text - The text to search within the document for. Even a regular expression is a valid parameter.
type - The TextSearchtype but remember that this is relative to the single pages of the document.

assertCreatorEquals

public void assertCreatorEquals(String expected)
The method compares the supposed creator to the creator of the document.

Parameters:
expected - The supposed creator of the document.

assertCreationDateEquals

public void assertCreationDateEquals(Calendar expected)
The method comapares the supposed creation date to the creation date of the document.

Parameters:
expected - The expected creation date of the document. It will be compared to the creation date of the document.

assertDecryptWithOwnerPasswd

public void assertDecryptWithOwnerPasswd(String expected)
The method compares the supposed owner password with the owner password if it exists of the document and trys to decrypt the document.

Parameters:
expected - The supposed owner password. This method tries to decrypt the file with this password.

assertDecryptWithUserPasswd

public void assertDecryptWithUserPasswd(String expected)
The method compares the supposed user password with the user password if it exists of the document and trys to decrypt the document.

Parameters:
expected - The supposed user password. This method tries to decrypt the file with this password.

assertDocumentTitleEquals

public void assertDocumentTitleEquals(String exspected)
The method comapares the supposed document title of the document informations with the document title of the document.

Parameters:
exspected - The expected document title, the methods checks if the expected value equals the document title of the file.

assertEncryptionLenghthEquals

public void assertEncryptionLenghthEquals(int exspected)
The method compares the supposed encryption length with the encryption length of the document if it is encrypted else it returns 0.

Parameters:
exspected - The expected encryption length, the method checks if the expected value equals the encryption length of the file.

assertKeywordsEquals

public void assertKeywordsEquals(String exspected)
The method compares the supposed keywords to the keywords of the document informations of the document.

Parameters:
exspected - The expected keywords, the method checks if the expected keywords equals the keywords of the file.

assertPageCount

public void assertPageCount(int exspected)
The method compares the supposed page number to the page number of the document.

Parameters:
exspected - The expected page count. The method checks if the expected page count equals the page count of the file. The page count is 1-based.

assertSubjectEquals

public void assertSubjectEquals(String expected)
The method compares the supposed subject to the subject of the document.

Parameters:
expected - The expected subject, the method checks if the expected subject equals the subject of the file.

assertIsDocumentEncrypted

public void assertIsDocumentEncrypted(boolean expected)
The method checks if the current document is encrypted and comapares it to the parameter.

Parameters:
expected - Expected has to be set to "true" if you suppose that the document is encrypted.

assertIsOwnerPasswd

public void assertIsOwnerPasswd(String expected)
The method compares the supposed owner password with the owner password if it exists of the document.

Parameters:
expected - The expected owner password. The method compares the expected owner password to the owner password of the file. This is necessary for changing the document attributes.

assertIsUserPasswd

public void assertIsUserPasswd(String expected)
The method compares the supposed user password with the user password if it exists of the document.

Parameters:
expected - The expected user password. The method compares the expected user password to the user password of the file. This is necessary for reading the file.

assertVersionEquals

public void assertVersionEquals(float expected)
The method compares the supposed version to the version of the document.

Parameters:
expected - The expected version of the file. The method checks if the expected version equals the version of the file.

assertFontNameInDocument

public void assertFontNameInDocument(String expected)
Parameters:
expected - A expected font name like "Verdana-BoldItalic".

assertAllFontNamesInDocument

public void assertAllFontNamesInDocument(String[] expected)
Parameters:
expected - Expected font names like "Verdana-BoldItalic".

assertFontNameOnPage

public void assertFontNameOnPage(String expected,
                                 int page)
Parameters:
expected - A expected font name like "Verdana-BoldItalic".
page - The supposed page number, notice it is 1-based.

assertAllFontNamesOnPage

public void assertAllFontNamesOnPage(String[] expected,
                                     int page)
Parameters:
expected - Expected font names like "Verdana-BoldItalic".
page - The supposed page number, notice it is 1-based.

assertFontTypeInDocument

public void assertFontTypeInDocument(String expected)
Parameters:
expected - A supposed font type, i.e. "TrueType" or "Type1".

assertAllFontTypesInDocument

public void assertAllFontTypesInDocument(String[] expected)
Parameters:
expected - All supposed font types in the document. Be carefull and list all of them. A supposed font type is i.e. "TrueType" or "Type1".

assertFontTypeOnPage

public void assertFontTypeOnPage(String expected,
                                 int page)
Parameters:
expected - A supposed font type, i.e "TrueType" or "Type1".
page - The supposed page to search for the font type.

assertAllFontTypesOnPage

public void assertAllFontTypesOnPage(String[] expected,
                                     int page)
Parameters:
expected - All supposed font types in the document. Be carefull and list all of them. A supposed font type is i.e. "TrueType" or "Type1".
page - The supposed page to search for the font types.

onSetup

protected void onSetup()
If you would like to perform some additional steps. You can use this method by overwriting it.


setUp

protected final void setUp()
                    throws Exception
The setUp method of the JUnit framework. This extension sets up the testing document and provides the user the possiblity of an individual extension via the onSetup method.

Overrides:
setUp in class junit.framework.TestCase
Throws:
Exception

getDataSource

protected abstract DocumentDataSource getDataSource()
A must have if you want to extend the DocumentTestCase therefore you need a DocumentDataSource.

Returns:
A DocumentDataSource this data source is necessary for starting the test.

setUpTestingDocument

protected void setUpTestingDocument(DocumentDataSource source)
The method instanciates the DocumentTester for the DocumentTestCase.

Parameters:
source - This method sets up the inital tester for handling the file. The kind of tester depends on the DocumentDataSource.

tearDown

protected void tearDown()
                 throws Exception
A must have for a testcase. This tearDown method closes the DocumentTesters Document.

Overrides:
tearDown in class junit.framework.TestCase
Throws:
Exception

getTester

public DocumentTester getTester()
The method returns the used DocumentTester of the DocumentTestCase.

Returns:
Returns the tester.

assertNumberOfBookmarks

public void assertNumberOfBookmarks(int numberOfBookmarks)

assertBookmarkExists

public void assertBookmarkExists(String bookmarkName)

assertBookmarksAre

public void assertBookmarksAre(String[] bookmarks)


Copyright © 2011. All Rights Reserved.