aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-02-19 16:49:10 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-02-19 22:28:59 +0100
commit0f517d524485bcc0acb47a7f00d54b2e1bac4f50 (patch)
treeff618f5e8d4886dae0f2e16254f76b67dd2203fc /sonar-batch
parenteac465bea9f5bf89a7beb8036e4d8eea4723f421 (diff)
downloadsonarqube-0f517d524485bcc0acb47a7f00d54b2e1bac4f50.tar.gz
sonarqube-0f517d524485bcc0acb47a7f00d54b2e1bac4f50.zip
SONAR-5931 Remove beta test API
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java56
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java118
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java59
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/scan2/package-info.java21
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java21
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java41
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseCoverageValueCoder.java81
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java90
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/test/TestCaseCoverageCache.java65
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/test/TestCaseExecutionCache.java69
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/test/package-info.java24
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java128
12 files changed, 0 insertions, 773 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
index 245f85bd38d..edde3baad06 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/mediumtest/TaskResult.java
@@ -31,8 +31,6 @@ import org.sonar.api.batch.sensor.duplication.Duplication;
import org.sonar.api.batch.sensor.highlighting.TypeOfText;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
import org.sonar.api.batch.sensor.symbol.Symbol;
-import org.sonar.api.batch.sensor.test.TestCaseCoverage;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
import org.sonar.api.issue.Issue;
import org.sonar.api.issue.internal.DefaultIssue;
import org.sonar.api.measures.Measure;
@@ -47,8 +45,6 @@ import org.sonar.batch.scan.ProjectScanContainer;
import org.sonar.batch.scan.filesystem.InputPathCache;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.symbol.SymbolData;
-import org.sonar.batch.test.TestCaseCoverageCache;
-import org.sonar.batch.test.TestCaseExecutionCache;
import org.sonar.core.source.SnapshotDataTypes;
import javax.annotation.CheckForNull;
@@ -73,8 +69,6 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver {
private Map<String, InputDir> inputDirs = new HashMap<>();
private Map<InputFile, SyntaxHighlightingData> highlightingPerFile = new HashMap<>();
private Map<InputFile, SymbolData> symbolTablePerFile = new HashMap<>();
- private Map<String, Map<String, TestCaseExecution>> testCasesPerFile = new HashMap<>();
- private Map<String, Map<String, Map<String, List<Integer>>>> coveragePerTest = new HashMap<>();
private Map<String, Map<String, Integer>> dependencies = new HashMap<>();
@Override
@@ -114,33 +108,6 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver {
}
}
- private void storeCoveragePerTest(ProjectScanContainer container) {
- TestCaseCoverageCache testCaseCoverageCache = container.getComponentByType(TestCaseCoverageCache.class);
- for (Entry<TestCaseCoverage> entry : testCaseCoverageCache.entries()) {
- String testFileKey = entry.key()[0].toString();
- if (!coveragePerTest.containsKey(testFileKey)) {
- coveragePerTest.put(testFileKey, new HashMap<String, Map<String, List<Integer>>>());
- }
- String testName = entry.key()[1].toString();
- if (!coveragePerTest.get(testFileKey).containsKey(testName)) {
- coveragePerTest.get(testFileKey).put(testName, new HashMap<String, List<Integer>>());
- }
- TestCaseCoverage value = entry.value();
- coveragePerTest.get(testFileKey).get(testName).put(entry.key()[2].toString(), value != null ? value.coveredLines() : null);
- }
- }
-
- private void storeTestCases(ProjectScanContainer container) {
- TestCaseExecutionCache testCaseCache = container.getComponentByType(TestCaseExecutionCache.class);
- for (Entry<TestCaseExecution> entry : testCaseCache.entries()) {
- String effectiveKey = entry.key()[0].toString();
- if (!testCasesPerFile.containsKey(effectiveKey)) {
- testCasesPerFile.put(effectiveKey, new HashMap<String, TestCaseExecution>());
- }
- testCasesPerFile.get(effectiveKey).put(entry.value().name(), entry.value());
- }
- }
-
private void storeDuplication(ProjectScanContainer container) {
DuplicationCache duplicationCache = container.getComponentByType(DuplicationCache.class);
for (String effectiveKey : duplicationCache.componentKeys()) {
@@ -214,29 +181,6 @@ public class TaskResult implements org.sonar.batch.mediumtest.ScanTaskObserver {
return duplications.get(((DefaultInputFile) inputFile).key());
}
- public Collection<TestCaseExecution> testCasesFor(InputFile inputFile) {
- String key = ((DefaultInputFile) inputFile).key();
- if (testCasesPerFile.containsKey(key)) {
- return testCasesPerFile.get(key).values();
- } else {
- return Collections.emptyList();
- }
- }
-
- public TestCaseExecution testCase(InputFile inputFile, String testCaseName) {
- return testCasesPerFile.get(((DefaultInputFile) inputFile).key()).get(testCaseName);
- }
-
- public List<Integer> coveragePerTest(InputFile testFile, String testCaseName, InputFile mainFile) {
- String testKey = ((DefaultInputFile) testFile).key();
- String mainKey = ((DefaultInputFile) mainFile).key();
- if (coveragePerTest.containsKey(testKey) && coveragePerTest.get(testKey).containsKey(testCaseName) && coveragePerTest.get(testKey).get(testCaseName).containsKey(mainKey)) {
- return coveragePerTest.get(testKey).get(testCaseName).get(mainKey);
- } else {
- return Collections.emptyList();
- }
- }
-
/**
* Get highlighting types at a given position in an inputfile
* @param charIndex 0-based offset in file
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java
deleted file mode 100644
index 5574c33e04e..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java
+++ /dev/null
@@ -1,118 +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.scan2;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Maps;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measure.MetricFinder;
-import org.sonar.api.batch.sensor.SensorStorage;
-import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
-import org.sonar.api.measures.FileLinesContext;
-import org.sonar.api.utils.KeyValueFormat;
-
-import java.util.Map;
-
-public class DefaultFileLinesContext implements FileLinesContext {
-
- private final SensorStorage sensorStorage;
- private final InputFile inputFile;
-
- /**
- * metric key -> line -> value
- */
- private final Map<String, Map<Integer, Object>> map = Maps.newHashMap();
- private MetricFinder metricFinder;
-
- public DefaultFileLinesContext(MetricFinder metricFinder, SensorStorage sensorStorage, InputFile inputFile) {
- this.metricFinder = metricFinder;
- this.sensorStorage = sensorStorage;
- this.inputFile = inputFile;
- }
-
- @Override
- public void setIntValue(String metricKey, int line, int value) {
- Preconditions.checkNotNull(metricKey);
- Preconditions.checkArgument(line > 0);
-
- setValue(metricKey, line, value);
- }
-
- @Override
- public Integer getIntValue(String metricKey, int line) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setStringValue(String metricKey, int line, String value) {
- Preconditions.checkNotNull(metricKey);
- Preconditions.checkArgument(line > 0);
- Preconditions.checkNotNull(value);
-
- setValue(metricKey, line, value);
- }
-
- @Override
- public String getStringValue(String metricKey, int line) {
- throw new UnsupportedOperationException();
- }
-
- private Map<Integer, Object> getOrCreateLines(String metricKey) {
- Map<Integer, Object> lines = map.get(metricKey);
- if (lines == null) {
- lines = Maps.newHashMap();
- map.put(metricKey, lines);
- }
- return lines;
- }
-
- private void setValue(String metricKey, int line, Object value) {
- getOrCreateLines(metricKey).put(line, value);
- }
-
- @Override
- public void save() {
- for (Map.Entry<String, Map<Integer, Object>> entry : map.entrySet()) {
- String metricKey = entry.getKey();
- org.sonar.api.batch.measure.Metric<String> metric = metricFinder.findByKey(metricKey);
- if (metric == null) {
- throw new IllegalStateException("Unable to find metric with key: " + metricKey);
- }
- Map<Integer, Object> lines = entry.getValue();
- String data = KeyValueFormat.format(lines);
- new DefaultMeasure<String>(sensorStorage)
- .forMetric(metric)
- .onFile(inputFile)
- .withValue(data)
- .save();
- entry.setValue(ImmutableMap.copyOf(lines));
- }
- }
-
- @Override
- public String toString() {
- return Objects.toStringHelper(this)
- .add("map", map)
- .toString();
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java
deleted file mode 100644
index 3ea69cad781..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContextFactory.java
+++ /dev/null
@@ -1,59 +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.scan2;
-
-import org.sonar.api.batch.bootstrap.ProjectDefinition;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.measure.MetricFinder;
-import org.sonar.api.batch.sensor.SensorStorage;
-import org.sonar.api.measures.FileLinesContext;
-import org.sonar.api.measures.FileLinesContextFactory;
-import org.sonar.api.resources.Resource;
-import org.sonar.batch.scan.filesystem.InputPathCache;
-
-public class DefaultFileLinesContextFactory implements FileLinesContextFactory {
-
- private final SensorStorage sensorStorage;
- private final MetricFinder metricFinder;
- private final ProjectDefinition def;
- private final InputPathCache fileCache;
-
- public DefaultFileLinesContextFactory(InputPathCache fileCache, MetricFinder metricFinder, SensorStorage sensorStorage,
- ProjectDefinition def) {
- this.fileCache = fileCache;
- this.metricFinder = metricFinder;
- this.sensorStorage = sensorStorage;
- this.def = def;
- }
-
- @Override
- public FileLinesContext createFor(Resource model) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public FileLinesContext createFor(InputFile inputFile) {
- if (fileCache.getFile(def.getKey(), inputFile.relativePath()) == null) {
- throw new IllegalStateException("InputFile is not indexed: " + inputFile);
- }
- return new DefaultFileLinesContext(metricFinder, sensorStorage, inputFile);
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/package-info.java
deleted file mode 100644
index 62ae62716bb..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/scan2/package-info.java
+++ /dev/null
@@ -1,21 +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.
- */
-@javax.annotation.ParametersAreNonnullByDefault
-package org.sonar.batch.scan2;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java
index 7dd0c1eab1c..667552ae840 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorContext.java
@@ -36,12 +36,6 @@ import org.sonar.api.batch.sensor.issue.internal.DefaultIssue;
import org.sonar.api.batch.sensor.measure.NewMeasure;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
import org.sonar.api.batch.sensor.symbol.SymbolTableBuilder;
-import org.sonar.api.batch.sensor.test.Coverage;
-import org.sonar.api.batch.sensor.test.TestCaseCoverage;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
-import org.sonar.api.batch.sensor.test.internal.DefaultCoverage;
-import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseCoverage;
-import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseExecution;
import org.sonar.api.config.Settings;
import org.sonar.batch.highlighting.DefaultHighlightingBuilder;
import org.sonar.batch.index.ComponentDataCache;
@@ -114,21 +108,6 @@ public class DefaultSensorContext implements SensorContext {
}
@Override
- public Coverage newCoverage() {
- return new DefaultCoverage(sensorStorage);
- }
-
- @Override
- public TestCaseExecution newTestCaseExecution() {
- return new DefaultTestCaseExecution(sensorStorage);
- }
-
- @Override
- public TestCaseCoverage newTestCaseCoverage() {
- return new DefaultTestCaseCoverage(sensorStorage);
- }
-
- @Override
public NewDependency newDependency() {
return new DefaultDependency(sensorStorage);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
index 4bc8ce21889..1624e10d7b2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/sensor/DefaultSensorStorage.java
@@ -33,9 +33,6 @@ import org.sonar.api.batch.sensor.issue.Issue;
import org.sonar.api.batch.sensor.issue.Issue.Severity;
import org.sonar.api.batch.sensor.measure.Measure;
import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
-import org.sonar.api.batch.sensor.test.TestCaseCoverage;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
-import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseExecution;
import org.sonar.api.component.ResourcePerspectives;
import org.sonar.api.config.Settings;
import org.sonar.api.design.Dependency;
@@ -52,10 +49,6 @@ import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
import org.sonar.api.resources.Scopes;
import org.sonar.api.rule.RuleKey;
-import org.sonar.api.test.MutableTestCase;
-import org.sonar.api.test.MutableTestPlan;
-import org.sonar.api.test.MutableTestable;
-import org.sonar.api.test.Testable;
import org.sonar.batch.duplication.DuplicationCache;
import org.sonar.batch.index.BatchResource;
import org.sonar.batch.index.ComponentDataCache;
@@ -182,40 +175,6 @@ public class DefaultSensorStorage implements SensorStorage {
.build();
}
- @Override
- public void store(TestCaseExecution testCase) {
- File testRes = getTestResource(((DefaultTestCaseExecution) testCase).testFile());
- MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, testRes);
- if (testPlan != null) {
- testPlan
- .addTestCase(testCase.name())
- .setDurationInMs(testCase.durationInMs())
- .setType(testCase.type().name())
- .setStatus(org.sonar.api.test.TestCase.Status.valueOf(testCase.status().name()))
- .setMessage(testCase.message())
- .setStackTrace(testCase.stackTrace());
- }
- }
-
- @Override
- public void store(TestCaseCoverage testCaseCoverage) {
- File testRes = getTestResource(testCaseCoverage.testFile());
- File mainRes = getMainResource(testCaseCoverage.coveredFile());
- Testable testAbleFile = perspectives.as(MutableTestable.class, mainRes);
- if (testAbleFile != null) {
- MutableTestPlan testPlan = perspectives.as(MutableTestPlan.class, testRes);
- if (testPlan != null) {
- for (MutableTestCase mutableTestCase : testPlan.testCasesByName(testCaseCoverage.testName())) {
- mutableTestCase.setCoverageBlock(testAbleFile, testCaseCoverage.coveredLines());
- }
- } else {
- throw new IllegalStateException("Unable to get MutableTestPlan perspective from " + testRes);
- }
- } else {
- throw new IllegalStateException("Unable to get MutableTestable perspective from " + mainRes);
- }
- }
-
private File getTestResource(InputFile testFile) {
File testRes = File.create(testFile.relativePath());
testRes.setQualifier(Qualifiers.UNIT_TEST_FILE);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseCoverageValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseCoverageValueCoder.java
deleted file mode 100644
index 69b7845fb68..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseCoverageValueCoder.java
+++ /dev/null
@@ -1,81 +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.test;
-
-import com.persistit.Value;
-import com.persistit.encoding.CoderContext;
-import com.persistit.encoding.ValueCoder;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseCoverage;
-import org.sonar.batch.scan.filesystem.InputPathCache;
-
-import java.util.ArrayList;
-import java.util.List;
-
-class DefaultTestCaseCoverageValueCoder implements ValueCoder {
-
- private InputPathCache inputPathCache;
-
- public DefaultTestCaseCoverageValueCoder(InputPathCache inputPathCache) {
- this.inputPathCache = inputPathCache;
- }
-
- @Override
- public void put(Value value, Object object, CoderContext context) {
- DefaultTestCaseCoverage t = (DefaultTestCaseCoverage) object;
- value.putUTF(((DefaultInputFile) t.testFile()).moduleKey());
- value.putUTF(((DefaultInputFile) t.testFile()).relativePath());
- value.putUTF(t.testName());
- value.putUTF(((DefaultInputFile) t.coveredFile()).moduleKey());
- value.putUTF(((DefaultInputFile) t.coveredFile()).relativePath());
- value.put(t.coveredLines().size());
- for (Integer line : t.coveredLines()) {
- value.put(line.intValue());
- }
- }
-
- @Override
- public Object get(Value value, Class clazz, CoderContext context) {
- String testModuleKey = value.getString();
- String testRelativePath = value.getString();
- InputFile testFile = inputPathCache.getFile(testModuleKey, testRelativePath);
- if (testFile == null) {
- throw new IllegalStateException("Unable to load InputFile " + testModuleKey + ":" + testRelativePath);
- }
- String name = value.getString();
- String mainModuleKey = value.getString();
- String mainRelativePath = value.getString();
- InputFile mainFile = inputPathCache.getFile(mainModuleKey, mainRelativePath);
- if (mainFile == null) {
- throw new IllegalStateException("Unable to load InputFile " + mainModuleKey + ":" + mainRelativePath);
- }
- int size = value.getInt();
- List<Integer> lines = new ArrayList<Integer>(size);
- for (int i = 0; i < size; i++) {
- lines.add(value.getInt());
- }
- return new DefaultTestCaseCoverage()
- .testFile(testFile)
- .testName(name)
- .cover(mainFile)
- .onLines(lines);
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java
deleted file mode 100644
index 3e31d653a69..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java
+++ /dev/null
@@ -1,90 +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.test;
-
-import com.persistit.Value;
-import com.persistit.encoding.CoderContext;
-import com.persistit.encoding.ValueCoder;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
-import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseExecution;
-import org.sonar.batch.scan.filesystem.InputPathCache;
-
-import javax.annotation.Nullable;
-
-class DefaultTestCaseExecutionValueCoder implements ValueCoder {
-
- private InputPathCache inputPathCache;
-
- public DefaultTestCaseExecutionValueCoder(InputPathCache inputPathCache) {
- this.inputPathCache = inputPathCache;
- }
-
- @Override
- public void put(Value value, Object object, CoderContext context) {
- DefaultTestCaseExecution t = (DefaultTestCaseExecution) object;
- value.putUTF(((DefaultInputFile) t.testFile()).moduleKey());
- value.putUTF(((DefaultInputFile) t.testFile()).relativePath());
- value.putUTF(t.name());
- putUTFOrNull(value, t.message());
- putUTFOrNull(value, t.stackTrace());
- Long durationInMs = t.durationInMs();
- value.put(durationInMs != null ? durationInMs.longValue() : -1);
- value.put(t.type().ordinal());
- value.put(t.status().ordinal());
- }
-
- private void putUTFOrNull(Value value, @Nullable String utfOrNull) {
- if (utfOrNull != null) {
- value.putUTF(utfOrNull);
- } else {
- value.putNull();
- }
- }
-
- @Override
- public Object get(Value value, Class clazz, CoderContext context) {
- String moduleKey = value.getString();
- String relativePath = value.getString();
- InputFile testFile = inputPathCache.getFile(moduleKey, relativePath);
- if (testFile == null) {
- throw new IllegalStateException("Unable to load InputFile " + moduleKey + ":" + relativePath);
- }
- String name = value.getString();
- String message = value.getString();
- String stack = value.getString();
- long duration = value.getLong();
- TestCaseExecution.Type type = TestCaseExecution.Type.values()[value.getInt()];
- TestCaseExecution.Status status = TestCaseExecution.Status.values()[value.getInt()];
- DefaultTestCaseExecution testCaseExecution = new DefaultTestCaseExecution();
- testCaseExecution
- .inTestFile(testFile)
- .ofType(type)
- .name(name)
- .status(status)
- .message(message)
- .stackTrace(stack);
- if (duration != -1) {
- testCaseExecution.durationInMs(duration);
- }
- return testCaseExecution;
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/TestCaseCoverageCache.java b/sonar-batch/src/main/java/org/sonar/batch/test/TestCaseCoverageCache.java
deleted file mode 100644
index 7e52932cf2f..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/test/TestCaseCoverageCache.java
+++ /dev/null
@@ -1,65 +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.test;
-
-import com.google.common.base.Preconditions;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.test.TestCaseCoverage;
-import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseCoverage;
-import org.sonar.batch.index.Cache;
-import org.sonar.batch.index.Cache.Entry;
-import org.sonar.batch.index.Caches;
-import org.sonar.batch.scan.filesystem.InputPathCache;
-
-import javax.annotation.CheckForNull;
-
-/**
- * Cache of coverage per test. This cache is shared amongst all project modules.
- */
-public class TestCaseCoverageCache implements BatchComponent {
-
- private final Cache<TestCaseCoverage> cache;
-
- public TestCaseCoverageCache(Caches caches, InputPathCache inputPathCache) {
- caches.registerValueCoder(DefaultTestCaseCoverage.class, new DefaultTestCaseCoverageValueCoder(inputPathCache));
- cache = caches.createCache("testCaseCoverage");
- }
-
- public Iterable<Entry<TestCaseCoverage>> entries() {
- return cache.entries();
- }
-
- @CheckForNull
- public TestCaseCoverage getCoverage(InputFile testFile, String testCaseName, InputFile mainFile) {
- Preconditions.checkNotNull(testFile);
- Preconditions.checkNotNull(testCaseName);
- Preconditions.checkNotNull(mainFile);
- return cache.get(((DefaultInputFile) testFile).key(), testCaseName, ((DefaultInputFile) mainFile).key());
- }
-
- public TestCaseCoverageCache put(TestCaseCoverage coverage) {
- Preconditions.checkNotNull(coverage);
- cache.put(((DefaultInputFile) coverage.testFile()).key(), coverage.testName(), ((DefaultInputFile) coverage.coveredFile()).key(), coverage);
- return this;
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/TestCaseExecutionCache.java b/sonar-batch/src/main/java/org/sonar/batch/test/TestCaseExecutionCache.java
deleted file mode 100644
index 02dab1cfa52..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/test/TestCaseExecutionCache.java
+++ /dev/null
@@ -1,69 +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.test;
-
-import com.google.common.base.Preconditions;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.batch.sensor.test.TestCaseExecution;
-import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseExecution;
-import org.sonar.batch.index.Cache;
-import org.sonar.batch.index.Cache.Entry;
-import org.sonar.batch.index.Caches;
-import org.sonar.batch.scan.filesystem.InputPathCache;
-
-import javax.annotation.CheckForNull;
-
-/**
- * Cache of all TestCases. This cache is shared amongst all project modules.
- */
-public class TestCaseExecutionCache implements BatchComponent {
-
- private final Cache<TestCaseExecution> cache;
-
- public TestCaseExecutionCache(Caches caches, InputPathCache inputPathCache) {
- caches.registerValueCoder(DefaultTestCaseExecution.class, new DefaultTestCaseExecutionValueCoder(inputPathCache));
- cache = caches.createCache("testCaseExecutions");
- }
-
- public Iterable<Entry<TestCaseExecution>> entries() {
- return cache.entries();
- }
-
- @CheckForNull
- public TestCaseExecution get(InputFile testFile, String testCaseName) {
- Preconditions.checkNotNull(testFile);
- Preconditions.checkNotNull(testCaseName);
- return cache.get(((DefaultInputFile) testFile).key(), testCaseName);
- }
-
- public TestCaseExecutionCache put(InputFile testFile, TestCaseExecution testCase) {
- Preconditions.checkNotNull(testFile);
- Preconditions.checkNotNull(testCase);
- cache.put(((DefaultInputFile) testFile).key(), testCase.name(), testCase);
- return this;
- }
-
- public boolean contains(InputFile testFile, String name) {
- return cache.containsKey(((DefaultInputFile) testFile).key(), name);
- }
-
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/package-info.java b/sonar-batch/src/main/java/org/sonar/batch/test/package-info.java
deleted file mode 100644
index d85ce0026bf..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/test/package-info.java
+++ /dev/null
@@ -1,24 +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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.batch.test;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java
deleted file mode 100644
index 700aa0aaee8..00000000000
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java
+++ /dev/null
@@ -1,128 +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.test;
-
-import com.google.common.collect.ImmutableMap;
-import org.apache.commons.io.FileUtils;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.rules.TestName;
-import org.sonar.batch.mediumtest.BatchMediumTester;
-import org.sonar.batch.mediumtest.TaskResult;
-import org.sonar.xoo.XooPlugin;
-
-import java.io.File;
-import java.io.IOException;
-
-public class TestMediumTest {
-
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- @Rule
- public TestName testName = new TestName();
-
- public BatchMediumTester tester = BatchMediumTester.builder()
- .registerPlugin("xoo", new XooPlugin())
- .addDefaultQProfile("xoo", "Sonar Way")
- .build();
-
- @Before
- public void prepare() {
- tester.start();
- }
-
- @After
- public void stop() {
- tester.stop();
- }
-
- @Test
- public void populateTestCaseOnTempProject() throws IOException {
-
- File baseDir = temp.newFolder();
- File srcDir = new File(baseDir, "src");
- srcDir.mkdir();
- File testDir = new File(baseDir, "test");
- testDir.mkdir();
-
- File xooTestFile = new File(testDir, "sampleTest.xoo");
- File xooTestPlanFile = new File(testDir, "sampleTest.xoo.testplan");
- FileUtils.write(xooTestFile, "Sample test xoo\ncontent");
- FileUtils.write(xooTestPlanFile, "test1:UNIT:OK:::\ntest2:INTEGRATION:ERROR:Assertion failure:A very long stack:12");
-
- TaskResult result = tester.newTask()
- .properties(ImmutableMap.<String, String>builder()
- .put("sonar.task", "scan")
- .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
- .put("sonar.projectKey", "com.foo.project")
- .put("sonar.projectName", "Foo Project")
- .put("sonar.projectVersion", "1.0-SNAPSHOT")
- .put("sonar.projectDescription", "Description of Foo Project")
- .put("sonar.sources", "src")
- .put("sonar.tests", "test")
- .build())
- .start();
-
- // assertThat(result.testCasesFor(new DefaultInputFile("com.foo.project", "test/sampleTest.xoo"))).hasSize(2);
- }
-
- @Test
- public void populateTestCaseAndCoveragePerTestOnTempProject() throws IOException {
-
- File baseDir = temp.newFolder();
- File srcDir = new File(baseDir, "src");
- srcDir.mkdir();
- File testDir = new File(baseDir, "test");
- testDir.mkdir();
-
- File xooMainFile = new File(srcDir, "sample.xoo");
- File xooTestFile = new File(testDir, "sampleTest.xoo");
- File xooTestPlanFile = new File(testDir, "sampleTest.xoo.testplan");
- File xooTestCoverageFile = new File(testDir, "sampleTest.xoo.coveragePerTest");
- FileUtils.write(xooMainFile, "Sample xoo\ncontent");
- FileUtils.write(xooTestFile, "Sample test xoo\ncontent");
- FileUtils.write(xooTestPlanFile, "test1:UNIT:OK:::3\ntest2:INTEGRATION:ERROR:Assertion failure:A very long stack:12");
- FileUtils.write(xooTestCoverageFile, "test1:src/sample.xoo:1,2,3,8,9,10\ntest2:src/sample.xoo:3,4");
-
- // TaskResult result = tester.newTask()
- // .properties(ImmutableMap.<String, String>builder()
- // .put("sonar.task", "scan")
- // .put("sonar.projectBaseDir", baseDir.getAbsolutePath())
- // .put("sonar.projectKey", "com.foo.project")
- // .put("sonar.projectName", "Foo Project")
- // .put("sonar.projectVersion", "1.0-SNAPSHOT")
- // .put("sonar.projectDescription", "Description of Foo Project")
- // .put("sonar.sources", "src")
- // .put("sonar.tests", "test")
- // .build())
- // .start();
- //
- // assertThat(result.coveragePerTest(new DefaultInputFile("com.foo.project", "test/sampleTest.xoo"), "test1", new
- // DefaultInputFile("com.foo.project", "src/sample.xoo")))
- // .containsExactly(1, 2, 3, 8, 9, 10);
- // assertThat(result.coveragePerTest(new DefaultInputFile("com.foo.project", "test/sampleTest.xoo"), "test2", new
- // DefaultInputFile("com.foo.project", "src/sample.xoo")))
- // .containsExactly(3, 4);
- }
-}