2 * Sonar, open source software quality management tool.
3 * Copyright (C) 2008-2011 SonarSource
4 * mailto:contact AT sonarsource DOT com
6 * Sonar is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * Sonar is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Sonar; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
20 package org.sonar.plugins.clover;
22 import org.apache.commons.configuration.PropertiesConfiguration;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.sonar.api.CoreProperties;
26 import org.sonar.api.batch.maven.MavenPlugin;
27 import org.sonar.api.resources.Project;
28 import org.sonar.api.test.MavenTestUtils;
30 import static org.hamcrest.MatcherAssert.assertThat;
31 import static org.hamcrest.Matchers.*;
33 public class CloverMavenPluginHandlerTest {
35 private CloverMavenPluginHandler handler;
36 private Project project;
37 private MavenPlugin plugin;
41 handler = new CloverMavenPluginHandler(new PropertiesConfiguration());
44 private void configurePluginHandler(String pom) {
45 project = MavenTestUtils.loadProjectFromPom(getClass(), pom);
46 plugin = MavenPlugin.getPlugin(project.getPom(), handler.getGroupId(), handler.getArtifactId());
47 handler.configure(project, plugin);
51 public void overrideConfiguration() throws Exception {
52 configurePluginHandler("overrideConfiguration.xml");
54 assertThat(plugin.getParameter("generateXml"), is("true"));
55 assertThat(plugin.getParameter("foo"), is("bar"));
56 String configuredReportPath = project.getConfiguration().getString(CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY);
57 assertThat(configuredReportPath, notNullValue());
58 configuredReportPath = configuredReportPath.replace('\\', '/');
59 assertThat(configuredReportPath, endsWith("clover/surefire-reports"));
63 public void shouldSkipCloverWithPomConfig() throws Exception {
64 configurePluginHandler("shouldSkipCloverWithPomConfig.xml");
66 assertThat(project.getConfiguration().getString(CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY), nullValue());
70 public void shouldSkipCloverWithPomProperty() throws Exception {
71 configurePluginHandler("shouldSkipCloverWithPomProperty.xml");
73 assertThat(project.getConfiguration().getString(CoreProperties.SUREFIRE_REPORTS_PATH_PROPERTY), nullValue());