use of org.nutz.mvc.adaptor.ParamInjector 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]);
}
use of org.nutz.mvc.adaptor.ParamInjector in project nutz by nutzam.
the class ArrayInjectorTest method test_array_auto_split.
/**
* for issue #816
*/
@Test
public void test_array_auto_split() {
// 准备数据
MockHttpServletRequest req = Mock.servlet.request();
req.setParameterValues("abc", Lang.array("A,B"));
// 执行
ParamInjector pi = inj("abc", String[].class, true);
Object obj = pi.get(null, req, null, null);
// 检测
assertEquals(String[].class, obj.getClass());
String[] ss = (String[]) obj;
assertEquals(2, ss.length);
assertEquals("A", ss[0]);
assertEquals("B", ss[1]);
}
use of org.nutz.mvc.adaptor.ParamInjector in project nutz by nutzam.
the class ArrayInjectorTest method test_array_no_split2.
/**
* for issue #816
*/
@Test
public void test_array_no_split2() {
// 准备数据
MockHttpServletRequest req = Mock.servlet.request();
req.setParameterValues("abc", Lang.array("A,B", "X,Y"));
// 执行
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(2, ss.length);
assertEquals("A,B", ss[0]);
assertEquals("X,Y", ss[1]);
}
Aggregations