aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test/java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-01-28 12:41:23 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-01-28 12:41:23 +0100
commit64264e236c5e298894dae1c082a0b54ffc9d113f (patch)
tree0a78c4b9877d87c04183512b602e836c1dc3d4d5 /sonar-batch/src/test/java
parent51a74be67239460f051c4f50f7abe14c600bac39 (diff)
downloadsonarqube-64264e236c5e298894dae1c082a0b54ffc9d113f.tar.gz
sonarqube-64264e236c5e298894dae1c082a0b54ffc9d113f.zip
SONAR-6111 Drop ability to execute Maven plugin as part of the batch analysis
Diffstat (limited to 'sonar-batch/src/test/java')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java91
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/phases/DatabaseModePhaseExecutorTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/phases/PhasesTest.java1
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java28
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java25
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/maven/MavenPluginsConfiguratorTest.java75
7 files changed, 6 insertions, 225 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java
deleted file mode 100644
index 3b1de1e4956..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java
+++ /dev/null
@@ -1,91 +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.batch.maven;
-
-import org.apache.maven.project.MavenProject;
-import org.junit.Test;
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.resources.Project;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-
-import java.io.File;
-
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyList;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.verify;
-
-public class DefaultMavenPluginExecutorTest {
-
- @Test
- public void plugin_version_should_be_optional() {
- assertThat(DefaultMavenPluginExecutor.getGoal("group", "artifact", null, "goal"), is("group:artifact::goal"));
- }
-
- @Test
- public void test_plugin_version() {
- assertThat(DefaultMavenPluginExecutor.getGoal("group", "artifact", "3.54", "goal"), is("group:artifact:3.54:goal"));
- }
-
- @Test
- public void should_ignore_non_maven_projects() {
- DefaultMavenPluginExecutor executor = new DefaultMavenPluginExecutor(null, null, mock(MavenProjectConverter.class)) {
- @Override
- public void concreteExecute(MavenProject pom, String goal) {
- pom.addCompileSourceRoot("src/java");
- }
- };
- Project foo = new Project("foo");
- DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class);
- executor.execute(foo, fs, new AddSourceMavenPluginHandler());
-
- verify(fs, never()).resetDirs(any(File.class), any(File.class), anyList(), anyList(), anyList());
- }
-
- static class AddSourceMavenPluginHandler implements MavenPluginHandler {
- public String getGroupId() {
- return "fake";
- }
-
- public String getArtifactId() {
- return "fake";
- }
-
- public String getVersion() {
- return "2.2";
- }
-
- public boolean isFixedVersion() {
- return false;
- }
-
- public String[] getGoals() {
- return new String[]{"fake"};
- }
-
- public void configure(Project project, MavenPlugin plugin) {
- }
- }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/phases/DatabaseModePhaseExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/phases/DatabaseModePhaseExecutorTest.java
index d3bc6b2f86e..57e72f0ed40 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/phases/DatabaseModePhaseExecutorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/phases/DatabaseModePhaseExecutorTest.java
@@ -35,17 +35,17 @@ public class DatabaseModePhaseExecutorTest {
MeasurePersister measurePersister = new MeasurePersister(null, null, null, null, null);
ResourcePersister resourcePersister = new ResourcePersister(null, null, null, null, null);
ScanPersister[] persisters = new ScanPersister[] {otherPersister, measurePersister, resourcePersister};
- DatabaseModePhaseExecutor executor = new DatabaseModePhaseExecutor(null, null, null, null, null, null,
+ DatabaseModePhaseExecutor executor = new DatabaseModePhaseExecutor(null, null, null, null, null,
null, null, null, null, null, persisters, null, null, null, null, null, null, null, null);
assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
persisters = new ScanPersister[] {measurePersister, resourcePersister, otherPersister};
- executor = new DatabaseModePhaseExecutor(null, null, null, null, null, null,
+ executor = new DatabaseModePhaseExecutor(null, null, null, null, null,
null, null, null, null, null, persisters, null, null, null, null, null, null, null, null);
assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
persisters = new ScanPersister[] {measurePersister, otherPersister, resourcePersister};
- executor = new DatabaseModePhaseExecutor(null, null, null, null, null, null,
+ executor = new DatabaseModePhaseExecutor(null, null, null, null, null,
null, null, null, null, null, persisters, null, null, null, null, null, null, null, null);
assertThat(executor.sortedPersisters()).containsSubsequence(resourcePersister, measurePersister);
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/phases/PhasesTest.java b/sonar-batch/src/test/java/org/sonar/batch/phases/PhasesTest.java
index 111bb24a9ae..14f7e0ac93e 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/phases/PhasesTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/phases/PhasesTest.java
@@ -47,7 +47,6 @@ public class PhasesTest {
phases.enable(Phases.Phase.values());
assertThat(phases.isEnabled(Phases.Phase.INIT)).isTrue();
- assertThat(phases.isEnabled(Phases.Phase.MAVEN)).isTrue();
assertThat(phases.isEnabled(Phases.Phase.DECORATOR)).isTrue();
assertThat(phases.isEnabled(Phases.Phase.SENSOR)).isTrue();
assertThat(phases.isEnabled(Phases.Phase.POSTJOB)).isTrue();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java
index b2617374f6b..82b19321da6 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/phases/PostJobsExecutorTest.java
@@ -26,8 +26,6 @@ import org.sonar.api.batch.SensorContext;
import org.sonar.api.resources.Project;
import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
import org.sonar.batch.events.EventBus;
-import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem;
-import org.sonar.batch.scan.maven.MavenPluginExecutor;
import java.util.Arrays;
@@ -40,14 +38,13 @@ public class PostJobsExecutorTest {
Project project = new Project("project");
BatchExtensionDictionnary selector = mock(BatchExtensionDictionnary.class);
- MavenPluginExecutor mavenPluginExecutor = mock(MavenPluginExecutor.class);
PostJob job1 = mock(PostJob.class);
PostJob job2 = mock(PostJob.class);
SensorContext context = mock(SensorContext.class);
@Before
public void setUp() {
- executor = new PostJobsExecutor(selector, project, mock(DefaultModuleFileSystem.class), mavenPluginExecutor, mock(EventBus.class));
+ executor = new PostJobsExecutor(selector, project, mock(EventBus.class));
}
@Test
diff --git a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
index 861903dda67..2802d2f7058 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/profiling/PhasesSumUpTimeProfilerTest.java
@@ -35,7 +35,6 @@ import org.sonar.api.batch.events.DecoratorExecutionHandler;
import org.sonar.api.batch.events.DecoratorsPhaseHandler;
import org.sonar.api.batch.events.InitializerExecutionHandler;
import org.sonar.api.batch.events.InitializersPhaseHandler;
-import org.sonar.api.batch.events.MavenPhaseHandler;
import org.sonar.api.batch.events.PostJobExecutionHandler;
import org.sonar.api.batch.events.PostJobsPhaseHandler;
import org.sonar.api.batch.events.ProjectAnalysisHandler;
@@ -87,7 +86,6 @@ public class PhasesSumUpTimeProfilerTest {
fakeAnalysis(profiler, project);
- assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.MAVEN).totalTime()).isEqualTo(4L);
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(7L);
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(10L);
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator1()).totalTime()).isEqualTo(20L);
@@ -108,7 +106,6 @@ public class PhasesSumUpTimeProfilerTest {
fakeAnalysis(profiler, moduleB);
fakeAnalysis(profiler, project);
- assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.MAVEN).totalTime()).isEqualTo(4L);
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(7L);
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(10L);
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator1()).totalTime()).isEqualTo(20L);
@@ -116,7 +113,6 @@ public class PhasesSumUpTimeProfilerTest {
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.PERSISTER).getProfilingPerItem(new FakeScanPersister()).totalTime()).isEqualTo(40L);
assertThat(profiler.currentModuleProfiling.getProfilingPerPhase(Phase.POSTJOB).getProfilingPerItem(new FakePostJob()).totalTime()).isEqualTo(30L);
- assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.MAVEN).totalTime()).isEqualTo(12L);
assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.INIT).getProfilingPerItem(new FakeInitializer()).totalTime()).isEqualTo(21L);
assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.SENSOR).getProfilingPerItem(new FakeSensor()).totalTime()).isEqualTo(30L);
assertThat(profiler.totalProfiling.getProfilingPerPhase(Phase.DECORATOR).getProfilingPerItem(new FakeDecorator1()).totalTime()).isEqualTo(60L);
@@ -166,7 +162,6 @@ public class PhasesSumUpTimeProfilerTest {
private void fakeAnalysis(PhasesSumUpTimeProfiler profiler, final Project module) throws InterruptedException {
// Start of moduleA
profiler.onProjectAnalysis(projectEvent(module, true));
- mavenPhase(profiler);
initializerPhase(profiler);
sensorPhase(profiler);
decoratorPhase(profiler);
@@ -214,14 +209,6 @@ public class PhasesSumUpTimeProfilerTest {
profiler.onBatchStep(new BatchStepEvent("Free memory", false));
}
- private void mavenPhase(PhasesSumUpTimeProfiler profiler) throws InterruptedException {
- // Start of maven phase
- profiler.onMavenPhase(mavenEvent(true));
- clock.sleep(4);
- // End of maven phase
- profiler.onMavenPhase(mavenEvent(false));
- }
-
private void initializerPhase(PhasesSumUpTimeProfiler profiler) throws InterruptedException {
Initializer initializer = new FakeInitializer();
// Start of initializer phase
@@ -394,21 +381,6 @@ public class PhasesSumUpTimeProfilerTest {
};
}
- private MavenPhaseHandler.MavenPhaseEvent mavenEvent(final boolean start) {
- return new MavenPhaseHandler.MavenPhaseEvent() {
-
- @Override
- public boolean isStart() {
- return start;
- }
-
- @Override
- public boolean isEnd() {
- return !start;
- }
- };
- }
-
private InitializersPhaseHandler.InitializersPhaseEvent initializersEvent(final boolean start) {
return new InitializersPhaseHandler.InitializersPhaseEvent() {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
index cc3a1158427..d80410825e3 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectScanContainerTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.scan;
-import org.sonar.batch.repository.ProjectRepositoriesLoader;
-
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.BatchExtension;
@@ -36,15 +34,15 @@ import org.sonar.api.platform.ComponentContainer;
import org.sonar.api.task.TaskExtension;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.TempFolder;
-import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.BootstrapProperties;
+import org.sonar.batch.bootstrap.DefaultAnalysisMode;
import org.sonar.batch.bootstrap.ExtensionInstaller;
import org.sonar.batch.bootstrap.GlobalSettings;
import org.sonar.batch.bootstrap.TaskProperties;
import org.sonar.batch.profiling.PhasesSumUpTimeProfiler;
import org.sonar.batch.protocol.input.GlobalRepositories;
import org.sonar.batch.protocol.input.ProjectRepositories;
-import org.sonar.batch.scan.maven.MavenPluginExecutor;
+import org.sonar.batch.repository.ProjectRepositoriesLoader;
import java.util.Collections;
@@ -85,25 +83,6 @@ public class ProjectScanContainerTest {
}
@Test
- public void should_add_fake_maven_executor_on_non_maven_env() {
- container.add(mock(ExtensionInstaller.class), projectBootstrapper);
- container.doBeforeStart();
-
- assertThat(container.getComponentByType(MavenPluginExecutor.class)).isNotNull();
- }
-
- @Test
- public void should_use_maven_executor_provided_by_maven() {
- container.add(mock(ExtensionInstaller.class), projectBootstrapper);
- MavenPluginExecutor mavenPluginExecutor = mock(MavenPluginExecutor.class);
- container.add(mavenPluginExecutor);
- container.doBeforeStart();
-
- assertThat(container.getComponentsByType(MavenPluginExecutor.class)).hasSize(1);
- assertThat(container.getComponentByType(MavenPluginExecutor.class)).isSameAs(mavenPluginExecutor);
- }
-
- @Test
public void should_activate_profiling() {
container.add(mock(ExtensionInstaller.class), projectBootstrapper, mock(TempFolder.class));
container.doBeforeStart();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/maven/MavenPluginsConfiguratorTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/maven/MavenPluginsConfiguratorTest.java
deleted file mode 100644
index ca1af7d653f..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/maven/MavenPluginsConfiguratorTest.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.batch.scan.maven;
-
-import org.junit.Test;
-import org.mockito.ArgumentMatcher;
-import org.sonar.api.batch.maven.MavenPlugin;
-import org.sonar.api.batch.maven.MavenPluginHandler;
-import org.sonar.api.resources.Project;
-import org.sonar.api.test.MavenTestUtils;
-import org.sonar.batch.bootstrap.BatchExtensionDictionnary;
-
-import java.util.Arrays;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.argThat;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-public class MavenPluginsConfiguratorTest {
-
- private MavenPluginsConfigurator newConfigurator(MavenPluginHandler... handlers) {
- BatchExtensionDictionnary selector = mock(BatchExtensionDictionnary.class);
- when(selector.selectMavenPluginHandlers(any(Project.class))).thenReturn(Arrays.asList(handlers));
- return new MavenPluginsConfigurator(selector);
- }
-
- @Test
- public void configureHandlers() {
- MavenPluginHandler handler1 = mock(MavenPluginHandler.class);
- when(handler1.getArtifactId()).thenReturn("myartifact1");
-
- MavenPluginHandler handler2 = mock(MavenPluginHandler.class);
- when(handler2.getArtifactId()).thenReturn("myartifact2");
-
- Project project = MavenTestUtils.loadProjectFromPom(getClass(), "pom.xml");
-
- newConfigurator(handler1, handler2).execute(project);
-
- verify(handler1).configure(eq(project), argThat(new IsMavenPlugin("myartifact1")));
- verify(handler2).configure(eq(project), argThat(new IsMavenPlugin("myartifact2")));
- }
-
- private class IsMavenPlugin extends ArgumentMatcher<MavenPlugin> {
- private String artifactId;
-
- public IsMavenPlugin(String artifactId) {
- this.artifactId = artifactId;
- }
-
- @Override
- public boolean matches(Object o) {
- return artifactId.equals(((MavenPlugin) o).getPlugin().getArtifactId());
- }
- }
-}