use of org.nutz.mock.servlet.MockHttpServletRequest 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$"));
}
use of org.nutz.mock.servlet.MockHttpServletRequest in project nutz by nutzam.
the class UploadingUnitTest method test_cast_dt01.
@Test
public void test_cast_dt01() throws UploadException {
MockHttpServletRequest req = Mock.servlet.request();
req.setHeader("content-type", "multipart/form-data; boundary=----ESDT-321271401654cc6d669eef664aac");
Uploading up = UploadUnit.TYPE.born();
ServletInputStream ins = Mock.servlet.ins("org/nutz/mvc/upload/files/cast_dt01");
req.setInputStream(ins);
req.init();
Map<String, Object> map = up.parse(req, UploadingContext.create(tmps));
assertEquals(1, map.size());
assertEquals("Shapes100.jpg", ((TempFile) map.get("fileData")).getSubmittedFileName());
}
use of org.nutz.mock.servlet.MockHttpServletRequest in project nutz by nutzam.
the class JspViewTest method test_req_path.
@Test
public void test_req_path() throws Exception {
MockHttpServletRequest req = Mock.servlet.fullRequest();
req.setPathInfo("/abc/bcd.do");
JspView fv = new JspView(null);
fv.render(req, null, null);
assertEquals("/WEB-INF/abc/bcd.jsp", req.getDispatcherTarget());
}
use of org.nutz.mock.servlet.MockHttpServletRequest in project nutz by nutzam.
the class JspViewTest method test_req_path3.
@Test
public void test_req_path3() throws Exception {
MockHttpServletRequest req = Mock.servlet.fullRequest();
req.setPathInfo("/abc/bcd.do");
JspView fv = new JspView(" \r\n\t ");
fv.render(req, null, null);
assertEquals("/WEB-INF/abc/bcd.jsp", req.getDispatcherTarget());
}
use of org.nutz.mock.servlet.MockHttpServletRequest in project nutz by nutzam.
the class ArrayInjectorTest method test_array_no_split.
/**
* for issue #816
*/
@Test
public void test_array_no_split() {
// 准备数据
MockHttpServletRequest req = Mock.servlet.request();
req.setParameterValues("abc", Lang.array("A,B"));
// 执行
ParamInjector pi = inj("abc", String[].class, false);
Object obj = pi.get(null, req, null, null);
// 检测
assertEquals(String[].class, obj.getClass());
String[] ss = (String[]) obj;
assertEquals(1, ss.length);
assertEquals("A,B", ss[0]);
}
Aggregations