use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class KotlinScriptTemplateTests method renderViewWithModel.
private MockHttpServletResponse renderViewWithModel(String viewUrl, Map<String, Object> model, Locale locale, Class<?> configuration) throws Exception {
ScriptTemplateView view = createViewWithUrl(viewUrl, configuration);
view.setLocale(locale);
MockHttpServletResponse response = new MockHttpServletResponse();
MockHttpServletRequest request = new MockHttpServletRequest();
view.renderMergedOutputModel(model, request, response);
return response;
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class ObjectToStringHttpMessageConverterTests method setUp.
@Before
public void setUp() {
ConversionService conversionService = new DefaultConversionService();
this.converter = new ObjectToStringHttpMessageConverter(conversionService);
this.servletResponse = new MockHttpServletResponse();
this.response = new ServletServerHttpResponse(this.servletResponse);
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class ModelFactoryOrderingTests method setup.
@Before
public void setup() {
this.sessionAttributeStore = new DefaultSessionAttributeStore();
this.webRequest = new ServletWebRequest(new MockHttpServletRequest(), new MockHttpServletResponse());
this.mavContainer = new ModelAndViewContainer();
this.mavContainer.addAttribute("methods", new ArrayList<String>());
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class RequestHeaderMethodArgumentResolverTests method setUp.
@Before
@SuppressWarnings("resource")
public void setUp() throws Exception {
GenericWebApplicationContext context = new GenericWebApplicationContext();
context.refresh();
resolver = new RequestHeaderMethodArgumentResolver(context.getBeanFactory());
Method method = ReflectionUtils.findMethod(getClass(), "params", (Class<?>[]) null);
paramNamedDefaultValueStringHeader = new SynthesizingMethodParameter(method, 0);
paramNamedValueStringArray = new SynthesizingMethodParameter(method, 1);
paramSystemProperty = new SynthesizingMethodParameter(method, 2);
paramContextPath = new SynthesizingMethodParameter(method, 3);
paramResolvedNameWithExpression = new SynthesizingMethodParameter(method, 4);
paramResolvedNameWithPlaceholder = new SynthesizingMethodParameter(method, 5);
paramNamedValueMap = new SynthesizingMethodParameter(method, 6);
paramDate = new SynthesizingMethodParameter(method, 7);
paramInstant = new SynthesizingMethodParameter(method, 8);
servletRequest = new MockHttpServletRequest();
webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());
// Expose request to the current thread (for SpEL expressions)
RequestContextHolder.setRequestAttributes(webRequest);
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class RequestParamMapMethodArgumentResolverTests method setUp.
@Before
public void setUp() throws Exception {
resolver = new RequestParamMapMethodArgumentResolver();
request = new MockHttpServletRequest();
webRequest = new ServletWebRequest(request, new MockHttpServletResponse());
}
Aggregations