]> source.dussan.org Git - sonarqube.git/commitdiff
Remove useless CeDbClient
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 25 Apr 2016 11:58:51 +0000 (13:58 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 25 Apr 2016 11:58:51 +0000 (13:58 +0200)
It's useless that DbClient return a ReadOnlyPropertiesDao, and it prevent any CE task to update a property

server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-ce/src/main/java/org/sonar/ce/db/CeDbClient.java [deleted file]
server/sonar-ce/src/test/java/org/sonar/ce/db/CeDbClientTest.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/computation/container/ReportComputeEngineContainerPopulator.java

index 12a117288d90e38e07a9b3beafec05c770d415e5..2dcf5dcd9ec0d9780fe74676a4a8532c98b20611 100644 (file)
@@ -35,7 +35,6 @@ import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
 import org.sonar.api.utils.Durations;
 import org.sonar.api.utils.System2;
 import org.sonar.api.utils.UriReader;
-import org.sonar.ce.db.CeDbClient;
 import org.sonar.ce.db.ReadOnlyPropertiesDao;
 import org.sonar.ce.es.EsIndexerEnabler;
 import org.sonar.ce.platform.ComputeEngineExtensionInstaller;
@@ -56,6 +55,7 @@ import org.sonar.core.user.DeprecatedUserFinder;
 import org.sonar.core.util.UuidFactoryImpl;
 import org.sonar.db.DaoModule;
 import org.sonar.db.DatabaseChecker;
+import org.sonar.db.DbClient;
 import org.sonar.db.DefaultDatabase;
 import org.sonar.db.permission.PermissionRepository;
 import org.sonar.db.purge.PurgeProfiler;
@@ -159,7 +159,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
     DaoModule.class,
     // DbClient.class, replaced by CeDbClient to use ReadOnlyPropertiesDao instead of PropertiesDao
     ReadOnlyPropertiesDao.class,
-    CeDbClient.class,
+    DbClient.class,
     // MigrationStepModule.class, DB maintenance, responsibility of Web Server
 
     // Elasticsearch
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/db/CeDbClient.java b/server/sonar-ce/src/main/java/org/sonar/ce/db/CeDbClient.java
deleted file mode 100644 (file)
index 6cf67f8..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.
- */
-package org.sonar.ce.db;
-
-import java.util.Map;
-import org.sonar.db.Dao;
-import org.sonar.db.Database;
-import org.sonar.db.DbClient;
-import org.sonar.db.MyBatis;
-import org.sonar.db.property.PropertiesDao;
-
-public class CeDbClient extends DbClient {
-  private ReadOnlyPropertiesDao readOnlyPropertiesDao;
-
-  public CeDbClient(Database database, MyBatis myBatis, Dao... daos) {
-    super(database, myBatis, daos);
-  }
-
-  @Override
-  protected void doOnLoad(Map<Class, Dao> daoByClass) {
-    this.readOnlyPropertiesDao = getDao(daoByClass, ReadOnlyPropertiesDao.class);
-  }
-
-  @Override
-  public PropertiesDao propertiesDao() {
-    return this.readOnlyPropertiesDao;
-  }
-}
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/db/CeDbClientTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/db/CeDbClientTest.java
deleted file mode 100644 (file)
index 883247a..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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.
- */
-package org.sonar.ce.db;
-
-import org.junit.Test;
-import org.sonar.db.Dao;
-import org.sonar.db.Database;
-import org.sonar.db.DbClient;
-import org.sonar.db.MyBatis;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-
-public class CeDbClientTest {
-  private Database database = mock(Database.class);
-  private MyBatis myBatis = mock(MyBatis.class);
-  private ReadOnlyPropertiesDao readOnlyPropertiesDao = new ReadOnlyPropertiesDao(myBatis);
-
-  private DbClient underTest = new CeDbClient(database, myBatis, (Dao) readOnlyPropertiesDao);
-
-  @Test
-  public void getPropertiesDao_returns_ReadOnlyPropertiesDao() {
-    assertThat(underTest.propertiesDao()).isSameAs(readOnlyPropertiesDao);
-  }
-}
index e571ffd1363b9f43af82c2a84795190213cd090b..e78c44c8e79169e85d567f665be86861b2e1b5a3 100644 (file)
@@ -26,7 +26,6 @@ import org.sonar.ce.queue.CeTask;
 import org.sonar.ce.settings.SettingsLoader;
 import org.sonar.core.issue.tracking.Tracker;
 import org.sonar.core.platform.ContainerPopulator;
-import org.sonar.db.property.PropertiesDao;
 import org.sonar.plugin.ce.ReportAnalysisComponentProvider;
 import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl;
 import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl;
@@ -135,9 +134,6 @@ public final class ReportComputeEngineContainerPopulator implements ContainerPop
 
       MetricModule.class,
 
-      // We need to add PropertiesDao here because otherwise we only have access to ReadOnlyPropertiesDao
-      PropertiesDao.class,
-
       // holders
       AnalysisMetadataHolderImpl.class,
       CrossProjectDuplicationStatusHolderImpl.class,