Search in sources :

Example 1 with VFSJavaIOFile

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"));
}
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 2 with VFSJavaIOFile

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"));
}
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 3 with VFSJavaIOFile

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"));
}
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 4 with VFSJavaIOFile

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());
}
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 5 with VFSJavaIOFile

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());
}
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