1 package org.apache.commons.fileupload; 2 3 56 57 import junit.framework.TestCase; 58 import javax.servlet.http.HttpServletRequest ; 59 60 67 public class FileUploadTest extends TestCase 68 { 69 public void testWithInvalidRequest() 70 { 71 FileUploadBase fu = null; 72 73 fu = new DiskFileUpload(); 74 75 HttpServletRequest req = HttpServletRequestFactory.createInvalidHttpServletRequest(); 76 77 78 try 79 { 80 fu.parseRequest(req); 81 fail("testWithInvalidRequest: expected exception was not thrown"); 82 } 83 catch (FileUploadException expected) 84 { 85 } 87 88 } 89 90 91 public void testWithNullContentType() 92 { 93 FileUploadBase fu = new DiskFileUpload(); 94 95 HttpServletRequest req = HttpServletRequestFactory.createHttpServletRequestWithNullContentType(); 96 97 try 98 { 99 fu.parseRequest(req); 100 fail("testWithNullContentType: expected exception was not thrown"); 101 } 102 catch (DiskFileUpload.InvalidContentTypeException expected) 103 { 104 } 106 catch (FileUploadException unexpected) 107 { 108 fail("testWithNullContentType: unexpected exception was thrown"); 109 } 110 111 } 112 113 114 public FileUploadTest(String name) 115 { 116 super(name); 117 } 118 119 public void testParseRequest() throws FileUploadException 120 { 121 122 String [] fileNames = 123 { 124 "filename1", 125 "filename2" 126 }; 127 128 FileUploadBase fu = new DiskFileUpload(); 129 130 HttpServletRequest req = HttpServletRequestFactory.createValidHttpServletRequest(fileNames); 131 132 135 } 136 } 137 138 | Popular Tags |