コード例 #1
0
 @Test
 public void testWriteRead() throws IOException {
   StripAfterTransformer t = new StripAfterTransformer();
   t.setInclusive(true);
   t.setStripAfterRegex("<p>");
   System.out.println("Writing/Reading this: " + t);
   ConfigurationUtil.assertWriteRead(t);
 }
コード例 #2
0
  @Test
  public void testTransformTextDocument() throws IOException, ImporterHandlerException {
    StripAfterTransformer t = new StripAfterTransformer();
    t.setStripAfterRegex("<p>");
    t.setCaseSensitive(false);
    t.setInclusive(true);
    File htmlFile = TestUtil.getAliceHtmlFile();
    FileInputStream is = new FileInputStream(htmlFile);

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    ImporterMetadata metadata = new ImporterMetadata();

    metadata.setString(ImporterMetadata.DOC_CONTENT_TYPE, "text/html");
    t.transformDocument(htmlFile.getAbsolutePath(), is, os, metadata, false);
    System.out.println(os.toString());

    Assert.assertEquals(
        "Length of doc content after transformation is incorrect.", 552, os.toString().length());

    is.close();
    os.close();
  }