aboutsummaryrefslogtreecommitdiffstats
path: root/tests/plugins/server-plugin/src/main/java
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2018-06-18 10:55:55 +0200
committerSonarTech <sonartech@sonarsource.com>2018-06-21 20:21:30 +0200
commit2b14abe26e05418cb9bfe6a2ec12aad8b7f1bee7 (patch)
tree55105175deedd9bf3cedd626f96fec5b44e6705e /tests/plugins/server-plugin/src/main/java
parent7a1963f09d9ff9fb917c7c79f87e23b9a5473ab1 (diff)
downloadsonarqube-2b14abe26e05418cb9bfe6a2ec12aad8b7f1bee7.tar.gz
sonarqube-2b14abe26e05418cb9bfe6a2ec12aad8b7f1bee7.zip
move ITs code to private directory
Diffstat (limited to 'tests/plugins/server-plugin/src/main/java')
-rw-r--r--tests/plugins/server-plugin/src/main/java/ServerPlugin.java72
-rw-r--r--tests/plugins/server-plugin/src/main/java/ServerStartupLock.java77
-rw-r--r--tests/plugins/server-plugin/src/main/java/StartupCrash.java44
-rw-r--r--tests/plugins/server-plugin/src/main/java/TempFolderExtension.java59
-rw-r--r--tests/plugins/server-plugin/src/main/java/ce/CePauseStep.java63
-rw-r--r--tests/plugins/server-plugin/src/main/java/ce/PauseMetric.java35
6 files changed, 0 insertions, 350 deletions
diff --git a/tests/plugins/server-plugin/src/main/java/ServerPlugin.java b/tests/plugins/server-plugin/src/main/java/ServerPlugin.java
deleted file mode 100644
index d9b81db3edc..00000000000
--- a/tests/plugins/server-plugin/src/main/java/ServerPlugin.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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 ce.CePauseStep;
-import ce.PauseMetric;
-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, ServerStartupLock.class, TempFolderExtension.class, PauseMetric.class, CePauseStep.class);
- }
-}
diff --git a/tests/plugins/server-plugin/src/main/java/ServerStartupLock.java b/tests/plugins/server-plugin/src/main/java/ServerStartupLock.java
deleted file mode 100644
index 02125e66341..00000000000
--- a/tests/plugins/server-plugin/src/main/java/ServerStartupLock.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.io.File;
-import java.util.Optional;
-import org.sonar.api.SonarRuntime;
-import org.sonar.api.Startable;
-import org.sonar.api.ce.ComputeEngineSide;
-import org.sonar.api.config.Configuration;
-import org.sonar.api.server.ServerSide;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-
-@ServerSide
-@ComputeEngineSide
-public class ServerStartupLock implements Startable {
-
- private static final Logger LOGGER = Loggers.get(ServerStartupLock.class);
-
- private final Configuration configuration;
- private final SonarRuntime runtime;
-
- public ServerStartupLock(Configuration configuration, SonarRuntime runtime) {
- this.configuration = configuration;
- this.runtime = runtime;
- }
-
- @Override
- public void start() {
- Optional<String> path = configuration.get(propertyKey());
- if (path.isPresent()) {
- File lock = new File(path.get());
- try {
- while (lock.exists()) {
- LOGGER.info("ServerStartupLock - Waiting for file to be deleted: " + lock.getAbsolutePath());
- Thread.sleep(100L);
- }
- LOGGER.info("ServerStartupLock - File deleted. Resuming startup.");
- } catch (InterruptedException e) {
- LOGGER.info("ServerStartupLock - interrupted");
- Thread.currentThread().interrupt();
- }
- }
- }
-
- @Override
- public void stop() {
- // nothing to do
- }
-
- private String propertyKey() {
- switch (runtime.getSonarQubeSide()) {
- case SERVER:
- return "sonar.web.startupLock.path";
- case COMPUTE_ENGINE:
- return "sonar.ce.startupLock.path";
- default:
- throw new IllegalArgumentException("Unsupported runtime: " + runtime.getSonarQubeSide());
- }
- }
-}
diff --git a/tests/plugins/server-plugin/src/main/java/StartupCrash.java b/tests/plugins/server-plugin/src/main/java/StartupCrash.java
deleted file mode 100644
index dcde8c8e1d3..00000000000
--- a/tests/plugins/server-plugin/src/main/java/StartupCrash.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.Startable;
-import org.sonar.api.config.Settings;
-import org.sonar.api.server.ServerSide;
-
-@ServerSide
-public class StartupCrash implements Startable {
-
- private final Settings settings;
-
- public StartupCrash(Settings settings) {
- this.settings = settings;
- }
-
- @Override
- public void start() {
- if (settings.getBoolean("failAtStartup")) {
- throw new IllegalStateException("Error in plugin [server]");
- }
- }
-
- @Override
- public void stop() {
- // do nothing
- }
-}
diff --git a/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java b/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java
deleted file mode 100644
index 77618177e0b..00000000000
--- a/tests/plugins/server-plugin/src/main/java/TempFolderExtension.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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());
- }
- }
-
-}
diff --git a/tests/plugins/server-plugin/src/main/java/ce/CePauseStep.java b/tests/plugins/server-plugin/src/main/java/ce/CePauseStep.java
deleted file mode 100644
index 73d84aa8afb..00000000000
--- a/tests/plugins/server-plugin/src/main/java/ce/CePauseStep.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import java.io.File;
-import org.sonar.api.ce.measure.Component;
-import org.sonar.api.ce.measure.MeasureComputer;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-
-public class CePauseStep implements MeasureComputer {
-
- private static final Logger LOGGER = Loggers.get(CePauseStep.class);
-
- @Override
- public MeasureComputerDefinition define(MeasureComputerDefinitionContext defContext) {
- return defContext.newDefinitionBuilder()
- .setInputMetrics("ncloc")
- .setOutputMetrics(PauseMetric.KEY)
- .build();
- }
-
- @Override
- public void compute(MeasureComputerContext context) {
- if (context.getComponent().getType() == Component.Type.PROJECT) {
- String path = context.getSettings().getString("sonar.ce.pauseTask.path");
- if (path != null) {
- waitForFileToBeDeleted(path);
- }
- }
- }
-
- private static void waitForFileToBeDeleted(String path) {
- LOGGER.info("CE analysis is paused. Waiting for file to be deleted: " + path);
- File file = new File(path);
- try {
- while (file.exists()) {
- Thread.sleep(500L);
- }
- LOGGER.info("CE analysis is resumed");
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new IllegalStateException("CE analysis has been interrupted");
- }
- }
-}
diff --git a/tests/plugins/server-plugin/src/main/java/ce/PauseMetric.java b/tests/plugins/server-plugin/src/main/java/ce/PauseMetric.java
deleted file mode 100644
index 26d48ef65f8..00000000000
--- a/tests/plugins/server-plugin/src/main/java/ce/PauseMetric.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 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.
- */
-package ce;
-
-import java.util.Arrays;
-import java.util.List;
-import org.sonar.api.measures.Metric;
-import org.sonar.api.measures.Metrics;
-
-public class PauseMetric implements Metrics {
-
- public static final String KEY = "pause";
-
- @Override
- public List<Metric> getMetrics() {
- return Arrays.asList(new Metric.Builder(KEY, "Pause", Metric.ValueType.INT).create());
- }
-}