aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-ws-client/src/test')
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java46
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/AbstractQueryTest.java27
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/DependencyQueryTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/EventQueryTest.java24
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/MetricQueryTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyCreateQueryTest.java8
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyDeleteQueryTest.java8
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyQueryTest.java8
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/QueryTestCase.java34
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java10
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerQueryTest.java9
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/SourceQueryTest.java17
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineQueryTest.java19
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java7
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyCreateQueryTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyDeleteQueryTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java12
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PluginUnmarshallerTest.java1
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java1
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java1
21 files changed, 144 insertions, 118 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java
index 1794466a5e2..716919076ea 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java
@@ -19,6 +19,14 @@
*/
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();
@@ -90,12 +93,6 @@ public class SonarTest {
}
@Test
- public void urlWithCharactersToEncode() {
- sonar.find(new QueryWithInvalidCharacters());
- // no exception
- }
-
- @Test
public void returnNullWhenSingleResultNotFound() {
Query<Metric> query = new EmptyQuery();
assertThat(sonar.find(query), nullValue());
@@ -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;
- }
- }
}
-
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/AbstractQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/AbstractQueryTest.java
index 76e73b8832d..c932a6f28ba 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/AbstractQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/AbstractQueryTest.java
@@ -17,20 +17,19 @@
* 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 {
@@ -45,6 +44,20 @@ public class AbstractQueryTest {
}
@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();
AbstractQuery.appendUrlParameter(url, "foo", "bar");
@@ -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());
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/DependencyQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/DependencyQueryTest.java
index b19568040de..98ccfca2b11 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/DependencyQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/DependencyQueryTest.java
@@ -19,13 +19,13 @@
*/
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() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/EventQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/EventQueryTest.java
index 332d1eb966b..428a2985bc8 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/EventQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/EventQueryTest.java
@@ -19,22 +19,16 @@
*/
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);
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/MetricQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/MetricQueryTest.java
index 3b9690dc43d..5545f093058 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/MetricQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/MetricQueryTest.java
@@ -19,12 +19,12 @@
*/
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() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyCreateQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyCreateQueryTest.java
index 9d1c321648a..269d5bb4463 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyCreateQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyCreateQueryTest.java
@@ -19,12 +19,12 @@
*/
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
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyDeleteQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyDeleteQueryTest.java
index 0c9b7484cd5..88819fa0b71 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyDeleteQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyDeleteQueryTest.java
@@ -19,12 +19,12 @@
*/
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
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyQueryTest.java
index 4c1e5cc15f2..85bb9f17d1d 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/PropertyQueryTest.java
@@ -19,12 +19,12 @@
*/
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
index 00000000000..8e1e6573b6f
--- /dev/null
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/QueryTestCase.java
@@ -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());
+ }
+
+}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java
index 6d9b506bbb4..017288450ba 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceQueryTest.java
@@ -19,18 +19,18 @@
*/
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&"));
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java
index 14ed894a277..46954f41e42 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/RuleQueryTest.java
@@ -19,12 +19,12 @@
*/
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() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerQueryTest.java
index 6f93db0171c..e90ad0480c4 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerQueryTest.java
@@ -19,15 +19,12 @@
*/
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();
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/SourceQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/SourceQueryTest.java
index 710296c201f..b639b992fa1 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/SourceQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/SourceQueryTest.java
@@ -19,28 +19,31 @@
*/
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&"));
}
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineQueryTest.java
index cd20be13f04..0fe80630287 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/TimeMachineQueryTest.java
@@ -19,21 +19,20 @@
*/
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&"));
}
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java
index c0d51e18191..86cbb742ce3 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UpdateCenterQueryTest.java
@@ -17,15 +17,14 @@
* 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() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyCreateQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyCreateQueryTest.java
index ad60316a29f..09aa7a03c21 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyCreateQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyCreateQueryTest.java
@@ -19,12 +19,12 @@
*/
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() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyDeleteQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyDeleteQueryTest.java
index 4978ff2d739..f9ef7be3bf1 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyDeleteQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/UserPropertyDeleteQueryTest.java
@@ -19,12 +19,12 @@
*/
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() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java
index 818ad935c3f..f7f9279906d 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ViolationQueryTest.java
@@ -19,17 +19,17 @@
*/
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&"));
}
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PluginUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PluginUnmarshallerTest.java
index 7a920dd3ec3..96c175a56cd 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PluginUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PluginUnmarshallerTest.java
@@ -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;
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java
index ef5f03afa67..2a4351b6a34 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java
@@ -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;
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java
index 0f1e3094e9d..33387b4e0ed 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java
@@ -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;