]> source.dussan.org Git - sonarqube.git/commitdiff
add Module for ElasticSearch components
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 13 May 2015 11:47:14 +0000 (13:47 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 27 May 2015 10:11:37 +0000 (12:11 +0200)
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java [new file with mode: 0644]
sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java

index 1752c5d9a79dfa4ec0db5097031de681659a091a..379715cd497ac56da4bbbaa184368613e9c15116 100644 (file)
@@ -19,6 +19,8 @@
  */
 package org.sonar.server.platform.platformlevel;
 
+import java.util.Properties;
+import javax.annotation.Nullable;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.internal.TempFolderCleaner;
 import org.sonar.core.config.CorePropertyDefinitions;
@@ -44,7 +46,6 @@ import org.sonar.server.db.DatabaseChecker;
 import org.sonar.server.db.DbClient;
 import org.sonar.server.db.EmbeddedDatabaseFactory;
 import org.sonar.server.db.migrations.MigrationSteps;
-import org.sonar.server.es.EsClient;
 import org.sonar.server.event.db.EventDao;
 import org.sonar.server.issue.db.IssueDao;
 import org.sonar.server.issue.index.IssueIndex;
@@ -63,19 +64,14 @@ import org.sonar.server.ruby.PlatformRackBridge;
 import org.sonar.server.rule.db.RuleDao;
 import org.sonar.server.rule.index.RuleIndex;
 import org.sonar.server.rule.index.RuleNormalizer;
-import org.sonar.server.search.IndexClient;
+import org.sonar.server.search.EsSearchModule;
 import org.sonar.server.search.IndexQueue;
-import org.sonar.server.search.SearchClient;
 import org.sonar.server.source.db.FileSourceDao;
 import org.sonar.server.user.ThreadLocalUserSession;
 import org.sonar.server.user.db.GroupDao;
 import org.sonar.server.user.db.UserDao;
 import org.sonar.server.user.db.UserGroupDao;
 
-import javax.annotation.Nullable;
-
-import java.util.Properties;
-
 public class PlatformLevel1 extends PlatformLevel {
   private final Platform platform;
   private final Properties properties;
@@ -122,9 +118,7 @@ public class PlatformLevel1 extends PlatformLevel {
       DbClient.class,
 
       // Elasticsearch
-      SearchClient.class,
-      IndexClient.class,
-      EsClient.class,
+      EsSearchModule.class,
 
       // users
       GroupDao.class,
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java b/server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java
new file mode 100644 (file)
index 0000000..f3e1b7f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.server.search;
+
+import org.sonar.core.component.Module;
+import org.sonar.server.es.EsClient;
+
+public class EsSearchModule extends Module {
+  @Override
+  protected void configureModule() {
+    add(
+      SearchClient.class,
+      IndexClient.class,
+      EsClient.class);
+  }
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java
new file mode 100644 (file)
index 0000000..0a121b2
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.server.search;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class EsSearchModuleTest {
+  @Test
+  public void verify_count_of_added_components() throws Exception {
+    ComponentContainer container = new ComponentContainer();
+    new EsSearchModule().configure(container);
+    assertThat(container.size()).isEqualTo(5);
+  }
+
+}
index 028edcef284147dc2637a22be242d96f9afee5ac..3f06b041ec1f5b1aa12d0b1e3ec53f269fcffbcf 100644 (file)
@@ -260,4 +260,8 @@ public class ComponentContainer {
   public MutablePicoContainer getPicoContainer() {
     return pico;
   }
+
+  public int size() {
+    return pico.getComponentAdapters().size();
+  }
 }