Search in sources :

Example 16 with ServerPlugin

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

the class DownloadActionTest method return_uncompressed_jar_if_client_does_not_accept_compression.

@Test
public void return_uncompressed_jar_if_client_does_not_accept_compression() throws Exception {
    ServerPlugin plugin = newCompressedPlugin();
    when(serverPluginRepository.findPlugin(plugin.getPluginInfo().getKey())).thenReturn(Optional.of(plugin));
    TestResponse response = tester.newRequest().setParam("plugin", plugin.getPluginInfo().getKey()).execute();
    assertThat(response.getHeader("Sonar-MD5")).isEqualTo(plugin.getJar().getMd5());
    assertThat(response.getHeader("Sonar-Compression")).isNull();
    assertThat(response.getHeader("Sonar-UncompressedMD5")).isNull();
    assertThat(response.getMediaType()).isEqualTo("application/java-archive");
    verifySameContent(response, plugin.getJar().getFile());
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) ServerPlugin(org.sonar.server.plugins.ServerPlugin) Test(org.junit.Test)

Example 17 with ServerPlugin

use of org.sonar.server.plugins.ServerPlugin 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

ServerPlugin (org.sonar.server.plugins.ServerPlugin)17 PluginInfo (org.sonar.core.platform.PluginInfo)9 Test (org.junit.Test)8 FileAndMd5 (org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5)6 TestResponse (org.sonar.server.ws.TestResponse)4 File (java.io.File)3 DbSession (org.sonar.db.DbSession)2 PluginDto (org.sonar.db.plugin.PluginDto)2 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 LinkedList (java.util.LinkedList)1 Random (java.util.Random)1 NotFoundException (org.sonar.server.exceptions.NotFoundException)1 PluginFilesAndMd5 (org.sonar.server.plugins.PluginFilesAndMd5)1 PluginWSCommons.buildPluginDetails (org.sonar.server.plugins.ws.PluginWSCommons.buildPluginDetails)1 Plugin (org.sonar.updatecenter.common.Plugin)1