]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5094 Do not let the HTTP exception be swallowed by the underlying lib
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 17 Mar 2014 16:02:52 +0000 (17:02 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 17 Mar 2014 16:02:52 +0000 (17:02 +0100)
sonar-batch/src/main/java/org/sonar/batch/qualitygate/QualityGateProvider.java
sonar-batch/src/test/java/org/sonar/batch/qualitygate/QualityGateProviderTest.java

index 2babe56d104e667f883f70b4dbe0d39f43654583..5a8cbc98f8956ef1527b50a8b4bcc3447a60bc9e 100644 (file)
@@ -83,9 +83,9 @@ public class QualityGateProvider extends ProviderAdapter {
     String jsonText = null;
     try {
       long qGateId = Long.valueOf(qualityGateSetting);
-      jsonText = client.request(SHOW_URL + "?id="+qGateId);
+      jsonText = client.request(SHOW_URL + "?id="+qGateId, false);
     } catch(NumberFormatException configIsNameInsteadOfId) {
-      jsonText = client.request(SHOW_URL + "?name="+qualityGateSetting);
+      jsonText = client.request(SHOW_URL + "?name="+qualityGateSetting, false);
     }
 
     JsonParser parser = new JsonParser();
index 4e8cf612c2cad15434206bac4c3ede8ddcc3940b..1c34d5add480edda27a8db09b2e2925aa95cf04a 100644 (file)
@@ -65,7 +65,7 @@ public class QualityGateProviderTest {
   public void should_load_empty_quality_gate_using_name() {
     String qGateName = "Sonar way";
     when(settings.getString("sonar.qualitygate")).thenReturn(qGateName);
-    when(client.request("/api/qualitygates/show?name=Sonar way")).thenReturn("{'id':12345,'name':'Sonar way'}");
+    when(client.request("/api/qualitygates/show?name=Sonar way", false)).thenReturn("{'id':12345,'name':'Sonar way'}");
     QualityGate qGate = new QualityGateProvider().init(settings, client, metricFinder, logger);
     assertThat(qGate.name()).isEqualTo(qGateName);
     assertThat(qGate.isEnabled()).isTrue();
@@ -78,7 +78,7 @@ public class QualityGateProviderTest {
     long qGateId = 12345L;
     String qGateName = "Sonar way";
     when(settings.getString("sonar.qualitygate")).thenReturn(Long.toString(qGateId));
-    when(client.request("/api/qualitygates/show?id=12345")).thenReturn("{'id':12345,'name':'Sonar way','conditions':["
+    when(client.request("/api/qualitygates/show?id=12345", false)).thenReturn("{'id':12345,'name':'Sonar way','conditions':["
       + "{'id':1,'metric':'metric1','op':'EQ','warning':'POLOP'},"
       + "{'id':2,'metric':'metric2','op':'NE','error':'PALAP','period':3}"
       + "]}");
@@ -106,7 +106,7 @@ public class QualityGateProviderTest {
   public void should_stop_analysis_if_gate_not_found() {
     String qGateName = "Sonar way";
     when(settings.getString("sonar.qualitygate")).thenReturn(qGateName);
-    when(client.request("/api/qualitygates/show?name=Sonar way")).thenThrow(
+    when(client.request("/api/qualitygates/show?name=Sonar way", false)).thenThrow(
         new HttpDownloader.HttpException(URI.create("/api/qualitygates/show?name=Sonar%20way"), HttpURLConnection.HTTP_NOT_FOUND));
     new QualityGateProvider().provide(settings, client, metricFinder);
   }
@@ -115,7 +115,7 @@ public class QualityGateProviderTest {
   public void should_stop_analysis_if_server_error() {
     String qGateName = "Sonar way";
     when(settings.getString("sonar.qualitygate")).thenReturn(qGateName);
-    when(client.request("/api/qualitygates/show?name=Sonar way")).thenThrow(
+    when(client.request("/api/qualitygates/show?name=Sonar way", false)).thenThrow(
         new HttpDownloader.HttpException(URI.create("/api/qualitygates/show?name=Sonar%20way"), HttpURLConnection.HTTP_NOT_ACCEPTABLE));
     new QualityGateProvider().provide(settings, client, metricFinder);
   }