Search in sources :

Example 1 with MissingPathVariableException

use of org.springframework.web.bind.MissingPathVariableException in project spring-framework by spring-projects.

the class ResponseEntityExceptionHandlerTests method missingPathVariable.

@Test
public void missingPathVariable() throws NoSuchMethodException {
    Method method = getClass().getDeclaredMethod("handle", String.class);
    MethodParameter parameter = new MethodParameter(method, 0);
    Exception ex = new MissingPathVariableException("param", parameter);
    testException(ex);
}
Also used : MissingPathVariableException(org.springframework.web.bind.MissingPathVariableException) Method(java.lang.reflect.Method) HttpMethod(org.springframework.http.HttpMethod) MethodParameter(org.springframework.core.MethodParameter) MissingPathVariableException(org.springframework.web.bind.MissingPathVariableException) HttpMessageNotWritableException(org.springframework.http.converter.HttpMessageNotWritableException) NoHandlerFoundException(org.springframework.web.servlet.NoHandlerFoundException) MissingServletRequestPartException(org.springframework.web.multipart.support.MissingServletRequestPartException) BindException(org.springframework.validation.BindException) ConversionNotSupportedException(org.springframework.beans.ConversionNotSupportedException) AsyncRequestTimeoutException(org.springframework.web.context.request.async.AsyncRequestTimeoutException) MissingServletRequestParameterException(org.springframework.web.bind.MissingServletRequestParameterException) MethodArgumentNotValidException(org.springframework.web.bind.MethodArgumentNotValidException) ServletRequestBindingException(org.springframework.web.bind.ServletRequestBindingException) TypeMismatchException(org.springframework.beans.TypeMismatchException) HttpMessageNotReadableException(org.springframework.http.converter.HttpMessageNotReadableException) HttpMediaTypeNotSupportedException(org.springframework.web.HttpMediaTypeNotSupportedException) HttpRequestMethodNotSupportedException(org.springframework.web.HttpRequestMethodNotSupportedException) HttpMediaTypeNotAcceptableException(org.springframework.web.HttpMediaTypeNotAcceptableException) Test(org.junit.Test)

Example 2 with MissingPathVariableException

use of org.springframework.web.bind.MissingPathVariableException in project spring-framework by spring-projects.

the class DefaultHandlerExceptionResolverTests method handleMissingPathVariable.

@Test
public void handleMissingPathVariable() throws NoSuchMethodException {
    Method method = getClass().getMethod("handle", String.class);
    MethodParameter parameter = new MethodParameter(method, 0);
    MissingPathVariableException ex = new MissingPathVariableException("foo", parameter);
    ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex);
    assertNotNull("No ModelAndView returned", mav);
    assertTrue("No Empty ModelAndView returned", mav.isEmpty());
    assertEquals("Invalid status code", 500, response.getStatus());
    assertEquals("Missing URI template variable 'foo' for method parameter of type String", response.getErrorMessage());
}
Also used : MissingPathVariableException(org.springframework.web.bind.MissingPathVariableException) ModelAndView(org.springframework.web.servlet.ModelAndView) Method(java.lang.reflect.Method) MethodParameter(org.springframework.core.MethodParameter) Test(org.junit.Test)

Aggregations

Method (java.lang.reflect.Method)2 Test (org.junit.Test)2 MethodParameter (org.springframework.core.MethodParameter)2 MissingPathVariableException (org.springframework.web.bind.MissingPathVariableException)2 ConversionNotSupportedException (org.springframework.beans.ConversionNotSupportedException)1 TypeMismatchException (org.springframework.beans.TypeMismatchException)1 HttpMethod (org.springframework.http.HttpMethod)1 HttpMessageNotReadableException (org.springframework.http.converter.HttpMessageNotReadableException)1 HttpMessageNotWritableException (org.springframework.http.converter.HttpMessageNotWritableException)1 BindException (org.springframework.validation.BindException)1 HttpMediaTypeNotAcceptableException (org.springframework.web.HttpMediaTypeNotAcceptableException)1 HttpMediaTypeNotSupportedException (org.springframework.web.HttpMediaTypeNotSupportedException)1 HttpRequestMethodNotSupportedException (org.springframework.web.HttpRequestMethodNotSupportedException)1 MethodArgumentNotValidException (org.springframework.web.bind.MethodArgumentNotValidException)1 MissingServletRequestParameterException (org.springframework.web.bind.MissingServletRequestParameterException)1 ServletRequestBindingException (org.springframework.web.bind.ServletRequestBindingException)1 AsyncRequestTimeoutException (org.springframework.web.context.request.async.AsyncRequestTimeoutException)1 MissingServletRequestPartException (org.springframework.web.multipart.support.MissingServletRequestPartException)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 NoHandlerFoundException (org.springframework.web.servlet.NoHandlerFoundException)1