aboutsummaryrefslogtreecommitdiffstats
path: root/tests/plugins/server-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/server-plugin
parent5dd574819854e9ce7e2f4e181e78153a7ecbf828 (diff)
downloadsonarqube-70b6899988da0d2ba0a39b846e4f1bd3fa27304f.tar.gz
sonarqube-70b6899988da0d2ba0a39b846e4f1bd3fa27304f.zip
Move integration tests to directory tests/
Diffstat (limited to 'tests/plugins/server-plugin')
-rw-r--r--tests/plugins/server-plugin/pom.xml39
-rw-r--r--tests/plugins/server-plugin/src/main/java/ServerPlugin.java91
-rw-r--r--tests/plugins/server-plugin/src/main/java/StartupCrash.java42
-rw-r--r--tests/plugins/server-plugin/src/main/java/TempFolderExtension.java59
4 files changed, 231 insertions, 0 deletions
diff --git a/tests/plugins/server-plugin/pom.xml b/tests/plugins/server-plugin/pom.xml
new file mode 100644
index 00000000000..5d436a95a67
--- /dev/null
+++ b/tests/plugins/server-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>server-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>sonar-plugin</packaging>
+ <name>SonarQube Integration Tests :: Plugins :: Server</name>
+ <description>Main plugin for Server tests</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>ServerPlugin</pluginClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/tests/plugins/server-plugin/src/main/java/ServerPlugin.java b/tests/plugins/server-plugin/src/main/java/ServerPlugin.java
new file mode 100644
index 00000000000..07aa1f861a2
--- /dev/null
+++ b/tests/plugins/server-plugin/src/main/java/ServerPlugin.java
@@ -0,0 +1,91 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyField;
+import org.sonar.api.SonarPlugin;
+
+import static org.sonar.api.PropertyType.BOOLEAN;
+import static org.sonar.api.PropertyType.FLOAT;
+import static org.sonar.api.PropertyType.INTEGER;
+import static org.sonar.api.PropertyType.LICENSE;
+import static org.sonar.api.PropertyType.LONG;
+import static org.sonar.api.PropertyType.METRIC;
+import static org.sonar.api.PropertyType.METRIC_LEVEL;
+import static org.sonar.api.PropertyType.PASSWORD;
+import static org.sonar.api.PropertyType.PROPERTY_SET;
+import static org.sonar.api.PropertyType.SINGLE_SELECT_LIST;
+import static org.sonar.api.PropertyType.STRING;
+import static org.sonar.api.PropertyType.TEXT;
+import static org.sonar.api.PropertyType.USER_LOGIN;
+
+@Properties({
+ @Property(key = "some-property", name = "Some Property", defaultValue = "aDefaultValue", global = true, project = false),
+ @Property(key = "boolean", name = "Boolean", defaultValue = "true", type = BOOLEAN, global = true, project = false),
+ @Property(key = "user", name = "User", type = USER_LOGIN, global = true, project = false),
+ @Property(key = "list", name = "List", type = SINGLE_SELECT_LIST, options = {"A", "B", "C"}, global = true, project = false),
+ @Property(key = "metric", name = "Metric", type = METRIC, global = true, project = false),
+ @Property(key = "metric_level", name = "Metric Level", type = METRIC_LEVEL, global = true, project = false),
+ @Property(key = "float", name = "Float", type = FLOAT, global = true, project = false),
+ @Property(key = "int", name = "Integer", type = INTEGER, global = true, project = false),
+ @Property(key = "string", name = "String", type = STRING, global = true, project = false),
+ @Property(key = "setting.license.secured", name = "License", type = LICENSE, global = true, project = false),
+ @Property(key = "long", name = "Long", type = LONG, global = true, project = false),
+ @Property(key = "password", name = "Password", type = PASSWORD, global = true, project = false),
+ @Property(key = "text", name = "Text", type = TEXT, global = true, project = false),
+ @Property(key = "multi", name = "Multi", type = STRING, multiValues = true, global = true, project = false),
+ @Property(key = "hidden", name = "Hidden", type = STRING, global = false, project = false),
+ @Property(key = "project.setting", name = "Project setting", type = STRING, global = false, project = true),
+ @Property(key = "setting.secured", name = "Secured", type = STRING, global = true, project = false),
+ @Property(key = "sonar.jira", name = "Jira Server", type = PROPERTY_SET, propertySetKey = "jira", fields = {
+ @PropertyField(key = "key", name = "Key", description = "Server key"),
+ @PropertyField(key = "type", name = "Type", options = {"A", "B"}),
+ @PropertyField(key = "url", name = "URL"),
+ @PropertyField(key = "port", name = "Port", type = INTEGER)}),
+})
+public class ServerPlugin extends SonarPlugin {
+ public List getExtensions() {
+ return Arrays.asList(
+ StartupCrash.class, TempFolderExtension.class);
+ }
+}
diff --git a/tests/plugins/server-plugin/src/main/java/StartupCrash.java b/tests/plugins/server-plugin/src/main/java/StartupCrash.java
new file mode 100644
index 00000000000..cf57ccbc653
--- /dev/null
+++ b/tests/plugins/server-plugin/src/main/java/StartupCrash.java
@@ -0,0 +1,42 @@
+/*
+ * 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.config.Settings;
+import org.sonar.api.server.ServerSide;
+
+
+@ServerSide
+public class StartupCrash {
+
+ private final Settings settings;
+
+ public StartupCrash(Settings settings) {
+ this.settings = settings;
+ }
+
+ public void start() {
+ if (settings.getBoolean("failAtStartup")) {
+ throw new IllegalStateException("Error in plugin [server]");
+ }
+ }
+
+ public void stop() {
+
+ }
+}
diff --git a/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java b/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java
new file mode 100644
index 00000000000..ddddf9d44de
--- /dev/null
+++ b/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java
@@ -0,0 +1,59 @@
+/*
+ * 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.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.PropertyType;
+import org.sonar.api.ServerExtension;
+import org.sonar.api.config.Settings;
+import org.sonar.api.utils.TempFolder;
+import org.sonar.api.utils.log.Logger;
+import org.sonar.api.utils.log.Loggers;
+
+@Properties({
+ @Property(
+ key = TempFolderExtension.CREATE_TEMP_FILES,
+ type = PropertyType.BOOLEAN,
+ name = "Property to decide if it should create temp files",
+ defaultValue = "false")
+})
+public class TempFolderExtension implements ServerExtension {
+
+ private static final Logger LOG = Loggers.get(TempFolderExtension.class);
+
+ public static final String CREATE_TEMP_FILES = "sonar.createTempFiles";
+
+ private Settings settings;
+
+ private TempFolder tempFolder;
+
+ public TempFolderExtension(Settings settings, TempFolder tempFolder) {
+ this.settings = settings;
+ this.tempFolder = tempFolder;
+ start();
+ }
+
+ public void start() {
+ if (settings.getBoolean(CREATE_TEMP_FILES)) {
+ LOG.info("Creating temp directory: " + tempFolder.newDir("sonar-it").getAbsolutePath());
+ LOG.info("Creating temp file: " + tempFolder.newFile("sonar-it", ".txt").getAbsolutePath());
+ }
+ }
+
+}