aboutsummaryrefslogtreecommitdiffstats
path: root/tests/plugins/posttask-plugin
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-06-23 21:31:56 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-06-25 23:42:50 +0200
commit70b6899988da0d2ba0a39b846e4f1bd3fa27304f (patch)
tree1ac093a87e0fba6b07c6feb6aceae89bdd9663cf /tests/plugins/posttask-plugin
parent5dd574819854e9ce7e2f4e181e78153a7ecbf828 (diff)
downloadsonarqube-70b6899988da0d2ba0a39b846e4f1bd3fa27304f.tar.gz
sonarqube-70b6899988da0d2ba0a39b846e4f1bd3fa27304f.zip
Move integration tests to directory tests/
Diffstat (limited to 'tests/plugins/posttask-plugin')
-rw-r--r--tests/plugins/posttask-plugin/pom.xml39
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java35
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java36
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java62
-rw-r--r--tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java29
5 files changed, 201 insertions, 0 deletions
diff --git a/tests/plugins/posttask-plugin/pom.xml b/tests/plugins/posttask-plugin/pom.xml
new file mode 100644
index 00000000000..a7fa06d39b8
--- /dev/null
+++ b/tests/plugins/posttask-plugin/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.sonarsource.sonarqube.tests</groupId>
+ <artifactId>plugins</artifactId>
+ <version>6.5-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>posttask-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: PostTask</name>
+ <description>Plugin testing the Compute Engine Post Task API</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.sonarsource.sonarqube</groupId>
+ <artifactId>sonar-plugin-api</artifactId>
+ <version>${apiVersion}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.sonarsource.sonar-packaging-maven-plugin</groupId>
+ <artifactId>sonar-packaging-maven-plugin</artifactId>
+ <version>1.15</version>
+ <extensions>true</extensions>
+ <configuration>
+ <pluginClass>PostTaskPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java b/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java
new file mode 100644
index 00000000000..7013a6707a8
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/AddScannerContextSensor.java
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+import org.sonar.api.batch.sensor.Sensor;
+import org.sonar.api.batch.sensor.SensorContext;
+import org.sonar.api.batch.sensor.SensorDescriptor;
+
+public class AddScannerContextSensor implements Sensor {
+ @Override
+ public void execute(SensorContext context) {
+ context.addContextProperty("foo1", "bar1");
+ context.addContextProperty("foo2", "bar2");
+ }
+
+ @Override
+ public void describe(SensorDescriptor descriptor) {
+
+ }
+}
diff --git a/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java b/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java
new file mode 100644
index 00000000000..120610a2da2
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/LogScannerContextPostTask.java
@@ -0,0 +1,36 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+import java.util.Map;
+import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+public class LogScannerContextPostTask implements PostProjectAnalysisTask {
+ private static final Logger LOG = Loggers.get(LogScannerContextPostTask.class);
+
+ @Override
+ public void finished(ProjectAnalysis analysis) {
+ for (Map.Entry<String, String> prop : analysis.getScannerContext().getProperties().entrySet()) {
+ LOG.info("POSTASKPLUGIN: ScannerProperty {}={}",
+ prop.getKey(),
+ prop.getValue());
+ }
+ }
+}
diff --git a/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java b/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java
new file mode 100644
index 00000000000..0c288ec01d5
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/PostProjectAnalysisTaskImpl.java
@@ -0,0 +1,62 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+import org.sonar.api.ce.posttask.CeTask;
+import org.sonar.api.ce.posttask.PostProjectAnalysisTask;
+import org.sonar.api.ce.posttask.Project;
+import org.sonar.api.ce.posttask.QualityGate;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+public class PostProjectAnalysisTaskImpl implements PostProjectAnalysisTask {
+ private static final Logger LOG = Loggers.get(PostProjectAnalysisTaskImpl.class);
+
+ @Override
+ public void finished(ProjectAnalysis analysis) {
+ CeTask ceTask = analysis.getCeTask();
+ Project project = analysis.getProject();
+ QualityGate qualityGate = analysis.getQualityGate();
+ LOG.info("POSTASKPLUGIN: finished() CeTask[{}][{}] Project[{}] Date[{}] QualityGate[{}]",
+ ceTask.getStatus(),
+ ceTask.getId(),
+ project.getKey(),
+ analysis.getDate().getTime(),
+ qualityGate == null ? null : qualityGate.getStatus());
+ }
+}
diff --git a/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java b/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java
new file mode 100644
index 00000000000..07ce105ff4e
--- /dev/null
+++ b/tests/plugins/posttask-plugin/src/main/java/PostTaskPlugin.java
@@ -0,0 +1,29 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program 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.
+ *
+ * This program 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.
+ */
+import java.util.Arrays;
+import java.util.List;
+import org.sonar.api.SonarPlugin;
+
+public class PostTaskPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(PostProjectAnalysisTaskImpl.class,
+ LogScannerContextPostTask.class, AddScannerContextSensor.class);
+ }
+}