use of org.olat.test.VFSJavaIOFile in project OpenOLAT by OpenOLAT.
the class OfficeDocumentTest method testWordOpenXMLDocument.
@Test
public void testWordOpenXMLDocument() throws IOException, DocumentException, DocumentAccessException, URISyntaxException {
URL docUrl = OfficeDocumentTest.class.getResource("Test_word_indexing.docx");
Assert.assertNotNull(docUrl);
VFSLeaf doc = new VFSJavaIOFile(new File(docUrl.toURI()));
WordOOXMLDocument document = new WordOOXMLDocument();
FileContent content = document.readContent(doc);
Assert.assertNotNull(content);
String body = content.getContent();
Assert.assertTrue(body.contains("Document compatibility test"));
Assert.assertTrue(body.contains("They prefer to start writing a document at home in desktop or laptop computer"));
}
use of org.olat.test.VFSJavaIOFile in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class PDFDocumentTest method testPDFDocument.
@Test
public void testPDFDocument() throws DocumentException, DocumentAccessException, URISyntaxException, IOException {
URL pdfUrl = PDFDocumentTest.class.getResource("Test_pdf_indexing.pdf");
Assert.assertNotNull(pdfUrl);
VFSLeaf doc = new VFSJavaIOFile("Test_1.pdf", new File(pdfUrl.toURI()));
String temp = System.getProperty("java.io.tmpdir");
PdfDocument document = new PdfDocument(temp, false);
FileContent content = document.readContent(doc);
Assert.assertNotNull(content);
Assert.assertEquals("Test pdf indexing", content.getTitle());
String body = content.getContent();
Assert.assertEquals("Un petit texte en français", body.trim());
}
use of org.olat.test.VFSJavaIOFile in project OpenOLAT by OpenOLAT.
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