org.sonar.updatecenter.common.Version.create()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中org.sonar.updatecenter.common.Version.create()方法的一些代码示例,展示了Version.create()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Version.create()方法的具体详情如下:
包路径:org.sonar.updatecenter.common.Version
类名称:Version
方法名:create

Version.create介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

public static RequiredPlugin parse(String s) {
 if (!PARSER.matcher(s).matches()) {
  throw new IllegalArgumentException("Manifest field does not have correct format: " + s);
 }
 String[] fields = StringUtils.split(s, ':');
 return new RequiredPlugin(fields[0], Version.create(fields[1]).removeQualifier());
}

代码示例来源:origin: SonarSource/sonarqube

PluginInfo withMinSqVersion(@Nullable String version) {
  PluginInfo pluginInfo = new PluginInfo("foo");
  if (version != null) {
   pluginInfo.setMinimalSqVersion(Version.create(version));
  }
  return pluginInfo;
 }
}

代码示例来源:origin: SonarSource/sonarqube

public Optional<UpdateCenter> getUpdateCenter(boolean refreshUpdateCenter) {
  Optional<UpdateCenter> updateCenter = centerClient.getUpdateCenter(refreshUpdateCenter);
  if (updateCenter.isPresent()) {
   org.sonar.api.utils.Version fullVersion = sonarRuntime.getApiVersion();
   org.sonar.api.utils.Version semanticVersion = org.sonar.api.utils.Version.create(fullVersion.major(), fullVersion.minor(), fullVersion.patch());

   return Optional.of(updateCenter.get().setInstalledSonarVersion(Version.create(semanticVersion.toString())).registerInstalledPlugins(
    installedPluginReferentialFactory.getInstalledPluginReferential())
    .setDate(centerClient.getLastRefreshDate()));
  }
  return Optional.absent();
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void create_from_file() {
 File checkstyleJar = FileUtils.toFile(getClass().getResource("/org/sonar/core/platform/sonar-checkstyle-plugin-2.8.jar"));
 PluginInfo checkstyleInfo = PluginInfo.create(checkstyleJar);
 assertThat(checkstyleInfo.getName()).isEqualTo("Checkstyle");
 assertThat(checkstyleInfo.getMinimalSqVersion()).isEqualTo(Version.create("2.8"));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void downloadUpdateCenter() throws URISyntaxException {
 when(reader.readString(new URI(BASE_URL), StandardCharsets.UTF_8)).thenReturn("publicVersions=2.2,2.3");
 UpdateCenter plugins = underTest.getUpdateCenter().get();
 verify(reader, times(1)).readString(new URI(BASE_URL), StandardCharsets.UTF_8);
 assertThat(plugins.getSonar().getVersions()).containsOnly(Version.create("2.2"), Version.create("2.3"));
 assertThat(underTest.getLastRefreshDate()).isNotNull();
}

代码示例来源:origin: SonarSource/sonarqube

private PluginInfo newPlugin(String key, String version) {
 return new PluginInfo(key)
  .setVersion(Version.create(version));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test_toString() throws Exception {
 PluginInfo pluginInfo = new PluginInfo("java").setVersion(Version.create("1.1"));
 assertThat(pluginInfo.toString()).isEqualTo("[java / 1.1]");
 pluginInfo.setImplementationBuild("SHA1");
 assertThat(pluginInfo.toString()).isEqualTo("[java / 1.1 / SHA1]");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void read_download_folder() throws Exception {
 pluginDownloader.start();
 assertThat(noDownloadedFiles()).isZero();
 copyFileToDirectory(TestProjectUtils.jarOf("test-base-plugin"), downloadDir);
 assertThat(pluginDownloader.getDownloadedPlugins()).hasSize(1);
 PluginInfo info = pluginDownloader.getDownloadedPlugins().iterator().next();
 assertThat(info.getKey()).isEqualTo("testbase");
 assertThat(info.getName()).isEqualTo("Base Plugin");
 assertThat(info.getVersion()).isEqualTo(Version.create("0.1-SNAPSHOT"));
 assertThat(info.getMainClass()).isEqualTo("BasePlugin");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void download_from_file() throws Exception {
 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()));
 test.addRelease(test10);
 when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
 pluginDownloader.start();
 pluginDownloader.download("foo", create("1.0"));
 verify(httpDownloader, never()).download(any(URI.class), any(File.class));
 assertThat(noDownloadedFiles()).isGreaterThan(0);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void fail_if_no_compatible_plugin_found() {
 expectedException.expect(BadRequestException.class);
 pluginDownloader.download("foo", create("1.0"));
}

代码示例来源:origin: SonarSource/sonarqube

@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();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void downloaded_file_overrides_existing_installed_file_on_startup() throws Exception {
 File installedV1 = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 File downloadedV2 = copyTestPluginTo("test-base-plugin-v2", fs.getDownloadedPluginsDir());
 underTest.start();
 // plugin is moved to extensions/plugins and replaces v1
 assertThat(downloadedV2).doesNotExist();
 assertThat(installedV1).doesNotExist();
 assertThat(new File(fs.getInstalledPluginsDir(), downloadedV2.getName())).exists();
 assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
 assertThat(underTest.getPluginInfo("testbase").getVersion()).isEqualTo(Version.create("0.2-SNAPSHOT"));
}

代码示例来源:origin: SonarSource/sonarqube

@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();
}

代码示例来源:origin: SonarSource/sonarqube

protected static PluginUpdate pluginUpdate(String key, String name) {
 return PluginUpdate.createWithStatus(
  new Release(Plugin.factory(key).setName(name), Version.create("1.0")),
  COMPATIBLE);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void download_when_update_center_is_unavailable_with_no_exception_thrown() {
 when(updateCenterMatrixFactory.getUpdateCenter(anyBoolean())).thenReturn(Optional.absent());
 Plugin test = Plugin.factory("test");
 Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar");
 test.addRelease(test10);
 pluginDownloader.start();
 pluginDownloader.download("foo", create("1.0"));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void test_example() {
 when(pluginRepository.getPluginInfos()).thenReturn(asList(
  new PluginInfo("findbugs").setName("Findbugs").setVersion(Version.create("2.1")),
  new PluginInfo("l10nfr").setName("French Pack").setVersion(Version.create("1.10")),
  new PluginInfo("jira").setName("JIRA").setVersion(Version.create("1.2"))));
 String result = ws.newRequest().execute().getInput();
 assertJson(result).isSimilarTo(ws.getDef().responseExampleAsString());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void log_warning_if_plugin_is_built_with_api_5_2_or_lower() throws Exception {
 File jarFile = temp.newFile();
 PluginInfo info = new PluginInfo("foo")
  .setJarFile(jarFile)
  .setMainClass("org.foo.FooPlugin")
  .setMinimalSqVersion(Version.create("4.5.2"));
 Collection<PluginClassLoaderDef> defs = underTest.defineClassloaders(ImmutableMap.of("foo", info));
 assertThat(defs).extracting(PluginClassLoaderDef::getBasePluginKey).containsExactly("foo");
 List<String> warnings = logTester.logs(LoggerLevel.WARN);
 assertThat(warnings).contains("API compatibility mode is no longer supported. In case of error, plugin foo [foo] should package its dependencies.");
}

代码示例来源:origin: SonarSource/sonarqube

private PluginInfo gitPluginInfo() {
 return new PluginInfo("scmgit")
  .setName("Git")
  .setDescription("Git SCM Provider.")
  .setVersion(Version.create("1.0"))
  .setLicense("GNU LGPL 3")
  .setOrganizationName("SonarSource")
  .setOrganizationUrl("http://www.sonarsource.com")
  .setHomepageUrl("https://redirect.sonarsource.com/plugins/scmgit.html")
  .setIssueTrackerUrl("http://jira.sonarsource.com/browse/SONARSCGIT")
  .setSonarLintSupported(true)
  .setJarFile(new File("sonar-scm-git-plugin-1.0.jar"));
}

代码示例来源:origin: SonarSource/sonarqube

private InstalledPlugin plugin(String key, String name) throws IOException {
 File file = temp.newFile();
 PluginInfo info = new PluginInfo(key)
  .setName(name)
  .setVersion(Version.create("1.0"));
 info.setJarFile(file);
 return new InstalledPlugin(info, new FileAndMd5(file), null);
}

代码示例来源:origin: SonarSource/sonarqube

private PluginInfo newScmGitPluginInfo() {
 return new PluginInfo("scmgit")
  .setName("Git")
  .setDescription("Git SCM Provider.")
  .setVersion(Version.create("1.0"))
  .setLicense("GNU LGPL 3")
  .setOrganizationName("SonarSource")
  .setOrganizationUrl("http://www.sonarsource.com")
  .setHomepageUrl("https://redirect.sonarsource.com/plugins/scmgit.html")
  .setIssueTrackerUrl("http://jira.sonarsource.com/browse/SONARSCGIT")
  .setImplementationBuild("9ce9d330c313c296fab051317cc5ad4b26319e07");
}

相关文章