]> source.dussan.org Git - sonarqube.git/commitdiff
Fix some quality flaws
authorSimon Brandhof <simon.brandhof@gmail.com>
Thu, 13 Jun 2013 16:00:07 +0000 (18:00 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Thu, 13 Jun 2013 16:00:56 +0000 (18:00 +0200)
sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java

index e454a5854483a80c4695470e0b5ac74b05e7f759..e8cd100597a639c61773cd24bdc7c399a2fcb0ba 100644 (file)
@@ -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());
     }
   }
 
index 9969090a1ee3edec220486412e1e3c7fc619163f..41100306f7d7a471f8b33a2c13ef83513e400a6e 100644 (file)
@@ -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\"}]}");