use of org.sonar.updatecenter.common.Version in project sonarqube by SonarSource.
the class UpdateActionTest method if_plugin_has_an_update_download_is_triggered_with_latest_version_from_updatecenter.
@Test
public void if_plugin_has_an_update_download_is_triggered_with_latest_version_from_updatecenter() throws Exception {
logInAsSystemAdministrator();
Version version = Version.create("1.0");
when(updateCenter.findPluginUpdates()).thenReturn(ImmutableList.of(PluginUpdate.createWithStatus(new Release(Plugin.factory(PLUGIN_KEY), version), Status.COMPATIBLE)));
underTest.handle(validRequest, response);
verify(pluginDownloader).download(PLUGIN_KEY, version);
assertThat(response.outputAsString()).isEmpty();
}
use of org.sonar.updatecenter.common.Version in project sonarqube by SonarSource.
the class InstallActionTest method if_plugin_is_found_available_download_is_triggered_with_latest_version_from_updatecenter.
@Test
public void if_plugin_is_found_available_download_is_triggered_with_latest_version_from_updatecenter() throws Exception {
logInAsSystemAdministrator();
Version version = Version.create("1.0");
when(updateCenter.findAvailablePlugins()).thenReturn(ImmutableList.of(PluginUpdate.createWithStatus(new Release(Plugin.factory(PLUGIN_KEY), version), PluginUpdate.Status.COMPATIBLE)));
WsTester.Result result = validRequest.execute();
verify(pluginDownloader).download(PLUGIN_KEY, version);
result.assertNoContent();
}
use of org.sonar.updatecenter.common.Version in project sonarqube by SonarSource.
the class PluginInfo method isCompatibleWith.
/**
* Find out if this plugin is compatible with a given version of SonarQube.
* The version of SQ must be greater than or equal to the minimal version
* needed by the plugin.
*/
public boolean isCompatibleWith(String runtimeVersion) {
if (null == this.minimalSqVersion) {
// no constraint defined on the plugin
return true;
}
Version effectiveMin = Version.create(minimalSqVersion.getName()).removeQualifier();
Version effectiveVersion = Version.create(runtimeVersion).removeQualifier();
if (runtimeVersion.endsWith("-SNAPSHOT")) {
// check only the major and minor versions (two first fields)
effectiveMin = Version.create(effectiveMin.getMajor() + "." + effectiveMin.getMinor());
}
return effectiveVersion.compareTo(effectiveMin) >= 0;
}
use of org.sonar.updatecenter.common.Version in project sonarqube by SonarSource.
the class PluginLoader method defineClassloaders.
/**
* Defines the different classloaders to be created. Number of classloaders can be
* different than number of plugins.
*/
@VisibleForTesting
Collection<PluginClassLoaderDef> defineClassloaders(Map<String, PluginInfo> infoByKeys) {
Map<String, PluginClassLoaderDef> classloadersByBasePlugin = new HashMap<>();
for (PluginInfo info : infoByKeys.values()) {
String baseKey = basePluginKey(info, infoByKeys);
PluginClassLoaderDef def = classloadersByBasePlugin.get(baseKey);
if (def == null) {
def = new PluginClassLoaderDef(baseKey);
classloadersByBasePlugin.put(baseKey, def);
}
ExplodedPlugin explodedPlugin = jarExploder.explode(info);
def.addFiles(asList(explodedPlugin.getMain()));
def.addFiles(explodedPlugin.getLibs());
def.addMainClass(info.getKey(), info.getMainClass());
for (String defaultSharedResource : DEFAULT_SHARED_RESOURCES) {
def.getExportMask().addInclusion(String.format("%s/%s/api/", defaultSharedResource, info.getKey()));
}
// They can't change metadata like ordering strategy or compatibility mode.
if (Strings.isNullOrEmpty(info.getBasePlugin())) {
def.setSelfFirstStrategy(info.isUseChildFirstClassLoader());
Version minSqVersion = info.getMinimalSqVersion();
boolean compatibilityMode = minSqVersion != null && minSqVersion.compareToIgnoreQualifier(COMPATIBILITY_MODE_MAX_VERSION) < 0;
def.setCompatibilityMode(compatibilityMode);
def.setPrivileged(isPrivileged(baseKey));
if (compatibilityMode) {
Loggers.get(getClass()).debug("API compatibility mode is enabled on plugin {} [{}] " + "(built with API lower than {})", info.getName(), info.getKey(), COMPATIBILITY_MODE_MAX_VERSION);
}
}
}
return classloadersByBasePlugin.values();
}
Aggregations