@Test public void handleRedirect() throws Exception { ODataServlet servlet = new ODataServlet(); prepareServlet(servlet); prepareRequest(reqMock); servlet.service(reqMock, respMock); Mockito.verify(respMock).setStatus(HttpStatusCodes.TEMPORARY_REDIRECT.getStatusCode()); Mockito.verify(respMock).setHeader(HttpHeaders.LOCATION, "/context-path/servlet-path/"); }
protected void handleRedirect(final HttpServletRequest req, final HttpServletResponse resp, ODataServiceFactory serviceFactory) throws IOException { String method = req.getMethod(); if (ODataHttpMethod.GET.name().equals(method) || ODataHttpMethod.POST.name().equals(method) || ODataHttpMethod.PUT.name().equals(method) || ODataHttpMethod.DELETE.name().equals(method) || ODataHttpMethod.PATCH.name().equals(method) || ODataHttpMethod.MERGE.name().equals(method) || HTTP_METHOD_HEAD.equals(method) || HTTP_METHOD_OPTIONS.equals(method)) { ODataResponse odataResponse = ODataResponse.status(HttpStatusCodes.TEMPORARY_REDIRECT) .header(HttpHeaders.LOCATION, createLocation(req)) .build(); createResponse(resp, odataResponse); } else { createNotImplementedResponse(req, ODataHttpException.COMMON, resp, serviceFactory); } }
ODataServlet extends HttpServlet { protected void handleRedirect(final HttpServletRequest req, final HttpServletResponse resp, ODataServiceFactory serviceFactory) throws IOException { String method = req.getMethod(); if (ODataHttpMethod.GET.name().equals(method) || ODataHttpMethod.POST.name().equals(method) || ODataHttpMethod.PUT.name().equals(method) || ODataHttpMethod.DELETE.name().equals(method) || ODataHttpMethod.PATCH.name().equals(method) || ODataHttpMethod.MERGE.name().equals(method) || HTTP_METHOD_HEAD.equals(method) || HTTP_METHOD_OPTIONS.equals(method)) { ODataResponse odataResponse = ODataResponse.status(HttpStatusCodes.TEMPORARY_REDIRECT) .header(HttpHeaders.LOCATION, createLocation(req)) .build(); createResponse(resp, odataResponse); } else { createNotImplementedResponse(req, ODataHttpException.COMMON, resp, serviceFactory); } } }
ODataServlet extends HttpServlet { protected void handleRedirect(final HttpServletRequest req, final HttpServletResponse resp, ODataServiceFactory serviceFactory) throws IOException { String method = req.getMethod(); if (ODataHttpMethod.GET.name().equals(method) || ODataHttpMethod.POST.name().equals(method) || ODataHttpMethod.PUT.name().equals(method) || ODataHttpMethod.DELETE.name().equals(method) || ODataHttpMethod.PATCH.name().equals(method) || ODataHttpMethod.MERGE.name().equals(method) || HTTP_METHOD_HEAD.equals(method) || HTTP_METHOD_OPTIONS.equals(method)) { ODataResponse odataResponse = ODataResponse.status(HttpStatusCodes.TEMPORARY_REDIRECT) .header(HttpHeaders.LOCATION, createLocation(req)) .build(); createResponse(resp, odataResponse); } else { createNotImplementedResponse(req, ODataHttpException.COMMON, resp, serviceFactory); } }  }
ODataServlet extends HttpServlet { protected void handleRedirect(final HttpServletRequest req, final HttpServletResponse resp, ODataServiceFactory serviceFactory) throws IOException { String method = req.getMethod(); if (ODataHttpMethod.GET.name().equals(method) || ODataHttpMethod.POST.name().equals(method) || ODataHttpMethod.PUT.name().equals(method) || ODataHttpMethod.DELETE.name().equals(method) || ODataHttpMethod.PATCH.name().equals(method) || ODataHttpMethod.MERGE.name().equals(method) || HTTP_METHOD_HEAD.equals(method) || HTTP_METHOD_OPTIONS.equals(method)) { ODataResponse odataResponse = ODataResponse.status(HttpStatusCodes.TEMPORARY_REDIRECT) .header(HttpHeaders.LOCATION, createLocation(req)) .build(); createResponse(resp, odataResponse); } else { createNotImplementedResponse(req, ODataHttpException.COMMON, resp, serviceFactory); } }   }
ODataServlet extends HttpServlet { protected void handleRedirect(final HttpServletRequest req, final HttpServletResponse resp, ODataServiceFactory serviceFactory) throws IOException { String method = req.getMethod(); if (ODataHttpMethod.GET.name().equals(method) || ODataHttpMethod.POST.name().equals(method) || ODataHttpMethod.PUT.name().equals(method) || ODataHttpMethod.DELETE.name().equals(method) || ODataHttpMethod.PATCH.name().equals(method) || ODataHttpMethod.MERGE.name().equals(method) || HTTP_METHOD_HEAD.equals(method) || HTTP_METHOD_OPTIONS.equals(method)) { ODataResponse odataResponse = ODataResponse.status(HttpStatusCodes.TEMPORARY_REDIRECT) .header(HttpHeaders.LOCATION, createLocation(req)) .build(); createResponse(resp, odataResponse); } else { createNotImplementedResponse(req, ODataHttpException.COMMON, resp, serviceFactory); } }    }