]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7484 Add ITs 998/head
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 18 May 2016 16:59:26 +0000 (18:59 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 19 May 2016 08:53:46 +0000 (10:53 +0200)
it/it-tests/src/test/java/it/Category4Suite.java
it/it-tests/src/test/java/it/ws/WsTest.java [new file with mode: 0644]

index bb75f2473f08da9aa590dd713d7fec5e42d96793..ea5ecc1175e7966f9348f747ff4ab5325dfb3b9e 100644 (file)
@@ -42,6 +42,7 @@ import it.user.LocalAuthenticationTest;
 import it.user.MyAccountPageTest;
 import it.user.OAuth2IdentityProviderTest;
 import it.ws.WsLocalCallTest;
+import it.ws.WsTest;
 import org.junit.ClassRule;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
@@ -85,7 +86,8 @@ import static util.ItUtils.xooPlugin;
   UiTest.class,
   // ui extensions
   UiExtensionsTest.class,
-  WsLocalCallTest.class
+  WsLocalCallTest.class,
+  WsTest.class
 })
 public class Category4Suite {
 
diff --git a/it/it-tests/src/test/java/it/ws/WsTest.java b/it/it-tests/src/test/java/it/ws/WsTest.java
new file mode 100644 (file)
index 0000000..84760bd
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+package it.ws;
+
+import com.sonar.orchestrator.Orchestrator;
+import it.Category4Suite;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.WsResponse;
+
+import static java.net.HttpURLConnection.HTTP_BAD_REQUEST;
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.newWsClient;
+
+public class WsTest {
+
+  @ClassRule
+  public static final Orchestrator orchestrator = Category4Suite.ORCHESTRATOR;
+
+  @Test
+  public void gets_protobuf() {
+    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.protobuf"));
+    assertThat(response.isSuccessful()).isTrue();
+    assertThat(response.contentType()).contains("application/x-protobuf");
+  }
+
+  @Test
+  public void gets_json() {
+    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.json"));
+    assertThat(response.isSuccessful()).isTrue();
+    assertThat(response.contentType()).contains("application/json");
+  }
+
+  /**
+   * SONAR-7484
+   */
+  @Test
+  public void fail_on_unknown_extension() {
+    WsResponse response = newWsClient(orchestrator).wsConnector().call(new GetRequest("api/issues/search.unknown"));
+    assertThat(response.isSuccessful()).isFalse();
+    assertThat(response.code()).isEqualTo(HTTP_BAD_REQUEST);
+  }
+
+}