]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6740 add fake plugin to emulate server startup failure
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 4 Feb 2016 21:40:54 +0000 (22:40 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 5 Feb 2016 13:24:25 +0000 (14:24 +0100)
it/it-plugins/server-plugin/src/main/java/ServerPlugin.java
it/it-plugins/server-plugin/src/main/java/StartupCrash.java [new file with mode: 0644]

index 7164283ce69387e6680010e196269932bead11b3..ce032d42c341b5544af8de187fa67ab1635b736a 100644 (file)
@@ -28,6 +28,7 @@ import org.sonar.api.SonarPlugin;
 })
 public class ServerPlugin extends SonarPlugin {
   public List getExtensions() {
-    return Arrays.asList(WidgetDisplayingProperties.class, TempFolderExtension.class);
+    return Arrays.asList(
+      StartupCrash.class, WidgetDisplayingProperties.class, TempFolderExtension.class);
   }
 }
diff --git a/it/it-plugins/server-plugin/src/main/java/StartupCrash.java b/it/it-plugins/server-plugin/src/main/java/StartupCrash.java
new file mode 100644 (file)
index 0000000..bda47b6
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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.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() {
+
+  }
+}