Skip to content

Commit

Permalink
Implemented TouK#130
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkosertic committed Feb 1, 2016
1 parent c7295cf commit 999e843
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ dependencies {
compile 'ch.qos.logback:logback-classic:1.0.13'
compile 'org.projectlombok:lombok:1.12.6'
compile 'commons-cli:commons-cli:1.2'
compile 'org.codehaus.sonar.runner:sonar-runner-api:2.4'
compile 'org.codehaus.sonar-plugins:sonar-issues-report-plugin:1.3'
compile 'org.sonarsource.sonar-runner:sonar-runner-api:2.5.1'
compile 'com.jayway.jsonpath:json-path:0.9.1'

compile 'com.urswolfer.gerrit.client.rest:gerrit-rest-java-client:0.8.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ Properties loadBaseProperties() throws IOException {
public File run() throws IOException {
Properties props = loadBaseProperties();
setAdditionalProperties(props);

sonarEmbeddedRunner.globalProperties().putAll(props);

log.info("Sonar configuration: {}", props.toString());
sonarEmbeddedRunner.addProperties(props);

sonarEmbeddedRunner.execute();
return new File(OUTPUT_DIR, OUTPUT_FILE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import org.sonar.runner.api.EmbeddedRunner;

import org.sonar.runner.api.StdOutLogOutput;
import pl.touk.sputnik.configuration.Configuration;
import pl.touk.sputnik.review.Review;
import pl.touk.sputnik.review.ReviewFile;
Expand All @@ -31,7 +32,7 @@ public SonarRunner prepareRunner(Review review, Configuration configuration) {
for (ReviewFile file : review.getFiles()) {
files.add("**/" + new File(file.getReviewFilename()).getName());
}
SonarRunner sonarRunner = new SonarRunner(files, EmbeddedRunner.create(), configuration);
SonarRunner sonarRunner = new SonarRunner(files, EmbeddedRunner.create(new StdOutLogOutput()), configuration);
return sonarRunner;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.*;

import java.io.File;
import java.io.FileNotFoundException;
Expand All @@ -11,6 +11,7 @@
import java.util.Properties;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -24,9 +25,6 @@

import com.google.common.collect.ImmutableList;

import freemarker.template.utility.StringUtil;


@RunWith(MockitoJUnitRunner.class)
public class SonarRunnerTest {
private static final String PROPERTY_1 = "sonar-property1";
Expand All @@ -40,6 +38,7 @@ public class SonarRunnerTest {
@Before
public void setUp() throws FileNotFoundException {
config = ConfigurationBuilder.initFromResource("test-sonar.properties");
when(sonarRunner.globalProperties()).thenReturn(new Properties());
}

@After
Expand All @@ -59,7 +58,7 @@ public void shouldRun() throws IOException {
List<String> files = ImmutableList.of("file");
SonarRunner runner = new SonarRunner(files, sonarRunner, config);
runner.run();
verify(sonarRunner).addProperties(any(Properties.class));
verify(sonarRunner, times(1)).globalProperties();
verify(sonarRunner).execute();
}

Expand All @@ -82,7 +81,7 @@ public void shouldSetBaseSonarConfig() throws IOException{
runner.setAdditionalProperties(props);
assertThat(props.getProperty(SonarProperties.INCLUDE_FILES)).contains("first");
assertThat(props.getProperty(SonarProperties.INCLUDE_FILES)).contains("second");
assertThat(StringUtil.split(props.getProperty(SonarProperties.INCLUDE_FILES), ',')).hasSize(2);
assertThat(StringUtils.split(props.getProperty(SonarProperties.INCLUDE_FILES), ',')).hasSize(2);
assertThat(props.getProperty(SonarProperties.ANALISYS_MODE)).isEqualTo("incremental");
assertThat(props.getProperty(SonarProperties.SCM_ENABLED)).isEqualTo("false");
assertThat(props.getProperty(SonarProperties.SCM_STAT_ENABLED)).isEqualTo("false");
Expand Down

0 comments on commit 999e843

Please sign in to comment.