Clover Coverage Report - Atlassian Core
Coverage timestamp: Sun Nov 30 2008 18:33:35 CST
7   43   3   2.33
0   28   0.43   3
3     1  
1    
 
 
  BufferedFileSpool       Line # 18 7 3 60% 0.6
 
  (1)
 
1    package com.atlassian.core.spool;
2   
3    import java.io.BufferedInputStream;
4    import java.io.BufferedOutputStream;
5    import java.io.File;
6    import java.io.FileOutputStream;
7    import java.io.IOException;
8    import java.io.InputStream;
9    import java.io.OutputStream;
10   
11    import org.apache.commons.io.IOUtils;
12   
13    /**
14    * Spool bytes via buffered file streams. The returned input stream is a SpoolFileInputStream
15    *
16    * @see SpoolFileInputStream
17    */
 
18    public class BufferedFileSpool implements FileSpool {
19   
20    private FileFactory fileFactory = DefaultSpoolFileFactory.getInstance();
21   
 
22  0 toggle public FileFactory getFileFactory()
23    {
24  0 return fileFactory;
25    }
26   
 
27  0 toggle public void setFileFactory(FileFactory fileFactory)
28    {
29  0 this.fileFactory = fileFactory;
30    }
31   
 
32  1 toggle public InputStream spool(InputStream is) throws IOException
33    {
34  1 File spoolFile = fileFactory.createNewFile();
35   
36  1 OutputStream os = new BufferedOutputStream(new FileOutputStream(spoolFile));
37  1 IOUtils.copy(is, os);
38  1 os.close();
39   
40  1 return new BufferedInputStream(new SpoolFileInputStream(spoolFile));
41    }
42   
43    }