From: Julien Lancelot Date: Wed, 18 May 2016 16:59:26 +0000 (+0200) Subject: SONAR-7484 Add ITs X-Git-Tag: 5.6-RC1~20 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F998%2Fhead;p=sonarqube.git SONAR-7484 Add ITs --- diff --git a/it/it-tests/src/test/java/it/Category4Suite.java b/it/it-tests/src/test/java/it/Category4Suite.java index bb75f2473f0..ea5ecc1175e 100644 --- a/it/it-tests/src/test/java/it/Category4Suite.java +++ b/it/it-tests/src/test/java/it/Category4Suite.java @@ -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 index 00000000000..84760bd99f9 --- /dev/null +++ b/it/it-tests/src/test/java/it/ws/WsTest.java @@ -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); + } + +}