From d871b268b3bf17bc4d08a5dec753dd78238180a3 Mon Sep 17 00:00:00 2001 From: Sébastien Lesaint Date: Wed, 14 Aug 2019 16:50:27 +0200 Subject: drop usage of dependency to sonar-webserver-api test jar --- server/sonar-webserver-api/build.gradle | 15 ------- .../org/sonar/server/branch/BranchFeatureRule.java | 46 --------------------- .../server/health/TestStandaloneHealthChecker.java | 39 ------------------ .../setting/TestProjectConfigurationLoader.java | 45 --------------------- .../sonar/server/util/TypeValidationsTesting.java | 40 ------------------ server/sonar-webserver-core/build.gradle | 1 - .../server/health/TestStandaloneHealthChecker.java | 39 ++++++++++++++++++ server/sonar-webserver-webapi/build.gradle | 1 - .../setting/TestProjectConfigurationLoader.java | 45 +++++++++++++++++++++ .../org/sonar/server/ui/ws/BranchFeatureRule.java | 47 ++++++++++++++++++++++ .../org/sonar/server/ui/ws/GlobalActionTest.java | 1 - .../sonar/server/util/TypeValidationsTesting.java | 40 ++++++++++++++++++ server/sonar-webserver/build.gradle | 1 - 13 files changed, 171 insertions(+), 189 deletions(-) delete mode 100644 server/sonar-webserver-api/src/test/java/org/sonar/server/branch/BranchFeatureRule.java delete mode 100644 server/sonar-webserver-api/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java delete mode 100644 server/sonar-webserver-api/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java delete mode 100644 server/sonar-webserver-api/src/test/java/org/sonar/server/util/TypeValidationsTesting.java create mode 100644 server/sonar-webserver-core/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java create mode 100644 server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java create mode 100644 server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/BranchFeatureRule.java create mode 100644 server/sonar-webserver-webapi/src/test/java/org/sonar/server/util/TypeValidationsTesting.java diff --git a/server/sonar-webserver-api/build.gradle b/server/sonar-webserver-api/build.gradle index 53fe4368afa..62d2bd8c42f 100644 --- a/server/sonar-webserver-api/build.gradle +++ b/server/sonar-webserver-api/build.gradle @@ -14,12 +14,6 @@ sourceSets { } } -configurations { - tests - - testCompile.extendsFrom tests -} - dependencies { // please keep the list grouped by configuration and ordered by name @@ -46,12 +40,3 @@ dependencies { testCompile project(path: ":server:sonar-server-common", configuration: "tests") testCompile project(':sonar-testing-harness') } - -task testJar(type: Jar) { - classifier = 'tests' - from sourceSets.test.output -} - -artifacts { - tests testJar -} diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/branch/BranchFeatureRule.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/branch/BranchFeatureRule.java deleted file mode 100644 index 2bf56463474..00000000000 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/branch/BranchFeatureRule.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info 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.server.branch; - -import org.junit.rules.ExternalResource; - -public class BranchFeatureRule extends ExternalResource implements BranchFeatureProxy { - - private boolean enabled; - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - @Override - protected void after() { - reset(); - } - - public void reset() { - this.enabled = false; - } - - @Override - public boolean isEnabled() { - return enabled; - } - -} diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java deleted file mode 100644 index 27c2e469dde..00000000000 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info 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.server.health; - -public class TestStandaloneHealthChecker implements HealthChecker { - - private Health health = Health.newHealthCheckBuilder().setStatus(Health.Status.GREEN).build(); - - public void setHealth(Health h) { - this.health = h; - } - - @Override - public Health checkNode() { - return health; - } - - @Override - public ClusterHealth checkCluster() { - throw new IllegalStateException(); - } -} diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java deleted file mode 100644 index e0c0b6d2854..00000000000 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info 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.server.setting; - -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import org.sonar.api.config.Configuration; -import org.sonar.db.DbSession; -import org.sonar.db.component.ComponentDto; - -public class TestProjectConfigurationLoader implements ProjectConfigurationLoader { - - private final Configuration config; - - public TestProjectConfigurationLoader(Configuration config) { - this.config = config; - } - - @Override - public Map loadProjectConfigurations(DbSession dbSession, Set projects) { - Map map = new HashMap<>(); - for (ComponentDto project : projects) { - map.put(project.uuid(), config); - } - return map; - } -} diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/util/TypeValidationsTesting.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/util/TypeValidationsTesting.java deleted file mode 100644 index b237ba62aab..00000000000 --- a/server/sonar-webserver-api/src/test/java/org/sonar/server/util/TypeValidationsTesting.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2019 SonarSource SA - * mailto:info 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.server.util; - -import java.util.Arrays; - -public class TypeValidationsTesting { - private TypeValidationsTesting() { - // utility class - } - - public static TypeValidations newFullTypeValidations() { - return new TypeValidations(Arrays.asList( - new BooleanTypeValidation(), - new IntegerTypeValidation(), - new LongTypeValidation(), - new FloatTypeValidation(), - new StringTypeValidation(), - new StringListTypeValidation(), - new MetricLevelTypeValidation() - )); - } -} diff --git a/server/sonar-webserver-core/build.gradle b/server/sonar-webserver-core/build.gradle index 0993d28c0f6..9e1d57fa1d7 100644 --- a/server/sonar-webserver-core/build.gradle +++ b/server/sonar-webserver-core/build.gradle @@ -73,7 +73,6 @@ dependencies { testCompile 'org.subethamail:subethasmtp' testCompile project(':server:sonar-db-testing') testCompile project(path: ":server:sonar-server-common", configuration: "tests") - testCompile project(path: ":server:sonar-webserver-api", configuration: "tests") testCompile project(path: ":server:sonar-webserver-auth", configuration: "tests") testCompile project(path: ":server:sonar-webserver-es", configuration: "tests") testCompile project(path: ":server:sonar-webserver-ws", configuration: "tests") diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java new file mode 100644 index 00000000000..27c2e469dde --- /dev/null +++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/health/TestStandaloneHealthChecker.java @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info 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.server.health; + +public class TestStandaloneHealthChecker implements HealthChecker { + + private Health health = Health.newHealthCheckBuilder().setStatus(Health.Status.GREEN).build(); + + public void setHealth(Health h) { + this.health = h; + } + + @Override + public Health checkNode() { + return health; + } + + @Override + public ClusterHealth checkCluster() { + throw new IllegalStateException(); + } +} diff --git a/server/sonar-webserver-webapi/build.gradle b/server/sonar-webserver-webapi/build.gradle index b2a02fd039d..b1428c97c94 100644 --- a/server/sonar-webserver-webapi/build.gradle +++ b/server/sonar-webserver-webapi/build.gradle @@ -35,7 +35,6 @@ dependencies { testCompile 'org.mockito:mockito-core' testCompile project(':server:sonar-db-testing') testCompile project(path: ":server:sonar-server-common", configuration: "tests") - testCompile project(path: ":server:sonar-webserver-api", configuration: "tests") testCompile project(path: ":server:sonar-webserver-auth", configuration: "tests") testCompile project(path: ":server:sonar-webserver-es", configuration: "tests") testCompile project(path: ":server:sonar-webserver-ws", configuration: "tests") diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java new file mode 100644 index 00000000000..e0c0b6d2854 --- /dev/null +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/TestProjectConfigurationLoader.java @@ -0,0 +1,45 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info 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.server.setting; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import org.sonar.api.config.Configuration; +import org.sonar.db.DbSession; +import org.sonar.db.component.ComponentDto; + +public class TestProjectConfigurationLoader implements ProjectConfigurationLoader { + + private final Configuration config; + + public TestProjectConfigurationLoader(Configuration config) { + this.config = config; + } + + @Override + public Map loadProjectConfigurations(DbSession dbSession, Set projects) { + Map map = new HashMap<>(); + for (ComponentDto project : projects) { + map.put(project.uuid(), config); + } + return map; + } +} diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/BranchFeatureRule.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/BranchFeatureRule.java new file mode 100644 index 00000000000..bd185e46b5d --- /dev/null +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/BranchFeatureRule.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info 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.server.ui.ws; + +import org.junit.rules.ExternalResource; +import org.sonar.server.branch.BranchFeatureProxy; + +public class BranchFeatureRule extends ExternalResource implements BranchFeatureProxy { + + private boolean enabled; + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + @Override + protected void after() { + reset(); + } + + public void reset() { + this.enabled = false; + } + + @Override + public boolean isEnabled() { + return enabled; + } + +} diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java index 1a20d2e87fe..0d4a2a29cd2 100644 --- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/ui/ws/GlobalActionTest.java @@ -37,7 +37,6 @@ import org.sonar.core.platform.PluginRepository; import org.sonar.db.DbClient; import org.sonar.db.dialect.H2; import org.sonar.db.dialect.PostgreSql; -import org.sonar.server.branch.BranchFeatureRule; import org.sonar.server.organization.DefaultOrganizationProvider; import org.sonar.server.organization.TestDefaultOrganizationProvider; import org.sonar.server.organization.TestOrganizationFlags; diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/util/TypeValidationsTesting.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/util/TypeValidationsTesting.java new file mode 100644 index 00000000000..b237ba62aab --- /dev/null +++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/util/TypeValidationsTesting.java @@ -0,0 +1,40 @@ +/* + * SonarQube + * Copyright (C) 2009-2019 SonarSource SA + * mailto:info 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.server.util; + +import java.util.Arrays; + +public class TypeValidationsTesting { + private TypeValidationsTesting() { + // utility class + } + + public static TypeValidations newFullTypeValidations() { + return new TypeValidations(Arrays.asList( + new BooleanTypeValidation(), + new IntegerTypeValidation(), + new LongTypeValidation(), + new FloatTypeValidation(), + new StringTypeValidation(), + new StringListTypeValidation(), + new MetricLevelTypeValidation() + )); + } +} diff --git a/server/sonar-webserver/build.gradle b/server/sonar-webserver/build.gradle index 863fa2769b9..4096c8a8f11 100644 --- a/server/sonar-webserver/build.gradle +++ b/server/sonar-webserver/build.gradle @@ -28,7 +28,6 @@ dependencies { testCompile 'org.eclipse.jetty:jetty-servlet' testCompile project(':server:sonar-db-testing') testCompile project(path: ":server:sonar-server-common", configuration: "tests") - testCompile project(path: ":server:sonar-webserver-api", configuration: "tests") testCompile project(path: ":server:sonar-webserver-auth", configuration: "tests") testCompile project(path: ":server:sonar-webserver-es", configuration: "tests") testCompile project(':sonar-testing-harness') -- cgit v1.2.3