Example usage for org.springframework.web.servlet.view AbstractView AbstractView

List of usage examples for org.springframework.web.servlet.view AbstractView AbstractView

Introduction

In this page you can find the example usage for org.springframework.web.servlet.view AbstractView AbstractView.

Prototype

AbstractView

Source Link

Usage

From source file:org.jnap.core.mvc.async.AsyncResponseModel.java

protected AsyncResponseModel() {
    super(new AbstractView() {
        @Override//  w w w .j av a  2 s .co  m
        protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
                HttpServletResponse response) throws Exception {
            // do nothing, async stream will handle the response
        }
    });
    init();
}

From source file:ar.com.zauber.commons.spring.exceptions.HeaderBasedStatusSimpleMappingExceptionHandlerTest.java

/** test */
public final void testFoo() {
    final Properties views = new Properties();
    views.put(NotOwnerException.class.getName(), "notowner");
    views.put(IllegalArgumentException.class.getName(), "arguments");
    views.put(DataAccessResourceFailureException.class.getName(), "data");

    final Properties status = new Properties();
    status.put("arguments", "400");
    status.put("notowner", "403");
    status.put("data", "500");

    AbstractView view = new AbstractView() {
        @Override/* w w w  .j a v  a2  s  .c  o m*/
        protected void renderMergedOutputModel(final Map<String, Object> model,
                final HttpServletRequest request, final HttpServletResponse response) throws Exception {
        }
    };
    view.setBeanName("test");
    final HeaderBasedStatusSimpleMappingExceptionHandler h = new HeaderBasedStatusSimpleMappingExceptionHandler(
            view, "application/json");

    h.setDefaultStatusCode(200);
    h.setExceptionMappings(views);
    h.setStatusMappings(status);
    h.setDefaultErrorView("default");

    MockHttpServletResponse response;
    ModelAndView v;

    response = new MockHttpServletResponse();

    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("Accept", "application/json");

    v = h.resolveException(request, response, null, new IllegalArgumentException("io!io!"));
    assertEquals(view, v.getView());
    assertEquals(400, response.getStatus());
}