Package org.apache.james.mime4j.message.storage

Examples of org.apache.james.mime4j.message.storage.TempPath


     * @param is the InputStream to use as source
     * @throws IOException
     */
    public TempFileBinaryBody(final InputStream is) throws IOException {
       
        TempPath tempPath = TempStorage.getInstance().getRootTempPath();
        tempFile = tempPath.createTempFile("attachment", ".bin");
       
        OutputStream out = tempFile.getOutputStream();
        CodecUtil.copy(is, out);
        out.close();
    }
View Full Code Here


    private TempFile tempFile = null;

    public TempFileTextBody(final InputStream is, final String mimeCharset) throws IOException {
       
        this.mimeCharset = mimeCharset;
        TempPath tempPath = TempStorage.getInstance().getRootTempPath();
        tempFile = tempPath.createTempFile("attachment", ".txt");
       
        OutputStream out = tempFile.getOutputStream();
        CodecUtil.copy(is, out);
        out.close();
    }
View Full Code Here

*/
public class SimpleTempStorageTest extends TestCase {

    public void testGetRootTempPath() {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath();
        File tmpdir = new File(System.getProperty("java.io.tmpdir"));
        assertEquals(tmpdir.getAbsolutePath(), path.getAbsolutePath());
    }
View Full Code Here

        assertEquals(tmpdir.getAbsolutePath(), path.getAbsolutePath());
    }

    public void testCreateTempPath() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        File tmpdir = new File(System.getProperty("java.io.tmpdir"));
        assertTrue(path.getAbsolutePath().startsWith(tmpdir.getAbsolutePath()));
       
        String fileName = path.getAbsolutePath().substring(
                path.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^[0-9]+$"));
        assertTrue("Temp dir doesn't exist",
                   new File(path.getAbsolutePath()).exists());
    }
View Full Code Here

                   new File(path.getAbsolutePath()).exists());
    }

    public void testCreateTempPathString() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath("test_prefix");
        File tmpdir = new File(System.getProperty("java.io.tmpdir"),
                               "test_prefix");
        assertTrue(path.getAbsolutePath().startsWith(tmpdir.getAbsolutePath()));
       
        String fileName = path.getAbsolutePath().substring(
                path.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^test_prefix[0-9]+$"));
        assertTrue("Temp dir doesn't exist",
                   new File(path.getAbsolutePath()).exists());
    }
View Full Code Here

                   new File(path.getAbsolutePath()).exists());
    }

    public void testCreateTempFile() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile();
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^[0-9]+\\.tmp$"));
View Full Code Here

        assertEquals(s, new String(buffer, 0, i));
    }
   
    public void testCreateTempFileStringString() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile file = path.createTempFile("test_prefix", ".suffix");
        assertTrue(file.getAbsolutePath().startsWith(path.getAbsolutePath()));
       
        String fileName = file.getAbsolutePath().substring(
                file.getAbsolutePath().lastIndexOf(File.separatorChar) + 1);
        assertTrue("Unexpected chars in file name " + fileName,
                    fileName.matches("^test_prefix[0-9]+\\.suffix$"));
View Full Code Here

                   new File(file.getAbsolutePath()).exists());
    }
   
    public void testDeleteTempFile() throws IOException {
        SimpleTempStorage man = new SimpleTempStorage();
        TempPath path = man.getRootTempPath().createTempPath();
        TempFile tempFile = path.createTempFile("test_prefix", ".suffix");

        File backingFile = new File(tempFile.getAbsolutePath());
        assertTrue(backingFile.exists());

        tempFile.delete();
View Full Code Here

     * @param is the InputStream to use as source
     * @throws IOException
     */
    public TempFileBinaryBody(final InputStream is) throws IOException {
       
        TempPath tempPath = TempStorage.getInstance().getRootTempPath();
        tempFile = tempPath.createTempFile("attachment", ".bin");
       
        OutputStream out = tempFile.getOutputStream();
        CodecUtil.copy(is, out);
        out.close();
    }
View Full Code Here

    private TempFile tempFile = null;

    public TempFileTextBody(final InputStream is, final String mimeCharset) throws IOException {
       
        this.mimeCharset = mimeCharset;
        TempPath tempPath = TempStorage.getInstance().getRootTempPath();
        tempFile = tempPath.createTempFile("attachment", ".txt");
       
        OutputStream out = tempFile.getOutputStream();
        CodecUtil.copy(is, out);
        out.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.james.mime4j.message.storage.TempPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.