Class TestingDocument

java.lang.Object
org.apache.rat.api.Document
org.apache.rat.testhelpers.TestingDocument
All Implemented Interfaces:
Comparable<Document>

public class TestingDocument extends Document
A Document for testing. The document is guaranteed to have a name and may have content (specified in the constructor).
  • Constructor Details

    • TestingDocument

      public TestingDocument()
      Constructs a TestingDocument with the name "name" and no content.
    • TestingDocument

      public TestingDocument(String name)
      Constructs a TestingDocument with the specified "name", no content and will not have an associated document name matcher.
      Parameters:
      name - the name of the document.
    • TestingDocument

      public TestingDocument(DocumentName documentName)
      Constructs a TestingDocument with the specified DocumentName, no content and the DocumentNameMatcher.MATCHES_ALL name matcher associated with it.
      Parameters:
      documentName - the document name.
    • TestingDocument

      public TestingDocument(String name, DocumentNameMatcher matcher)
      Constructs a TestingDocument with the specified "name", no content and the specified DocumentNameMatcher associated with it.
      Parameters:
      name - the document name.
      matcher - the associated document name matcher.
    • TestingDocument

      public TestingDocument(Reader reader, String name)
      Constructs a TestingDocument with the name "name" and the content provided by the reader.
      Parameters:
      reader - the reader that provides content for the document.
      name - the name of the document.
    • TestingDocument

      public TestingDocument(org.apache.commons.io.function.IOSupplier<InputStream> inputSupplier, String name)
      Constructs a TestingDocument with the name "name" and the content provided by the input stream.
      Parameters:
      inputSupplier - the input supplier that provides content for the document as an input stream.
      name - the name of the document.
  • Method Details

    • reader

      public Reader reader() throws IOException
      Gets the reader for the document content.
      Overrides:
      reader in class Document
      Returns:
      the reader for the contents.
      Throws:
      IOException - on IO error when reading from input stream.
      NullPointerException - if neither the reader nor the input stream were provided.
    • isDirectory

      public boolean isDirectory()
      Returns false as a document is no directory.
      Specified by:
      isDirectory in class Document
      Returns:
      always returns false.
    • listChildren

      public SortedSet<Document> listChildren()
      A document does not have any children.
      Specified by:
      listChildren in class Document
      Returns:
      always returns an empty set.
    • inputStream

      public InputStream inputStream() throws IOException
      Returns the input stream if it was provided in the constructor.
      Specified by:
      inputStream in class Document
      Returns:
      the input stream if it was provided in the constructor.
      Throws:
      IOException - if the input stream can not be retrieved.
      UnsupportedOperationException - if the input stream was not provided.