From 369d5f239a1debf6aad07ba92a3f6042415f9579 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 13 Jun 2013 18:00:07 +0200 Subject: [PATCH] Fix some quality flaws --- .../org/sonar/wsclient/internal/HttpRequestFactory.java | 5 +---- .../org/sonar/wsclient/internal/HttpRequestFactoryTest.java | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) 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 e454a585448..e8cd100597a 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 @@ -135,11 +135,8 @@ public class HttpRequestFactory { // TODO handle error messages throw new HttpException(request.url().toString(), request.code()); - } catch (HttpException e) { - throw e; - } catch (HttpRequest.HttpRequestException e) { - throw new IllegalStateException(e.getCause()); + throw new IllegalStateException("Fail to request " + request.url(), e.getCause()); } } 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 9969090a1ee..41100306f7d 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 @@ -58,7 +58,9 @@ public class HttpRequestFactoryTest { fail(); } catch (Exception e) { assertThat(e).isInstanceOf(IllegalStateException.class); - assertThat(e).hasMessage("java.net.ConnectException: Connection refused"); + assertThat(e).hasMessage("Fail to request http://localhost:1/api/issues"); + assertThat(e.getCause()).hasMessage("Connection refused"); + } } @@ -100,7 +102,7 @@ public class HttpRequestFactoryTest { } @Test - public void should_encore_characters() { + public void should_encode_characters() { HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); httpServer.doReturnBody("{\"issues\": [{\"key\": \"ABCDE\"}]}"); -- 2.39.5