diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-10-13 22:49:56 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-10-13 23:04:48 +0200 |
commit | 3afe7a9001453a7106c488a1429e3bff91c8545f (patch) | |
tree | 7cbb75ca3198b63b7cb6bd30334a37cf0b691208 /sonar-core/src/test | |
parent | ded4ba72e1abcf4522223514490356355fca9c1c (diff) | |
download | sonarqube-3afe7a9001453a7106c488a1429e3bff91c8545f.tar.gz sonarqube-3afe7a9001453a7106c488a1429e3bff91c8545f.zip |
Improve message when trying to install a non-plugin JAR
Diffstat (limited to 'sonar-core/src/test')
-rw-r--r-- | sonar-core/src/test/java/org/sonar/core/platform/PluginInfoTest.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/platform/PluginInfoTest.java b/sonar-core/src/test/java/org/sonar/core/platform/PluginInfoTest.java index 35893ede34e..1472639b0c6 100644 --- a/sonar-core/src/test/java/org/sonar/core/platform/PluginInfoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/platform/PluginInfoTest.java @@ -28,7 +28,10 @@ import org.apache.commons.io.FileUtils; import org.assertj.core.api.Assertions; import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; +import org.sonar.api.utils.MessageException; +import org.sonar.api.utils.ZipUtils; import org.sonar.updatecenter.common.PluginManifest; import org.sonar.updatecenter.common.Version; @@ -41,6 +44,9 @@ public class PluginInfoTest { @Rule public TemporaryFolder temp = new TemporaryFolder(); + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Test public void test_RequiredPlugin() throws Exception { PluginInfo.RequiredPlugin plugin = PluginInfo.RequiredPlugin.parse("java:1.1"); @@ -212,7 +218,20 @@ public class PluginInfoTest { public void l10n_plugins_should_not_extend_english_plugin() { PluginInfo pluginInfo = new PluginInfo("l10nfr").setBasePlugin("l10nen"); assertThat(pluginInfo.getBasePlugin()).isNull(); + } + + @Test + public void fail_when_jar_is_not_a_plugin() throws IOException { + // this JAR has a manifest but is not a plugin + File jarRootDir = temp.newFolder(); + FileUtils.write(new File(jarRootDir, "META-INF/MANIFEST.MF"), "Build-Jdk: 1.6.0_15"); + File jar = temp.newFile(); + ZipUtils.zipDir(jarRootDir, jar); + + expectedException.expect(MessageException.class); + expectedException.expectMessage("File is not a plugin. Please delete it and restart: " + jar.getAbsolutePath()); + PluginInfo.create(jar); } PluginInfo withMinSqVersion(@Nullable String version) { |