@Test(expected = HttpResponseException.class) public void testExpectationFailedTwice() throws ClientProtocolException, IOException { final String uri = "http://example.com/"; final HttpPut request = new HttpPut(uri); final SardineHttpClientImpl sardine = new SardineHttpClientImpl(new DefaultHttpClient()) { /** {@inheritDoc} */ @Override <T> T wrapResponseHandlerExceptions( HttpRequestBase request, ResponseHandler<T> responseHandler) throws IOException { throw new HttpResponseException(HttpStatus.SC_EXPECTATION_FAILED, "Expectation failed"); } }; sardine.put(uri, request, new StringEntity("hallo"), "text/xml", true); }