Package org.springframework.web.method

Examples of org.springframework.web.method.HandlerMethod


  protected HandlerMethod getHandlerInternal(HttpServletRequest request) throws Exception {
    String lookupPath = getUrlPathHelper().getLookupPathForRequest(request);
    if (logger.isDebugEnabled()) {
      logger.debug("Looking up handler method for path " + lookupPath);
    }
    HandlerMethod handlerMethod = lookupHandlerMethod(lookupPath, request);
    if (logger.isDebugEnabled()) {
      if (handlerMethod != null) {
        logger.debug("Returning handler method [" + handlerMethod + "]");
      }
      else {
        logger.debug("Did not find handler method for [" + lookupPath + "]");
      }
    }
    return (handlerMethod != null ? handlerMethod.createWithResolvedBean() : null);
  }
View Full Code Here


  }

  @Test
  public void resolveNoExceptionHandlerForException() throws NoSuchMethodException {
    Exception npe = new NullPointerException();
    HandlerMethod handlerMethod = new HandlerMethod(new IoExceptionController(), "handle");
    this.resolver.afterPropertiesSet();
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, npe);

    assertNull("NPE should not have been handled", mav);
  }
View Full Code Here

  }

  @Test
  public void resolveExceptionModelAndView() throws NoSuchMethodException {
    IllegalArgumentException ex = new IllegalArgumentException("Bad argument");
    HandlerMethod handlerMethod = new HandlerMethod(new ModelAndViewController(), "handle");
    this.resolver.afterPropertiesSet();
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull(mav);
    assertFalse(mav.isEmpty());
View Full Code Here

  }

  @Test
  public void resolveExceptionResponseBody() throws UnsupportedEncodingException, NoSuchMethodException {
    IllegalArgumentException ex = new IllegalArgumentException();
    HandlerMethod handlerMethod = new HandlerMethod(new ResponseBodyController(), "handle");
    this.resolver.afterPropertiesSet();
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull(mav);
    assertTrue(mav.isEmpty());
View Full Code Here

  }

  @Test
  public void resolveExceptionResponseWriter() throws Exception {
    IllegalArgumentException ex = new IllegalArgumentException();
    HandlerMethod handlerMethod = new HandlerMethod(new ResponseWriterController(), "handle");
    this.resolver.afterPropertiesSet();
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull(mav);
    assertTrue(mav.isEmpty());
View Full Code Here

    AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext(MyConfig.class);
    this.resolver.setApplicationContext(cxt);
    this.resolver.afterPropertiesSet();

    IllegalAccessException ex = new IllegalAccessException();
    HandlerMethod handlerMethod = new HandlerMethod(new ResponseBodyController(), "handle");
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull("Exception was not handled", mav);
    assertTrue(mav.isEmpty());
    assertEquals("AnotherTestExceptionResolver: IllegalAccessException", this.response.getContentAsString());
View Full Code Here

    AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext(MyConfig.class);
    this.resolver.setApplicationContext(cxt);
    this.resolver.afterPropertiesSet();

    IllegalStateException ex = new IllegalStateException();
    HandlerMethod handlerMethod = new HandlerMethod(new ResponseBodyController(), "handle");
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull("Exception was not handled", mav);
    assertTrue(mav.isEmpty());
    assertEquals("TestExceptionResolver: IllegalStateException", this.response.getContentAsString());
View Full Code Here

    AnnotationConfigApplicationContext cxt = new AnnotationConfigApplicationContext(MyControllerAdviceConfig.class);
    this.resolver.setApplicationContext(cxt);
    this.resolver.afterPropertiesSet();

    IllegalStateException ex = new IllegalStateException();
    HandlerMethod handlerMethod = new HandlerMethod(new ResponseBodyController(), "handle");
    ModelAndView mav = this.resolver.resolveException(this.request, this.response, handlerMethod, ex);

    assertNotNull("Exception was not handled", mav);
    assertTrue(mav.isEmpty());
    assertEquals("BasePackageTestExceptionResolver: IllegalStateException", this.response.getContentAsString());
View Full Code Here

  @Test
  public void getNameExplicit() {

    Method method = ClassUtils.getMethod(TestController.class, "handle");
    HandlerMethod handlerMethod = new HandlerMethod(new TestController(), method);

    RequestMappingInfo rmi = new RequestMappingInfo("foo", null, null, null, null, null, null, null);

    HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();
View Full Code Here

  @Test
  public void getNameConvention() {

    Method method = ClassUtils.getMethod(TestController.class, "handle");
    HandlerMethod handlerMethod = new HandlerMethod(new TestController(), method);

    RequestMappingInfo rmi = new RequestMappingInfo(null, null, null, null, null, null, null, null);

    HandlerMethodMappingNamingStrategy strategy = new RequestMappingInfoHandlerMethodMappingNamingStrategy();
View Full Code Here

TOP

Related Classes of org.springframework.web.method.HandlerMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.