diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-10-23 18:28:13 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-10-23 21:18:27 +0200 |
commit | 4c3993eb0204b526be90108a1185e691596ef06c (patch) | |
tree | 62ad76970d10ddcafd144b03e2514a69f80f4b0e /sonar-maven-plugin/src/test/java/org/sonar | |
parent | ff739ecc971cf8a9d610477cd414569540fe88b8 (diff) | |
download | sonarqube-4c3993eb0204b526be90108a1185e691596ef06c.tar.gz sonarqube-4c3993eb0204b526be90108a1185e691596ef06c.zip |
SONAR-5705 Drop support of Maven 2
Diffstat (limited to 'sonar-maven-plugin/src/test/java/org/sonar')
3 files changed, 0 insertions, 147 deletions
diff --git a/sonar-maven-plugin/src/test/java/org/sonar/maven/ExceptionHandlingTest.java b/sonar-maven-plugin/src/test/java/org/sonar/maven/ExceptionHandlingTest.java deleted file mode 100644 index 78db2d14675..00000000000 --- a/sonar-maven-plugin/src/test/java/org/sonar/maven/ExceptionHandlingTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.maven; - -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; -import org.junit.Test; -import org.sonar.runner.impl.RunnerException; - -import static org.fest.assertions.Assertions.assertThat; -import static org.fest.assertions.Fail.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -public class ExceptionHandlingTest { - - private static final String MESSAGE = "the error message"; - - @Test - public void should_log_message_and_throw_exception() throws Exception { - Log log = mock(Log.class); - try { - ExceptionHandling.handle(MESSAGE, log); - fail(); - } catch (MojoExecutionException e) { - assertThat(e.getMessage()).isEqualTo(MESSAGE); - verify(log).error(MESSAGE); - } - } - - @Test - public void should_log_message_and_rethrow_exception() throws Exception { - Log log = mock(Log.class); - IllegalStateException cause = new IllegalStateException(MESSAGE); - try { - ExceptionHandling.handle(cause, log); - fail(); - } catch (MojoExecutionException e) { - assertThat(e.getMessage()).isEqualTo(MESSAGE); - assertThat(e.getCause()).isSameAs(cause); - verify(log).error(MESSAGE); - } - } - - @Test - public void should_hide_sonar_runner_stacktrace() throws Exception { - Log log = mock(Log.class); - IllegalStateException cause = new IllegalStateException(MESSAGE); - try { - ExceptionHandling.handle(new RunnerException(cause), log); - fail(); - } catch (MojoExecutionException e) { - assertThat(e.getMessage()).isEqualTo(MESSAGE); - assertThat(e.getCause()).isSameAs(cause); - verify(log).error(MESSAGE); - } - } -} diff --git a/sonar-maven-plugin/src/test/java/org/sonar/maven/SonarMojoTest.java b/sonar-maven-plugin/src/test/java/org/sonar/maven/SonarMojoTest.java deleted file mode 100644 index 7b1be21b330..00000000000 --- a/sonar-maven-plugin/src/test/java/org/sonar/maven/SonarMojoTest.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.maven; - -import org.apache.maven.artifact.versioning.DefaultArtifactVersion; -import org.apache.maven.execution.RuntimeInformation; -import org.apache.maven.plugin.MojoExecutionException; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -public class SonarMojoTest { - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void shouldFailWithOldMavenVersion() throws Exception { - SonarMojo mojo = new SonarMojo(); - mojo.runtimeInformation = mock(RuntimeInformation.class); - when(mojo.runtimeInformation.getApplicationVersion()).thenReturn(new DefaultArtifactVersion("2.0.11")); - thrown.expect(MojoExecutionException.class); - thrown.expectMessage("Please use at least Maven 2.2.x to perform SonarQube analysis (current version is 2.0.11)"); - mojo.execute(); - } -} diff --git a/sonar-maven-plugin/src/test/java/org/sonar/runner/impl/RunnerException.java b/sonar-maven-plugin/src/test/java/org/sonar/runner/impl/RunnerException.java deleted file mode 100644 index 7208f75891d..00000000000 --- a/sonar-maven-plugin/src/test/java/org/sonar/runner/impl/RunnerException.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.runner.impl; - -public class RunnerException extends RuntimeException { - public RunnerException(Throwable throwable) { - super(throwable); - } -} |