Example usage for org.springframework.mock.web MockHttpServletRequest getRequestURI

List of usage examples for org.springframework.mock.web MockHttpServletRequest getRequestURI

Introduction

In this page you can find the example usage for org.springframework.mock.web MockHttpServletRequest getRequestURI.

Prototype

@Override
    @Nullable
    public String getRequestURI() 

Source Link

Usage

From source file:org.cloudifysource.rest.ControllerTest.java

/**
 * This method finds the handler for a given request URI. It will also ensure that the URI Parameters i.e.
 * /context/test/{name} are added to the request
 *
 * @param request//from w w  w  . j  a va2  s  . c o m
 *            The request object to be used
 * @return The correct handler for the request
 * @throws Exception
 *             Indicates a matching handler could not be found
 */
private HandlerExecutionChain getHandlerToRequest(final MockHttpServletRequest request) throws Exception {
    HandlerExecutionChain chain = null;

    final Map<String, HandlerMapping> map = applicationContext.getBeansOfType(HandlerMapping.class);

    for (final HandlerMapping mapping : map.values()) {
        chain = mapping.getHandler(request);

        if (chain != null) {
            break;
        }
    }

    if (chain == null) {
        throw new InvalidParameterException(
                "Unable to find handler for request URI: " + request.getRequestURI());
    }
    return chain;
}