Clover Coverage Report - kew-test 2.0.0-SNAPSHOT
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
12   83   11   1.09
0   48   0.92   11
11     1  
1    
 
  MockFormFile       Line # 33 12 0% 11 23 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2005-2008 The Kuali Foundation
3    *
4    *
5    * Licensed under the Educational Community License, Version 2.0 (the "License");
6    * you may not use this file except in compliance with the License.
7    * You may obtain a copy of the License at
8    *
9    * http://www.opensource.org/licenses/ecl2.php
10    *
11    * Unless required by applicable law or agreed to in writing, software
12    * distributed under the License is distributed on an "AS IS" BASIS,
13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    * See the License for the specific language governing permissions and
15    * limitations under the License.
16    */
17   
18    package org.kuali.rice.kew.test.web;
19   
20    import java.io.File;
21    import java.io.FileInputStream;
22    import java.io.FileNotFoundException;
23    import java.io.IOException;
24    import java.io.InputStream;
25   
26    import org.apache.struts.upload.FormFile;
27    import org.springframework.util.FileCopyUtils;
28   
29    /**
30    * A mock FormFile which is constructed directly from a File on disk
31    * @author Kuali Rice Team (rice.collab@kuali.org)
32    */
 
33    public class MockFormFile implements FormFile {
34    private File file;
35    private String fileName;
36    private int fileSize;
37    private String contentType = "application/octet-stream";
38   
 
39  0 toggle public MockFormFile(File file) {
40  0 this.file = file;
41  0 this.fileName = file.getName();
42  0 this.fileSize = (int) file.length();
43    }
44   
 
45  0 toggle public String getContentType() {
46  0 return contentType;
47    }
48   
 
49  0 toggle public void setContentType(String contentType) {
50  0 this.contentType = contentType;
51    }
52   
 
53  0 toggle public byte[] getFileData() throws FileNotFoundException, IOException {
54  0 return FileCopyUtils.copyToByteArray(file);
55    }
56   
 
57  0 toggle public String getFileName() {
58  0 return fileName;
59    }
60   
 
61  0 toggle public void setFileName(String fileName) {
62  0 this.fileName = fileName;
63    }
64   
 
65  0 toggle public int getFileSize() {
66  0 return fileSize;
67    }
68   
 
69  0 toggle public void setFileSize(int fileSize) {
70  0 this.fileSize = fileSize;
71    }
72   
 
73  0 toggle public InputStream getInputStream() throws FileNotFoundException, IOException {
74  0 return new FileInputStream(file);
75    }
76   
 
77  0 toggle public void destroy() {
78    }
79   
 
80  0 toggle public String toString() {
81  0 return "[MockFormFile: " + file + "]";
82    }
83    }