aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2013-05-31 10:14:40 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2013-05-31 10:14:40 +0200
commit942d823359234eb9cdd9e42c33235d2a5e96375b (patch)
treecb6e262f52a1cb8d23b7c9632e766f842de424f7 /sonar-ws-client
parent4f4091d09b31b18c3053518c84dff26e3a6d48ce (diff)
downloadsonarqube-942d823359234eb9cdd9e42c33235d2a5e96375b.tar.gz
sonarqube-942d823359234eb9cdd9e42c33235d2a5e96375b.zip
Support HTTP proxy in new ws-client
Diffstat (limited to 'sonar-ws-client')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java73
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java101
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java41
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java22
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java14
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultIssueClientTest.java22
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java2
7 files changed, 234 insertions, 41 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java
index 12b71f21aff..1ecc19f01ab 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java
@@ -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;
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
index 2c3d26e135f..4d10be6f043 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
@@ -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) {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java
index 9c9acbbbd55..8216d88767e 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java
@@ -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");
+ }
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java
index bcba002682f..43575e83b5f 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java
@@ -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
+ }
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java
index a9b29aa8370..d6597c2e918 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java
@@ -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);
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultIssueClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultIssueClientTest.java
index ae0d4c587ba..41118a61ff9 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultIssueClientTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultIssueClientTest.java
@@ -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);
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java
index b559b693dfc..716802c6fde 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java
@@ -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);