use of cn.taketoday.web.mock.MockRequestDispatcher in project today-infrastructure by TAKETODAY.
the class InternalResourceViewTests method includeOnAttribute.
@Test
public void includeOnAttribute() throws Exception {
given(request.getRequestDispatcher(url)).willReturn(new MockRequestDispatcher(url));
given(request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI)).willReturn("somepath");
RequestContext context = new ServletRequestContext(null, request, response);
view.setUrl(url);
// Can now try multiple tests
view.render(model, context);
assertThat(response.getIncludedUrl()).isEqualTo(url);
model.forEach((key, value) -> verify(request).setAttribute(key, value));
}
use of cn.taketoday.web.mock.MockRequestDispatcher in project today-infrastructure by TAKETODAY.
the class InternalResourceViewTests method alwaysInclude.
@Test
public void alwaysInclude() throws Exception {
given(request.getRequestDispatcher(url)).willReturn(new MockRequestDispatcher(url));
view.setUrl(url);
view.setAlwaysInclude(true);
RequestContext context = new ServletRequestContext(null, request, response);
// Can now try multiple tests
view.render(model, context);
assertThat(response.getIncludedUrl()).isEqualTo(url);
model.forEach((key, value) -> verify(request).setAttribute(key, value));
}
use of cn.taketoday.web.mock.MockRequestDispatcher in project today-infrastructure by TAKETODAY.
the class InternalResourceViewTests method includeOnCommitted.
@Test
public void includeOnCommitted() throws Exception {
given(request.getRequestDispatcher(url)).willReturn(new MockRequestDispatcher(url));
response.setCommitted(true);
view.setUrl(url);
RequestContext context = new ServletRequestContext(null, request, response);
// Can now try multiple tests
view.render(model, context);
assertThat(response.getIncludedUrl()).isEqualTo(url);
model.forEach((k, v) -> verify(request).setAttribute(k, v));
}
Aggregations