]> source.dussan.org Git - sonarqube.git/commitdiff
Support HTTP proxy in new ws-client
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 31 May 2013 08:14:40 +0000 (10:14 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 31 May 2013 08:14:40 +0000 (10:14 +0200)
pom.xml
sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java
sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultIssueClientTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java

diff --git a/pom.xml b/pom.xml
index 5c62f24936e3c160dc65fe0f5763ca8d5585b3a4..73cac67243df86b38ec6d70802fa8cfd459e6f89 100644 (file)
--- a/pom.xml
+++ b/pom.xml
       <dependency>
         <groupId>com.github.kevinsawicki</groupId>
         <artifactId>http-request</artifactId>
-        <version>4.1</version>
+        <version>5.1</version>
       </dependency>
     </dependencies>
   </dependencyManagement>
index 12b71f21aff62840295b7286e23a3dd01d731f18..1ecc19f01aba93a89838ae3c81b6db4357f27bf8 100644 (file)
@@ -27,15 +27,31 @@ import org.sonar.wsclient.issue.IssueClient;
 import org.sonar.wsclient.user.DefaultUserClient;
 import org.sonar.wsclient.user.UserClient;
 
+import javax.annotation.Nullable;
+
 /**
  * @since 3.6
  */
 public class SonarClient {
 
-  private final HttpRequestFactory requestFactory;
+  public static final int DEFAULT_CONNECT_TIMEOUT_MILLISECONDS = 30000;
+  public static final int DEFAULT_READ_TIMEOUT_MILLISECONDS = 60000;
+
+  /**
+   * Visibility relaxed for unit tests
+   */
+  final HttpRequestFactory requestFactory;
 
   private SonarClient(Builder builder) {
-    requestFactory = new HttpRequestFactory(builder.url, builder.login, builder.password);
+    requestFactory = new HttpRequestFactory(builder.url)
+      .setLogin(builder.login)
+      .setPassword(builder.password)
+      .setProxyHost(builder.proxyHost)
+      .setProxyPort(builder.proxyPort)
+      .setProxyLogin(builder.proxyLogin)
+      .setProxyPassword(builder.proxyPassword)
+      .setConnectTimeoutInMilliseconds(builder.connectTimeoutMs)
+      .setReadTimeoutInMilliseconds(builder.readTimeoutMs);
   }
 
   public IssueClient issueClient() {
@@ -54,24 +70,67 @@ public class SonarClient {
     return new Builder();
   }
 
+  /**
+   * Create a client with default configuration. Use {@link #builder()} to define a custom configuration.
+   */
+  public static SonarClient create(String serverUrl) {
+    return builder().url(serverUrl).build();
+  }
+
   public static class Builder {
-    private String login, password, url;
+    private String login, password, url, proxyHost, proxyLogin, proxyPassword;
+    private int proxyPort = 0;
+    private int connectTimeoutMs = DEFAULT_CONNECT_TIMEOUT_MILLISECONDS, readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLISECONDS;
 
     private Builder() {
     }
 
-    public Builder login(String login) {
+    public Builder url(String url) {
+      this.url = url;
+      return this;
+    }
+
+    public Builder login(@Nullable String login) {
       this.login = login;
       return this;
     }
 
-    public Builder password(String password) {
+    public Builder password(@Nullable String password) {
       this.password = password;
       return this;
     }
 
-    public Builder url(String url) {
-      this.url = url;
+    public Builder proxy(String proxyHost, int proxyPort) {
+      this.proxyHost = proxyHost;
+      this.proxyPort = proxyPort;
+      return this;
+    }
+
+    public Builder proxyLogin(@Nullable String proxyLogin) {
+      this.proxyLogin = proxyLogin;
+      return this;
+    }
+
+    public Builder proxyPassword(@Nullable String proxyPassword) {
+      this.proxyPassword = proxyPassword;
+      return this;
+    }
+
+    /**
+     * Sets a specified timeout value, in milliseconds, to be used when opening HTTP connection.
+     * A timeout of zero is interpreted as an infinite timeout. Default value is {@link SonarClient#DEFAULT_CONNECT_TIMEOUT_MILLISECONDS}
+     */
+    public Builder connectTimeoutMilliseconds(int i) {
+      this.connectTimeoutMs = i;
+      return this;
+    }
+
+    /**
+     * Sets the read timeout to a specified timeout, in milliseconds.
+     * A timeout of zero is interpreted as an infinite timeout. Default value is {@link SonarClient#DEFAULT_READ_TIMEOUT_MILLISECONDS}
+     */
+    public Builder readTimeoutMilliseconds(int i) {
+      this.readTimeoutMs = i;
       return this;
     }
 
index 2c3d26e135f8cde6db194369b44fe67845713b8d..4d10be6f04318f2e9f687d3c7073bb2a69061168 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.wsclient.internal;
 
 import com.github.kevinsawicki.http.HttpRequest;
 
+import javax.annotation.Nullable;
 import java.util.Map;
 
 /**
@@ -28,36 +29,116 @@ import java.util.Map;
  */
 public class HttpRequestFactory {
 
-  static final int CONNECT_TIMEOUT_MILLISECONDS = 30000;
-  static final int READ_TIMEOUT_MILLISECONDS = 60000;
+  private final String baseUrl;
+  private String login, password, proxyHost, proxyLogin, proxyPassword;
+  private int proxyPort;
+  private int connectTimeoutInMilliseconds;
+  private int readTimeoutInMilliseconds;
 
-  private final String baseURl;
-  private final String login, password;
+  public HttpRequestFactory(String baseUrl) {
+    this.baseUrl = baseUrl;
+  }
 
-  public HttpRequestFactory(String baseURl, String login, String password) {
-    this.baseURl = baseURl;
+  public HttpRequestFactory setLogin(@Nullable String login) {
     this.login = login;
+    return this;
+  }
+
+  public HttpRequestFactory setPassword(@Nullable String password) {
     this.password = password;
+    return this;
+  }
+
+  public HttpRequestFactory setProxyHost(@Nullable String proxyHost) {
+    this.proxyHost = proxyHost;
+    return this;
+  }
+
+  public HttpRequestFactory setProxyLogin(@Nullable String proxyLogin) {
+    this.proxyLogin = proxyLogin;
+    return this;
+  }
+
+  public HttpRequestFactory setProxyPassword(@Nullable String proxyPassword) {
+    this.proxyPassword = proxyPassword;
+    return this;
+  }
+
+  public HttpRequestFactory setProxyPort(int proxyPort) {
+    this.proxyPort = proxyPort;
+    return this;
+  }
+
+  public HttpRequestFactory setConnectTimeoutInMilliseconds(int connectTimeoutInMilliseconds) {
+    this.connectTimeoutInMilliseconds = connectTimeoutInMilliseconds;
+    return this;
+  }
+
+  public HttpRequestFactory setReadTimeoutInMilliseconds(int readTimeoutInMilliseconds) {
+    this.readTimeoutInMilliseconds = readTimeoutInMilliseconds;
+    return this;
+  }
+
+  public String getBaseUrl() {
+    return baseUrl;
+  }
+
+  public String getLogin() {
+    return login;
+  }
+
+  public String getPassword() {
+    return password;
+  }
+
+  public String getProxyHost() {
+    return proxyHost;
+  }
+
+  public String getProxyLogin() {
+    return proxyLogin;
+  }
+
+  public String getProxyPassword() {
+    return proxyPassword;
+  }
+
+  public int getProxyPort() {
+    return proxyPort;
+  }
+
+  public int getConnectTimeoutInMilliseconds() {
+    return connectTimeoutInMilliseconds;
+  }
+
+  public int getReadTimeoutInMilliseconds() {
+    return readTimeoutInMilliseconds;
   }
 
   public HttpRequest get(String wsUrl, Map<String, Object> queryParams) {
-    HttpRequest request = HttpRequest.get(baseURl + wsUrl, queryParams, true);
+    HttpRequest request = HttpRequest.get(baseUrl + wsUrl, queryParams, true);
     return prepare(request);
   }
 
   public HttpRequest post(String wsUrl, Map<String, Object> queryParams) {
-    HttpRequest request = HttpRequest.post(baseURl + wsUrl, queryParams, true);
+    HttpRequest request = HttpRequest.post(baseUrl + wsUrl, queryParams, true);
     return prepare(request);
   }
 
   private HttpRequest prepare(HttpRequest request) {
+    if (proxyHost != null) {
+      request.useProxy(proxyHost, proxyPort);
+      if (proxyLogin != null) {
+        request.proxyBasic(proxyLogin, proxyPassword);
+      }
+    }
     request
       .acceptGzipEncoding()
       .uncompress(true)
       .acceptJson()
       .acceptCharset(HttpRequest.CHARSET_UTF8)
-      .connectTimeout(CONNECT_TIMEOUT_MILLISECONDS)
-      .readTimeout(READ_TIMEOUT_MILLISECONDS)
+      .connectTimeout(connectTimeoutInMilliseconds)
+      .readTimeout(readTimeoutInMilliseconds)
       .trustAllCerts()
       .trustAllCerts();
     if (login != null) {
index 9c9acbbbd552ff6e93a3510b577d240ad0b315e5..8216d88767e7264806347bade293ea76153f1216 100644 (file)
@@ -30,7 +30,7 @@ import static org.fest.assertions.Fail.fail;
 public class SonarClientTest {
   @Test
   public void should_build_clients() {
-    SonarClient client = SonarClient.builder().url("http://localhost:9000").build();
+    SonarClient client = SonarClient.create("http://localhost:9000");
     assertThat(client.issueClient()).isNotNull().isInstanceOf(DefaultIssueClient.class);
     assertThat(client.actionPlanClient()).isNotNull().isInstanceOf(DefaultActionPlanClient.class);
     assertThat(client.userClient()).isNotNull().isInstanceOf(DefaultUserClient.class);
@@ -49,10 +49,47 @@ public class SonarClientTest {
   @Test
   public void url_should_not_be_empty() {
     try {
-      SonarClient.builder().url("").build();
+      SonarClient.create("");
       fail();
     } catch (IllegalStateException e) {
       assertThat(e).hasMessage("Server URL must be set");
     }
   }
+
+  @Test
+  public void test_default_configuration() throws Exception {
+    SonarClient client = SonarClient.create("http://localhost:9000");
+    assertThat(client.requestFactory.getBaseUrl()).isEqualTo("http://localhost:9000");
+    assertThat(client.requestFactory.getLogin()).isNull();
+    assertThat(client.requestFactory.getPassword()).isNull();
+    assertThat(client.requestFactory.getConnectTimeoutInMilliseconds()).isEqualTo(SonarClient.DEFAULT_CONNECT_TIMEOUT_MILLISECONDS);
+    assertThat(client.requestFactory.getReadTimeoutInMilliseconds()).isEqualTo(SonarClient.DEFAULT_READ_TIMEOUT_MILLISECONDS);
+    assertThat(client.requestFactory.getProxyHost()).isNull();
+    assertThat(client.requestFactory.getProxyPort()).isEqualTo(0);
+    assertThat(client.requestFactory.getProxyLogin()).isNull();
+    assertThat(client.requestFactory.getProxyPassword()).isNull();
+
+  }
+
+  @Test
+  public void test_custom_configuration() throws Exception {
+    SonarClient client = SonarClient.builder().url("http://localhost:9000")
+      .login("eric")
+      .password("pass")
+      .connectTimeoutMilliseconds(12345)
+      .readTimeoutMilliseconds(6789)
+      .proxy("localhost", 2052)
+      .proxyLogin("proxyLogin")
+      .proxyPassword("proxyPass")
+      .build();
+    assertThat(client.requestFactory.getBaseUrl()).isEqualTo("http://localhost:9000");
+    assertThat(client.requestFactory.getLogin()).isEqualTo("eric");
+    assertThat(client.requestFactory.getPassword()).isEqualTo("pass");
+    assertThat(client.requestFactory.getConnectTimeoutInMilliseconds()).isEqualTo(12345);
+    assertThat(client.requestFactory.getReadTimeoutInMilliseconds()).isEqualTo(6789);
+    assertThat(client.requestFactory.getProxyHost()).isEqualTo("localhost");
+    assertThat(client.requestFactory.getProxyPort()).isEqualTo(2052);
+    assertThat(client.requestFactory.getProxyLogin()).isEqualTo("proxyLogin");
+    assertThat(client.requestFactory.getProxyPassword()).isEqualTo("proxyPass");
+  }
 }
index bcba002682f4dc443970de2f1b078c3634136088..43575e83b5fff7a48ccd13f92ec876178c73e1bf 100644 (file)
@@ -36,7 +36,7 @@ public class HttpRequestFactoryTest {
   public void test_get() {
     httpServer.doReturnStatus(200).doReturnBody("list of issues");
 
-    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url());
     HttpRequest request = factory.get("/api/issues", Collections.<String, Object>emptyMap());
 
     assertThat(request.method()).isEqualTo("GET");
@@ -49,7 +49,7 @@ public class HttpRequestFactoryTest {
   public void test_post() {
     httpServer.doReturnStatus(200);
 
-    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url());
     HttpRequest request = factory.post("/api/issues/change", Collections.<String, Object>emptyMap());
 
     assertThat(request.method()).isEqualTo("POST");
@@ -61,7 +61,7 @@ public class HttpRequestFactoryTest {
   public void test_authentication() {
     httpServer.doReturnStatus(200).doReturnBody("list of issues");
 
-    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url(), "karadoc", "legrascestlavie");
+    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url()).setLogin("karadoc").setPassword("legrascestlavie");
     HttpRequest request = factory.get("/api/issues", Collections.<String, Object>emptyMap());
 
     assertThat(request.body()).isEqualTo("list of issues");
@@ -69,4 +69,20 @@ public class HttpRequestFactoryTest {
     assertThat(httpServer.requestedPath()).isEqualTo("/api/issues");
     assertThat(httpServer.requestHeaders().get("Authorization")).isEqualTo("Basic a2FyYWRvYzpsZWdyYXNjZXN0bGF2aWU=");
   }
+
+  @Test
+  public void test_proxy() throws Exception {
+    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url()).setProxyHost("localhost").setProxyPort(5020);
+    HttpRequest request = factory.get("/api/issues", Collections.<String, Object>emptyMap());
+    // it's not possible to check that the proxy is correctly configured
+  }
+
+  @Test
+  public void test_proxy_credentials() throws Exception {
+    HttpRequestFactory factory = new HttpRequestFactory(httpServer.url())
+      .setProxyHost("localhost").setProxyPort(5020)
+      .setProxyLogin("john").setProxyPassword("smith");
+    HttpRequest request = factory.get("/api/issues", Collections.<String, Object>emptyMap());
+    // it's not possible to check that the proxy is correctly configured
+  }
 }
index a9b29aa8370d5f4b045820606021fc73a27c7a7b..d6597c2e91817d265f4e418e16456f13019040ec 100644 (file)
@@ -37,7 +37,7 @@ public class DefaultActionPlanClientTest {
 
   @Test
   public void should_find_action_plans() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"actionPlans\": [{\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\",\n" +
                               "\"name\": \"Long term\",\n" +
                               "\"status\": \"CLOSED\",\n" +
@@ -69,7 +69,7 @@ public class DefaultActionPlanClientTest {
 
   @Test
   public void should_create_action_plan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"actionPlan\": {\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\"}}");
 
     ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
@@ -81,7 +81,7 @@ public class DefaultActionPlanClientTest {
 
   @Test
   public void should_update_action_plan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"actionPlan\": {\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\"}}");
 
     ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
@@ -93,7 +93,7 @@ public class DefaultActionPlanClientTest {
 
   @Test
   public void should_delete_action_plan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
 
     ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
     client.delete("382f6f2e-ad9d-424a-b973-9b065e04348a");
@@ -103,7 +103,7 @@ public class DefaultActionPlanClientTest {
 
   @Test
   public void should_fail_to_delete_action_plan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnStatus(500);
 
     ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
@@ -117,7 +117,7 @@ public class DefaultActionPlanClientTest {
 
   @Test
   public void should_open_action_plan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"actionPlan\": {\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\"}}");
 
     ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
@@ -129,7 +129,7 @@ public class DefaultActionPlanClientTest {
 
   @Test
   public void should_close_action_plan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"actionPlan\": {\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\"}}");
 
     ActionPlanClient client = new DefaultActionPlanClient(requestFactory);
index ae0d4c587ba1fe8f614cfb1eeb5a21516ed74c87..41118a61ff9388736a6dc9f0b06e37f03ad260d2 100644 (file)
@@ -36,7 +36,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_find_issues() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issues\": [{\"key\": \"ABCDE\"}]}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -50,7 +50,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_fail_to_find_issues() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnStatus(500);
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -64,7 +64,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_set_severity() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issue\": {\"key\": \"ABCDE\"}}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -76,7 +76,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_assign() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issue\": {\"key\": \"ABCDE\"}}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -88,7 +88,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_unassign() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issue\": {\"key\": \"ABCDE\"}}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -100,7 +100,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_plan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issue\": {\"key\": \"ABCDE\"}}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -112,7 +112,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_unplan() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issue\": {\"key\": \"ABCDE\"}}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -124,7 +124,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_create_issue() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issue\": {\"key\": \"ABCDE\"}}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -136,7 +136,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_get_transitions() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\n" +
       "  \"transitions\": [\n" +
       "    \"resolve\",\n" +
@@ -154,7 +154,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_apply_transition() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"issue\": {\"key\": \"ABCDE\"}}");
 
     IssueClient client = new DefaultIssueClient(requestFactory);
@@ -166,7 +166,7 @@ public class DefaultIssueClientTest {
 
   @Test
   public void should_add_comment() throws Exception {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody(IOUtils.toString(getClass().getResourceAsStream("/org/sonar/wsclient/issue/DefaultIssueClientTest/add_comment_result.json")));
 
     IssueClient client = new DefaultIssueClient(requestFactory);
index b559b693dfcaaafe73467bf2b657cbad3dd7f693..716802c6fde886c5eb7af2977b8952b9d7b68054 100644 (file)
@@ -34,7 +34,7 @@ public class DefaultUserClientTest {
 
   @Test
   public void should_find_issues() {
-    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null);
+    HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url());
     httpServer.doReturnBody("{\"users\": [{\"login\": \"simon\", \"name\": \"Simon\", \"active\": true}]}");
 
     UserClient client = new DefaultUserClient(requestFactory);