aboutsummaryrefslogtreecommitdiffstats
path: root/it/src
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2016-04-08 16:44:18 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2016-04-08 16:44:18 +0200
commit7a1c1f3bdff7193e448f3d5746bde3c82a9f6a4d (patch)
tree9e00ec9549e8130e481bca99f71b1700227e7582 /it/src
parent1d4a8d4d14df3d498bb0ea68feee8ec6a2370856 (diff)
downloadsonar-scanner-cli-7a1c1f3bdff7193e448f3d5746bde3c82a9f6a4d.tar.gz
sonar-scanner-cli-7a1c1f3bdff7193e448f3d5746bde3c82a9f6a4d.zip
Fix ITs
Diffstat (limited to 'it/src')
-rw-r--r--it/src/test/java/com/sonar/runner/it/CacheTest.java159
-rw-r--r--it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java2
2 files changed, 1 insertions, 160 deletions
diff --git a/it/src/test/java/com/sonar/runner/it/CacheTest.java b/it/src/test/java/com/sonar/runner/it/CacheTest.java
deleted file mode 100644
index a226521..0000000
--- a/it/src/test/java/com/sonar/runner/it/CacheTest.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * SonarSource :: IT :: SonarQube Scanner
- * 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 com.sonar.runner.it;
-
-import com.sonar.orchestrator.build.BuildFailureException;
-import com.sonar.orchestrator.build.BuildResult;
-import com.sonar.orchestrator.build.SonarRunner;
-import com.sonar.orchestrator.locator.ResourceLocation;
-import java.io.File;
-import java.io.IOException;
-import org.junit.AfterClass;
-import org.junit.Assume;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class CacheTest extends ScannerTestCase {
- @Rule
- public TemporaryFolder temp = new TemporaryFolder();
-
- private File currentTemp = null;
- private static boolean serverRunning = false;
-
- @BeforeClass
- public static void setUpClass() {
- orchestrator.resetData();
- orchestrator.getServer().restoreProfile(ResourceLocation.create("/sonar-way-profile.xml"));
- orchestrator.getServer().provisionProject("java:sample", "Java Sample, with comma");
- orchestrator.getServer().associateProjectToQualityProfile("java:sample", "java", "sonar-way");
- serverRunning = true;
- }
-
- @AfterClass
- public static void restartForOtherTests() {
- ensureStarted();
- }
-
- private static void ensureStarted() {
- if (!serverRunning) {
- orchestrator.start();
- serverRunning = true;
- }
- }
-
- private static void ensureStopped() {
- if (serverRunning) {
- orchestrator.stop();
- serverRunning = false;
- }
- }
-
- @Test
- public void testIssuesMode() throws IOException {
- Assume.assumeTrue(orchestrator.getServer().version().isGreaterThanOrEquals("5.3"));
-
- // online, cache empty -> should sync
- ensureStarted();
- SonarRunner build = createRunner("issues", true, "java-sample");
- BuildResult result = orchestrator.executeBuild(build, false);
- assertThat(result.isSuccess()).isTrue();
-
- // offline, don't use cache by default -> should fail
- ensureStopped();
- build = createRunner("issues", false, "java-sample");
- result = orchestrator.executeBuildQuietly(build, false);
- assertThat(result.isSuccess()).isFalse();
-
- // offline, don't use cache -> should run from cache
- build = createRunner("issues", false, "java-sample");
- build.setProperty("sonar.useWsCache", "true");
- result = orchestrator.executeBuild(build, false);
- assertThat(result.isSuccess()).isTrue();
-
- // offline, cache empty -> should fail
- build = createRunner("issues", true, "java-sample");
- build.setProperty("sonar.useWsCache", "true");
- result = orchestrator.executeBuildQuietly(build, false);
- assertThat(result.isSuccess()).isFalse();
- // this message is specific to the server_first cache strategy
- assertThat(result.getLogs()).contains("can not be reached, trying cache");
- assertThat(result.getLogs()).contains("can not be reached and data is not cached");
- }
-
- @Test
- public void testNonAssociatedMode() throws IOException {
- Assume.assumeTrue(orchestrator.getServer().version().isGreaterThanOrEquals("5.2"));
-
- // online, without cache -> should sync
- ensureStarted();
- SonarRunner build = createRunner("issues", true, "java-sample-non-associated");
- BuildResult result = orchestrator.executeBuild(build, false);
- assertThat(result.isSuccess()).isTrue();
-
- // offline, with cache -> should run from cache
- ensureStopped();
- build = createRunner("issues", false, "java-sample-non-associated");
- build.setProperty("sonar.useWsCache", "true");
- result = orchestrator.executeBuild(build, false);
- assertThat(result.isSuccess()).isTrue();
- }
-
- @Test
- public void testPublishModeOffline() throws IOException {
- Assume.assumeTrue(orchestrator.getServer().version().isGreaterThanOrEquals("5.2"));
-
- // online (cache not used)
- ensureStarted();
- SonarRunner build = createRunner("publish", "java-sample");
- BuildResult result = orchestrator.executeBuild(build, false);
- assertThat(result.isSuccess()).isTrue();
-
- // offline (cache not used) -> should fail
- ensureStopped();
- build = createRunner("publish", false, "java-sample");
- try {
- result = orchestrator.executeBuild(build);
- } catch (BuildFailureException e) {
- assertThat(e.getResult().getLogs()).contains("Fail to download libraries from server");
- }
-
- }
-
- private SonarRunner createRunner(String mode, String project) throws IOException {
- return createRunner(mode, false, project);
- }
-
- private SonarRunner createRunner(String mode, boolean refreshCache, String project) throws IOException {
- if (refreshCache || currentTemp == null) {
- currentTemp = temp.newFolder();
- }
-
- SonarRunner runner = newScanner(new File("projects/" + project))
- .setProperty("sonar.analysis.mode", mode)
- .setProperty("sonar.userHome", currentTemp.getAbsolutePath());
-
- return runner;
- }
-
-}
diff --git a/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java b/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
index 1cb56cc..b835e67 100644
--- a/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
+++ b/it/src/test/java/com/sonar/runner/it/SonarScannerTestSuite.java
@@ -26,7 +26,7 @@ import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
-@SuiteClasses({JavaTest.class, MultimoduleTest.class, CacheTest.class})
+@SuiteClasses({JavaTest.class, MultimoduleTest.class})
public class SonarScannerTestSuite {
@ClassRule