]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7857 Upgrade to update center 1.17
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 15 Jul 2016 09:06:02 +0000 (11:06 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Fri, 15 Jul 2016 11:19:30 +0000 (13:19 +0200)
14 files changed:
pom.xml
server/sonar-server/src/test/java/org/sonar/server/platform/ws/UpgradesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/AbstractUpdateCenterBasedPluginsWsActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/AvailableActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/InstallActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/InstalledActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PendingActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PluginUpdateAggregateBuilderTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PluginUpdateAggregatorTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/PluginWSCommonsTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/UpdateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/plugins/ws/UpdatesActionTest.java
server/sonar-server/src/test/resources/org/sonar/server/plugins/ws/AvailableActionTest/properties_per_plugin.json

diff --git a/pom.xml b/pom.xml
index 2b6ce8740d6c0af330d75cb1173061a68ba20aae..9aba3be4934b5ea046145a0a420278c2b72ef78e 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -54,7 +54,7 @@
   </distributionManagement>
 
   <properties>
-    <sonarUpdateCenter.version>1.16-build309</sonarUpdateCenter.version>
+    <sonarUpdateCenter.version>1.17</sonarUpdateCenter.version>
     <sonarJava.version>4.0</sonarJava.version>
     <sonarJavaScript.version>2.14</sonarJavaScript.version>
     <sonarCSharp.version>5.3.1</sonarCSharp.version>
index e567008154bbb67a14cd213cfbbcd8f693bc60fc..478efa5001a8f4f9d1618cb52025ab7cc4d1556c 100644 (file)
@@ -109,7 +109,7 @@ public class UpgradesActionTest {
   }
 
   private static SonarUpdate createSonar_51_update() {
-    Plugin brandingPlugin = new Plugin("branding")
+    Plugin brandingPlugin = Plugin.factory("branding")
       .setCategory("Integration")
       .setName("Branding")
       .setDescription("Allows to add your own logo to the SonarQube UI.")
@@ -119,7 +119,7 @@ public class UpgradesActionTest {
       .setOrganizationUrl("http://www.sonarsource.com")
       .setIssueTrackerUrl("http://jira.sonarsource.com/browse/SONARPLUGINS/component/14663")
       .setSourcesUrl("https://github.com/SonarCommunity/sonar-branding");
-    Plugin viewsPlugin = new Plugin("views")
+    Plugin viewsPlugin = Plugin.factory("views")
       .setName("Views")
       .setCategory("Governance")
       .setDescription("Create aggregation trees to group projects. Projects can for instance be grouped by applications,   applications by team, teams by department.")
index a80c2eca18243398224e2bb5d23636f017beb321..82aeee20103b1dc4a089933d6357022f7dff3905 100644 (file)
@@ -112,7 +112,7 @@ public class PluginDownloaderTest {
 
   @Test
   public void download_from_url() {
-    Plugin test = new Plugin("test");
+    Plugin test = Plugin.factory("test");
     Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar");
     test.addRelease(test10);
 
@@ -132,7 +132,7 @@ public class PluginDownloaderTest {
   public void download_when_update_center_is_unavailable_with_no_exception_thrown() {
     when(updateCenterMatrixFactory.getUpdateCenter(anyBoolean())).thenReturn(Optional.<UpdateCenter>absent());
 
-    Plugin test = new Plugin("test");
+    Plugin test = Plugin.factory("test");
     Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar");
     test.addRelease(test10);
 
@@ -145,7 +145,7 @@ public class PluginDownloaderTest {
    */
   @Test
   public void download_from_redirect_url() {
-    Plugin test = new Plugin("plugin-test");
+    Plugin test = Plugin.factory("plugintest");
     Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/redirect?r=release&g=test&a=test&v=1.0&e=jar");
     test.addRelease(test10);
 
@@ -156,9 +156,9 @@ public class PluginDownloaderTest {
 
     // SONAR-4523: do not corrupt JAR files when restarting the server while a plugin is being downloaded.
     // The JAR file is downloaded in a temp file
-    verify(httpDownloader).download(any(URI.class), argThat(new HasFileName("plugin-test-1.0.jar.tmp")));
-    assertThat(new File(downloadDir, "plugin-test-1.0.jar")).exists();
-    assertThat(new File(downloadDir, "plugin-test-1.0.jar.tmp")).doesNotExist();
+    verify(httpDownloader).download(any(URI.class), argThat(new HasFileName("plugintest-1.0.jar.tmp")));
+    assertThat(new File(downloadDir, "plugintest-1.0.jar")).exists();
+    assertThat(new File(downloadDir, "plugintest-1.0.jar.tmp")).doesNotExist();
   }
 
   @Test
@@ -186,7 +186,7 @@ public class PluginDownloaderTest {
 
   @Test
   public void download_from_file() throws Exception {
-    Plugin test = new Plugin("test");
+    Plugin test = Plugin.factory("test");
     File file = testFolder.newFile("test-1.0.jar");
     file.createNewFile();
     Release test10 = new Release(test, "1.0").setDownloadUrl("file://" + separatorsToUnix(file.getCanonicalPath()));
@@ -202,7 +202,7 @@ public class PluginDownloaderTest {
 
   @Test
   public void throw_exception_if_could_not_download() {
-    Plugin test = new Plugin("test");
+    Plugin test = Plugin.factory("test");
     Release test10 = new Release(test, "1.0").setDownloadUrl("file://not_found");
     test.addRelease(test10);
 
@@ -219,7 +219,7 @@ public class PluginDownloaderTest {
 
   @Test
   public void throw_exception_if_download_fail() {
-    Plugin test = new Plugin("test");
+    Plugin test = Plugin.factory("test");
     Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar");
     test.addRelease(test10);
     when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
@@ -279,15 +279,15 @@ public class PluginDownloaderTest {
   // SONAR-5011
   @Test
   public void download_common_transitive_dependency() {
-    Plugin test1 = new Plugin("test1");
+    Plugin test1 = Plugin.factory("test1");
     Release test1R = new Release(test1, "1.0").setDownloadUrl("http://server/test1-1.0.jar");
     test1.addRelease(test1R);
 
-    Plugin test2 = new Plugin("test2");
+    Plugin test2 = Plugin.factory("test2");
     Release test2R = new Release(test2, "1.0").setDownloadUrl("http://server/test2-1.0.jar");
     test2.addRelease(test2R);
 
-    Plugin testDep = new Plugin("testdep");
+    Plugin testDep = Plugin.factory("testdep");
     Release testDepR = new Release(testDep, "1.0").setDownloadUrl("http://server/testdep-1.0.jar");
     testDep.addRelease(testDepR);
 
index c8cb5055cdeb606191ec9e6781360883fae74e99..cf2d8ba51f9c7882842efd005cfc0913d8a9ed7f 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.server.plugins.ws;
 
 import com.google.common.base.Optional;
+import java.net.URL;
 import org.junit.Before;
 import org.sonar.api.server.ws.Request;
 import org.sonar.api.utils.DateUtils;
@@ -31,8 +32,6 @@ import org.sonar.updatecenter.common.Release;
 import org.sonar.updatecenter.common.UpdateCenter;
 import org.sonar.updatecenter.common.Version;
 
-import java.net.URL;
-
 import static org.mockito.Matchers.anyBoolean;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -45,8 +44,8 @@ public abstract class AbstractUpdateCenterBasedPluginsWsActionTest {
     "{" +
       "  \"plugins\":" + "[]" +
       "}";
-  protected static final Plugin PLUGIN_1 = new Plugin("p_key_1").setName("p_name_1");
-  protected static final Plugin PLUGIN_2 = new Plugin("p_key_2").setName("p_name_2").setDescription("p_desc_2");
+  protected static final Plugin PLUGIN_1 = Plugin.factory("pkey1").setName("p_name_1");
+  protected static final Plugin PLUGIN_2 = Plugin.factory("pkey2").setName("p_name_2").setDescription("p_desc_2");
 
   protected UpdateCenterMatrixFactory updateCenterFactory = mock(UpdateCenterMatrixFactory.class);
   protected UpdateCenter updateCenter = mock(UpdateCenter.class);
@@ -68,7 +67,7 @@ public abstract class AbstractUpdateCenterBasedPluginsWsActionTest {
 
   protected static PluginUpdate pluginUpdate(String key, String name) {
     return PluginUpdate.createWithStatus(
-      new Release(new Plugin(key).setName(name), Version.create("1.0")),
+      new Release(Plugin.factory(key).setName(name), Version.create("1.0")),
       COMPATIBLE
       );
   }
index 27db1d72c2d4f86b61506e581b0890212dfce55b..f5d10cec26f646aeec190ea9d33a7aef03c441a9 100644 (file)
@@ -41,7 +41,7 @@ import static org.sonar.updatecenter.common.PluginUpdate.Status.REQUIRE_SONAR_UP
 
 public class AvailableActionTest extends AbstractUpdateCenterBasedPluginsWsActionTest {
 
-  private static final Plugin FULL_PROPERTIES_PLUGIN = new Plugin("p_key")
+  private static final Plugin FULL_PROPERTIES_PLUGIN = Plugin.factory("pkey")
     .setName("p_name")
     .setCategory("p_category")
     .setDescription("p_description")
index 33ddda90f625a173da9987828a5e4ee310100a45..a93b3c9153da20ceea4405fba5f05ab26622b783 100644 (file)
@@ -137,7 +137,7 @@ public class InstallActionTest {
   public void if_plugin_is_found_available_download_is_triggered_with_latest_version_from_updatecenter() throws Exception {
     Version version = Version.create("1.0");
     when(updateCenter.findAvailablePlugins()).thenReturn(ImmutableList.of(
-      PluginUpdate.createWithStatus(new Release(new Plugin(PLUGIN_KEY), version), PluginUpdate.Status.COMPATIBLE)
+      PluginUpdate.createWithStatus(new Release(Plugin.factory(PLUGIN_KEY), version), PluginUpdate.Status.COMPATIBLE)
       ));
 
     WsTester.Result result = validRequest.execute();
index 2ecc8132f0cdf11b64bc9d92d6ea05207dfad40b..58c1dd49a57cc20d596d1fddcfed16329e0384a7 100644 (file)
@@ -169,7 +169,7 @@ public class InstalledActionTest {
     when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
     when(updateCenter.findAllCompatiblePlugins()).thenReturn(
       Arrays.asList(
-        new Plugin("plugKey")
+        Plugin.factory("plugKey")
           .setCategory("cat_1")
       )
     );
index 7b82a95890a2ad05839380be6f0df0545d6201e1..6a2cf6d56fd6d5de95c0fa4d2e86581385e230d1 100644 (file)
@@ -304,7 +304,7 @@ public class PendingActionTest {
     when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
     List<Plugin> plugins = new ArrayList<>();
     for (String pluginKey : pluginKeys) {
-      plugins.add(new Plugin(pluginKey).setCategory("cat_1"));
+      plugins.add(Plugin.factory(pluginKey).setCategory("cat_1"));
     }
     when(updateCenter.findAllCompatiblePlugins()).thenReturn(plugins);
     return updateCenter;
index 4e94607746dedf3e339eaaefc3701dfc501684d6..b16c897031e7d0987a59da636de6604da809f58a 100644 (file)
@@ -28,8 +28,8 @@ import org.sonar.updatecenter.common.Version;
 
 public class PluginUpdateAggregateBuilderTest {
 
-  private static final Plugin PLUGIN_1 = new Plugin("key1");
-  private static final Plugin PLUGIN_2 = new Plugin("key2");
+  private static final Plugin PLUGIN_1 = Plugin.factory("key1");
+  private static final Plugin PLUGIN_2 = Plugin.factory("key2");
   private static final Version SOME_VERSION = Version.create("1.0");
   private static final PluginUpdate.Status SOME_STATUS = PluginUpdate.Status.COMPATIBLE;
 
@@ -49,10 +49,10 @@ public class PluginUpdateAggregateBuilderTest {
   public void add_uses_equals_which_takes_only_key_into_account() {
     PluginUpdateAggregateBuilder builder = PluginUpdateAggregateBuilder.builderFor(PLUGIN_1);
 
-    builder.add(createPluginUpdate(new Plugin(PLUGIN_1.getKey())));
+    builder.add(createPluginUpdate(Plugin.factory(PLUGIN_1.getKey())));
   }
 
   private static PluginUpdate createPluginUpdate(Plugin plugin) {
     return PluginUpdate.createWithStatus(new Release(plugin, SOME_VERSION), SOME_STATUS);
   }
-}
\ No newline at end of file
+}
index a3cfb7d910c168c1282c65eeda8e8197dd6f8a76..899dbbc2beff6deadf8c35e21d6557429835a576 100644 (file)
 package org.sonar.server.plugins.ws;
 
 import com.google.common.collect.ImmutableList;
+import java.util.Collection;
+import java.util.Collections;
 import org.junit.Test;
 import org.sonar.updatecenter.common.Plugin;
 import org.sonar.updatecenter.common.PluginUpdate;
 import org.sonar.updatecenter.common.Release;
 import org.sonar.updatecenter.common.Version;
 
-import java.util.Collection;
-import java.util.Collections;
-
 import static org.assertj.core.api.Assertions.assertThat;
 
 public class PluginUpdateAggregatorTest {
@@ -81,6 +80,6 @@ public class PluginUpdateAggregatorTest {
   }
 
   private PluginUpdate createPluginUpdate(String pluginKey) {
-    return PluginUpdate.createWithStatus(new Release(new Plugin(pluginKey), SOME_VERSION), SOME_STATUS);
+    return PluginUpdate.createWithStatus(new Release(Plugin.factory(pluginKey), SOME_VERSION), SOME_STATUS);
   }
 }
index 63d87e9fc4f3596f4c5dc834e97e7d812202516b..e232f225f76522566350dafc72f9907182e78e70 100644 (file)
@@ -86,7 +86,7 @@ public class PluginWSCommonsTest {
 
     jsonWriter.close();
     assertJson(response.outputAsString()).isSimilarTo("{" +
-      "  \"key\": \"p_key\"," +
+      "  \"key\": \"pkey\"," +
       "  \"name\": \"p_name\"," +
       "  \"description\": \"p_description\"," +
       "  \"category\": \"p_category\"," +
@@ -109,7 +109,7 @@ public class PluginWSCommonsTest {
 
     jsonWriter.close();
     assertJson(response.outputAsString()).isSimilarTo("{" +
-      "  \"key\": \"p_key\"," +
+      "  \"key\": \"pkey\"," +
       "  \"name\": \"p_name\"," +
       "  \"description\": \"p_description\"," +
       "  \"category\": \"p_category\"," +
@@ -140,7 +140,7 @@ public class PluginWSCommonsTest {
   @Test
   public void writeArtifact_from_release_writes_artifact_object_and_file_name() {
     jsonWriter.beginObject();
-    underTest.writeArtifact(jsonWriter, release("p_key").setDownloadUrl("http://toto.com/file.jar"));
+    underTest.writeArtifact(jsonWriter, release("pkey").setDownloadUrl("http://toto.com/file.jar"));
     jsonWriter.endObject();
 
     jsonWriter.close();
@@ -188,7 +188,7 @@ public class PluginWSCommonsTest {
       "  \"update\": {" +
       "    \"requires\": [" +
       "      {" +
-      "        \"key\": \"p_key\"," +
+      "        \"key\": \"pkey\"," +
       "        \"name\": \"p_name\"," +
       "        \"description\": \"p_description\"" +
       "      }" +
@@ -202,7 +202,7 @@ public class PluginWSCommonsTest {
   }
 
   private static Release release(String key) {
-    return new Release(new Plugin(key), version("1.0"));
+    return new Release(Plugin.factory(key), version("1.0"));
   }
 
   private PluginInfo gitPluginInfo() {
@@ -218,7 +218,7 @@ public class PluginWSCommonsTest {
   }
 
   private Plugin newPlugin() {
-    return new Plugin("p_key")
+    return Plugin.factory("pkey")
       .setName("p_name")
       .setCategory("p_category")
       .setDescription("p_description")
index d625790cfffb239d2429da406cd75f23226a5483..be00df7ebb45fcc74b94a309fe3307680b495d57 100644 (file)
@@ -139,7 +139,7 @@ public class UpdateActionTest {
   public void if_plugin_has_an_update_download_is_triggered_with_latest_version_from_updatecenter() throws Exception {
     Version version = Version.create("1.0");
     when(updateCenter.findPluginUpdates()).thenReturn(ImmutableList.of(
-      PluginUpdate.createWithStatus(new Release(new Plugin(PLUGIN_KEY), version), Status.COMPATIBLE)
+      PluginUpdate.createWithStatus(new Release(Plugin.factory(PLUGIN_KEY), version), Status.COMPATIBLE)
     ));
 
     underTest.handle(validRequest, response);
index 0b4ab210e14ba71b676c52472e9e53f1b56d11de..64589dbe2cb3fef655c539e864618cc8a254e21a 100644 (file)
@@ -34,10 +34,10 @@ import static org.sonar.updatecenter.common.PluginUpdate.Status.COMPATIBLE;
 import static org.sonar.updatecenter.common.PluginUpdate.Status.INCOMPATIBLE;
 
 public class UpdatesActionTest extends AbstractUpdateCenterBasedPluginsWsActionTest {
-  private static final Plugin JAVA_PLUGIN = new Plugin("java")
+  private static final Plugin JAVA_PLUGIN = Plugin.factory("java")
     .setName("Java")
     .setDescription("SonarQube rule engine.");
-  private static final Plugin ABAP_PLUGIN = new Plugin("abap")
+  private static final Plugin ABAP_PLUGIN = Plugin.factory("abap")
     .setName("ABAP")
     .setCategory("Languages")
     .setDescription("Enable analysis and reporting on ABAP projects")
@@ -55,7 +55,7 @@ public class UpdatesActionTest extends AbstractUpdateCenterBasedPluginsWsActionT
     .setDescription("14 new rules, most of them designed to detect potential performance hotspots.")
     .setDownloadUrl("http://dist.sonarsource.com/abap/download/sonar-abap-plugin-3.2.jar")
     .setChangelogUrl("http://jira.sonarsource.com/secure/ReleaseNote.jspa?projectId=10054&version=10575");
-  private static final Plugin ANDROID_PLUGIN = new Plugin("android")
+  private static final Plugin ANDROID_PLUGIN = Plugin.factory("android")
     .setName("Android")
     .setCategory("Languages")
     .setDescription("Import Android Lint reports.")
index 44e8587022a7cb23d597a9d3c373c7ad74c66cfb..dc6002d5d77e2293315d8257e330e3e6a9567d99 100644 (file)
@@ -1,16 +1,16 @@
 {
   "plugins": [
     {
-      "key": "p_key",
+      "key": "pkey",
       "name": "p_name",
       "category": "p_category",
       "description": "p_description",
       "license": "p_license",
+      "termsAndConditionsUrl": "p_t_and_c_url",
       "organizationName": "p_orga_name",
       "organizationUrl": "p_orga_url",
       "homepageUrl": "p_homepage_url",
       "issueTrackerUrl": "p_issue_url",
-      "termsAndConditionsUrl": "p_t_and_c_url",
       "release": {
         "version": "1.12.1",
         "date": "2015-04-16"
         "status": "COMPATIBLE",
         "requires": [
           {
-            "key": "p_key_1",
+            "key": "pkey1",
             "name": "p_name_1"
           },
           {
-            "key": "p_key_2",
+            "key": "pkey2",
             "name": "p_name_2",
             "description": "p_desc_2"
           }