import com.google.common.collect.HashMultimap;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.lang.ArrayUtils;
+import org.apache.commons.lang.StringUtils;
import org.picocontainer.MutablePicoContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
if (ArrayUtils.isEmpty(selectedPluginKeys)) {
selectedPluginKeys = new String[]{AbstractCoverageExtension.DEFAULT_PLUGIN};
}
- return ArrayUtils.contains(selectedPluginKeys, pluginKey);
+ String oldCoveragePluginKey = getOldCoveragePluginKey(pluginKey);
+ return ArrayUtils.contains(selectedPluginKeys, pluginKey) || ArrayUtils.contains(selectedPluginKeys, oldCoveragePluginKey);
+ }
+
+ private String getOldCoveragePluginKey(String pluginKey) {
+ if (StringUtils.equals("sonar-jacoco-plugin", pluginKey)) {
+ return "jacoco";
+ }
+ if (StringUtils.equals("sonar-emma-plugin", pluginKey)) {
+ return "emma";
+ }
+ return null;
}
@Override
assertThat(repository.shouldRegisterCoverageExtension("other"), is(false));
}
+ @Test
+ public void shouldActivateOldVersionOfEmma() {
+ Configuration conf = new PropertiesConfiguration();
+ conf.setProperty(AbstractCoverageExtension.PARAM_PLUGIN, "emma");
+ BatchPluginRepository repository = new BatchPluginRepository(conf);
+
+ assertThat(repository.shouldRegisterCoverageExtension("sonar-emma-plugin"), is(true));
+ assertThat(repository.shouldRegisterCoverageExtension("emma"), is(true));
+
+ assertThat(repository.shouldRegisterCoverageExtension("sonar-jacoco-plugin"), is(false));
+ assertThat(repository.shouldRegisterCoverageExtension("jacoco"), is(false));
+ assertThat(repository.shouldRegisterCoverageExtension("clover"), is(false));
+ assertThat(repository.shouldRegisterCoverageExtension("cobertura"), is(false));
+ }
+
+ @Test
+ public void shouldActivateOldVersionOfJacoco() {
+ Configuration conf = new PropertiesConfiguration();
+ conf.setProperty(AbstractCoverageExtension.PARAM_PLUGIN, "cobertura,jacoco");
+ BatchPluginRepository repository = new BatchPluginRepository(conf);
+
+ assertThat(repository.shouldRegisterCoverageExtension("sonar-jacoco-plugin"), is(true));
+ assertThat(repository.shouldRegisterCoverageExtension("jacoco"), is(true));
+ assertThat(repository.shouldRegisterCoverageExtension("emma"), is(false));
+ }
public static class FakeBatchExtension implements BatchExtension {