aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/test
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-01-26 19:21:54 +0300
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-01-27 17:11:11 +0300
commit815899837ca07904fe9dc9223b4a4e8ac486cb59 (patch)
treeb92834ad5dd92bdd9eb8504e8bd649e81e559d41 /sonar-ws-client/src/test
parent40e0e78a54535e1a5009a626fb43dccad9230328 (diff)
downloadsonarqube-815899837ca07904fe9dc9223b4a4e8ac486cb59.tar.gz
sonarqube-815899837ca07904fe9dc9223b4a4e8ac486cb59.zip
SONAR-2046: Reuse unmarshallers from sonar-ws-client for sonar-gwt-api
* WSUtils has two implementations - one for GWT and another for Java, so can be used by unmarshallers in both cases. But this not very good, because code is not type-safe. In fact it would be better to use emulation of types from org.json.simple for GWT, but this solution is more straightforward.
Diffstat (limited to 'sonar-ws-client/src/test')
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshallerTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/EventUnmarshallerTest.java4
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java2
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java8
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PluginUnmarshallerTest.java8
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java8
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java12
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java4
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java8
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java25
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java6
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/WSTestUtils.java39
15 files changed, 69 insertions, 79 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshallerTest.java
index 4d5e412330e..b96defeba12 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshallerTest.java
@@ -27,13 +27,13 @@ import java.util.List;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-public class DependencyTreeUnmarshallerTest {
+public class DependencyTreeUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void singleDepthOfDependencies() {
List<DependencyTree> trees = new DependencyTreeUnmarshaller().toModels("[]");
assertThat(trees.size(), is(0));
- trees = new DependencyTreeUnmarshaller().toModels(WSTestUtils.loadFile("/dependency_tree/single_depth.json"));
+ trees = new DependencyTreeUnmarshaller().toModels(loadFile("/dependency_tree/single_depth.json"));
assertThat(trees.size(), is(2));
assertThat(trees.get(0).getDepId(), is("12345"));
assertThat(trees.get(0).getResourceId(), is("2000"));
@@ -48,7 +48,7 @@ public class DependencyTreeUnmarshallerTest {
@Test
public void manyDepthsOfDependencies() {
- List<DependencyTree> trees = new DependencyTreeUnmarshaller().toModels(WSTestUtils.loadFile("/dependency_tree/many_depths.json"));
+ List<DependencyTree> trees = new DependencyTreeUnmarshaller().toModels(loadFile("/dependency_tree/many_depths.json"));
assertThat(trees.size(), is(1));
List<DependencyTree> secondLevelTrees = trees.get(0).getTo();
assertThat(secondLevelTrees.size(), is(2));
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java
index d5c999d57ff..1ad4d090a2a 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java
@@ -28,14 +28,14 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-public class DependencyUnmarshallerTest {
+public class DependencyUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModel() {
Dependency dependency = new DependencyUnmarshaller().toModel("[]");
assertThat(dependency, nullValue());
- dependency = new DependencyUnmarshaller().toModel(WSTestUtils.loadFile("/dependencies/single.json"));
+ dependency = new DependencyUnmarshaller().toModel(loadFile("/dependencies/single.json"));
assertThat(dependency.getId(), is("1649"));
assertThat(dependency.getFromKey(), is("org.apache.shiro:shiro-core:org.apache.shiro.authc.pam"));
assertThat(dependency.getToKey(), is("org.apache.shiro:shiro-core:org.apache.shiro.realm"));
@@ -52,7 +52,7 @@ public class DependencyUnmarshallerTest {
Collection<Dependency> dependencies = new DependencyUnmarshaller().toModels("[]");
assertThat(dependencies.size(), is(0));
- dependencies = new DependencyUnmarshaller().toModels(WSTestUtils.loadFile("/dependencies/many.json"));
+ dependencies = new DependencyUnmarshaller().toModels(loadFile("/dependencies/many.json"));
assertThat(dependencies.size(), is(15));
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/EventUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/EventUnmarshallerTest.java
index 1577760bb23..b5c19029f0b 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/EventUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/EventUnmarshallerTest.java
@@ -29,11 +29,11 @@ import java.util.List;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-public class EventUnmarshallerTest {
+public class EventUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModel() throws Exception {
- List<Event> events = new EventUnmarshaller().toModels(WSTestUtils.loadFile("/events/events.json"));
+ List<Event> events = new EventUnmarshaller().toModels(loadFile("/events/events.json"));
Event event = events.get(0);
assertThat(event.getId(), is("10"));
assertThat(event.getName(), is("foo"));
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java
index dde72bf07a1..ef2e1c3aaf0 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java
@@ -30,7 +30,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
-public class JsonUtilsTest {
+public class JsonUtilsTest extends UnmarshallerTestCase {
@Test
public void getIntFields() {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java
index 1ac9d9a83b1..0eb4ff65fa7 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java
@@ -29,14 +29,14 @@ import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public class MetricUnmarshallerTest {
+public class MetricUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModel() {
Metric metric = new MetricUnmarshaller().toModel("[]");
assertThat(metric, nullValue());
- metric = new MetricUnmarshaller().toModel(WSTestUtils.loadFile("/metrics/one_metric.json"));
+ metric = new MetricUnmarshaller().toModel(loadFile("/metrics/one_metric.json"));
assertThat(metric.getKey(), is("ncloc"));
assertThat(metric.getName(), is("Lines of code"));
assertThat(metric.getDescription(), is("Non Commenting Lines of Code"));
@@ -49,10 +49,10 @@ public class MetricUnmarshallerTest {
Collection<Metric> metrics = new MetricUnmarshaller().toModels("[]");
assertThat(metrics.size(), is(0));
- metrics = new MetricUnmarshaller().toModels(WSTestUtils.loadFile("/metrics/one_metric.json"));
+ metrics = new MetricUnmarshaller().toModels(loadFile("/metrics/one_metric.json"));
assertThat(metrics.size(), is(1));
- metrics = new MetricUnmarshaller().toModels(WSTestUtils.loadFile("/metrics/many_metrics.json"));
+ metrics = new MetricUnmarshaller().toModels(loadFile("/metrics/many_metrics.json"));
assertThat(metrics.size(), is(10));
}
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 6b709a3a594..12423bf5ef7 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
@@ -1,18 +1,22 @@
package org.sonar.wsclient.unmarshallers;
import org.junit.Test;
+import org.sonar.wsclient.JdkUtils;
import org.sonar.wsclient.services.Plugin;
+import org.sonar.wsclient.services.WSUtils;
import java.util.List;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-public class PluginUnmarshallerTest {
+public class PluginUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModel() throws Exception {
- List<Plugin> plugins = new PluginUnmarshaller().toModels(WSTestUtils.loadFile("/plugins/plugins.json"));
+ WSUtils.setInstance(new JdkUtils());
+
+ List<Plugin> plugins = new PluginUnmarshaller().toModels(loadFile("/plugins/plugins.json"));
Plugin plugin = plugins.get(0);
assertThat(plugin.getKey(), is("foo"));
assertThat(plugin.getName(), is("Foo"));
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java
index ea919cb18f6..9ffb0de4b8c 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java
@@ -28,13 +28,13 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-public class PropertyUnmarshallerTest {
+public class PropertyUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModel() {
Property property = new PropertyUnmarshaller().toModel("[]");
assertThat(property, nullValue());
- property = new PropertyUnmarshaller().toModel(WSTestUtils.loadFile("/properties/single.json"));
+ property = new PropertyUnmarshaller().toModel(loadFile("/properties/single.json"));
assertThat(property.getKey(), is("myprop"));
assertThat(property.getValue(), is("myvalue"));
}
@@ -44,10 +44,10 @@ public class PropertyUnmarshallerTest {
Collection<Property> properties = new PropertyUnmarshaller().toModels("[]");
assertThat(properties.size(), is(0));
- properties = new PropertyUnmarshaller().toModels(WSTestUtils.loadFile("/properties/single.json"));
+ properties = new PropertyUnmarshaller().toModels(loadFile("/properties/single.json"));
assertThat(properties.size(), is(1));
- properties = new PropertyUnmarshaller().toModels(WSTestUtils.loadFile("/properties/many.json"));
+ properties = new PropertyUnmarshaller().toModels(loadFile("/properties/many.json"));
assertThat(properties.size(), is(3));
}
}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java
index 98df780a512..acfda91f3e5 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java
@@ -29,11 +29,11 @@ import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-public class ResourceUnmarshallerTest {
+public class ResourceUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void singleResource() {
- String json = WSTestUtils.loadFile("/resources/single-resource.json");
+ String json = loadFile("/resources/single-resource.json");
assertSonar(new ResourceUnmarshaller().toModel(json));
List<Resource> resources = new ResourceUnmarshaller().toModels(json);
@@ -43,7 +43,7 @@ public class ResourceUnmarshallerTest {
@Test
public void singleResourceWithMeasures() {
- Resource resource = new ResourceUnmarshaller().toModel(WSTestUtils.loadFile("/resources/single-resource-with-measures.json"));
+ Resource resource = new ResourceUnmarshaller().toModel(loadFile("/resources/single-resource-with-measures.json"));
assertSonar(resource);
assertThat(resource.getMeasures().size(), is(2));
@@ -54,7 +54,7 @@ public class ResourceUnmarshallerTest {
@Test
public void singleResourceWithTrends() {
- Resource resource = new ResourceUnmarshaller().toModel(WSTestUtils.loadFile("/resources/single-resource-with-trends.json"));
+ Resource resource = new ResourceUnmarshaller().toModel(loadFile("/resources/single-resource-with-trends.json"));
assertSonar(resource);
assertThat(resource.getMeasures().size(), is(2));
@@ -68,7 +68,7 @@ public class ResourceUnmarshallerTest {
@Test
public void manyResources() {
- List<Resource> resources = new ResourceUnmarshaller().toModels(WSTestUtils.loadFile("/resources/many-resources.json"));
+ List<Resource> resources = new ResourceUnmarshaller().toModels(loadFile("/resources/many-resources.json"));
assertThat(resources.size(), is(19));
for (Resource resource : resources) {
@@ -80,7 +80,7 @@ public class ResourceUnmarshallerTest {
@Test
public void manyResourcesWithMeasures() {
- List<Resource> resources = new ResourceUnmarshaller().toModels(WSTestUtils.loadFile("/resources/many-resources-with-measures.json"));
+ List<Resource> resources = new ResourceUnmarshaller().toModels(loadFile("/resources/many-resources-with-measures.json"));
assertThat(resources.size(), is(17));
for (Resource resource : resources) {
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java
index 71484bbe97e..6f75b766871 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/RuleUnmarshallerTest.java
@@ -28,7 +28,7 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertThat;
-public class RuleUnmarshallerTest {
+public class RuleUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModels() {
@@ -38,7 +38,7 @@ public class RuleUnmarshallerTest {
List<Rule> rules = new RuleUnmarshaller().toModels("[]");
assertThat(rules.size(), is(0));
- rules = new RuleUnmarshaller().toModels(WSTestUtils.loadFile("/rules/rules.json"));
+ rules = new RuleUnmarshaller().toModels(loadFile("/rules/rules.json"));
assertThat(rules.size(), is(6));
rule = rules.get(0);
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java
index 8e966d1a7c1..c6936bc56a5 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java
@@ -26,11 +26,11 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-public class ServerUnmarshallerTest {
+public class ServerUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void testToModel() {
- Server server = new ServerUnmarshaller().toModel(WSTestUtils.loadFile("/server/server.json"));
+ Server server = new ServerUnmarshaller().toModel(loadFile("/server/server.json"));
assertThat(server.getId(), is("123456789"));
assertThat(server.getVersion(), is("2.0-SNAPSHOT"));
assertThat(server.getStatus(), is(Server.Status.UP));
@@ -39,7 +39,7 @@ public class ServerUnmarshallerTest {
@Test
public void shouldNotFailIfStatusIsMissing() {
- Server server = new ServerUnmarshaller().toModel(WSTestUtils.loadFile("/server/status_missing.json"));
+ Server server = new ServerUnmarshaller().toModel(loadFile("/server/status_missing.json"));
assertThat(server.getId(), is("123456789"));
assertThat(server.getVersion(), is("2.0-SNAPSHOT"));
assertThat(server.getStatus(), nullValue());
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java
index 31061fa2bbe..b97d71c216f 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java
@@ -26,21 +26,21 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
-public class SourceUnmarshallerTest {
+public class SourceUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModel() {
Source source = new SourceUnmarshaller().toModel("[]");
assertThat(source, nullValue());
- source = new SourceUnmarshaller().toModel(WSTestUtils.loadFile("/sources/source.json"));
+ source = new SourceUnmarshaller().toModel(loadFile("/sources/source.json"));
assertThat(source.getLines().size(), is(236));
assertThat(source.getLine(3), is(" * Copyright (C) 2009 SonarSource SA"));
}
@Test
public void fromLineToLine() {
- Source source = new SourceUnmarshaller().toModel(WSTestUtils.loadFile("/sources/from_line_to_line.json"));
+ Source source = new SourceUnmarshaller().toModel(loadFile("/sources/from_line_to_line.json"));
assertThat(source.getLines().size(), is(15));
assertThat(source.getLine(1), nullValue());
assertThat(source.getLine(3), is(" * Copyright (C) 2009 SonarSource SA"));
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java
index 731d58e24f7..bad185a6b79 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshallerTest.java
@@ -26,11 +26,11 @@ import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
-public class TimeMachineUnmarshallerTest {
+public class TimeMachineUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void testToModel() throws Exception {
- TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(WSTestUtils.loadFile("/timemachine/timemachine.json"));
+ TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/timemachine.json"));
// columns
assertThat(timeMachine.getColumns().length, is(2));
@@ -52,7 +52,7 @@ public class TimeMachineUnmarshallerTest {
@Test
public void shouldAcceptNullValues() throws Exception {
- TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(WSTestUtils.loadFile("/timemachine/null-values.json"));
+ TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/null-values.json"));
assertThat(timeMachine.getCells()[0].getValues().length, is(2));
assertThat(timeMachine.getCells()[0].getValues()[0], nullValue());
@@ -64,7 +64,7 @@ public class TimeMachineUnmarshallerTest {
@Test
public void shouldCastValues() throws Exception {
- TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(WSTestUtils.loadFile("/timemachine/typed-values.json"));
+ TimeMachine timeMachine = new TimeMachineUnmarshaller().toModel(loadFile("/timemachine/typed-values.json"));
assertThat(timeMachine.getCells()[0].getValues().length, is(2));
assertThat((String) timeMachine.getCells()[0].getValues()[0], is("Sonar way"));
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
new file mode 100644
index 00000000000..82792d381d3
--- /dev/null
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallerTestCase.java
@@ -0,0 +1,25 @@
+package org.sonar.wsclient.unmarshallers;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.BeforeClass;
+import org.sonar.wsclient.JdkUtils;
+import org.sonar.wsclient.services.WSUtils;
+
+import java.io.IOException;
+
+public abstract class UnmarshallerTestCase {
+
+ @BeforeClass
+ public static void setupWsUtils() {
+ WSUtils.setInstance(new JdkUtils());
+ }
+
+ public static String loadFile(String path) {
+ try {
+ return IOUtils.toString(UnmarshallerTestCase.class.getResourceAsStream(path));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
index 22e256dc73b..fd83fcca74b 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
@@ -30,14 +30,14 @@ import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat;
-public class ViolationUnmarshallerTest {
+public class ViolationUnmarshallerTest extends UnmarshallerTestCase {
@Test
public void toModels() {
Violation violation = new ViolationUnmarshaller().toModel("[]");
assertThat(violation, nullValue());
- List<Violation> violations = new ViolationUnmarshaller().toModels(WSTestUtils.loadFile("/violations/violations.json"));
+ List<Violation> violations = new ViolationUnmarshaller().toModels(loadFile("/violations/violations.json"));
assertThat(violations.size(), is(2));
violation = violations.get(0);
@@ -56,7 +56,7 @@ public class ViolationUnmarshallerTest {
@Test
public void violationWithoutLineNumber() {
- Violation violation = new ViolationUnmarshaller().toModel(WSTestUtils.loadFile("/violations/violation-without-optional-fields.json"));
+ Violation violation = new ViolationUnmarshaller().toModel(loadFile("/violations/violation-without-optional-fields.json"));
assertThat(violation.getMessage(), not(nullValue()));
assertThat(violation.getLine(), nullValue());
assertThat(violation.getCreatedAt(), nullValue());
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/WSTestUtils.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/WSTestUtils.java
deleted file mode 100644
index a6c8981137d..00000000000
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/WSTestUtils.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2009 SonarSource SA
- * 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.unmarshallers;
-
-import org.apache.commons.io.IOUtils;
-
-import java.io.IOException;
-
-public final class WSTestUtils {
-
- public static String loadFile(String path) {
- try {
- return IOUtils.toString(WSTestUtils.class.getResourceAsStream(path));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- private WSTestUtils() {
- }
-
-}