diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-12-02 11:40:43 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-12-02 14:16:49 +0100 |
commit | 92b68fdb6bca9347e153424fb4f79ceae400fc3d (patch) | |
tree | 78c7cd28e588d4f69c37575d7d84d14c0e45ec1f /sonar-ws | |
parent | b4201256a7e4d8b153ecf0cb074f6e264df67f17 (diff) | |
download | sonarqube-92b68fdb6bca9347e153424fb4f79ceae400fc3d.tar.gz sonarqube-92b68fdb6bca9347e153424fb4f79ceae400fc3d.zip |
ws-client should not throw HttpException by default
Diffstat (limited to 'sonar-ws')
15 files changed, 112 insertions, 223 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseResponse.java index 8b9789bcf15..d649f618aa1 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/package-info.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseResponse.java @@ -17,9 +17,21 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +package org.sonarqube.ws.client; -@ParametersAreNonnullByDefault -package org.sonarqube.ws.client.ce; +abstract class BaseResponse implements WsResponse { -import javax.annotation.ParametersAreNonnullByDefault; + @Override + public boolean isSuccessful() { + return code() >= 200 && code() < 300; + } + @Override + public WsResponse failIfNotSuccessful() { + if (!isSuccessful()) { + throw new HttpException(requestUrl(), code()); + } + return this; + } + +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java index 11d4d006419..fea0cecd615 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/BaseService.java @@ -40,20 +40,20 @@ public abstract class BaseService { protected <T extends Message> T call(BaseRequest request, Parser<T> parser) { request.setMediaType(MediaTypes.PROTOBUF); - WsResponse response = wsConnector.call(request); + WsResponse response = call(request); return convert(response, parser); } protected WsResponse call(WsRequest request) { - return wsConnector.call(request); + return wsConnector.call(request).failIfNotSuccessful(); } public <T extends Message> T convert(WsResponse response, Parser<T> parser) { - try (InputStream byteStream = response.getContentStream()) { + try (InputStream byteStream = response.contentStream()) { // HTTP header "Content-Type" is not verified. It may be different than protobuf. return parser.parseFrom(byteStream); } catch (Exception e) { - throw new IllegalStateException("Fail to parse protobuf response of " + response.getRequestUrl(), e); + throw new IllegalStateException("Fail to parse protobuf response of " + response.requestUrl(), e); } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java index 7f46d08cacb..c76672924c5 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpConnector.java @@ -23,7 +23,6 @@ import com.squareup.okhttp.Call; import com.squareup.okhttp.Credentials; import com.squareup.okhttp.Headers; import com.squareup.okhttp.HttpUrl; -import com.squareup.okhttp.Interceptor; import com.squareup.okhttp.MediaType; import com.squareup.okhttp.MultipartBuilder; import com.squareup.okhttp.OkHttpClient; @@ -32,8 +31,6 @@ import com.squareup.okhttp.RequestBody; import com.squareup.okhttp.Response; import java.io.IOException; import java.net.Proxy; -import java.util.ArrayList; -import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; import javax.annotation.CheckForNull; @@ -84,7 +81,6 @@ public class HttpConnector implements WsConnector { this.okHttpClient.setConnectTimeout(builder.connectTimeoutMs, TimeUnit.MILLISECONDS); this.okHttpClient.setReadTimeout(builder.readTimeoutMs, TimeUnit.MILLISECONDS); - this.okHttpClient.interceptors().addAll(builder.interceptors); } @Override @@ -92,18 +88,13 @@ public class HttpConnector implements WsConnector { return baseUrl.url().toExternalForm(); } - public OkHttpClient okHttpClient() { - return okHttpClient; - } - @CheckForNull public String userAgent() { return userAgent; } - @CheckForNull - public String credentials() { - return credentials; + public OkHttpClient okHttpClient() { + return okHttpClient; } @Override @@ -176,9 +167,6 @@ public class HttpConnector implements WsConnector { Call call = okHttpClient.newCall(okRequest); try { Response okResponse = call.execute(); - if (!okResponse.isSuccessful()) { - throw new HttpException(okRequest.urlString(), okResponse.code(), okResponse.message()); - } return new HttpResponse(okResponse); } catch (IOException e) { throw new IllegalStateException("Fail to request " + okRequest.urlString(), e); @@ -195,7 +183,6 @@ public class HttpConnector implements WsConnector { private String proxyPassword; private int connectTimeoutMs = DEFAULT_CONNECT_TIMEOUT_MILLISECONDS; private int readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLISECONDS; - private final List<Interceptor> interceptors = new ArrayList<>(); /** * Optional User Agent @@ -260,15 +247,6 @@ public class HttpConnector implements WsConnector { return this; } - /** - * Adds a OkHttp interceptor, for example to log request URLs or response errors. - * See https://github.com/square/okhttp/wiki/Interceptors - */ - public Builder interceptor(Interceptor interceptor) { - this.interceptors.add(interceptor); - return this; - } - public HttpConnector build() { checkArgument(!isNullOrEmpty(url), "Server URL is not defined"); return new HttpConnector(this); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpException.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpException.java index 393c6232f89..81fd1d69ab8 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpException.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpException.java @@ -27,8 +27,8 @@ public class HttpException extends RuntimeException { private final String url; private final int code; - public HttpException(String url, int code, String message) { - super(String.format("Error %d on %s : %s", code, url, message)); + public HttpException(String url, int code) { + super(String.format("Error %d on %s", code, url)); this.url = url; this.code = code; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpResponse.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpResponse.java index b2e3f2766e4..0eac10b596c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpResponse.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpResponse.java @@ -26,7 +26,7 @@ import java.io.Reader; import static java.net.HttpURLConnection.HTTP_NO_CONTENT; -class HttpResponse implements WsResponse { +class HttpResponse extends BaseResponse { private final Response okResponse; @@ -35,7 +35,12 @@ class HttpResponse implements WsResponse { } @Override - public String getRequestUrl() { + public int code() { + return okResponse.code(); + } + + @Override + public String requestUrl() { return okResponse.request().urlString(); } @@ -45,7 +50,7 @@ class HttpResponse implements WsResponse { } @Override - public String getContentType() { + public String contentType() { return okResponse.header("Content-Type"); } @@ -53,7 +58,7 @@ class HttpResponse implements WsResponse { * Get stream of bytes */ @Override - public InputStream getContentStream() { + public InputStream contentStream() { try { return okResponse.body().byteStream(); } catch (IOException e) { @@ -67,7 +72,7 @@ class HttpResponse implements WsResponse { * charset, this will attempt to decode the response body as UTF-8. */ @Override - public Reader getContentReader() { + public Reader contentReader() { try { return okResponse.body().charStream(); } catch (IOException e) { @@ -76,7 +81,7 @@ class HttpResponse implements WsResponse { } @Override - public String getContent() { + public String content() { try { return okResponse.body().string(); } catch (IOException e) { @@ -85,6 +90,6 @@ class HttpResponse implements WsResponse { } private RuntimeException fail(Exception e) { - throw new IllegalStateException("Fail to read response of " + getRequestUrl(), e); + throw new IllegalStateException("Fail to read response of " + requestUrl(), e); } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java index e9e69a7e8b7..d172f4bbf88 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/HttpWsClient.java @@ -20,7 +20,6 @@ package org.sonarqube.ws.client; -import org.sonarqube.ws.client.ce.ComputeEngineService; import org.sonarqube.ws.client.component.ComponentsService; import org.sonarqube.ws.client.issue.IssuesService; import org.sonarqube.ws.client.permission.PermissionsService; @@ -34,7 +33,6 @@ import org.sonarqube.ws.client.usertoken.UserTokensService; */ public class HttpWsClient implements WsClient { - private final ComputeEngineService ceWsClient; private final PermissionsService permissionsService; private final ComponentsService componentsService; private final QualityProfilesService qualityProfilesService; @@ -44,7 +42,6 @@ public class HttpWsClient implements WsClient { public HttpWsClient(WsConnector wsConnector) { this.wsConnector = wsConnector; - this.ceWsClient = new ComputeEngineService(wsConnector); this.permissionsService = new PermissionsService(wsConnector); this.componentsService = new ComponentsService(wsConnector); this.qualityProfilesService = new QualityProfilesService(wsConnector); @@ -63,11 +60,6 @@ public class HttpWsClient implements WsClient { } @Override - public ComputeEngineService computeEngine() { - return ceWsClient; - } - - @Override public ComponentsService components() { return componentsService; } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/MockWsResponse.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/MockWsResponse.java index 00411fb8601..54f1c05c556 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/MockWsResponse.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/MockWsResponse.java @@ -25,20 +25,32 @@ import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.io.StringReader; +import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; import org.apache.commons.io.IOUtils; import org.sonarqube.ws.MediaTypes; import static java.util.Objects.requireNonNull; -public class MockWsResponse implements WsResponse { +public class MockWsResponse extends BaseResponse { + private int code = HttpURLConnection.HTTP_OK; private String requestUrl; private byte[] content; private String contentType; @Override - public String getContentType() { + public int code() { + return code; + } + + public MockWsResponse setCode(int code) { + this.code = code; + return this; + } + + @Override + public String contentType() { requireNonNull(contentType); return contentType; } @@ -77,25 +89,25 @@ public class MockWsResponse implements WsResponse { } @Override - public String getRequestUrl() { + public String requestUrl() { requireNonNull(requestUrl); return requestUrl; } @Override - public InputStream getContentStream() { + public InputStream contentStream() { requireNonNull(content); return new ByteArrayInputStream(content); } @Override - public Reader getContentReader() { + public Reader contentReader() { requireNonNull(content); return new StringReader(new String(content, StandardCharsets.UTF_8)); } @Override - public String getContent() { + public String content() { requireNonNull(content); return new String(content, StandardCharsets.UTF_8); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 4b125627b5b..3f980d7c591 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -19,7 +19,6 @@ */ package org.sonarqube.ws.client; -import org.sonarqube.ws.client.ce.ComputeEngineService; import org.sonarqube.ws.client.component.ComponentsService; import org.sonarqube.ws.client.issue.IssuesService; import org.sonarqube.ws.client.permission.PermissionsService; @@ -32,8 +31,6 @@ import org.sonarqube.ws.client.usertoken.UserTokensService; public interface WsClient { ComponentsService components(); - ComputeEngineService computeEngine(); - IssuesService issues(); PermissionsService permissions(); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java index d7754d598fc..4d4829b6006 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java @@ -26,17 +26,16 @@ package org.sonarqube.ws.client; public interface WsConnector { /** + * Server base URL, always with trailing slash, for instance "http://localhost:9000/" + */ + String baseUrl(); + + /** * @throws IllegalStateException if the request could not be executed due to * a connectivity problem or timeout. Because networks can * fail during an exchange, it is possible that the remote server * accepted the request before the failure - * @throws HttpException if the response code is not in range [200..300) */ WsResponse call(WsRequest wsRequest); - /** - * Server base URL, always with trailing slash, for instance "http://localhost:9000/" - */ - String baseUrl(); - } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsResponse.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsResponse.java index c6550ffb44a..d1045ba3d4e 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsResponse.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsResponse.java @@ -27,15 +27,35 @@ import java.io.Reader; */ public interface WsResponse { - boolean hasContent(); + /** + * The absolute requested URL + */ + String requestUrl(); + + /** + * HTTP status code + */ + int code(); + + /** + * Returns true if the code is in [200..300), which means the request was + * successfully received, understood, and accepted. + */ + boolean isSuccessful() ; - String getContentType(); + /** + * Throws a {@link HttpException} if {@link #isSuccessful()} is false. + */ + WsResponse failIfNotSuccessful(); + + String contentType(); + + boolean hasContent(); - String getRequestUrl(); + InputStream contentStream(); - InputStream getContentStream(); + Reader contentReader(); - Reader getContentReader(); + String content(); - String getContent(); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/ComputeEngineService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/ComputeEngineService.java deleted file mode 100644 index 465b96dc7b9..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/ComputeEngineService.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonarqube.ws.client.ce; - -import org.sonarqube.ws.MediaTypes; -import org.sonarqube.ws.WsCe; -import org.sonarqube.ws.client.BaseService; -import org.sonarqube.ws.client.PostRequest; -import org.sonarqube.ws.client.WsConnector; - -public class ComputeEngineService extends BaseService { - - public ComputeEngineService(WsConnector wsConnector) { - super(wsConnector, "api/ce"); - } - - public WsCe.SubmitResponse submit(SubmitWsRequest request) { - PostRequest.Part filePart = new PostRequest.Part(MediaTypes.ZIP, request.getReport()); - PostRequest post = new PostRequest(path("submit")) - .setParam("projectKey", request.getProjectKey()) - .setParam("projectName", request.getProjectName()) - .setParam("projectBranch", request.getProjectBranch()) - .setPart("report", filePart); - return call(post, WsCe.SubmitResponse.parser()); - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/SubmitWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/SubmitWsRequest.java deleted file mode 100644 index af414ee6fcc..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/ce/SubmitWsRequest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonarqube.ws.client.ce; - -import java.io.File; -import javax.annotation.CheckForNull; - -public class SubmitWsRequest { - - private String projectKey; - private String projectName; - private String projectBranch; - private File report; - - public String getProjectKey() { - return projectKey; - } - - public SubmitWsRequest setProjectKey(String projectKey) { - this.projectKey = projectKey; - return this; - } - - @CheckForNull - public String getProjectName() { - return projectName; - } - - public SubmitWsRequest setProjectName(String projectName) { - this.projectName = projectName; - return this; - } - - @CheckForNull - public String getProjectBranch() { - return projectBranch; - } - - public SubmitWsRequest setProjectBranch(String projectBranch) { - this.projectBranch = projectBranch; - return this; - } - - @CheckForNull - public File getReport() { - return report; - } - - public SubmitWsRequest setReport(File report) { - this.report = report; - return this; - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseServiceTest.java index 2d92809cbd7..5fbab7b84c9 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseServiceTest.java @@ -43,7 +43,7 @@ public class BaseServiceTest { WsResponse response = call(get); - assertThat(response.getContent()).isEqualTo("ok"); + assertThat(response.content()).isEqualTo("ok"); } }.test(); @@ -69,6 +69,25 @@ public class BaseServiceTest { } @Test + public void fail_if_http_error() { + new BaseService(wsConnector, "api/issues") { + + public void test() { + GetRequest get = new GetRequest(path("issue")).setParam("key", "ABC"); + when(wsConnector.call(get)).thenReturn(new MockWsResponse().setCode(403).setRequestUrl("https://local/foo")); + + try { + call(get, Testing.Fake.parser()); + fail(); + } catch (HttpException e) { + assertThat(e.code()).isEqualTo(403); + } + } + + }.test(); + } + + @Test public void fail_to_parse_protobuf_response() { new BaseService(wsConnector, "api/issues") { diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java index 79362ea815f..27f68d64bc7 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java @@ -19,14 +19,10 @@ */ package org.sonarqube.ws.client; -import com.squareup.okhttp.Interceptor; -import com.squareup.okhttp.Response; import com.squareup.okhttp.mockwebserver.MockResponse; import com.squareup.okhttp.mockwebserver.MockWebServer; import com.squareup.okhttp.mockwebserver.RecordedRequest; import java.io.File; -import java.io.IOException; -import java.util.concurrent.atomic.AtomicBoolean; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; @@ -70,7 +66,7 @@ public class HttpConnectorTest { // verify response assertThat(response.hasContent()).isTrue(); - assertThat(response.getContent()).isEqualTo("hello, world!"); + assertThat(response.content()).isEqualTo("hello, world!"); // verify the request received by server RecordedRequest recordedRequest = server.takeRequest(); @@ -196,7 +192,7 @@ public class HttpConnectorTest { // verify response assertThat(response.hasContent()).isTrue(); - assertThat(response.getContent()).isEqualTo("hello, world!"); + assertThat(response.content()).isEqualTo("hello, world!"); // verify the request received by server RecordedRequest recordedRequest = server.takeRequest(); @@ -234,34 +230,8 @@ public class HttpConnectorTest { PostRequest request = new PostRequest("api/issues/search"); HttpConnector underTest = new HttpConnector.Builder().url(serverUrl).build(); - try { - underTest.call(request); - fail(); - } catch (HttpException e) { - assertThat(e.code()).isEqualTo(404); - - } - } - - @Test - public void intercept_request_and_response() { - final AtomicBoolean called = new AtomicBoolean(false); - Interceptor interceptor = new Interceptor() { - @Override - public Response intercept(Chain chain) throws IOException { - called.set(true); - return chain.proceed(chain.request()); - } - }; - - answerHelloWorld(); - HttpConnector underTest = new HttpConnector.Builder() - .url(serverUrl) - .interceptor(interceptor) - .build(); - underTest.call(new GetRequest("")); - - assertThat(called.get()).isTrue(); + WsResponse wsResponse = underTest.call(request); + assertThat(wsResponse.code()).isEqualTo(404); } @Test @@ -284,11 +254,11 @@ public class HttpConnectorTest { GetRequest request = new GetRequest("api/issues/search"); answerHelloWorld(); - assertThat(underTest.call(request).getRequestUrl()).isEqualTo(serverUrl + "sonar/api/issues/search"); + assertThat(underTest.call(request).requestUrl()).isEqualTo(serverUrl + "sonar/api/issues/search"); request = new GetRequest("/api/issues/search"); answerHelloWorld(); - assertThat(underTest.call(request).getRequestUrl()).isEqualTo(serverUrl + "sonar/api/issues/search"); + assertThat(underTest.call(request).requestUrl()).isEqualTo(serverUrl + "sonar/api/issues/search"); } private void answerHelloWorld() { diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpExceptionTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpExceptionTest.java index 2db49ea358b..0e8a325e701 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpExceptionTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpExceptionTest.java @@ -26,9 +26,9 @@ import static org.assertj.core.api.Assertions.assertThat; public class HttpExceptionTest { @Test public void test_exception() throws Exception { - HttpException exception = new HttpException("http://localhost:9000/api/search", 500, "Not found"); + HttpException exception = new HttpException("http://localhost:9000/api/search", 500); assertThat(exception.code()).isEqualTo(500); assertThat(exception.url()).isEqualTo("http://localhost:9000/api/search"); - assertThat(exception.getMessage()).isEqualTo("Error 500 on http://localhost:9000/api/search : Not found"); + assertThat(exception.getMessage()).isEqualTo("Error 500 on http://localhost:9000/api/search"); } } |