use of org.olat.test.VFSJavaIOFile in project openolat by klemens.
the class OfficeDocumentTest method testPowerPointOpenXMLDocument.
@Test
public void testPowerPointOpenXMLDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
URL docUrl = OfficeDocumentTest.class.getResource("Test_ppt_indexing.pptx");
Assert.assertNotNull(docUrl);
VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
PowerPointOOXMLDocument document = new PowerPointOOXMLDocument();
FileContent content = document.readContent(doc);
Assert.assertNotNull(content);
String body = content.getContent();
Assert.assertTrue(body.contains("Here is some text"));
}
use of org.olat.test.VFSJavaIOFile in project openolat by klemens.
the class OfficeDocumentTest method testExcelOpenXMLDocument.
@Test
public void testExcelOpenXMLDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
URL docUrl = OfficeDocumentTest.class.getResource("Test_excel_indexing.xlsx");
Assert.assertNotNull(docUrl);
VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
ExcelOOXMLDocument document = new ExcelOOXMLDocument();
FileContent content = document.readContent(doc);
Assert.assertNotNull(content);
String body = content.getContent();
Assert.assertTrue(body.contains("Numbers and their Squares"));
Assert.assertTrue(body.contains("225"));
}
use of org.olat.test.VFSJavaIOFile in project openolat by klemens.
the class OfficeDocumentTest method testPowerPointDocument.
@Test
public void testPowerPointDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
URL docUrl = OfficeDocumentTest.class.getResource("Test_ppt_indexing.ppt");
Assert.assertNotNull(docUrl);
VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
PowerPointDocument document = new PowerPointDocument();
FileContent content = document.readContent(doc);
Assert.assertNotNull(content);
String body = content.getContent();
Assert.assertTrue(body.contains("Sample Powerpoint Slide"));
}
use of org.olat.test.VFSJavaIOFile in project openolat by klemens.
the class OfficeDocumentTest method testWordDocument.
@Test
public void testWordDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
URL docUrl = OfficeDocumentTest.class.getResource("Test_word_indexing.doc");
Assert.assertNotNull(docUrl);
VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
WordDocument document = new WordDocument();
FileContent content = document.readContent(doc);
Assert.assertNotNull(content);
String body = content.getContent();
// content
Assert.assertTrue(body.contains("Lorem ipsum dolor sit amet"));
// footer
Assert.assertTrue(body.contains("Rue (domicile)"));
}
use of org.olat.test.VFSJavaIOFile in project openolat by klemens.
the class PDFDocumentTest method testPDFDocumentCaching.
@Test
public void testPDFDocumentCaching() throws DocumentException, DocumentAccessException, URISyntaxException, IOException {
URL pdfUrl = PDFDocumentTest.class.getResource("Test_pdf_indexing.pdf");
Assert.assertNotNull(pdfUrl);
VFSLeaf doc = new VFSJavaIOFile(UUID.randomUUID().toString() + ".pdf", new File(pdfUrl.toURI()));
String temp = System.getProperty("java.io.tmpdir");
PdfDocument document = new PdfDocument(temp, false);
// index the pdf
FileContent contentIndexed = document.readContent(doc);
Assert.assertNotNull(contentIndexed);
Assert.assertEquals("Test pdf indexing", contentIndexed.getTitle());
String bodyIndexed = contentIndexed.getContent();
Assert.assertEquals("Un petit texte en français", bodyIndexed.trim());
// take from the cache
FileContent contentCached = document.readContent(doc);
Assert.assertNotNull(contentCached);
Assert.assertEquals("Test pdf indexing", contentCached.getTitle());
String cachedBody = contentCached.getContent();
Assert.assertEquals("Un petit texte en français", cachedBody.trim());
}
Aggregations