}
public void runAnalysis(Properties analysisProperties, @Nullable IssueListener issueListener) {
+ checkLauncherExists();
Properties copy = new Properties();
copy.putAll(analysisProperties);
initAnalysisProperties(copy);
}
public void syncProject(String projectKey) {
+ checkLauncherExists();
if (!VersionUtils.isAtLeast52(launcher.getVersion())) {
throw new IllegalStateException("not supported in current SonarQube version: " + launcher.getVersion());
}
}
public void stop() {
+ checkLauncherExists();
doStop();
}
+
+ public String serverVersion() {
+ checkLauncherExists();
+ return launcher.getVersion();
+ }
+
/**
* @deprecated since 2.5 use {@link #start()}, {@link #runAnalysis(Properties)} and then {@link #stop()}
launcher.executeOldVersion(prop);
}
}
+
+ private void checkLauncherExists() {
+ if(launcher == null) {
+ throw new IllegalStateException("not started");
+ }
+ }
static class IssueListenerAdapter implements org.sonar.runner.batch.IssueListener {
private IssueListener apiIssueListener;
}
@Test
- public void test_syncProject() {
+ public void test_sync_project() {
String projectKey = "proj";
runner.start();
runner.syncProject(projectKey);
verify(launcher).syncProject(projectKey);
}
+
+ @Test
+ public void test_server_version() {
+ runner.start();
+ assertThat(runner.serverVersion()).isEqualTo("5.2");
+ }
+
+ @Test
+ public void test_run_before_start() {
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("started");
+
+ runner.runAnalysis(new Properties());
+ }
@Test
- public void test_fail_projectSync_old_sq() {
+ public void test_fail_project_sync_old_sq() {
when(launcher.getVersion()).thenReturn("5.0");
expectedException.expect(IllegalStateException.class);
public void executeOldVersion(Properties properties) {
createBatch(properties, null).execute();
}
-
+
@Override
public String getVersion() {
InputStream is = this.getClass().getClassLoader().getResourceAsStream("sq-version.txt");