]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2204,SONAR-2259 Fix URL encoding
authorEvgeny Mandrikov <mandrikov@gmail.com>
Sat, 5 Mar 2011 22:34:12 +0000 (01:34 +0300)
committerEvgeny Mandrikov <mandrikov@gmail.com>
Sun, 6 Mar 2011 02:14:27 +0000 (05:14 +0300)
* For correct URL encoding we must encode parameters on lower level - in Query itself,
  but not in concrete implementation of Connector, because in Query we can distinguish
  concrete parts of URL.

* Moreover in this case any additional encoding routines in Connector are useless,
  so were removed.

40 files changed:
sonar-ws-client/pom.xml
sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java
sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java
sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java
sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/AbstractQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/DependencyQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/EventQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/MetricQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyCreateQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyDeleteQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/QueryTestCase.java [new file with mode: 0644]
sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/SourceQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyCreateQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyDeleteQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PluginUnmarshallerTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java
sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java

index dbd5c4658b6ea45ed8b6558b7539633164c168eb..ed92d1fdf86ac5a708fab82971a13693920f6df8 100644 (file)
@@ -87,4 +87,4 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
-</project>
\ No newline at end of file
+</project>
index 94cf646b6c941c7d039cee6524a240ecc9c470d7..25545be4446ce9aaf8d4862e55cf6eedefb8f94b 100644 (file)
  */
 package org.sonar.wsclient.connectors;
 
-import org.apache.commons.httpclient.*;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpMethodBase;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.DeleteMethod;
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.StringRequestEntity;
 import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
-import org.apache.commons.httpclient.util.URIUtil;
 import org.sonar.wsclient.Host;
+import org.sonar.wsclient.services.AbstractQuery;
 import org.sonar.wsclient.services.CreateQuery;
 import org.sonar.wsclient.services.DeleteQuery;
 import org.sonar.wsclient.services.Query;
 import org.sonar.wsclient.services.UpdateQuery;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-
 /**
  * @since 2.1
  */
@@ -123,61 +131,43 @@ public class HttpClient3Connector extends Connector {
   }
 
   private HttpMethodBase newGetRequest(Query<?> query) {
-    try {
-      String url = server.getHost() + URIUtil.encodeQuery(query.getUrl());
-      HttpMethodBase method = new GetMethod(url);
-      method.setRequestHeader("Accept", "application/json");
-      return method;
+    HttpMethodBase method = new GetMethod(server.getHost() + query.getUrl());
+    setJsonHeader(method);
+    return method;
+  }
 
-    } catch (URIException e) {
-      throw new ConnectionException("Query: " + query, e);
-    }
+  private HttpMethodBase newDeleteRequest(DeleteQuery<?> query) {
+    HttpMethodBase method = new DeleteMethod(server.getHost() + query.getUrl());
+    setJsonHeader(method);
+    return method;
   }
 
   private HttpMethodBase newPostRequest(CreateQuery<?> query) {
-    try {
-      String url = server.getHost() + URIUtil.encodeQuery(query.getUrl());
-      PostMethod method = new PostMethod(url);
-      method.setRequestHeader("Accept", "application/json");
-      if (query.getBody() != null) {
-        method.setRequestEntity(new StringRequestEntity(query.getBody(), "text/plain; charset=UTF-8", "UTF-8"));
-      }
-      return method;
-
-    } catch (URIException e) {
-      throw new ConnectionException("Query: " + query, e);
-    } catch (UnsupportedEncodingException e) {
-      throw new ConnectionException("Unsupported encoding", e);
-    }
+    PostMethod method = new PostMethod(server.getHost() + query.getUrl());
+    setJsonHeader(method);
+    setRequestEntity(method, query);
+    return method;
   }
 
   private HttpMethodBase newPutRequest(UpdateQuery<?> query) {
-    try {
-      String url = server.getHost() + URIUtil.encodeQuery(query.getUrl());
-      PutMethod method = new PutMethod(url);
-      method.setRequestHeader("Accept", "application/json");
-      if (query.getBody() != null) {
-        method.setRequestEntity(new StringRequestEntity(query.getBody(), "text/plain; charset=UTF-8", "UTF-8"));
-      }
-      return method;
+    PutMethod method = new PutMethod(server.getHost() + query.getUrl());
+    setJsonHeader(method);
+    setRequestEntity(method, query);
+    return method;
+  }
 
-    } catch (URIException e) {
-      throw new ConnectionException("Query: " + query, e);
-    } catch (UnsupportedEncodingException e) {
-      throw new ConnectionException("Unsupported encoding", e);
+  private void setRequestEntity(EntityEnclosingMethod request, AbstractQuery<?> query) {
+    if (query.getBody() != null) {
+      try {
+        request.setRequestEntity(new StringRequestEntity(query.getBody(), "text/plain; charset=UTF-8", "UTF-8"));
+      } catch (UnsupportedEncodingException e) {
+        throw new ConnectionException("Unsupported encoding", e);
+      }
     }
   }
 
-  private HttpMethodBase newDeleteRequest(DeleteQuery<?> query) {
-    try {
-      String url = server.getHost() + URIUtil.encodeQuery(query.getUrl());
-      HttpMethodBase method = new DeleteMethod(url);
-      method.setRequestHeader("Accept", "application/json");
-      return method;
-
-    } catch (URIException e) {
-      throw new ConnectionException("Query: " + query, e);
-    }
+  private void setJsonHeader(HttpMethodBase request) {
+    request.setRequestHeader("Accept", "application/json");
   }
 
   private String getResponseBodyAsString(HttpMethod method) {
index d85796ebc551ef7238e04c37abb598a85810fafd..382f5bd3614e2d636410d25fc4fb54217624768b 100644 (file)
  */
 package org.sonar.wsclient.connectors;
 
-import org.apache.http.*;
-import org.apache.http.auth.*;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpRequest;
+import org.apache.http.HttpRequestInterceptor;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.auth.AuthScheme;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.AuthState;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
 import org.apache.http.client.CredentialsProvider;
 import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpPut;
@@ -38,14 +52,12 @@ import org.apache.http.protocol.ExecutionContext;
 import org.apache.http.protocol.HttpContext;
 import org.apache.http.util.EntityUtils;
 import org.sonar.wsclient.Host;
+import org.sonar.wsclient.services.AbstractQuery;
 import org.sonar.wsclient.services.CreateQuery;
 import org.sonar.wsclient.services.DeleteQuery;
 import org.sonar.wsclient.services.Query;
 import org.sonar.wsclient.services.UpdateQuery;
 
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
 /**
  * @since 2.1
  */
@@ -85,7 +97,9 @@ public class HttpClient4Connector extends Connector {
           json = EntityUtils.toString(entity);
 
         } else if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_FOUND) {
-          throw new ConnectionException("HTTP error: " + response.getStatusLine().getStatusCode() + ", msg: " + response.getStatusLine().getReasonPhrase() + ", query: " + request.toString());
+          throw new ConnectionException("HTTP error: " + response.getStatusLine().getStatusCode()
+              + ", msg: " + response.getStatusLine().getReasonPhrase()
+              + ", query: " + request.toString());
         }
       }
 
@@ -104,7 +118,8 @@ public class HttpClient4Connector extends Connector {
     HttpConnectionParams.setConnectionTimeout(params, TIMEOUT_MS);
     HttpConnectionParams.setSoTimeout(params, TIMEOUT_MS);
     if (server.getUsername() != null) {
-      client.getCredentialsProvider().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(server.getUsername(), server.getPassword()));
+      client.getCredentialsProvider()
+          .setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(server.getUsername(), server.getPassword()));
     }
     return client;
   }
