use of cn.taketoday.web.servlet.MockMultipartServletRequestContext in project today-infrastructure by TAKETODAY.
the class RequestContextDataBinderTests method testMultipartFileAsStringArray.
@Test
public void testMultipartFileAsStringArray() {
TestBean target = new TestBean();
RequestContextDataBinder binder = new RequestContextDataBinder(target);
binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
binder.bind(new MockMultipartServletRequestContext(request, null));
assertThat(target.getStringArray().length).isEqualTo(1);
assertThat(target.getStringArray()[0]).isEqualTo("Juergen");
}
use of cn.taketoday.web.servlet.MockMultipartServletRequestContext in project today-infrastructure by TAKETODAY.
the class RequestContextDataBinderTests method testMultipartFileAsString.
@Test
public void testMultipartFileAsString() {
TestBean target = new TestBean();
RequestContextDataBinder binder = new RequestContextDataBinder(target);
binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
binder.bind(new MockMultipartServletRequestContext(request, null));
assertThat(target.getName()).isEqualTo("Juergen");
}
use of cn.taketoday.web.servlet.MockMultipartServletRequestContext in project today-infrastructure by TAKETODAY.
the class RequestContextDataBinderTests method testMultipartFilesAsStringArray.
@Test
public void testMultipartFilesAsStringArray() {
TestBean target = new TestBean();
RequestContextDataBinder binder = new RequestContextDataBinder(target);
binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
request.addFile(new MockMultipartFile("stringArray", "Eva".getBytes()));
binder.bind(new MockMultipartServletRequestContext(request, null));
assertThat(target.getStringArray().length).isEqualTo(2);
assertThat(target.getStringArray()[0]).isEqualTo("Juergen");
assertThat(target.getStringArray()[1]).isEqualTo("Eva");
}
use of cn.taketoday.web.servlet.MockMultipartServletRequestContext in project today-framework by TAKETODAY.
the class RequestContextDataBinderTests method testMultipartFileAsStringArray.
@Test
public void testMultipartFileAsStringArray() {
TestBean target = new TestBean();
RequestContextDataBinder binder = new RequestContextDataBinder(target);
binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
request.addFile(new MockMultipartFile("stringArray", "Juergen".getBytes()));
binder.bind(new MockMultipartServletRequestContext(request, null));
assertThat(target.getStringArray().length).isEqualTo(1);
assertThat(target.getStringArray()[0]).isEqualTo("Juergen");
}
use of cn.taketoday.web.servlet.MockMultipartServletRequestContext in project today-framework by TAKETODAY.
the class RequestContextDataBinderTests method testMultipartFileAsString.
@Test
public void testMultipartFileAsString() {
TestBean target = new TestBean();
RequestContextDataBinder binder = new RequestContextDataBinder(target);
binder.registerCustomEditor(String.class, new StringMultipartFileEditor());
MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
request.addFile(new MockMultipartFile("name", "Juergen".getBytes()));
binder.bind(new MockMultipartServletRequestContext(request, null));
assertThat(target.getName()).isEqualTo("Juergen");
}
Aggregations