*/
package batch;
+import com.sonar.orchestrator.build.BuildFailureException;
+
import util.ItUtils;
import com.google.common.collect.Maps;
import com.sonar.orchestrator.Orchestrator;
import java.util.concurrent.Future;
import static org.junit.Assert.*;
-
import static org.assertj.core.api.Assertions.assertThat;
import org.apache.commons.lang.ObjectUtils;
import org.json.simple.JSONArray;
SonarRunner runner = configureRunnerIssues("shared/xoo-sample");
orchestrator.executeBuild(runner);
}
+
+ @Test
+ public void invalidIncrementalMode() throws IOException {
+ restoreProfile("one-issue-per-line.xml");
+ orchestrator.getServer().provisionProject("sample", "xoo-sample");
+ orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
+ SonarRunner runner = configureRunner("shared/xoo-sample");
+ runner.setProperty("sonar.analysis.mode", "incremental");
+
+ thrown.expect(BuildFailureException.class);
+ BuildResult res = orchestrator.executeBuild(runner);
+
+ assertThat(res.getLogs()).contains("Invalid analysis mode: incremental. This mode was removed in SonarQube 5.2");
+ }
// SONAR-5715
@Test
package org.sonar.batch.bootstrap;
import org.sonar.batch.cache.WSLoaderResult;
-
import org.sonar.batch.cache.WSLoader;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Lists;
File download(final RemotePlugin remote) {
try {
final RemotePluginFile file = remote.file();
- return fileCache.get(file.getFilename(), file.getHash(), new FileCache.Downloader() {
- @Override
- public void download(String filename, File toFile) throws IOException {
- String url = "/deploy/plugins/" + remote.getKey() + "/" + file.getFilename();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Download {} to {}", url, toFile.getAbsolutePath());
- } else {
- LOG.info("Download {}", file.getFilename());
- }
-
- serverClient.download(url, toFile);
- }
- });
-
+ return fileCache.get(file.getFilename(), file.getHash(), new FileDownloader(remote.getKey()));
} catch (Exception e) {
throw new IllegalStateException("Fail to download plugin: " + remote.getKey(), e);
}
private String loadPluginIndex() {
Profiler profiler = Profiler.create(LOG).startInfo("Load plugins index");
WSLoaderResult<String> wsResult = wsLoader.loadString(PLUGINS_INDEX_URL);
+ profiler.stopInfo(wsResult.isFromCache());
+ return wsResult.get();
+ }
+
+ private class FileDownloader implements FileCache.Downloader {
+ private String key;
- if (wsResult.isFromCache()) {
- profiler.stopInfo("Load plugins index (done from cache)");
- } else {
- profiler.stopInfo();
+ FileDownloader(String key) {
+ this.key = key;
}
- return wsResult.get();
- }
+ @Override
+ public void download(String filename, File toFile) throws IOException {
+ String url = "/deploy/plugins/" + key + "/" + filename;
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Download {} to {}", url, toFile.getAbsolutePath());
+ } else {
+ LOG.info("Download {}", filename);
+ }
+ serverClient.download(url, toFile);
+ }
+ }
}
public void listRemotePlugins() {
WSLoader wsLoader = mock(WSLoader.class);
- when(wsLoader.load("/deploy/plugins/index.txt")).thenReturn(new WSLoaderResult<byte[]>("checkstyle\nsqale".getBytes(), true));
when(wsLoader.loadString("/deploy/plugins/index.txt")).thenReturn(new WSLoaderResult<String>("checkstyle\nsqale", true));
BatchPluginInstaller installer = new BatchPluginInstaller(wsLoader, serverClient, fileCache, pluginPredicate);