Class TestUtils

java.lang.Object
org.sejda.tests.TestUtils

public final class TestUtils extends Object
Test utilities
Author:
Andrea Vacondio
  • Method Details

    • setProperty

      public static void setProperty(Object instance, String propertyName, Object propertyValue)
      Sets the given property to the given instance at the given value.
      Parameters:
      instance -
      propertyName -
      propertyValue -
    • assertInvalidParameters

      public static void assertInvalidParameters(TaskParameters parameters)
    • assertValidParameters

      public static void assertValidParameters(TaskParameters parameters)
    • testEqualsAndHashCodes

      public static <T> void testEqualsAndHashCodes(T eq1, T eq2, T eq3, T diff)
      Test that the equals and hashCode implementations respect the general rules being reflexive, transitive and symmetric.
      Type Parameters:
      T -
      Parameters:
      eq1 - equal instance
      eq2 - equal instance
      eq3 - equal instance
      diff - not equal instance
    • getEncryptionAtRestPolicy

      public static EncryptionAtRestPolicy getEncryptionAtRestPolicy()
    • encryptedAtRest

      public static StreamSource encryptedAtRest(StreamSource source) throws IOException
      Throws:
      IOException
    • encryptedAtRest

      public static FileSource encryptedAtRest(FileSource source) throws IOException
      Throws:
      IOException
    • encryptedAtRest

      public static PdfStreamSource encryptedAtRest(PdfStreamSource source) throws IOException
      Throws:
      IOException
    • encryptedAtRest

      public static PdfFileSource encryptedAtRest(PdfFileSource source) throws IOException
      Throws:
      IOException
    • getPageText

      public static String getPageText(org.sejda.sambox.pdmodel.PDPage page) throws IOException
      Throws:
      IOException
    • withPageText

      public static void withPageText(org.sejda.sambox.pdmodel.PDPage page, Consumer<String> callback)
    • getPageTextNormalized

      public static String getPageTextNormalized(org.sejda.sambox.pdmodel.PDPage page) throws IOException
      Throws:
      IOException
    • getDocTextNormalized

      public static String getDocTextNormalized(org.sejda.sambox.pdmodel.PDDocument doc) throws IOException
      Throws:
      IOException
    • assertPageText

      public static void assertPageText(org.sejda.sambox.pdmodel.PDPage page, String text)
    • assertPageTextExact

      public static void assertPageTextExact(org.sejda.sambox.pdmodel.PDPage page, String text)
    • assertPageTextExactLines

      public static void assertPageTextExactLines(org.sejda.sambox.pdmodel.PDPage page, String text)
    • assertDocTextExactLines

      public static void assertDocTextExactLines(org.sejda.sambox.pdmodel.PDDocument doc, String text) throws IOException
      Throws:
      IOException
    • assertPageTextContains

      public static void assertPageTextContains(org.sejda.sambox.pdmodel.PDPage page, String text)
    • assertPageTextDoesNotContain

      public static void assertPageTextDoesNotContain(org.sejda.sambox.pdmodel.PDPage page, String text)
    • getAnnotationsOf

      public static <T> List<T> getAnnotationsOf(org.sejda.sambox.pdmodel.PDPage page, Class<T> clazz)
    • iteratorToList

      public static <T> List<T> iteratorToList(Iterator<T> iterator)
    • assertPDRectanglesEqual

      public static void assertPDRectanglesEqual(org.sejda.sambox.pdmodel.common.PDRectangle expected, org.sejda.sambox.pdmodel.common.PDRectangle actual)
    • assertPageDestination

      public static void assertPageDestination(org.sejda.sambox.pdmodel.interactive.annotation.PDAnnotationLink link, org.sejda.sambox.pdmodel.PDPage expectedPage) throws IOException
      Throws:
      IOException
    • assertPageLabelIndexesAre

      public static void assertPageLabelIndexesAre(org.sejda.sambox.pdmodel.common.PDPageLabels labels, Integer... expected)
    • assertPageLabelRangeIs

      public static void assertPageLabelRangeIs(org.sejda.sambox.pdmodel.common.PDPageLabels labels, int startPage, org.sejda.sambox.pdmodel.common.PDPageLabelRange expected)
    • assertPageLabelRangeIsDefault

      public static void assertPageLabelRangeIsDefault(org.sejda.sambox.pdmodel.common.PDPageLabels labels, int startPage)
    • assertPageLabelRangeIs

      public static void assertPageLabelRangeIs(org.sejda.sambox.pdmodel.common.PDPageLabels labels, int startPage, String style)
    • assertPageLabelRangeIs

      public static void assertPageLabelRangeIs(org.sejda.sambox.pdmodel.common.PDPageLabels labels, int startPage, String style, String prefix, Integer start)
    • getCipher

      public static Cipher getCipher(String salt, String key, int mode)
    • shortInput

      public static PdfStreamSource shortInput()
    • regularInput

      public static PdfStreamSource regularInput()
    • mediumInput

      public static PdfStreamSource mediumInput()
    • largeInput

      public static PdfStreamSource largeInput()
    • largeOutlineInput

      public static PdfStreamSource largeOutlineInput()
    • encryptedInput

      public static PdfStreamSource encryptedInput()
    • formInput

      public static PdfStreamSource formInput()
    • stronglyEncryptedInput

      public static PdfStreamSource stronglyEncryptedInput()
    • customInput

      public static PdfStreamSource customInput(String path)
    • customInput

      public static PdfStreamSource customInput(String path, String name)
    • customInputAsFileSource

      public static PdfFileSource customInputAsFileSource(String path)
    • customInputAsFileSource

      public static PdfFileSource customInputAsFileSource(String path, String filename)
    • customInput

      public static PdfFileSource customInput(org.sejda.sambox.pdmodel.PDDocument doc, String name)
    • customEncryptedInput

      public static PdfStreamSource customEncryptedInput(String path, String password)
    • customNonPdfInputAsStreamSource

      public static StreamSource customNonPdfInputAsStreamSource(String path)
    • customNonPdfInput

      public static FileSource customNonPdfInput(String path)
    • customNonPdfInput

      public static FileSource customNonPdfInput(String path, String filename)
    • customNonPdfInputAsStreamSource

      public static StreamSource customNonPdfInputAsStreamSource(String path, String filename)
    • customNonPdfInputAsFileSource

      public static FileSource customNonPdfInputAsFileSource(String path)
    • customNonPdfInputAsFileSource

      public static FileSource customNonPdfInputAsFileSource(String path, String filename)
    • streamToTmpFile

      public static File streamToTmpFile(InputStream in, String filename)