<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>
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;
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;
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;
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[] {
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;
.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();
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;
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
+ @Rule
+ public DbTester dbTester = DbTester.create(System2.INSTANCE);
private ComputeEngineContainerImpl underTest = new ComputeEngineContainerImpl();
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
);
}
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))