Search in sources :

Example 6 with VFSJavaIOFile

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"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Example 7 with VFSJavaIOFile

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"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Example 8 with VFSJavaIOFile

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"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Example 9 with VFSJavaIOFile

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)"));
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Example 10 with VFSJavaIOFile

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());
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) File(java.io.File) URL(java.net.URL) VFSJavaIOFile(org.olat.test.VFSJavaIOFile) Test(org.junit.Test)

Aggregations

File (java.io.File)16 URL (java.net.URL)16 Test (org.junit.Test)16 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)16 VFSJavaIOFile (org.olat.test.VFSJavaIOFile)16