aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-runner-api/src/test
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-12 08:33:30 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2015-08-12 13:46:58 +0200
commit43acac9dcbbbcb5a74bd13218d422e01487c5521 (patch)
tree46123883920973f203fdcf65acc1922e22e667b6 /sonar-runner-api/src/test
parent957ee8dda99b4ad469bc08250aab65a77863dc97 (diff)
downloadsonar-scanner-cli-43acac9dcbbbcb5a74bd13218d422e01487c5521.tar.gz
sonar-scanner-cli-43acac9dcbbbcb5a74bd13218d422e01487c5521.zip
SONARUNNER-145 Expose cache sync API
Diffstat (limited to 'sonar-runner-api/src/test')
-rw-r--r--sonar-runner-api/src/test/java/org/sonar/runner/api/EmbeddedRunnerTest.java26
-rw-r--r--sonar-runner-api/src/test/java/org/sonar/runner/impl/IsolatedLauncherFactoryTest.java6
-rw-r--r--sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java3
3 files changed, 31 insertions, 4 deletions
diff --git a/sonar-runner-api/src/test/java/org/sonar/runner/api/EmbeddedRunnerTest.java b/sonar-runner-api/src/test/java/org/sonar/runner/api/EmbeddedRunnerTest.java
index ea1e658..a1ffdce 100644
--- a/sonar-runner-api/src/test/java/org/sonar/runner/api/EmbeddedRunnerTest.java
+++ b/sonar-runner-api/src/test/java/org/sonar/runner/api/EmbeddedRunnerTest.java
@@ -19,9 +19,10 @@
*/
package org.sonar.runner.api;
+import org.junit.rules.ExpectedException;
+
import org.sonar.runner.api.EmbeddedRunner.IssueListenerAdapter;
-import java.awt.geom.IllegalPathStateException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -50,6 +51,9 @@ public class EmbeddedRunnerTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
@Test
public void should_create() {
assertThat(EmbeddedRunner.create(mock(LogOutput.class))).isNotNull().isInstanceOf(EmbeddedRunner.class);
@@ -69,6 +73,26 @@ public class EmbeddedRunnerTest {
}
@Test
+ public void test_syncProject() {
+ String projectKey = "proj";
+ runner.start();
+ runner.syncProject(projectKey);
+ verify(launcher).syncProject(projectKey);
+ }
+
+ @Test
+ public void test_fail_projectSync_old_sq() {
+ when(launcher.getVersion()).thenReturn("5.0");
+
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("version");
+
+ runner.setGlobalProperty("sonar.projectKey", "foo");
+ runner.start();
+ runner.syncProject("foo");
+ }
+
+ @Test
public void test_app() {
EmbeddedRunner runner = EmbeddedRunner.create(mock(LogOutput.class)).setApp("Eclipse", "3.1");
assertThat(runner.app()).isEqualTo("Eclipse");
diff --git a/sonar-runner-api/src/test/java/org/sonar/runner/impl/IsolatedLauncherFactoryTest.java b/sonar-runner-api/src/test/java/org/sonar/runner/impl/IsolatedLauncherFactoryTest.java
index 957d840..661bee7 100644
--- a/sonar-runner-api/src/test/java/org/sonar/runner/impl/IsolatedLauncherFactoryTest.java
+++ b/sonar-runner-api/src/test/java/org/sonar/runner/impl/IsolatedLauncherFactoryTest.java
@@ -60,7 +60,7 @@ public class IsolatedLauncherFactoryTest {
public static IssueListener listener = null;
@Override
- public void start(Properties properties, LogOutput logger) {
+ public void start(Properties properties, LogOutput logger, boolean forceSync) {
}
@Override
@@ -86,5 +86,9 @@ public class IsolatedLauncherFactoryTest {
FakeIsolatedLauncher.props = properties;
FakeIsolatedLauncher.listener = listener;
}
+
+ @Override
+ public void syncProject(String projectKey) {
+ }
}
}
diff --git a/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java b/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java
index 4a147f6..4698576 100644
--- a/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java
+++ b/sonar-runner-api/src/test/java/org/sonar/runner/impl/ServerConnectionTest.java
@@ -86,8 +86,7 @@ public class ServerConnectionTest {
httpServer.setMockResponseData("abcde");
Properties props = new Properties();
props.setProperty("sonar.host.url", httpServer.url() + "/");
- props.setProperty("sonar.analysis.mode", "quick");
- props.setProperty("sonar.enableOffline", "true");
+ props.setProperty("sonar.analysis.mode", "issues");
assertThat(cacheDir.list().length).isEqualTo(0);
ServerConnection connection = ServerConnection.create(props, cache, mock(Logger.class));