use of org.nutz.mock.servlet.MockHttpServletRequest in project nutz by nutzam.
the class ObjectNavlPairInjectorTest method test_string_to_string.
@Test
public void test_string_to_string() {
// 准备数据
MockHttpServletRequest req = Mock.servlet.request();
req.setParameterValues("pojo.str", Lang.array("A"));
// 执行
MvcTestPojo pojo = (MvcTestPojo) inj().get(null, req, null, null);
// 检测
assertEquals("A", pojo.str);
}
use of org.nutz.mock.servlet.MockHttpServletRequest in project nutz by nutzam.
the class ObjectPairInjectorTest method test_duplicated_name_params.
/**
* 这个测试将检验在 HTTP 请求中,如果存在多个参数同名的情况,本注入器能否正确处理
*/
@Test
public void test_duplicated_name_params() {
// 准备数据
MockHttpServletRequest req = Mock.servlet.request();
req.setParameter("num", 23);
req.setParameterValues("names", Lang.array("A", "B", "C"));
// 执行
MvcTestPojo pojo = (MvcTestPojo) inj().get(null, req, null, null);
// 检测
assertNull(pojo.longValue);
assertEquals(23, pojo.num);
assertEquals(3, pojo.names.length);
assertEquals("A", pojo.names[0]);
assertEquals("B", pojo.names[1]);
assertEquals("C", pojo.names[2]);
}
use of org.nutz.mock.servlet.MockHttpServletRequest in project nutz by nutzam.
the class ObjectPairInjectorTest method test_balnk_param_to_number.
/**
* 根据 Issue 272,如果为空串,原生类型的外覆类应该返回 null
*/
@Test
public void test_balnk_param_to_number() {
// 准备数据
MockHttpServletRequest req = Mock.servlet.request();
req.setParameter("longValue", " ");
req.setParameter("num", " ");
// 执行
MvcTestPojo pojo = (MvcTestPojo) inj().get(null, req, null, null);
// 检测
assertNull(pojo.longValue);
assertEquals(0, pojo.num);
}
Aggregations