aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src/test/java/org
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-01-31 12:05:58 +0100
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-01-31 12:06:05 +0100
commit47de0ecd410920fc000151f5c528b97b28505ec9 (patch)
treefcb7f4b6dd93cc36fd6fd044281dbc5ffa4ec23a /sonar-ws-client/src/test/java/org
parentaf595f0fda1855b09033a0ed98c955db0c5432c6 (diff)
downloadsonarqube-47de0ecd410920fc000151f5c528b97b28505ec9.tar.gz
sonarqube-47de0ecd410920fc000151f5c528b97b28505ec9.zip
WS client should consider codes other than 200 for success
Diffstat (limited to 'sonar-ws-client/src/test/java/org')
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java
index ff870ec5938..c0f8c726cc3 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/internal/HttpRequestFactoryTest.java
@@ -76,6 +76,28 @@ public class HttpRequestFactoryTest {
}
@Test
+ public void post_successful_if_created() {
+ httpServer.stubStatusCode(201).stubResponseBody("{}");
+
+ HttpRequestFactory factory = new HttpRequestFactory(httpServer.url());
+ String json = factory.post("/api/issues/change", Collections.<String, Object>emptyMap());
+
+ assertThat(json).isEqualTo("{}");
+ assertThat(httpServer.requestedPath()).isEqualTo("/api/issues/change");
+ }
+
+ @Test
+ public void post_successful_if_no_content() {
+ httpServer.stubStatusCode(204).stubResponseBody("");
+
+ HttpRequestFactory factory = new HttpRequestFactory(httpServer.url());
+ String json = factory.post("/api/issues/change", Collections.<String, Object>emptyMap());
+
+ assertThat(json).isEqualTo("");
+ assertThat(httpServer.requestedPath()).isEqualTo("/api/issues/change");
+ }
+
+ @Test
public void test_authentication() {
httpServer.stubStatusCode(200).stubResponseBody("{}");