]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6732 add components from PlatformLevel3 to CE container
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Fri, 11 Mar 2016 16:04:29 +0000 (17:04 +0100)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 21 Mar 2016 15:44:04 +0000 (16:44 +0100)
server/sonar-ce/pom.xml
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java

index 357ead56d1a6c12a543db2c92ffdfe5e2f3d9397..f9ead798b1d354a80f9fd1299fb7db27c4844ad1 100644 (file)
       <artifactId>sonar-testing-harness</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>sonar-db</artifactId>
+      <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.dbunit</groupId>
+      <artifactId>dbunit</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
   <build>
index 6bb67ee7f8705d8b2bd6c1d900f993615d171812..a3a4c65fec0e1b5ed8caeccb8a520e9434a91ab9 100644 (file)
@@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting;
 import java.util.List;
 import org.sonar.api.utils.Durations;
 import org.sonar.api.utils.System2;
+import org.sonar.api.utils.UriReader;
 import org.sonar.core.config.CorePropertyDefinitions;
 import org.sonar.core.i18n.DefaultI18n;
 import org.sonar.core.i18n.RuleI18nManager;
@@ -31,6 +32,7 @@ import org.sonar.core.platform.Module;
 import org.sonar.core.platform.PluginClassloaderFactory;
 import org.sonar.core.platform.PluginLoader;
 import org.sonar.core.platform.SonarQubeVersionProvider;
+import org.sonar.core.util.DefaultHttpDownloader;
 import org.sonar.core.util.UuidFactoryImpl;
 import org.sonar.db.DaoModule;
 import org.sonar.db.DatabaseChecker;
@@ -45,6 +47,8 @@ import org.sonar.server.issue.index.IssueIndex;
 import org.sonar.server.platform.DatabaseServerCompatibility;
 import org.sonar.server.platform.DefaultServerFileSystem;
 import org.sonar.server.platform.DefaultServerUpgradeStatus;
+import org.sonar.server.platform.PersistentSettings;
+import org.sonar.server.platform.ServerIdGenerator;
 import org.sonar.server.platform.ServerImpl;
 import org.sonar.server.platform.ServerSettings;
 import org.sonar.server.platform.TempFolderProvider;
@@ -55,6 +59,7 @@ import org.sonar.server.plugins.ServerPluginRepository;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
 import org.sonar.server.rule.index.RuleIndex;
 import org.sonar.server.search.EsSearchModule;
+import org.sonar.server.startup.ServerMetadataPersister;
 
 public class ComputeEngineContainerImpl implements ComputeEngineContainer {
   private static final Object[] LEVEL_1_COMPONENTS = new Object[] {
@@ -113,6 +118,13 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
     RuleI18nManager.class, // used by DebtRulesXMLImporter
     Durations.class, // used in Web Services and DebtCalculator
   };
+  private static final Object[] LEVEL_3_COMPONENTS = new Object[] {
+    PersistentSettings.class,
+    ServerMetadataPersister.class,
+    DefaultHttpDownloader.class,
+    UriReader.class,
+    ServerIdGenerator.class
+  };
 
   private final ComponentContainer componentContainer;
 
@@ -127,7 +139,8 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
       .add(LEVEL_1_COMPONENTS)
       .add(toArray(CorePropertyDefinitions.all()))
       .add(toArray(CePropertyDefinitions.all()))
-      .add(LEVEL_2_COMPONENTS);
+      .add(LEVEL_2_COMPONENTS)
+      .add(LEVEL_3_COMPONENTS);
 
     configureFromModules();
 
index dfba271036d5842a86fee41e8ede9496491216d4..2dc1905e4f96275128eebe97946967da9a5a293b 100644 (file)
@@ -22,13 +22,16 @@ package org.sonar.ce.container;
 import java.io.File;
 import java.io.IOException;
 import java.util.Properties;
+import org.apache.commons.dbcp.BasicDataSource;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 import org.picocontainer.MutablePicoContainer;
 import org.sonar.api.config.PropertyDefinitions;
 import org.sonar.api.database.DatabaseProperties;
+import org.sonar.api.utils.System2;
 import org.sonar.core.platform.ComponentContainer;
+import org.sonar.db.DbTester;
 import org.sonar.process.ProcessProperties;
 import org.sonar.process.Props;
 
@@ -39,6 +42,8 @@ public class ComputeEngineContainerImplTest {
 
   @Rule
   public TemporaryFolder tempFolder = new TemporaryFolder();
+  @Rule
+  public DbTester dbTester = DbTester.create(System2.INSTANCE);
 
   private ComputeEngineContainerImpl underTest = new ComputeEngineContainerImpl();
 
@@ -66,13 +71,14 @@ public class ComputeEngineContainerImplTest {
 
     assertThat(underTest.getComponentContainer().getPicoContainer().getComponentAdapters())
       .hasSize(COMPONENTS_IN_CONTAINER_AT_CONSTRUCTION
-          + 22 // level 1
-          + 47 // content of DaoModule
-          + 1  // content of EsSearchModule
-          + 58 // content of CorePropertyDefinitions
-          + 1 // content of CePropertyDefinitions
-          + 59 // content of MigrationStepModule
-          + 10 // level 2
+        + 22 // level 1
+        + 47 // content of DaoModule
+        + 1 // content of EsSearchModule
+        + 58 // content of CorePropertyDefinitions
+        + 1 // content of CePropertyDefinitions
+        + 59 // content of MigrationStepModule
+        + 10 // level 2
+        + 5 // level 3
       );
   }
 
@@ -85,7 +91,10 @@ public class ComputeEngineContainerImplTest {
     properties.setProperty(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath());
     properties.setProperty(ProcessProperties.PATH_DATA, dataDir.getAbsolutePath());
     properties.setProperty(ProcessProperties.PATH_TEMP, tmpDir.getAbsolutePath());
-    properties.setProperty(DatabaseProperties.PROP_URL, "jdbc:h2:mem:sonar");
+    String url = ((BasicDataSource) dbTester.database().getDataSource()).getUrl();
+    properties.setProperty(DatabaseProperties.PROP_URL, url);
+    properties.setProperty(DatabaseProperties.PROP_USER, "sonar");
+    properties.setProperty(DatabaseProperties.PROP_PASSWORD, "sonar");
 
     underTest
       .configure(new Props(properties))