Example #1
0
  @Test
  public void testNPEFromFile() throws Exception {
    OpenDocumentParser parser = new OpenDocumentParser();
    try (TikaInputStream tis =
        TikaInputStream.get(
            this.getClass().getResource("/test-documents/testNPEOpenDocument.odt"))) {
      Metadata metadata = new Metadata();
      ContentHandler handler = new BodyContentHandler();
      parser.parse(tis, handler, metadata, new ParseContext());

      assertEquals("application/vnd.oasis.opendocument.text", metadata.get(Metadata.CONTENT_TYPE));

      String content = handler.toString();
      assertContains("primero hay que generar un par de claves", content);
    }
  }
Example #2
0
  @Test
  public void testFromFile() throws Exception {
    try (TikaInputStream tis =
        TikaInputStream.get(this.getClass().getResource("/test-documents/testODFwithOOo3.odt"))) {
      assertEquals(true, tis.hasFile());
      OpenDocumentParser parser = new OpenDocumentParser();
      Metadata metadata = new Metadata();
      ContentHandler handler = new BodyContentHandler();
      parser.parse(tis, handler, metadata, new ParseContext());

      assertEquals("application/vnd.oasis.opendocument.text", metadata.get(Metadata.CONTENT_TYPE));

      String content = handler.toString();
      assertContains("Tika is part of the Lucene project.", content);
    }
  }