diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2012-11-12 11:21:07 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2012-11-12 11:22:28 +0100 |
commit | 130c447b05766d2bf5082b8d56fd186c5bf192cf (patch) | |
tree | 3f417727a573452511b2b76d60197acfaa87ce0f /sonar-ws-client | |
parent | f6b2b0e962f0ecea9f7a699addfc55d4cae761d3 (diff) | |
download | sonarqube-130c447b05766d2bf5082b8d56fd186c5bf192cf.tar.gz sonarqube-130c447b05766d2bf5082b8d56fd186c5bf192cf.zip |
SONAR-3951 Encode "s" url parameter for resources/search service
Diffstat (limited to 'sonar-ws-client')
-rw-r--r-- | sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java | 5 | ||||
-rw-r--r-- | sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java | 7 |
2 files changed, 9 insertions, 3 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java index aae35d9f2e0..8648524329c 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java @@ -75,9 +75,8 @@ public class ResourceSearchQuery extends Query<ResourceSearchResult> { @Override public String getUrl() { StringBuilder url = new StringBuilder(); - url.append("/api/resources/search?s="); - url.append(text); - url.append("&"); + url.append("/api/resources/search?"); + appendUrlParameter(url, "s", text); if (page > 0) { appendUrlParameter(url, "p", page); } diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java index f789d361819..717c321c702 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceSearchQueryTest.java @@ -34,6 +34,13 @@ public class ResourceSearchQueryTest extends QueryTestCase { } @Test + public void test_encode_url_search_param() { + ResourceSearchQuery query = ResourceSearchQuery.create("commons logging"); + assertThat(query.getUrl(), is("/api/resources/search?s=commons+logging&")); + assertThat(query.getModelClass().getName(), is(ResourceSearchResult.class.getName())); + } + + @Test public void test_optional_parameters() { ResourceSearchQuery query = ResourceSearchQuery.create("commons"); query.setPage(5); |