use of org.nutz.mock.servlet.multipart.MultipartInputStream in project nutz by nutzam.
the class UploadingUnitTest method test_limit_file_content_type_fail.
/**
* 测试限制文件类型:限制文件类型
*/
@Test(expected = UploadUnsupportedFileTypeException.class)
public void test_limit_file_content_type_fail() throws UploadException {
MockHttpServletRequest req = Mock.servlet.request();
req.setPathInfo("/nutz/junit/uploading");
File blue = Files.findFile("org/nutz/mvc/upload/files/quick/blue.png");
MultipartInputStream ins = Mock.servlet.insmulti(charset);
ins.append("blue", blue);
req.setInputStream(ins);
req.init();
/*
* 文件超大,会限制
*/
Uploading up = UploadUnit.TYPE.born();
up.parse(req, UploadingContext.create(tmps).setContentTypeFilter("^image/gif$"));
}
Aggregations