@Test(expected=InterceptionException.class) public void shouldThrowInterceptionExceptionIfAnIOExceptionOccurs() throws Exception { doThrow(new IOException()).when(response).sendError(anyInt()); this.handler.deny(request, EnumSet.of(HttpMethod.GET, HttpMethod.POST)); }
public void deny(RequestInfo request, Set<HttpMethod> allowedMethods) { request.getResponse().addHeader( "Allow", allowedMethods.toString().replaceAll("\\[|\\]", "")); try { if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) { request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new InterceptionException(e); } }
DefaultMethodNotAllowedHandler implements MethodNotAllowedHandler { public void deny(RequestInfo request, Set<HttpMethod> allowedMethods) { request.getResponse().addHeader( "Allow", allowedMethods.toString().replaceAll("\\[|\\]", "")); try { if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) { request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new InterceptionException(e); } } }
DefaultMethodNotAllowedHandler implements MethodNotAllowedHandler { public void deny(RequestInfo request, Set<HttpMethod> allowedMethods) { request.getResponse().addHeader( "Allow", allowedMethods.toString().replaceAll("\\[|\\]", "")); try { if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) { request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new InterceptionException(e); } }  }
DefaultMethodNotAllowedHandler implements MethodNotAllowedHandler { public void deny(RequestInfo request, Set<HttpMethod> allowedMethods) { request.getResponse().addHeader( "Allow", allowedMethods.toString().replaceAll("\\[|\\]", "")); try { if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) { request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new InterceptionException(e); } }  void deny(RequestInfo request, Set<HttpMethod> allowedMethods); }
DefaultMethodNotAllowedHandler implements MethodNotAllowedHandler { public void deny(RequestInfo request, Set<HttpMethod> allowedMethods) { request.getResponse().addHeader( "Allow", allowedMethods.toString().replaceAll("\\[|\\]", "")); try { if (!"OPTIONS".equalsIgnoreCase(request.getRequest().getMethod())) { request.getResponse().sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } } catch (IOException e) { throw new InterceptionException(e); } }  void deny(RequestInfo request, Set<HttpMethod> allowedMethods);  }