@@ -138,28 +153,26 @@ public class HttpClient4Connector extends Connector {
 
   private HttpPost newPostMethod(CreateQuery<?> query) {
     HttpPost post = new HttpPost(server.getHost() + query.getUrl());
-    if (query.getBody() != null) {
-      try {
-        post.setEntity(new StringEntity(query.getBody(), "UTF-8"));
-      } catch (UnsupportedEncodingException e) {
-        throw new ConnectionException("Encoding is not supported", e);
-      }
-    }
     setJsonHeader(post);
+    setRequestEntity(post, query);
     return post;
   }
 
   private HttpPut newPutMethod(UpdateQuery<?> query) {
     HttpPut put = new HttpPut(server.getHost() + query.getUrl());
+    setJsonHeader(put);
+    setRequestEntity(put, query);
+    return put;
+  }
+
+  private void setRequestEntity(HttpEntityEnclosingRequestBase request, AbstractQuery<?> query) {
     if (query.getBody() != null) {
       try {
-        put.setEntity(new StringEntity(query.getBody(), "UTF-8"));
+        request.setEntity(new StringEntity(query.getBody(), "UTF-8"));
       } catch (UnsupportedEncodingException e) {
         throw new ConnectionException("Encoding is not supported", e);
       }
     }
-    setJsonHeader(put);
-    return put;
   }
 
   private void setJsonHeader(HttpRequestBase request) {
index 923830480e4cb2f5481ef950e91609a2db901bea..288dfba7ee277dc2ecacc0be260b35bb269d2a4b 100644 (file)
@@ -28,21 +28,36 @@ public abstract class AbstractQuery<MODEL extends Model> {
 
   /**
    * Must start with a slash, for example: /api/metrics
+   * <p>
+   * IMPORTANT: In implementations of this method we must use helper methods to construct URL.
+   * </p>
+   * 
+   * @see #encode(String)
+   * @see #appendUrlParameter(StringBuilder, String, Object)
+   * @see #appendUrlParameter(StringBuilder, String, Object[])
+   * @see #appendUrlParameter(StringBuilder, String, Date, boolean)
    */
   public abstract String getUrl();
 
   /**
-   * Request body. By defaut it is empty but it can be overriden. 
+   * Request body. By default it is empty but it can be overridden.
    */
   public String getBody() {
     return null;
   }
 
+  /**
+   * Encodes single parameter value.
+   */
+  protected static String encode(String value) {
+    return WSUtils.getINSTANCE().encodeUrl(value);
+  }
+
   protected static void appendUrlParameter(StringBuilder url, String paramKey, Object paramValue) {
     if (paramValue != null) {
       url.append(paramKey)
           .append('=')
-          .append(paramValue)
+          .append(encode(paramValue.toString()))
           .append('&');
     }
   }
@@ -55,7 +70,7 @@ public abstract class AbstractQuery<MODEL extends Model> {
           url.append(',');
         }
         if (paramValues[index] != null) {
-          url.append(paramValues[index]);
+          url.append(encode(paramValues[index].toString()));
         }
       }
       url.append('&');
@@ -67,7 +82,7 @@ public abstract class AbstractQuery<MODEL extends Model> {
       String format = (includeTime ? "yyyy-MM-dd'T'HH:mm:ssZ" : "yyyy-MM-dd");
       url.append(paramKey)
           .append('=')
-          .append(WSUtils.getINSTANCE().encodeUrl(WSUtils.getINSTANCE().format(paramValue, format)))
+          .append(encode(WSUtils.getINSTANCE().format(paramValue, format)))
           .append('&');
     }
   }
index 65e4447c7f2067a28ea8c7da3f9ac2db40d638c9..5c20923c731afa44064393e8f264c301b774121a 100644 (file)
@@ -59,18 +59,10 @@ public class DependencyQuery extends Query<Dependency> {
   public String getUrl() {
     StringBuilder url = new StringBuilder(BASE_URL);
     url.append('?');
-    if (resourceIdOrKey != null) {
-      url.append("resource=").append(resourceIdOrKey).append('&');
-    }
-    if (direction != null) {
-      url.append("dir=").append(direction).append('&');
-    }
-    if (parentId !=null) {
-      url.append("parent=").append(parentId).append('&');
-    }
-    if (id !=null) {
-      url.append("id=").append(id).append('&');
-    }
+    appendUrlParameter(url, "resource", resourceIdOrKey);
+    appendUrlParameter(url, "dir", direction);
+    appendUrlParameter(url, "parent", parentId);
+    appendUrlParameter(url, "id", id);
     return url.toString();
   }
 
@@ -99,7 +91,7 @@ public class DependencyQuery extends Query<Dependency> {
 
   /**
    * Resources that depend upon a resource
-   *
+   * 
    * @param resourceIdOrKey the target resource. Can be the primary key (a number) or the logical key (String)
    */
   public static DependencyQuery createForIncomingDependencies(String resourceIdOrKey) {
@@ -111,7 +103,7 @@ public class DependencyQuery extends Query<Dependency> {
 
   /**
    * Resources that are depended upon a resource = all the resources that a resource depends upon
-   *
+   * 
    * @param resourceIdOrKey the target resource. Can be the primary key (an integer) or the logical key (String)
    */
   public static DependencyQuery createForOutgoingDependencies(String resourceIdOrKey) {
@@ -124,7 +116,7 @@ public class DependencyQuery extends Query<Dependency> {
   /**
    * Resources that depend upon or are depended upon a resource. It equals the merge of createForIncomingDependencies(resourceIdOrKey)
    * and createForOutgoingDependencies(resourceIdOrKey)
-   *
+   * 
    * @param resourceIdOrKey the target resource. Can be the primary key (an integer) or the logical key (String)
    */
   public static DependencyQuery createForResource(String resourceIdOrKey) {
index 27e25081a526b1bcaa0e400073f6a64d7ab3f99e..552de333a4e24c026ea4b370f043e45e6fd88f00 100644 (file)
@@ -53,23 +53,9 @@ public class DependencyTreeQuery extends Query<DependencyTree> {
   @Override
   public String getUrl() {
     StringBuilder url = new StringBuilder(BASE_URL);
-    url.append("?resource=")
-        .append(resourceId)
-        .append("&");
-    if (scopes != null) {
-      url.append("scopes=");
-      if (scopes != null) {
-        for (int index = 0; index < scopes.length; index++) {
-          if (index > 0) {
-            url.append(',');
-          }
-          if (scopes[index] != null) {
-            url.append(scopes[index]);
-          }
-        }
-        url.append('&');
-      }
-    }
+    url.append('?');
+    appendUrlParameter(url, "resource", resourceId);
+    appendUrlParameter(url, "scopes", scopes);
     return url.toString();
   }
 
index 9ec9958e3ec4dd5b1ecbedaa52c528f7490702b9..a22b11bfc78140286a566b53340bdf4296182586 100644 (file)
@@ -29,7 +29,9 @@ public class FavouriteCreateQuery extends CreateQuery<Favourite> {
 
   @Override
   public String getUrl() {
-    return new StringBuilder().append(FavouriteQuery.BASE_URL).append("?key=").append(idOrKey).toString();
+    StringBuilder url = new StringBuilder(FavouriteQuery.BASE_URL).append('?');
+    appendUrlParameter(url, "key", idOrKey);
+    return url.toString();
   }
 
   @Override
index b1d64eaca7b13cc4a961320c218defa4c9bda343..40ac6d21e7989eabf0f8316f24c7670523261555 100644 (file)
@@ -33,6 +33,6 @@ public class FavouriteDeleteQuery extends DeleteQuery<Favourite> {
 
   @Override
   public String getUrl() {
-    return new StringBuilder().append(FavouriteQuery.BASE_URL).append('/').append(idOrKey).toString();
+    return new StringBuilder().append(FavouriteQuery.BASE_URL).append('/').append(encode(idOrKey)).toString();
   }
 }
index 708d4836639d4cb27e2b11efe0f3c83ad62b8e0a..b0647b2f7b05f79117ccf2d20850c89bd9a22128 100644 (file)
@@ -36,7 +36,7 @@ public final class MetricQuery extends Query<Metric> {
     StringBuilder sb = new StringBuilder(BASE_URL);
     if (key != null && !"".equals(key)) {
       sb.append("/");
-      sb.append(key);
+      sb.append(encode(key));
     }
     sb.append("?");
     return sb.toString();
index 5c945ce6205e8ef53f3051c6a1d0800b9b99db9f..f2159494d3b5fe0101d42171701ff838c55a0c65 100644 (file)
@@ -17,7 +17,6 @@
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.services;
 
 /**
index 2a1f9d4651453b06c837b79ec14df0c0fec95541..bc26094bdfa2990b9d7a1a138e0ebfac9c65e9b1 100644 (file)
@@ -78,7 +78,7 @@ public class PropertyCreateQuery extends CreateQuery<Property> {
   public String getUrl() {
     StringBuilder url = new StringBuilder();
     url.append(PropertyQuery.BASE_URL);
-    url.append("/").append(key);
+    url.append("/").append(encode(key));
     url.append('?');
     appendUrlParameter(url, "value", value);
     appendUrlParameter(url, "resource", resourceKeyOrId);
index 316059671c4f05d4a5352e2b1263af154dce9619..8e6b7b119dd530dcabcfe73a4b0c449fe1fea0da 100644 (file)
@@ -62,7 +62,7 @@ public class PropertyDeleteQuery extends DeleteQuery<Property> {
   public String getUrl() {
     StringBuilder url = new StringBuilder();
     url.append(PropertyQuery.BASE_URL);
-    url.append("/").append(key);
+    url.append("/").append(encode(key));
     url.append('?');
     appendUrlParameter(url, "resource", resourceKeyOrId);
     return url.toString();
index d4dbbfd2d54db30f49f29ea026e8a82d741233fe..21715c96be8337b2a027c08d8535263d6c5fb865 100644 (file)
@@ -47,7 +47,7 @@ public class PropertyQuery extends Query<Property> {
   public String getUrl() {
     StringBuilder url = new StringBuilder(BASE_URL);
     if (key != null) {
-      url.append("/").append(key);
+      url.append("/").append(encode(key));
     }
     url.append('?');
     appendUrlParameter(url, "resource", resourceKeyOrId);
index 749870393ce1dac50f87d2d017e1f7d90d9204c3..35964e16d39f0e459ce22d4d39fa69580f1c55ab 100644 (file)
@@ -78,7 +78,7 @@ public class PropertyUpdateQuery extends UpdateQuery<Property> {
   public String getUrl() {
     StringBuilder url = new StringBuilder();
     url.append(PropertyQuery.BASE_URL);
-    url.append("/").append(key);
+    url.append("/").append(encode(key));
     url.append('?');
     appendUrlParameter(url, "resource", resourceKeyOrId);
     return url.toString();
index d4c9070fa347f67fe3c223fd53b69e2938ade706..64cde183f347cd6ab2ddb30243a7403e7e375e57 100644 (file)
@@ -46,8 +46,8 @@ public class SourceQuery extends Query<Source> {
 
   /**
    * Get only a few lines
-   *
-   * @param from       Index of the first line, starts to 1
+   * 
+   * @param from Index of the first line, starts to 1
    * @param excludedTo Index of the last line (excluded).
    */
   public SourceQuery setFromLineToLine(int from, int excludedTo) {
@@ -78,9 +78,8 @@ public class SourceQuery extends Query<Source> {
   @Override
   public String getUrl() {
     StringBuilder url = new StringBuilder(BASE_URL);
-    url.append("?resource=")
-        .append(resourceKeyOrId)
-        .append("&");
+    url.append('?');
+    appendUrlParameter(url, "resource", resourceKeyOrId);
     if (from > 0 && to > 0) {
       url.append("from=").append(from).append("&to=").append(to).append("&");
     }
index daef570e4990067eeac4d4b95232c6f2f3ad936a..19a3b989cb4ee8b837d563d030de2e8e09809386 100644 (file)
@@ -17,7 +17,6 @@
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.services;
 
 /**
index 972cc8d4e34ea2312000d1a0b5ecb169e7bf139d..81f1e182134c9141f3404afa8785de8b62591234 100644 (file)
@@ -45,6 +45,6 @@ public class UserPropertyDeleteQuery extends DeleteQuery<Property> {
 
   @Override
   public String getUrl() {
-    return new StringBuilder().append(UserPropertyQuery.BASE_URL).append('/').append(key).toString();
+    return new StringBuilder().append(UserPropertyQuery.BASE_URL).append('/').append(encode(key)).toString();
   }
 }
index 999375228d425240e3cdeef5c99e0053070bc566..6307b596b0772072bda23fd7da921acab481cc17 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.wsclient.services;
 
 /**
  * Get properties of the authenticated user.
- *
+ * 
  * @since 2.2
  */
 public class UserPropertyQuery extends Query<Property> {
@@ -55,7 +55,7 @@ public class UserPropertyQuery extends Query<Property> {
   public String getUrl() {
     String url = BASE_URL;
     if (key != null) {
-      url += "/" + key;
+      url += "/" + encode(key);
     }
     return url + "?";
   }
index d3b0917de241a1a487fc20fa5074dc21bc8b1d6e..3c5f9b69dc18624547979f01d39ff11f5ada7bdf 100644 (file)
@@ -17,7 +17,6 @@
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.unmarshallers;
 
 import org.sonar.wsclient.services.Plugin;
index 1794466a5e2d6f137d1ecf3ef5ed5b4d78675564..716919076ea816699d8cf80362071968614fbd95 100644 (file)
  */
 package org.sonar.wsclient;
 
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.assertThat;
+
+import java.util.Arrays;
+import java.util.Collection;
+
 import org.junit.AfterClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -27,15 +35,11 @@ import org.mortbay.jetty.testing.ServletTester;
 import org.sonar.wsclient.connectors.ConnectionException;
 import org.sonar.wsclient.connectors.HttpClient3Connector;
 import org.sonar.wsclient.connectors.HttpClient4Connector;
-import org.sonar.wsclient.services.*;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
+import org.sonar.wsclient.services.Metric;
+import org.sonar.wsclient.services.MetricQuery;
+import org.sonar.wsclient.services.Query;
+import org.sonar.wsclient.services.Server;
+import org.sonar.wsclient.services.ServerQuery;
 
 @RunWith(value = Parameterized.class)
 public class SonarTest {
@@ -64,13 +68,12 @@ public class SonarTest {
     baseUrl = tester.createSocketConnector(true);
     tester.start();
 
-    return Arrays.asList(new Object[][]{
-        {new Sonar(new HttpClient4Connector(new Host(baseUrl)))},
-        {new Sonar(new HttpClient3Connector(new Host(baseUrl)))}
+    return Arrays.asList(new Object[][] {
+        { new Sonar(new HttpClient4Connector(new Host(baseUrl))) },
+        { new Sonar(new HttpClient3Connector(new Host(baseUrl))) }
     });
   }
 
-
   @AfterClass
   public static void stopServer() throws Exception {
     tester.stop();
@@ -89,12 +92,6 @@ public class SonarTest {
     assertThat(metrics.size(), is(0));
   }
 
-  @Test
-  public void urlWithCharactersToEncode() {
-    sonar.find(new QueryWithInvalidCharacters());
-    // no exception
-  }
-
   @Test
   public void returnNullWhenSingleResultNotFound() {
     Query<Metric> query = new EmptyQuery();
@@ -124,15 +121,4 @@ public class SonarTest {
     }
   }
 
-  static class QueryWithInvalidCharacters extends Query<Metric> {
-    public String getUrl() {
-      // [] must be encoded
-      return "/api/violations?resource=myproject:[default]:Foo";
-    }
-
-    public Class<Metric> getModelClass() {
-      return Metric.class;
-    }
-  }
 }
-
index 76e73b8832d3e512b2ca82e1d17f15d48711d50d..c932a6f28ba6b8c1b82b975706ca877083331549 100644 (file)
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.services;
 
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.sonar.wsclient.JdkUtils;
+import static junit.framework.Assert.assertEquals;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.TimeZone;
 
-import static junit.framework.Assert.assertEquals;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.sonar.wsclient.JdkUtils;
 
 public class AbstractQueryTest {
 
@@ -44,6 +43,20 @@ public class AbstractQueryTest {
     WSUtils.setInstance(null);
   }
 
+  @Test
+  public void appendSpecialChars() {
+    StringBuilder url = new StringBuilder();
+    AbstractQuery.appendUrlParameter(url, "foo", "should escape []()");
+    assertEquals("foo=should+escape+%5B%5D%28%29&", url.toString());
+  }
+
+  @Test
+  public void appendSpecialCharsInArray() {
+    StringBuilder url = new StringBuilder();
+    AbstractQuery.appendUrlParameter(url, "foo", new String[] { "should escape", "[]()" });
+    assertEquals("foo=should+escape,%5B%5D%28%29&", url.toString());
+  }
+
   @Test
   public void appendUrlParameter() {
     StringBuilder url = new StringBuilder();
@@ -70,7 +83,7 @@ public class AbstractQueryTest {
   @Test
   public void appendUrlArrayParameter() {
     StringBuilder url = new StringBuilder();
-    AbstractQuery.appendUrlParameter(url, "foo", new String[]{"bar", "bar2"});
+    AbstractQuery.appendUrlParameter(url, "foo", new String[] { "bar", "bar2" });
     assertEquals("foo=bar,bar2&", url.toString());
   }
 
index b19568040deac1d30841798853e03d2980356a0e..98ccfca2b11fa8e2956145469fecaafd8e903d28 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.core.IsNull.nullValue;
 import static org.junit.Assert.assertThat;
 
-public class DependencyQueryTest {
+import org.junit.Test;
+
+public class DependencyQueryTest extends QueryTestCase {
 
   @Test
   public void createAllDependencies() {
index 332d1eb966bd47c30c56b598c5f5f989e4b2081a..428a2985bc806d17b391e0713c6e39e16bb4514b 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.wsclient.JdkUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Date;
 
-import static org.junit.Assert.*;
-
-public final class EventQueryTest {
+import org.junit.Test;
 
-  @Before
-  public void before() {
-    // WSUtils is called during getUrl()
-    // It has to be initialized.
-    WSUtils.setInstance(new JdkUtils());
-  }
+public final class EventQueryTest extends QueryTestCase {
 
   @Test
   public void from() {
@@ -59,7 +53,7 @@ public final class EventQueryTest {
   @Test
   public void urlWithTime() {
     EventQuery query = new EventQuery("key");
-    query.setCategories(new String[]{"category"});
+    query.setCategories(new String[] { "category" });
     Date date = new Date();
     query.setTo(date, true);
     query.setFrom(date, true);
@@ -76,7 +70,7 @@ public final class EventQueryTest {
   @Test
   public void urlWithoutTime() {
     EventQuery query = new EventQuery("key");
-    query.setCategories(new String[]{"category"});
+    query.setCategories(new String[] { "category" });
     Date date = new Date();
     query.setTo(date, false);
     query.setFrom(date, false);
@@ -92,7 +86,7 @@ public final class EventQueryTest {
   @Test
   public void urlWithoutDate() {
     EventQuery query = new EventQuery("key");
-    query.setCategories(new String[]{"category"});
+    query.setCategories(new String[] { "category" });
 
     final String url = query.getUrl();
     assertNotNull(url);
index 3b9690dc43d6fbbcbf6f5f7e1841a8faac58de67..5545f093058920996fc42812475128cc6fc8daa6 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
-public class MetricQueryTest {
+import org.junit.Test;
+
+public class MetricQueryTest extends QueryTestCase {
 
   @Test
   public void all() {
index 9d1c321648a37a61e08f313694f4bf68b0d491ce..269d5bb4463d5a3557b8008a3768f5ea8b5288b2 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
-public class PropertyCreateQueryTest {
+import org.junit.Test;
+
+public class PropertyCreateQueryTest extends QueryTestCase {
 
   @Test
   public void create() {
@@ -36,7 +36,7 @@ public class PropertyCreateQueryTest {
   @Test
   public void createForResource() {
     PropertyCreateQuery query = new PropertyCreateQuery("foo", "bar", "my:resource");
-    assertThat(query.getUrl(), is("/api/properties/foo?value=bar&resource=my:resource&"));
+    assertThat(query.getUrl(), is("/api/properties/foo?value=bar&resource=my%3Aresource&"));
     assertThat(query.getModelClass().getName(), is(Property.class.getName()));
   }
 }
\ No newline at end of file
index 0c9b7484cd5e23348eddbb62add2dcabaac2f810..88819fa0b718a7a2712150f48ddade71fc7de345 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
-public class PropertyDeleteQueryTest {
+import org.junit.Test;
+
+public class PropertyDeleteQueryTest extends QueryTestCase {
 
   @Test
   public void delete() {
@@ -35,6 +35,6 @@ public class PropertyDeleteQueryTest {
   @Test
   public void deleteResourceProp() {
     PropertyDeleteQuery query = new PropertyDeleteQuery("foo", "my:resource");
-    assertThat(query.getUrl(), is("/api/properties/foo?resource=my:resource&"));
+    assertThat(query.getUrl(), is("/api/properties/foo?resource=my%3Aresource&"));
   }
 }
\ No newline at end of file
index 4c1e5cc15f2a43f461597b6351746981f5baf09b..85bb9f17d1d487da225dd0723c493da14964825d 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
-public class PropertyQueryTest {
+import org.junit.Test;
+
+public class PropertyQueryTest extends QueryTestCase {
 
   @Test
   public void all() {
@@ -40,7 +40,7 @@ public class PropertyQueryTest {
 
   @Test
   public void byKeyAndResource() {
-    assertThat(PropertyQuery.createForResource("myprop", "my:resource").getUrl(), is("/api/properties/myprop?resource=my:resource&"));
+    assertThat(PropertyQuery.createForResource("myprop", "my:resource").getUrl(), is("/api/properties/myprop?resource=my%3Aresource&"));
     assertThat(PropertyQuery.createForResource("myprop", "my:resource").getModelClass().getName(), is(Property.class.getName()));
   }
 }
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/QueryTestCase.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/QueryTestCase.java
new file mode 100644 (file)
index 0000000..8e1e657
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
+ */
+package org.sonar.wsclient.services;
+
+import org.junit.BeforeClass;
+import org.sonar.wsclient.JdkUtils;
+
+public abstract class QueryTestCase {
+
+  @BeforeClass
+  public static void setupWsUtils() {
+    // WSUtils is called during getUrl()
+    // It has to be initialized.
+    WSUtils.setInstance(new JdkUtils());
+  }
+
+}
index 6d9b506bbb42866b6d0af5003b681adac9b44803..017288450badc17736bdca0f8a1bce88fcf323f7 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.core.IsNull.nullValue;
 import static org.junit.Assert.assertThat;
 
-public class ResourceQueryTest {
+import org.junit.Test;
+
+public class ResourceQueryTest extends QueryTestCase {
 
   @Test
   public void resource() {
     ResourceQuery query = new ResourceQuery("org.foo:bar");
-    assertThat(query.getUrl(), is("/api/resources?resource=org.foo:bar&verbose=false&"));
+    assertThat(query.getUrl(), is("/api/resources?resource=org.foo%3Abar&verbose=false&"));
     assertThat(query.getResourceKeyOrId(), is("org.foo:bar"));
     assertThat(query.isVerbose(), is(false));
   }
@@ -62,7 +62,7 @@ public class ResourceQueryTest {
   @Test
   public void measuresOnRulePriorities() {
     ResourceQuery query = new ResourceQuery().setMetrics("violations");
-    query.setRuleSeverities("MAJOR,MINOR");
+    query.setRuleSeverities("MAJOR", "MINOR");
 
     assertThat(query.getUrl(), is("/api/resources?metrics=violations&rule_priorities=MAJOR,MINOR&verbose=false&"));
   }
index 14ed894a2777e90fa05e24350e6e61552ca8508b..46954f41e42a24f930bf189f4cfbdbcc3268af80 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
-public class RuleQueryTest {
+import org.junit.Test;
+
+public class RuleQueryTest extends QueryTestCase {
 
   @Test
   public void languageRules() {
index 6f93db0171c028bd79a6d625fd709364ae21aa16..e90ad0480c4446b369048e121435a3b74e62b7f4 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
-/**
- * @author Evgeny Mandrikov
- */
-public class ServerQueryTest {
+import org.junit.Test;
+
+public class ServerQueryTest extends QueryTestCase {
   @Test
   public void index() {
     ServerQuery query = new ServerQuery();
index 710296c201fdfdeb0f4c41c73f2a7e1af6c603d6..b639b992fa17a1121ee78f7118d239156e05fa58 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
-public class SourceQueryTest {
+import org.junit.Test;
+
+public class SourceQueryTest extends QueryTestCase {
 
   @Test
   public void create() {
-    assertThat(SourceQuery.create("myproject:org.foo.Bar").getUrl(), is("/api/sources?resource=myproject:org.foo.Bar&"));
+    assertThat(SourceQuery.create("myproject:org.foo.Bar").getUrl(), is("/api/sources?resource=myproject%3Aorg.foo.Bar&"));
     assertThat(SourceQuery.create("myproject:org.foo.Bar").getModelClass().getName(), is(Source.class.getName()));
   }
 
   @Test
   public void createWithHighlightedSyntax() {
-    assertThat(SourceQuery.createWithHighlightedSyntax("myproject:org.foo.Bar").getUrl(), is("/api/sources?resource=myproject:org.foo.Bar&color=true&"));
+    assertThat(SourceQuery.createWithHighlightedSyntax("myproject:org.foo.Bar").getUrl(),
+        is("/api/sources?resource=myproject%3Aorg.foo.Bar&color=true&"));
     assertThat(SourceQuery.createWithHighlightedSyntax("myproject:org.foo.Bar").getModelClass().getName(), is(Source.class.getName()));
   }
 
   @Test
   public void getOnlyAFewLines() {
-    assertThat(SourceQuery.create("myproject:org.foo.Bar").setFromLineToLine(10, 30).getUrl(), is("/api/sources?resource=myproject:org.foo.Bar&from=10&to=30&"));
-    assertThat(SourceQuery.create("myproject:org.foo.Bar").setLinesFromLine(10, 20).getUrl(), is("/api/sources?resource=myproject:org.foo.Bar&from=10&to=30&"));
+    assertThat(SourceQuery.create("myproject:org.foo.Bar").setFromLineToLine(10, 30).getUrl(),
+        is("/api/sources?resource=myproject%3Aorg.foo.Bar&from=10&to=30&"));
+    assertThat(SourceQuery.create("myproject:org.foo.Bar").setLinesFromLine(10, 20).getUrl(),
+        is("/api/sources?resource=myproject%3Aorg.foo.Bar&from=10&to=30&"));
   }
 }
index cd20be13f04d08159190779ec3cab96caee085b6..0fe80630287ef84ae319c7d4c08fe56682864d23 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.wsclient.JdkUtils;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.Locale;
 import java.util.TimeZone;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.wsclient.JdkUtils;
 
-public class TimeMachineQueryTest {
+public class TimeMachineQueryTest extends QueryTestCase {
 
   private TimeZone systemTimeZone;
 
@@ -60,6 +59,8 @@ public class TimeMachineQueryTest {
     Date from = new SimpleDateFormat("yyyy-MM-dd").parse("2010-02-18");
     Date to = new SimpleDateFormat("yyyy-MM-dd HH:mm").parse("2010-03-25 14:59");
     TimeMachineQuery query = TimeMachineQuery.createForMetrics("12345", "ncloc").setFrom(from).setTo(to);
-    assertThat(query.getUrl(), is("/api/timemachine?resource=12345&metrics=ncloc&fromDateTime=2010-02-18T00%3A00%3A00%2B0000&toDateTime=2010-03-25T14%3A59%3A00%2B0000&"));
+    assertThat(
+        query.getUrl(),
+        is("/api/timemachine?resource=12345&metrics=ncloc&fromDateTime=2010-02-18T00%3A00%3A00%2B0000&toDateTime=2010-03-25T14%3A59%3A00%2B0000&"));
   }
 }
index c0d51e181916b210081fd21b1e5d0a724f394992..86cbb742ce3d79188ef642b15ded44a6539e73fb 100644 (file)
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
-public class UpdateCenterQueryTest {
+import org.junit.Test;
+
+public class UpdateCenterQueryTest extends QueryTestCase {
 
   @Test
   public void index() {
index ad60316a29f1ea30fed312d5be959c08368fadb2..09aa7a03c2193b660b8f92a1e5f77ca210ecc897 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
-public class UserPropertyCreateQueryTest {
+import org.junit.Test;
+
+public class UserPropertyCreateQueryTest extends QueryTestCase {
 
   @Test
   public void create() {
index 4978ff2d73942b72bc1557b3febb337172b96145..f9ef7be3bf14a21520a437bcc8ece6447308aaa3 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
 
-public class UserPropertyDeleteQueryTest {
+import org.junit.Test;
+
+public class UserPropertyDeleteQueryTest extends QueryTestCase {
 
   @Test
   public void delete() {
index 818ad935c3fde9b626390ca9a8780f73e71e289b..f7f9279906d5d6699523d86b498e0a111217ee55 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import org.junit.Test;
-
 import static org.hamcrest.Matchers.is;
 import static org.junit.Assert.assertThat;
 
-public class ViolationQueryTest {
+import org.junit.Test;
+
+public class ViolationQueryTest extends QueryTestCase {
 
   @Test
   public void resourceViolations() {
     ViolationQuery query = ViolationQuery.createForResource("myproject:org.foo:bar");
-    assertThat(query.getUrl(), is("/api/violations?resource=myproject:org.foo:bar&"));
+    assertThat(query.getUrl(), is("/api/violations?resource=myproject%3Aorg.foo%3Abar&"));
     assertThat(query.getModelClass().getName(), is(Violation.class.getName()));
   }
 
@@ -41,6 +41,8 @@ public class ViolationQueryTest {
         .setSeverities("MAJOR", "BLOCKER")
         .setQualifiers("FIL")
         .setRuleKeys("checkstyle:foo", "pmd:bar");
-    assertThat(query.getUrl(), is("/api/violations?resource=myproject&depth=-1&limit=20&qualifiers=FIL&rules=checkstyle:foo,pmd:bar&priorities=MAJOR,BLOCKER&"));
+    assertThat(
+        query.getUrl(),
+        is("/api/violations?resource=myproject&depth=-1&limit=20&qualifiers=FIL&rules=checkstyle%3Afoo,pmd%3Abar&priorities=MAJOR,BLOCKER&"));
   }
 }
index 7a920dd3ec3e276822b0551b03aec1b8c4d10e02..96c175a56cdffb43ceb621792b63cbfc5817547e 100644 (file)
@@ -17,7 +17,6 @@
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.unmarshallers;
 
 import org.junit.Test;
index ef5f03afa67a63d6a63e44a010567a9f8a57b98e..2a4351b6a347d245b4439601b6301aadc3bee19a 100644 (file)
@@ -17,7 +17,6 @@
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.unmarshallers;
 
 import org.apache.commons.io.IOUtils;
index 0f1e3094e9d65f62509c649c65c8452b5115603d..33387b4e0edf37bc9e94d2d3f95cfb31f1ddcda4 100644 (file)
@@ -17,7 +17,6 @@
  * License along with Sonar; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
  */
-
 package org.sonar.wsclient.unmarshallers;
 
 import org.junit.Test;