aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test/java
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-04 15:14:50 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-05 13:40:26 +0200
commit92ab7df5f6d58a9711cdc00dbaafd0648b22e940 (patch)
tree4a1101db723ac3d89c734d05b22d034acc1f38fa /sonar-batch/src/test/java
parent15ec53105ce82aa3d85ad322b0a2cca16cfe7d0b (diff)
downloadsonarqube-92ab7df5f6d58a9711cdc00dbaafd0648b22e940.tar.gz
sonarqube-92ab7df5f6d58a9711cdc00dbaafd0648b22e940.zip
SONAR-6761 Drop incremental mode
Diffstat (limited to 'sonar-batch/src/test/java')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IncrementalModeMediumTest.java155
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java14
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java5
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java9
5 files changed, 4 insertions, 185 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java
index fb174d9d506..1c01582f13a 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/GlobalModeTest.java
@@ -41,12 +41,6 @@ public class GlobalModeTest {
}
@Test
- public void testIncremental() {
- GlobalMode mode = createMode(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_INCREMENTAL);
- assertThat(mode.isPreview()).isTrue();
- }
-
- @Test
public void testOtherProperty() {
GlobalMode mode = createMode(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_ANALYSIS);
assertThat(mode.isPreview()).isFalse();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IncrementalModeMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IncrementalModeMediumTest.java
deleted file mode 100644
index 6d1685a3d1f..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/preview/IncrementalModeMediumTest.java
+++ /dev/null
@@ -1,155 +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.mediumtest.preview;
-
-import com.google.common.collect.ImmutableMap;
-import java.io.File;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.rule.RuleKey;
-import org.sonar.batch.mediumtest.BatchMediumTester;
-import org.sonar.batch.mediumtest.TaskResult;
-import org.sonar.batch.protocol.Constants.Severity;
-import org.sonar.batch.protocol.input.ActiveRule;
-import org.sonar.batch.protocol.input.FileData;
-import org.sonar.xoo.XooPlugin;
-import org.sonar.xoo.rule.XooRulesDefinition;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.groups.Tuple.tuple;
-
-public class IncrementalModeMediumTest {
-
- private static final String SAMPLE_CONTENT = "Sample content\nwith\n4\nlines";
-
- @org.junit.Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- private static SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
-
- private static Long date(String date) {
- try {
- return sdf.parse(date).getTime();
- } catch (ParseException e) {
- throw new IllegalStateException(e);
- }
- }
-
- public BatchMediumTester tester = BatchMediumTester
- .builder()
- .bootstrapProperties(ImmutableMap.of(CoreProperties.ANALYSIS_MODE, CoreProperties.ANALYSIS_MODE_INCREMENTAL))
- .registerPlugin("xoo", new XooPlugin())
- .addRules(new XooRulesDefinition())
- .addDefaultQProfile("xoo", "Sonar Way")
- .activateRule(new ActiveRule("xoo", "OneIssuePerLine", null, "One issue per line", "MAJOR", null, "xoo"))
- .activateRule(new ActiveRule("manual", "MyManualIssue", null, "My manual issue", "MAJOR", null, null))
- .setPreviousAnalysisDate(new Date())
- .addFileData("sample", "src/sample.xoo", new FileData(DigestUtils.md5Hex(SAMPLE_CONTENT), false))
- .mockLineHashes("sample:src/sample.xoo",
- new String[] {DigestUtils.md5Hex("Samplecontent"), DigestUtils.md5Hex("oldcode"), DigestUtils.md5Hex("4"), DigestUtils.md5Hex("lines")})
- // Remote open issue => will be tracked and not new
- .mockServerIssue(org.sonar.batch.protocol.input.BatchInput.ServerIssue.newBuilder().setKey("xyz")
- .setModuleKey("sample")
- .setPath("src/sample.xoo")
- .setRuleRepository("xoo")
- .setRuleKey("OneIssuePerLine")
- .setLine(1)
- .setSeverity(Severity.MAJOR)
- .setCreationDate(date("14/03/2004"))
- .setChecksum(DigestUtils.md5Hex("Samplecontent"))
- .setStatus("OPEN")
- .build())
- // Remote open issue that no more exists => will be closed
- .mockServerIssue(org.sonar.batch.protocol.input.BatchInput.ServerIssue.newBuilder().setKey("resolved")
- .setModuleKey("sample")
- .setPath("src/sample.xoo")
- .setRuleRepository("xoo")
- .setRuleKey("OneIssuePerFile")
- .setMsg("An issue that is no more detected")
- .setLine(2)
- .setSeverity(Severity.MAJOR)
- .setCreationDate(date("14/03/2004"))
- .setChecksum(DigestUtils.md5Hex("oldcode"))
- .setStatus("OPEN")
- .build())
- // Manual issue
- .mockServerIssue(org.sonar.batch.protocol.input.BatchInput.ServerIssue.newBuilder().setKey("manual")
- .setModuleKey("sample")
- .setPath("src/sample.xoo")
- .setRuleRepository("manual")
- .setRuleKey("MyManualIssue")
- .setLine(4)
- .setSeverity(Severity.MAJOR)
- .setCreationDate(date("14/03/2004"))
- .setChecksum(DigestUtils.md5Hex("lines"))
- .setStatus("OPEN")
- .build())
- .build();
-
- @Before
- public void prepare() {
- tester.start();
- }
-
- @After
- public void stop() {
- tester.stop();
- }
-
- @Test
- public void testIssueTrackingIncrementalMode() throws Exception {
- File baseDir = temp.newFolder();
- File srcDir = new File(baseDir, "src");
- srcDir.mkdir();
-
- File xooFile = new File(srcDir, "sample.xoo");
- FileUtils.write(xooFile, SAMPLE_CONTENT + "\nmodification");
-
- TaskResult result = tester.newTask()
- .properties(ImmutableMap.<String, String>builder()
- .put("sonar.task", "scan")
- .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
- .put("sonar.projectKey", "sample")
- .put("sonar.projectName", "Foo Project")
- .put("sonar.projectVersion", "1.0-SNAPSHOT")
- .put("sonar.projectDescription", "Description of Foo Project")
- .put("sonar.sources", "src")
- .build())
- .start();
-
- assertThat(result.trackedIssues()).extracting("ruleKey", "line", "message", "status", "resolution", "new").containsOnly(
- tuple(RuleKey.of("xoo", "OneIssuePerLine"), 1, "This issue is generated on each line", "OPEN", null, false),
- tuple(RuleKey.of("xoo", "OneIssuePerLine"), 2, "This issue is generated on each line", "OPEN", null, true),
- tuple(RuleKey.of("xoo", "OneIssuePerLine"), 3, "This issue is generated on each line", "OPEN", null, true),
- tuple(RuleKey.of("xoo", "OneIssuePerLine"), 4, "This issue is generated on each line", "OPEN", null, true),
- tuple(RuleKey.of("xoo", "OneIssuePerLine"), 5, "This issue is generated on each line", "OPEN", null, true),
- tuple(RuleKey.of("manual", "MyManualIssue"), 4, null, "OPEN", null, false),
- tuple(RuleKey.of("xoo", "OneIssuePerFile"), null, "An issue that is no more detected", "CLOSED", "REMOVED", false));
- }
-
-}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java
index 75a705a95d3..c7a04640777 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/ProjectAnalysisModeTest.java
@@ -39,12 +39,10 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(null);
assertThat(mode.isPreview()).isFalse();
- assertThat(mode.isIncremental()).isFalse();
mode = createMode(CoreProperties.ANALYSIS_MODE, "pouet");
assertThat(mode.isPreview()).isFalse();
- assertThat(mode.isIncremental()).isFalse();
}
@Test(expected = IllegalStateException.class)
@@ -57,7 +55,6 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_ANALYSIS);
assertThat(mode.isPreview()).isFalse();
- assertThat(mode.isIncremental()).isFalse();
}
@Test
@@ -65,7 +62,6 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_PREVIEW);
assertThat(mode.isPreview()).isTrue();
- assertThat(mode.isIncremental()).isFalse();
}
@Test
@@ -73,19 +69,10 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_QUICK);
assertThat(mode.isPreview()).isTrue();
- assertThat(mode.isIncremental()).isFalse();
assertThat(mode.isQuick()).isTrue();
}
@Test
- public void support_incremental_mode() {
- ProjectAnalysisMode mode = createMode(CoreProperties.ANALYSIS_MODE_INCREMENTAL);
-
- assertThat(mode.isPreview()).isTrue();
- assertThat(mode.isIncremental()).isTrue();
- }
-
- @Test
public void support_deprecated_dryrun_property() {
Map<String, String> bootstrapMap = new HashMap<>();
Map<String, String> analysisMap = new HashMap<>();
@@ -96,7 +83,6 @@ public class ProjectAnalysisModeTest {
ProjectAnalysisMode mode = new ProjectAnalysisMode(new BootstrapProperties(bootstrapMap), new AnalysisProperties(analysisMap));
assertThat(mode.isPreview()).isTrue();
- assertThat(mode.isIncremental()).isFalse();
}
private static ProjectAnalysisMode createMode(@Nullable String mode) {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
index 2f5141d676e..1c60bacd9d5 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.batch.scan.ProjectAnalysisMode;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
@@ -37,10 +35,9 @@ public class InputFileBuilderFactoryTest {
LanguageDetectionFactory langDetectionFactory = mock(LanguageDetectionFactory.class, Mockito.RETURNS_MOCKS);
StatusDetectionFactory statusDetectionFactory = mock(StatusDetectionFactory.class, Mockito.RETURNS_MOCKS);
DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class);
- ProjectAnalysisMode analysisMode = mock(ProjectAnalysisMode.class);
InputFileBuilderFactory factory = new InputFileBuilderFactory(ProjectDefinition.create().setKey("struts"), pathResolver, langDetectionFactory,
- statusDetectionFactory, analysisMode, new Settings(), new FileMetadata());
+ statusDetectionFactory, new Settings(), new FileMetadata());
InputFileBuilder builder = factory.create(fs);
assertThat(builder.langDetection()).isNotNull();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
index 5b14b2bc9be..c6fa8ec6822 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.scan.filesystem;
-import org.sonar.batch.scan.ProjectAnalysisMode;
-
import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
@@ -48,7 +46,6 @@ public class InputFileBuilderTest {
LanguageDetection langDetection = mock(LanguageDetection.class);
StatusDetection statusDetection = mock(StatusDetection.class);
DefaultModuleFileSystem fs = mock(DefaultModuleFileSystem.class);
- ProjectAnalysisMode analysisMode = mock(ProjectAnalysisMode.class);
@Test
public void complete_input_file() throws Exception {
@@ -68,7 +65,7 @@ public class InputFileBuilderTest {
.thenReturn(InputFile.Status.ADDED);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
+ langDetection, statusDetection, fs, new Settings(), new FileMetadata());
DefaultInputFile inputFile = builder.create(srcFile);
builder.completeAndComputeMetadata(inputFile, InputFile.Type.MAIN);
@@ -91,7 +88,7 @@ public class InputFileBuilderTest {
when(fs.baseDir()).thenReturn(basedir);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
+ langDetection, statusDetection, fs, new Settings(), new FileMetadata());
DefaultInputFile inputFile = builder.create(srcFile);
assertThat(inputFile).isNull();
@@ -111,7 +108,7 @@ public class InputFileBuilderTest {
when(langDetection.language(any(InputFile.class))).thenReturn(null);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode, new Settings(), new FileMetadata());
+ langDetection, statusDetection, fs, new Settings(), new FileMetadata());
DefaultInputFile inputFile = builder.create(srcFile);
inputFile = builder.completeAndComputeMetadata(inputFile, InputFile.Type.MAIN);