From: Simon Brandhof Date: Wed, 12 Apr 2017 19:40:06 +0000 (+0200) Subject: Drop test PluginsWsMediumTest X-Git-Tag: 6.3.2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=eede8ce813a0d21dd5c48c6468a89ecb52de657a;p=sonarqube.git Drop test PluginsWsMediumTest This test is badly implemented. It is heavily coupled with the build version and does not correctly support all kinds of versions (SNAPSHOT, release on 3 digits, build on 4 digits). --- diff --git a/server/sonar-server/pom.xml b/server/sonar-server/pom.xml index 129faac8c14..c9d21aa4fb3 100644 --- a/server/sonar-server/pom.xml +++ b/server/sonar-server/pom.xml @@ -264,15 +264,10 @@ src/test/resources false - - src/test/filteredresources - true - src/test/projects false - diff --git a/server/sonar-server/src/test/filteredresources/org/sonar/server/plugins/ws/PluginsWsMediumTest/update-center.properties b/server/sonar-server/src/test/filteredresources/org/sonar/server/plugins/ws/PluginsWsMediumTest/update-center.properties deleted file mode 100644 index 9c778b8945d..00000000000 --- a/server/sonar-server/src/test/filteredresources/org/sonar/server/plugins/ws/PluginsWsMediumTest/update-center.properties +++ /dev/null @@ -1,57 +0,0 @@ -# Current development version (single value) -devVersion=${project.version} - -publicVersions=5.6 - -# Long Term Support release. Must be declared in "publicVersions". -ltsVersion=5.6 - -5.6.description=Long-Term Support version - Many bug fixes and small improvements -5.6.downloadUrl=https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.6.zip -5.6.changelogUrl=https://jira.sonarsource.com/jira/secure/ReleaseNote.jspa?projectId=10930&version=12869 -5.6.date=2016-06-01 - -# list of plugins. It is used to load other files from the same directory. No need to sort. -plugins=foo,decoy - -# =============== decoy plugin -# Releases. Note that no need for "privateVersions" for now. -decoy.publicVersions=1.0,1.1 - -decoy.description=decoy -decoy.category=Languages - -decoy.defaults.mavenGroupId=org.codehaus.sonar-plugins -decoy.defaults.mavenArtifactId=sonar-decoy-plugin - -# Metadata of each release -# The range of supported SQ versions accepts the alias LATEST and * -decoy.1.0.date=2012-03-18 -decoy.1.0.sqVersions=6.2,${project.version} -decoy.1.0.description=Surprise -decoy.1.0.downloadUrl=[[decoy.10.jar]] -decoy.1.0.changelogUrl=http://jira.sonarsource.com/foo - -decoy.1.1.date=2012-03-18 -decoy.1.1.sqVersions=6.2,${project.version} -decoy.1.1.description=Surprise -decoy.1.1.downloadUrl=[[decoy.11.jar]] -decoy.1.1.changelogUrl=http://jira.sonarsource.com/foo - -# =============== decoy plugin -# Releases. Note that no need for "privateVersions" for now. -foo.publicVersions=1.0 - -foo.description=Foo -foo.category=Languages - -foo.defaults.mavenGroupId=org.codehaus.sonar-plugins -foo.defaults.mavenArtifactId=sonar-foo-plugin - -# Metadata of each release -# The range of supported SQ versions accepts the alias LATEST and * -foo.1.0.date=2012-03-18 -foo.1.0.sqVersions=6.2,${project.version} -foo.1.0.description=Surprise -foo.1.0.downloadUrl=[[foo.10.jar]] -foo.1.0.changelogUrl=http://jira.sonarsource.com/foo diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PluginsWsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PluginsWsMediumTest.java deleted file mode 100644 index 33b88bea6ce..00000000000 --- a/server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PluginsWsMediumTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2017 SonarSource SA - * mailto:info 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 org.sonar.server.plugins.ws; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import org.apache.commons.io.FileUtils; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.sonar.server.tester.ServerTester; -import org.sonar.server.tester.UserSessionRule; -import org.sonar.server.ws.WsTester; - -public class PluginsWsMediumTest { - private static final String ENCODING = "UTF-8"; - - @ClassRule - public static TemporaryFolder temporaryFolder = new TemporaryFolder(); - @ClassRule - public static ServerTester serverTester = new ServerTester() - .withEsIndexes() - .addPluginJar(getFile("sonar-decoy-plugin-1.0.jar")) - .setUpdateCenterUrl(createUpdateCenterPropertiesFile()); - - @Rule - public UserSessionRule userSessionRule = UserSessionRule.forServerTester(serverTester); - - @Test - public void test_update_existing_and_install_new_scenario() throws Exception { - WsTester wsTester = new WsTester(serverTester.get(PluginsWs.class)); - - // 1 - check what's installed, available and pending - userSessionRule.logIn().setSystemAdministrator(); - wsTester.newGetRequest("api/plugins", "installed").execute().assertJson("{" + - " \"plugins\": [" + - " {" + - " \"key\": \"decoy\"," + - " \"version\": \"1.0\"" + - " }" + - " ]" + - "}" - ); - - wsTester.newGetRequest("api/plugins", "available").execute().assertJson("{" + - " \"plugins\": [" + - " {" + - " \"key\": \"foo\"," + - " \"release\": {" + - " \"version\": \"1.0\"" + - " }," + - " \"update\": {" + - " \"status\": \"COMPATIBLE\"," + - " \"requires\": []" + - " }" + - " }" + - " ]" + - "}"); - - wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{\"installing\":[],\"removing\":[],\"updating\":[]}"); - - // 2 - install one plugin, update another, verify pending status in the process - wsTester.newPostRequest("api/plugins", "update").setParam("key", "decoy").execute().assertNoContent(); - - wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{" + - " \"updating\": [" + - " {" + - " \"key\": \"decoy\"," + - " \"version\": \"1.1\"" + - " }" + - " ]," + - " \"installing\": []," + - " \"removing\": []" + - "}"); - - wsTester.newPostRequest("api/plugins", "install").setParam("key", "foo").execute().assertNoContent(); - - wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{" + - " \"installing\": [" + - " {" + - " \"key\": \"foo\"," + - " \"version\": \"1.0\"" + - " }" + - " ]," + - " \"updating\": [" + - " {" + - " \"key\": \"decoy\"," + - " \"version\": \"1.1\"" + - " }" + - " ]," + - " \"removing\": []" + - "}"); - - // 3 - simulate SQ restart - wsTester = restartServerTester(); - - // 4 - make sure plugin is installed - userSessionRule.logIn().setSystemAdministrator(); - wsTester.newGetRequest("api/plugins", "installed").execute().assertJson("{" + - " \"plugins\": [" + - " {" + - " \"key\": \"decoy\"," + - " \"version\": \"1.1\"" + - " }," + - " {" + - " \"key\": \"foo\"," + - " \"version\": \"1.0\"" + - " }" + - " ]" + - "}" - ); - - // 5 - uninstall a plugin, verify pending status in the process - wsTester.newPostRequest("api/plugins", "uninstall").setParam("key", "foo").execute().assertNoContent(); - - wsTester.newGetRequest("api/plugins", "pending").execute().assertJson("{" + - " \"installing\": []," + - " \"updating\": []," + - " \"removing\": [" + - " {" + - " \"key\": \"foo\"," + - " \"version\": \"1.0\"" + - " }" + - " ]," + - "}"); - - // 6 - simulate SQ restart again - wsTester = restartServerTester(); - - // 7 - make sure plugin has been uninstalled - userSessionRule.logIn().setSystemAdministrator(); - wsTester.newGetRequest("api/plugins", "installed").execute().assertJson("{" + - " \"plugins\": [" + - " {" + - " \"key\": \"decoy\"," + - " \"version\": \"1.1\"" + - " }" + - " ]" + - "}" - ); - } - - private WsTester restartServerTester() { - serverTester.restart(); - // correctly simulate a server restart (ie. user is disconnected) - userSessionRule.anonymous(); - // must use a new WsTester to reference the right PluginWs instance - return new WsTester(serverTester.get(PluginsWs.class)); - } - - private static URL createUpdateCenterPropertiesFile() { - try { - temporaryFolder.create(); - String content = FileUtils.readFileToString(getFile("update-center.properties"), ENCODING) - .replace("[[decoy.10.jar]]", getFileUrl("sonar-decoy-plugin-1.0.jar").toString()) - .replace("[[decoy.11.jar]]", getFileUrl("sonar-decoy-plugin-1.1.jar").toString()) - .replace("[[foo.10.jar]]", getFileUrl("sonar-foo-plugin-1.0.jar").toString()); - File res = temporaryFolder.newFile("update-center.properties"); - FileUtils.write(res, content, "UTF-8"); - return res.toURI().toURL(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private static File getFile(String jarFileName) { - try { - return new File(getFileUrl(jarFileName).toURI()); - } catch (URISyntaxException e) { - throw new RuntimeException(e); - } - } - - private static URL getFileUrl(String fileName) { - return PluginsWsMediumTest.class.getResource(PluginsWsMediumTest.class.getSimpleName() + "/" + fileName); - } -} diff --git a/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-decoy-plugin-1.0.jar b/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-decoy-plugin-1.0.jar deleted file mode 100644 index e6ba8a4cc4b..00000000000 Binary files a/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-decoy-plugin-1.0.jar and /dev/null differ diff --git a/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-decoy-plugin-1.1.jar b/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-decoy-plugin-1.1.jar deleted file mode 100644 index 59fc4bcfc75..00000000000 Binary files a/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-decoy-plugin-1.1.jar and /dev/null differ diff --git a/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-foo-plugin-1.0.jar b/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-foo-plugin-1.0.jar deleted file mode 100644 index 4e58b7f8b58..00000000000 Binary files a/server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/PluginsWsMediumTest/sonar-foo-plugin-1.0.jar and /dev/null differ