Search in sources :

Example 6 with FileAndMd5

use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.

the class RegisterPluginsTest method addPlugin.

private ServerPlugin addPlugin(String key, PluginType type, @Nullable String basePlugin) throws IOException {
    File file = createPluginFile(key);
    PluginFilesAndMd5.FileAndMd5 jar = new PluginFilesAndMd5.FileAndMd5(file);
    PluginInfo info = new PluginInfo(key).setBasePlugin(basePlugin).setJarFile(file);
    ServerPlugin serverPlugin = new ServerPlugin(info, type, null, jar, null, null);
    serverPluginRepository.addPlugin(serverPlugin);
    return serverPlugin;
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) ServerPlugin(org.sonar.server.plugins.ServerPlugin) PluginFilesAndMd5(org.sonar.server.plugins.PluginFilesAndMd5) File(java.io.File)

Example 7 with FileAndMd5

use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.

the class InstalledActionTest method newInstalledPluginWithCompression.

private ServerPlugin newInstalledPluginWithCompression(PluginInfo plugin) throws IOException {
    FileAndMd5 jar = new FileAndMd5(temp.newFile());
    FileAndMd5 compressedJar = new FileAndMd5(temp.newFile());
    return new ServerPlugin(plugin, PluginType.BUNDLED, null, jar, compressedJar, null);
}
Also used : FileAndMd5(org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5) ServerPlugin(org.sonar.server.plugins.ServerPlugin)

Example 8 with FileAndMd5

use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.

the class InstalledActionTest method commercial_plugins_from_SonarSource_has_flag_editionBundled_true_based_on_jar_info.

@Test
@UseDataProvider("editionBundledLicenseValues")
public void commercial_plugins_from_SonarSource_has_flag_editionBundled_true_based_on_jar_info(String license) throws Exception {
    String jarFilename = getClass().getSimpleName() + "/" + "some.jar";
    Random random = new Random();
    String organization = random.nextBoolean() ? "SonarSource" : "SONARSOURCE";
    String pluginKey = "plugKey";
    File jar = new File(getClass().getResource(jarFilename).toURI());
    when(serverPluginRepository.getPlugins()).thenReturn(asList(new ServerPlugin(new PluginInfo(pluginKey).setName("plugName").setVersion(Version.create("1.0")).setLicense(license).setOrganizationName(organization).setImplementationBuild("sou_rev_sha1"), PluginType.BUNDLED, null, new FileAndMd5(jar), new FileAndMd5(jar), null)));
    db.pluginDbTester().insertPlugin(p -> p.setKee(pluginKey), p -> p.setType(Type.BUNDLED), p -> p.setFileHash("abcdplugKey"), p -> p.setUpdatedAt(111111L));
    // ensure flag editionBundled is computed from jar info by enabling datacenter with other organization and license values
    UpdateCenter updateCenter = mock(UpdateCenter.class);
    when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
    when(updateCenter.findAllCompatiblePlugins()).thenReturn(singletonList(Plugin.factory(pluginKey).setOrganization("foo").setLicense("bar").setCategory("cat_1")));
    String response = tester.newRequest().execute().getInput();
    verifyZeroInteractions(updateCenterMatrixFactory);
    assertJson(response).isSimilarTo("{" + "  \"plugins\":" + "  [" + "    {" + "      \"key\": \"plugKey\"," + "      \"name\": \"plugName\"," + "      \"license\": \"" + license + "\"," + "      \"organizationName\": \"" + organization + "\"," + "      \"editionBundled\": true" + "    }" + "  ]" + "}");
}
Also used : FileAndMd5(org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5) UpdateCenter(org.sonar.updatecenter.common.UpdateCenter) Random(java.util.Random) ServerPlugin(org.sonar.server.plugins.ServerPlugin) PluginInfo(org.sonar.core.platform.PluginInfo) File(java.io.File) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 9 with FileAndMd5

use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.

the class DownloadActionTest method newCompressedPlugin.

private ServerPlugin newCompressedPlugin() throws IOException {
    FileAndMd5 jar = new FileAndMd5(temp.newFile());
    FileAndMd5 compressedJar = new FileAndMd5(temp.newFile());
    return new ServerPlugin(new PluginInfo("foo"), PluginType.BUNDLED, null, jar, compressedJar, null);
}
Also used : FileAndMd5(org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5) ServerPlugin(org.sonar.server.plugins.ServerPlugin) PluginInfo(org.sonar.core.platform.PluginInfo)

Aggregations

FileAndMd5 (org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5)8 ServerPlugin (org.sonar.server.plugins.ServerPlugin)7 PluginInfo (org.sonar.core.platform.PluginInfo)6 File (java.io.File)4 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 InputStream (java.io.InputStream)1 Random (java.util.Random)1 Test (org.junit.Test)1 Plugin (org.sonar.api.Plugin)1 NotFoundException (org.sonar.server.exceptions.NotFoundException)1 PluginFilesAndMd5 (org.sonar.server.plugins.PluginFilesAndMd5)1 UpdateCenter (org.sonar.updatecenter.common.UpdateCenter)1