diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-02-19 16:49:10 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-02-19 22:28:59 +0100 |
commit | 0f517d524485bcc0acb47a7f00d54b2e1bac4f50 (patch) | |
tree | ff618f5e8d4886dae0f2e16254f76b67dd2203fc /plugins/sonar-xoo-plugin | |
parent | eac465bea9f5bf89a7beb8036e4d8eea4723f421 (diff) | |
download | sonarqube-0f517d524485bcc0acb47a7f00d54b2e1bac4f50.tar.gz sonarqube-0f517d524485bcc0acb47a7f00d54b2e1bac4f50.zip |
SONAR-5931 Remove beta test API
Diffstat (limited to 'plugins/sonar-xoo-plugin')
5 files changed, 0 insertions, 447 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java index 50fe968725c..df3a7b5c64e 100644 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java +++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/XooPlugin.java @@ -20,12 +20,10 @@ package org.sonar.xoo; import org.sonar.api.SonarPlugin; -import org.sonar.xoo.lang.CoveragePerTestSensor; import org.sonar.xoo.lang.DependencySensor; import org.sonar.xoo.lang.MeasureSensor; import org.sonar.xoo.lang.SymbolReferencesSensor; import org.sonar.xoo.lang.SyntaxHighlightingSensor; -import org.sonar.xoo.lang.TestCaseSensor; import org.sonar.xoo.lang.XooCpdMapping; import org.sonar.xoo.lang.XooTokenizer; import org.sonar.xoo.rule.ChecksSensor; @@ -76,8 +74,6 @@ public class XooPlugin extends SonarPlugin { MeasureSensor.class, SyntaxHighlightingSensor.class, SymbolReferencesSensor.class, - TestCaseSensor.class, - CoveragePerTestSensor.class, DependencySensor.class, ChecksSensor.class, RandomAccessSensor.class, diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CoveragePerTestSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CoveragePerTestSensor.java deleted file mode 100644 index fcdb738e46d..00000000000 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/CoveragePerTestSensor.java +++ /dev/null @@ -1,113 +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.xoo.lang; - -import com.google.common.base.Splitter; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.fs.FilePredicates; -import org.sonar.api.batch.fs.FileSystem; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.sensor.Sensor; -import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorDescriptor; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.xoo.Xoo; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * Parse files *.xoo.coveragePerTest - */ -public class CoveragePerTestSensor implements Sensor { - - private static final Logger LOG = Loggers.get(CoveragePerTestSensor.class); - - private static final String COVER_PER_TEST_EXTENSION = ".coveragePerTest"; - - private void processCoveragePerTest(InputFile inputFile, SensorContext context) { - File ioFile = inputFile.file(); - File coverPerTestFile = new File(ioFile.getParentFile(), ioFile.getName() + COVER_PER_TEST_EXTENSION); - if (coverPerTestFile.exists()) { - LOG.debug("Processing " + coverPerTestFile.getAbsolutePath()); - try { - List<String> lines = FileUtils.readLines(coverPerTestFile, context.fileSystem().encoding().name()); - int lineNumber = 0; - for (String line : lines) { - lineNumber++; - if (StringUtils.isBlank(line) || line.startsWith("#")) { - continue; - } - processLine(coverPerTestFile, lineNumber, context, line, inputFile); - } - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - } - - private void processLine(File coverPerTest, int lineNumber, SensorContext context, String line, InputFile testFile) { - try { - Iterator<String> split = Splitter.on(":").split(line).iterator(); - String testCaseName = split.next(); - String mainFileRelativePath = split.next(); - FileSystem fs = context.fileSystem(); - InputFile mainFile = fs.inputFile(fs.predicates().hasRelativePath(mainFileRelativePath)); - if (mainFile == null) { - throw new IllegalStateException("Unable to find file " + mainFileRelativePath); - } - List<Integer> coveredLines = new ArrayList<Integer>(); - Iterator<String> lines = Splitter.on(",").split(split.next()).iterator(); - while (lines.hasNext()) { - coveredLines.add(Integer.parseInt(lines.next())); - } - context.newTestCaseCoverage() - .testFile(testFile) - .testName(testCaseName) - .cover(mainFile) - .onLines(coveredLines) - .save(); - } catch (Exception e) { - throw new IllegalStateException("Error processing line " + lineNumber + " of file " + coverPerTest.getAbsolutePath(), e); - } - } - - @Override - public void describe(SensorDescriptor descriptor) { - descriptor - .name("Xoo Coverage Per Test Sensor") - .onlyOnLanguages(Xoo.KEY) - .onlyOnFileType(InputFile.Type.TEST); - } - - @Override - public void execute(SensorContext context) { - FileSystem fs = context.fileSystem(); - FilePredicates p = fs.predicates(); - for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(InputFile.Type.TEST)))) { - processCoveragePerTest(file, context); - } - } -} diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java deleted file mode 100644 index f7b38976489..00000000000 --- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java +++ /dev/null @@ -1,112 +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.xoo.lang; - -import com.google.common.base.Splitter; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.batch.fs.FilePredicates; -import org.sonar.api.batch.fs.FileSystem; -import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.sensor.Sensor; -import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorDescriptor; -import org.sonar.api.batch.sensor.test.TestCaseExecution; -import org.sonar.api.utils.log.Logger; -import org.sonar.api.utils.log.Loggers; -import org.sonar.xoo.Xoo; - -import java.io.File; -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - -/** - * Parse files *.xoo.testplan - */ -public class TestCaseSensor implements Sensor { - - private static final Logger LOG = Loggers.get(TestCaseSensor.class); - - private static final String TESTPLAN_EXTENSION = ".testplan"; - - private void processFileTestPlan(InputFile inputFile, SensorContext context) { - File ioFile = inputFile.file(); - File testPlanFile = new File(ioFile.getParentFile(), ioFile.getName() + TESTPLAN_EXTENSION); - if (testPlanFile.exists()) { - LOG.debug("Processing " + testPlanFile.getAbsolutePath()); - try { - List<String> lines = FileUtils.readLines(testPlanFile, context.fileSystem().encoding().name()); - int lineNumber = 0; - for (String line : lines) { - lineNumber++; - if (StringUtils.isBlank(line) || line.startsWith("#")) { - continue; - } - processLine(testPlanFile, lineNumber, line, context, inputFile); - } - } catch (IOException e) { - throw new IllegalStateException(e); - } - } - } - - private void processLine(File testplanFile, int lineNumber, String line, SensorContext context, InputFile testFile) { - try { - Iterator<String> split = Splitter.on(":").split(line).iterator(); - String name = split.next(); - String type = split.next(); - String status = split.next(); - String message = split.next(); - String stack = split.next(); - String durationStr = StringUtils.trimToNull(split.next()); - TestCaseExecution test = context.newTestCaseExecution() - .inTestFile(testFile) - .name(name) - .ofType(TestCaseExecution.Type.valueOf(type)) - .status(TestCaseExecution.Status.valueOf(status)) - .message(StringUtils.trimToNull(message)) - .stackTrace(StringUtils.trimToNull(stack)); - if (durationStr != null) { - test.durationInMs(Long.parseLong(durationStr)); - } - test.save(); - } catch (Exception e) { - throw new IllegalStateException("Error processing line " + lineNumber + " of file " + testplanFile.getAbsolutePath(), e); - } - } - - @Override - public void describe(SensorDescriptor descriptor) { - descriptor - .name("Xoo TestPlan Sensor") - .onlyOnLanguages(Xoo.KEY) - .onlyOnFileType(InputFile.Type.TEST); - } - - @Override - public void execute(SensorContext context) { - FileSystem fs = context.fileSystem(); - FilePredicates p = fs.predicates(); - for (InputFile file : fs.inputFiles(p.and(p.hasLanguages(Xoo.KEY), p.hasType(InputFile.Type.TEST)))) { - processFileTestPlan(file, context); - } - } -} diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CoveragePerTestSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CoveragePerTestSensorTest.java deleted file mode 100644 index 4b57e397362..00000000000 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CoveragePerTestSensorTest.java +++ /dev/null @@ -1,109 +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.xoo.lang; - -import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.sonar.api.batch.fs.InputFile.Type; -import org.sonar.api.batch.fs.internal.DefaultFileSystem; -import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorStorage; -import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; -import org.sonar.api.batch.sensor.test.TestCaseCoverage; -import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseCoverage; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class CoveragePerTestSensorTest { - - private CoveragePerTestSensor sensor; - private SensorContext context = mock(SensorContext.class); - private DefaultFileSystem fileSystem; - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - private File baseDir; - - @Before - public void prepare() throws IOException { - baseDir = temp.newFolder(); - sensor = new CoveragePerTestSensor(); - fileSystem = new DefaultFileSystem(baseDir.toPath()); - when(context.fileSystem()).thenReturn(fileSystem); - } - - @Test - public void testDescriptor() { - sensor.describe(new DefaultSensorDescriptor()); - } - - @Test - public void testNoExecutionIfCoveragePerTestFile() { - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") - .setType(Type.TEST); - fileSystem.add(testFile); - sensor.execute(context); - } - - @Test - public void testExecution() throws IOException { - File coverPerTest = new File(baseDir, "test/fooTest.xoo.coveragePerTest"); - FileUtils.write(coverPerTest, "test1:src/foo.xoo:1,2,3,4\ntest2:src/foo.xoo:5,6,7\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") - .setType(Type.TEST); - fileSystem.add(inputFile); - fileSystem.add(testFile); - - final SensorStorage sensorStorage = mock(SensorStorage.class); - - when(context.newTestCaseCoverage()).thenAnswer(new Answer<TestCaseCoverage>() { - @Override - public TestCaseCoverage answer(InvocationOnMock invocation) throws Throwable { - return new DefaultTestCaseCoverage(sensorStorage); - } - }); - - sensor.execute(context); - - verify(sensorStorage).store(new DefaultTestCaseCoverage() - .testFile(testFile) - .testName("test1") - .cover(inputFile) - .onLines(Arrays.asList(1, 2, 3, 4))); - verify(sensorStorage).store(new DefaultTestCaseCoverage() - .testFile(testFile) - .testName("test2") - .cover(inputFile) - .onLines(Arrays.asList(5, 6, 7))); - } -} diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/TestCaseSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/TestCaseSensorTest.java deleted file mode 100644 index 5e1a1344f4e..00000000000 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/TestCaseSensorTest.java +++ /dev/null @@ -1,109 +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.xoo.lang; - -import org.apache.commons.io.FileUtils; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.sonar.api.batch.fs.InputFile.Type; -import org.sonar.api.batch.fs.internal.DefaultFileSystem; -import org.sonar.api.batch.fs.internal.DefaultInputFile; -import org.sonar.api.batch.sensor.SensorContext; -import org.sonar.api.batch.sensor.SensorStorage; -import org.sonar.api.batch.sensor.internal.DefaultSensorDescriptor; -import org.sonar.api.batch.sensor.test.TestCaseExecution; -import org.sonar.api.batch.sensor.test.internal.DefaultTestCaseExecution; - -import java.io.File; -import java.io.IOException; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -public class TestCaseSensorTest { - - private TestCaseSensor sensor; - private SensorContext context = mock(SensorContext.class); - private DefaultFileSystem fileSystem; - - @Rule - public TemporaryFolder temp = new TemporaryFolder(); - private File baseDir; - - @Before - public void prepare() throws IOException { - baseDir = temp.newFolder(); - sensor = new TestCaseSensor(); - fileSystem = new DefaultFileSystem(baseDir.toPath()); - when(context.fileSystem()).thenReturn(fileSystem); - } - - @Test - public void testDescriptor() { - sensor.describe(new DefaultSensorDescriptor()); - } - - @Test - public void testNoExecutionIfNoTestFile() { - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") - .setType(Type.TEST); - fileSystem.add(testFile); - sensor.execute(context); - } - - @Test - public void testExecution() throws IOException { - File testPlan = new File(baseDir, "test/fooTest.xoo.testplan"); - FileUtils.write(testPlan, "test1:UNIT:OK:::10\ntest2:INTEGRATION:ERROR:message:stack:15\n\n#comment"); - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") - .setType(Type.TEST); - fileSystem.add(testFile); - - final SensorStorage sensorStorage = mock(SensorStorage.class); - - when(context.newTestCaseExecution()).thenAnswer(new Answer<TestCaseExecution>() { - @Override - public TestCaseExecution answer(InvocationOnMock invocation) throws Throwable { - return new DefaultTestCaseExecution(sensorStorage); - } - }); - - sensor.execute(context); - - verify(sensorStorage).store(new DefaultTestCaseExecution(null) - .inTestFile(testFile) - .name("test1") - .durationInMs(10)); - verify(sensorStorage).store(new DefaultTestCaseExecution(null) - .inTestFile(testFile) - .name("test2") - .ofType(TestCaseExecution.Type.INTEGRATION) - .status(TestCaseExecution.Status.ERROR) - .message("message") - .stackTrace("stack") - .durationInMs(15)); - } - -} |