diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-11-22 17:31:02 +0100 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-11-22 17:31:02 +0100 |
commit | aaed40e6d57e48340334b6ea27da091f20578fa6 (patch) | |
tree | 53994f375ed536fbf6bac7bc44514797cbb00858 | |
parent | d5a18084379c287c2f031177d930267bcbfe0274 (diff) | |
download | sonarqube-aaed40e6d57e48340334b6ea27da091f20578fa6.tar.gz sonarqube-aaed40e6d57e48340334b6ea27da091f20578fa6.zip |
SONAR-2897 Support old name for "sonar.cobertura.maxmen"
2 files changed, 23 insertions, 2 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 06067cb2434..3e46998a784 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 @@ -65,7 +65,10 @@ public class CoberturaMavenPluginHandler implements MavenPluginHandler { } coberturaPlugin.addParameter("instrumentation/excludes/exclude", pattern); } - coberturaPlugin.setParameter("maxmem", project.getConfiguration().getString(CoreProperties.COBERTURA_MAXMEM_PROPERTY, - CoreProperties.COBERTURA_MAXMEM_DEFAULT_VALUE)); + // http://jira.codehaus.org/browse/SONAR-2897: there used to be a typo in the parameter name (was "sonar.cobertura.maxmen") + coberturaPlugin.setParameter( + "maxmem", + project.getConfiguration().getString(CoreProperties.COBERTURA_MAXMEM_PROPERTY, + project.getConfiguration().getString("sonar.cobertura.maxmen", CoreProperties.COBERTURA_MAXMEM_DEFAULT_VALUE))); } } 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 afd80a29786..e1351f6aa59 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 @@ -24,6 +24,8 @@ import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import org.apache.commons.configuration.BaseConfiguration; +import org.apache.commons.configuration.Configuration; import org.apache.commons.configuration.PropertiesConfiguration; import org.apache.maven.project.MavenProject; import org.junit.Before; @@ -33,6 +35,7 @@ import org.sonar.api.resources.Project; import org.sonar.plugins.cobertura.api.CoberturaUtils; public class CoberturaMavenPluginHandlerTest { + protected CoberturaMavenPluginHandler handler; @Before @@ -73,6 +76,21 @@ public class CoberturaMavenPluginHandlerTest { assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")[0], is("**/Foo.class")); assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")[1], is("com/*Test.*")); assertThat(coberturaPlugin.getParameters("instrumentation/excludes/exclude")[2], is("com/*.class")); + } + + @Test + // http://jira.codehaus.org/browse/SONAR-2897: there used to be a typo in the parameter name (was "sonar.cobertura.maxmen") + public void checkOldParamNameCompatibility() { + Configuration conf = new BaseConfiguration(); + conf.setProperty("sonar.cobertura.maxmen", "FOO"); + Project project = mock(Project.class); + when(project.getConfiguration()).thenReturn(conf); + when(project.getPom()).thenReturn(new MavenProject()); + when(project.getExclusionPatterns()).thenReturn(new String[0]); + + MavenPlugin coberturaPlugin = new MavenPlugin(CoberturaUtils.COBERTURA_GROUP_ID, CoberturaUtils.COBERTURA_ARTIFACT_ID, null); + handler.configure(project, coberturaPlugin); + assertThat(coberturaPlugin.getParameter("maxmem"), is("FOO")); } } |