aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-10-20 11:16:32 +0000
committerGodin <mandrikov@gmail.com>2010-10-20 11:16:32 +0000
commit71fba38c4f5cfe22803b3a253e07772a76d9219e (patch)
tree7a0e537b7faa2df8db7a47f975f175f90859763d /plugins
parent77c389b4620b3399fbb7946892c0cf1c420ec3e6 (diff)
downloadsonarqube-71fba38c4f5cfe22803b3a253e07772a76d9219e.tar.gz
sonarqube-71fba38c4f5cfe22803b3a253e07772a76d9219e.zip
SONAR-1808: Add CoberturaUtils
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java9
-rw-r--r--plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java7
-rw-r--r--plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java18
3 files changed, 17 insertions, 17 deletions
diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java
index 0e044eff8ae..8bf085f5325 100644
--- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java
+++ b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandler.java
@@ -24,20 +24,17 @@ import org.sonar.api.CoreProperties;
import org.sonar.api.batch.maven.MavenPlugin;
import org.sonar.api.batch.maven.MavenPluginHandler;
import org.sonar.api.batch.maven.MavenSurefireUtils;
-import org.sonar.api.batch.maven.MavenUtils;
import org.sonar.api.resources.Project;
+import org.sonar.plugins.cobertura.api.CoberturaUtils;
public class CoberturaMavenPluginHandler implements MavenPluginHandler {
- public static final String GROUP_ID = MavenUtils.GROUP_ID_CODEHAUS_MOJO;
- public static final String ARTIFACT_ID = "cobertura-maven-plugin";
-
public String getGroupId() {
- return GROUP_ID;
+ return CoberturaUtils.COBERTURA_GROUP_ID;
}
public String getArtifactId() {
- return ARTIFACT_ID;
+ return CoberturaUtils.COBERTURA_ARTIFACT_ID;
}
public String getVersion() {
diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
index e8d7cc1bcce..adf4c5bb27d 100644
--- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
+++ b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java
@@ -2,9 +2,9 @@ package org.sonar.plugins.cobertura.api;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.maven.MavenPlugin;
+import org.sonar.api.batch.maven.MavenUtils;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.Logs;
-import org.sonar.plugins.cobertura.CoberturaMavenPluginHandler;
import java.io.File;
@@ -13,6 +13,9 @@ import java.io.File;
*/
public final class CoberturaUtils {
+ public static String COBERTURA_GROUP_ID = MavenUtils.GROUP_ID_CODEHAUS_MOJO;
+ public static String COBERTURA_ARTIFACT_ID = "cobertura-maven-plugin";
+
public static File getReport(Project project) {
File report = getReportFromProperty(project);
if (report == null) {
@@ -38,7 +41,7 @@ public final class CoberturaUtils {
}
private static File getReportFromPluginConfiguration(Project project) {
- MavenPlugin mavenPlugin = MavenPlugin.getPlugin(project.getPom(), CoberturaMavenPluginHandler.GROUP_ID, CoberturaMavenPluginHandler.ARTIFACT_ID);
+ MavenPlugin mavenPlugin = MavenPlugin.getPlugin(project.getPom(), COBERTURA_GROUP_ID, COBERTURA_ARTIFACT_ID);
if (mavenPlugin != null) {
String path = mavenPlugin.getParameter("outputDirectory");
if (path != null) {
diff --git a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java
index 5f1489029fd..0dd64edf611 100644
--- a/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java
+++ b/plugins/sonar-cobertura-plugin/src/test/java/org/sonar/plugins/cobertura/CoberturaMavenPluginHandlerTest.java
@@ -19,17 +19,18 @@
*/
package org.sonar.plugins.cobertura;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.maven.project.MavenProject;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.batch.maven.MavenPlugin;
import org.sonar.api.resources.Project;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import org.sonar.plugins.cobertura.api.CoberturaUtils;
public class CoberturaMavenPluginHandlerTest {
protected CoberturaMavenPluginHandler handler;
@@ -39,7 +40,6 @@ public class CoberturaMavenPluginHandlerTest {
handler = new CoberturaMavenPluginHandler();
}
-
@Test
public void notFixedVersion() {
// first of all, version was fixed : see http://jira.codehaus.org/browse/SONAR-1055
@@ -54,7 +54,7 @@ public class CoberturaMavenPluginHandlerTest {
when(project.getPom()).thenReturn(new MavenProject());
when(project.getExclusionPatterns()).thenReturn(new String[0]);
- MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaMavenPluginHandler.GROUP_ID, CoberturaMavenPluginHandler.ARTIFACT_ID, null);
+ MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null);
handler.configure(project, coberturaPlugin);
assertThat(coberturaPlugin.getParameter("formats/format"), is("xml"));
@@ -65,9 +65,9 @@ public class CoberturaMavenPluginHandlerTest {
Project project = mock(Project.class);
when(project.getConfiguration()).thenReturn(new PropertiesConfiguration());
when(project.getPom()).thenReturn(new MavenProject());
- when(project.getExclusionPatterns()).thenReturn(new String[]{"**/Foo.java", "com/*Test.*", "com/*"});
+ when(project.getExclusionPatterns()).thenReturn(new String[] { "**/Foo.java", "com/*Test.*", "com/*" });
- MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaMavenPluginHandler.GROUP_ID, CoberturaMavenPluginHandler.ARTIFACT_ID, null);
+ MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null);
handler.configure(project, coberturaPlugin);
assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")[0], is("**/Foo.class"));