diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-16 14:29:56 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2013-01-16 14:29:56 +0100 |
commit | 2fc32f40571c66a5fdb29aba8e5e41de5c090f9e (patch) | |
tree | dce648a1c0adf9817d86994d4ab3c83bb2b1e6ad /src/test/java/org/sonar/runner/RunnerTest.java | |
parent | 240e7abe2af7caa5900865b4df59b3e9f6a9ec3e (diff) | |
download | sonar-scanner-cli-2fc32f40571c66a5fdb29aba8e5e41de5c090f9e.tar.gz sonar-scanner-cli-2fc32f40571c66a5fdb29aba8e5e41de5c090f9e.zip |
SONARPLUGINS-2540 Restore compatibility with older Sonar versions.
Diffstat (limited to 'src/test/java/org/sonar/runner/RunnerTest.java')
-rw-r--r-- | src/test/java/org/sonar/runner/RunnerTest.java | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/src/test/java/org/sonar/runner/RunnerTest.java b/src/test/java/org/sonar/runner/RunnerTest.java index 2752999..d3e89de 100644 --- a/src/test/java/org/sonar/runner/RunnerTest.java +++ b/src/test/java/org/sonar/runner/RunnerTest.java @@ -80,16 +80,35 @@ public class RunnerTest { assertThat(Runner.isUnsupportedVersion("2.4")).isTrue(); assertThat(Runner.isUnsupportedVersion("2.4.1")).isTrue(); assertThat(Runner.isUnsupportedVersion("2.5")).isTrue(); - assertThat(Runner.isUnsupportedVersion("2.11")).isTrue(); - assertThat(Runner.isUnsupportedVersion("3.0")).isTrue(); - assertThat(Runner.isUnsupportedVersion("3.1")).isTrue(); - assertThat(Runner.isUnsupportedVersion("3.2")).isTrue(); - assertThat(Runner.isUnsupportedVersion("3.3")).isTrue(); - assertThat(Runner.isUnsupportedVersion("3.4")).isTrue(); + assertThat(Runner.isUnsupportedVersion("2.11")).isFalse(); + assertThat(Runner.isUnsupportedVersion("3.0")).isFalse(); + assertThat(Runner.isUnsupportedVersion("3.1")).isFalse(); + assertThat(Runner.isUnsupportedVersion("3.2")).isFalse(); + assertThat(Runner.isUnsupportedVersion("3.3")).isFalse(); + assertThat(Runner.isUnsupportedVersion("3.4")).isFalse(); assertThat(Runner.isUnsupportedVersion("3.5")).isFalse(); } @Test + public void shouldCheckVersionForTasks() { + assertThat(Runner.isUnsupportedVersionForTasks("1.0")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.0")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.1")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.2")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.3")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.4")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.4.1")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.5")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("2.11")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("3.0")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("3.1")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("3.2")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("3.3")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("3.4")).isTrue(); + assertThat(Runner.isUnsupportedVersionForTasks("3.5")).isFalse(); + } + + @Test public void shouldGetServerUrl() { Properties properties = new Properties(); Runner runner = Runner.create(properties); @@ -176,14 +195,30 @@ public class RunnerTest { Bootstrapper bootstrapper = mock(Bootstrapper.class); // nothing happens, OK - when(bootstrapper.getServerVersion()).thenReturn("3.5"); + when(bootstrapper.getServerVersion()).thenReturn("3.0"); runner.checkSonarVersion(bootstrapper); // but fails with older versions when(bootstrapper.getServerVersion()).thenReturn("2.1"); thrown.expect(RunnerException.class); - thrown.expectMessage("Sonar 2.1 is not supported. Please upgrade Sonar to version 3.5 or more."); + thrown.expectMessage("Sonar 2.1 is not supported. Please upgrade Sonar to version 2.11 or more."); runner.checkSonarVersion(bootstrapper); } + @Test + public void shouldCheckSonarVersionForTasks() { + Properties properties = new Properties(); + Runner runner = Runner.create("foo-cmd", properties, properties); + Bootstrapper bootstrapper = mock(Bootstrapper.class); + + // nothing happens, OK + when(bootstrapper.getServerVersion()).thenReturn("3.5"); + runner.checkSonarVersion(bootstrapper); + + // but fails with older versions + when(bootstrapper.getServerVersion()).thenReturn("3.4"); + thrown.expect(RunnerException.class); + thrown.expectMessage("Sonar 3.4 doesn't support tasks. Please upgrade Sonar to version 3.5 or more."); + runner.checkSonarVersion(bootstrapper); + } } |