Search in sources :

Example 21 with POIDataSamples

use of org.apache.poi.POIDataSamples in project poi by apache.

the class TestReWrite method setUp.

@Before
public void setUp() throws Exception {
    POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
    pfsA = new POIFSFileSystem(slTests.openResourceAsStream("basic_test_ppt_file.ppt"));
    hssA = new HSLFSlideShowImpl(pfsA);
    pfsB = new POIFSFileSystem(slTests.openResourceAsStream("ParagraphStylesShorterThanCharStyles.ppt"));
    hssB = new HSLFSlideShowImpl(pfsB);
    pfsC = new POIFSFileSystem(slTests.openResourceAsStream("WithMacros.ppt"));
    hssC = new HSLFSlideShowImpl(pfsC);
}
Also used : POIFSFileSystem(org.apache.poi.poifs.filesystem.POIFSFileSystem) POIDataSamples(org.apache.poi.POIDataSamples) HSLFSlideShowImpl(org.apache.poi.hslf.usermodel.HSLFSlideShowImpl) Before(org.junit.Before)

Example 22 with POIDataSamples

use of org.apache.poi.POIDataSamples in project poi by apache.

the class TestTextRunReWrite method setUp.

/**
	 * Load up a test PPT file with rich data
	 */
@Before
public void setUp() throws Exception {
    POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
    String filename = "Single_Coloured_Page_With_Fonts_and_Alignments.ppt";
    ss = new HSLFSlideShow(slTests.openResourceAsStream(filename));
}
Also used : POIDataSamples(org.apache.poi.POIDataSamples) HSLFSlideShow(org.apache.poi.hslf.usermodel.HSLFSlideShow) Before(org.junit.Before)

Example 23 with POIDataSamples

use of org.apache.poi.POIDataSamples in project poi by apache.

the class TestHMEFContentsExtractor method TestExtractMessageBody_File.

@Test
public void TestExtractMessageBody_File() throws IOException {
    POIDataSamples samples = POIDataSamples.getHMEFInstance();
    File winmailTNEFFile = samples.getFile("quick-winmail.dat");
    HMEFContentsExtractor extractor = new HMEFContentsExtractor(winmailTNEFFile);
    File rtf = TempFile.createTempFile("quick-winmail-message-body", ".rtf");
    assertTrue(rtf.delete());
    extractor.extractMessageBody(rtf);
    assertTrue("RTF message body is empty", rtf.length() > 0);
}
Also used : POIDataSamples(org.apache.poi.POIDataSamples) TempFile(org.apache.poi.util.TempFile) File(java.io.File) Test(org.junit.Test)

Example 24 with POIDataSamples

use of org.apache.poi.POIDataSamples in project poi by apache.

the class TestHMEFContentsExtractor method TestExtractMessageBody_OutputStream.

@Test
public void TestExtractMessageBody_OutputStream() throws IOException {
    POIDataSamples samples = POIDataSamples.getHMEFInstance();
    File winmailTNEFFile = samples.getFile("quick-winmail.dat");
    HMEFContentsExtractor extractor = new HMEFContentsExtractor(winmailTNEFFile);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    extractor.extractMessageBody(out);
    assertTrue(out.size() > 0);
    byte[] expectedMagic = new byte[] { '{', '\\', 'r', 't', 'f' };
    byte[] magic = Arrays.copyOf(out.toByteArray(), 5);
    assertArrayEquals("RTF magic number", expectedMagic, magic);
    out.close();
}
Also used : POIDataSamples(org.apache.poi.POIDataSamples) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TempFile(org.apache.poi.util.TempFile) File(java.io.File) Test(org.junit.Test)

Example 25 with POIDataSamples

use of org.apache.poi.POIDataSamples in project poi by apache.

the class TestHMEFContentsExtractor method TestMain.

@Test
public void TestMain() throws IOException {
    POIDataSamples samples = POIDataSamples.getHMEFInstance();
    File message = samples.getFile("quick-winmail.dat");
    File outputDirectory = TempFile.createTempDirectory("quick-winmail-main");
    String[] args = new String[] { message.getAbsolutePath(), outputDirectory.getAbsolutePath() };
    HMEFContentsExtractor.main(args);
    String[] contents = new String[] { // from extractMessageBody
    "message.rtf", // from extractAttachments
    "quick.txt", // from extractAttachments
    "quick.pdf", // from extractAttachments
    "quick.xml", // from extractAttachments
    "quick.doc", // from extractAttachments
    "quick.html" };
    for (String filename : contents) {
        File f = new File(outputDirectory, filename);
        assertTrue(f + " does not exist", f.exists());
    }
    outputDirectory.delete();
}
Also used : POIDataSamples(org.apache.poi.POIDataSamples) TempFile(org.apache.poi.util.TempFile) File(java.io.File) Test(org.junit.Test)

Aggregations

POIDataSamples (org.apache.poi.POIDataSamples)27 Test (org.junit.Test)13 File (java.io.File)7 Before (org.junit.Before)7 HSLFSlideShow (org.apache.poi.hslf.usermodel.HSLFSlideShow)4 TempFile (org.apache.poi.util.TempFile)4 HSLFSlideShowImpl (org.apache.poi.hslf.usermodel.HSLFSlideShowImpl)3 POIFSFileSystem (org.apache.poi.poifs.filesystem.POIFSFileSystem)3 BeforeClass (org.junit.BeforeClass)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 MAPIAttribute (org.apache.poi.hmef.attribute.MAPIAttribute)2 BufferedReader (java.io.BufferedReader)1 FileFilter (java.io.FileFilter)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 SimpleDateFormat (java.text.SimpleDateFormat)1