@Test
public void testGetSignedUrl() throws IOException, UrlSigningException {

  HttpGet notAccepted = new HttpGet("http://notAccepted.com");
  HttpGet alreadySigned = new HttpGet("http://alreadySigned.com?signature=thesignature&keyId=theKeyId&policy=thePolicy");
  HttpPost notGetOrHead = new HttpPost("http://notGetOrHead.com");
  HttpGet ok = new HttpGet("http://ok.com");
  String signedOk = "http://ok.com?signature=thesignature&keyId=theKeyId&policy=thePolicy";
  // Setup signing service
  UrlSigningService urlSigningService = EasyMock.createMock(UrlSigningService.class);
  EasyMock.expect(urlSigningService.accepts(notAccepted.getURI().toString())).andReturn(false);
  EasyMock.expect(urlSigningService.accepts(alreadySigned.getURI().toString())).andReturn(true);
  EasyMock.expect(urlSigningService.accepts(notGetOrHead.getURI().toString())).andReturn(true);
  EasyMock.expect(urlSigningService.accepts(ok.getURI().toString())).andReturn(true);
  EasyMock.expect(
          urlSigningService.sign(ok.getURI().toString(), TrustedHttpClientImpl.DEFAULT_URL_SIGNING_EXPIRES_DURATION,
                  null, null)).andReturn(signedOk);
  EasyMock.replay(urlSigningService);
  client = new TrustedHttpClientImpl("user", "pass");
  client.setUrlSigningService(urlSigningService);
  assertTrue(client.getSignedUrl(notAccepted).isNone());
  assertTrue(client.getSignedUrl(notGetOrHead).isNone());
  Opt<HttpUriRequest> result = client.getSignedUrl(ok);
  assertTrue(result.isSome());
  assertEquals(signedOk, result.get().getURI().toString());
}