aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-07-28 10:27:21 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-08-07 11:44:06 +0200
commitd43366ba83a9112bfe1b320640b9afc7d171d6c4 (patch)
tree0cf109a48d6d367314ba44389f7f773b6fb821a0 /sonar-scanner-engine
parentf48a201c2a691281e689b2a4aee9df976a5f3986 (diff)
downloadsonarqube-d43366ba83a9112bfe1b320640b9afc7d171d6c4.tar.gz
sonarqube-d43366ba83a9112bfe1b320640b9afc7d171d6c4.zip
SONAR-9639 Support CE task characteristics
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java4
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java31
2 files changed, 35 insertions, 0 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
index 84eeab591f4..0815ffdf81d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisher.java
@@ -173,6 +173,10 @@ public class ReportPublisher implements Startable {
.setParam("projectBranch", moduleHierarchy.root().getBranch())
.setPart("report", filePart);
+ if (analysisMode.isIncremental()) {
+ post.setParam("characteristic", "incremental=true");
+ }
+
WsResponse response;
try {
response = wsClient.call(post).failIfNotSuccessful();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
index 2a2651e162f..ae65b6d01b7 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/report/ReportPublisherTest.java
@@ -225,5 +225,36 @@ public class ReportPublisherTest {
entry("organization", "MyOrg"),
entry("projectKey", "struts"));
}
+
+ @Test
+ public void test_send_characteristics() throws Exception {
+ ReportPublisher underTest = new ReportPublisher(settings.asConfig(), wsClient, server, contextPublisher, moduleHierarchy, mode, mock(TempFolder.class),
+ new ReportPublisherStep[0]);
+
+ when(mode.isIncremental()).thenReturn(true);
+ settings.setProperty(CoreProperties.PROJECT_ORGANIZATION_PROPERTY, "MyOrg");
+
+ WsResponse response = mock(WsResponse.class);
+
+ PipedOutputStream out = new PipedOutputStream();
+ PipedInputStream in = new PipedInputStream(out);
+ WsCe.SubmitResponse.newBuilder().build().writeTo(out);
+ out.close();
+
+ when(response.failIfNotSuccessful()).thenReturn(response);
+ when(response.contentStream()).thenReturn(in);
+
+ when(wsClient.call(any(WsRequest.class))).thenReturn(response);
+ underTest.upload(temp.newFile());
+
+ ArgumentCaptor<WsRequest> capture = ArgumentCaptor.forClass(WsRequest.class);
+ verify(wsClient).call(capture.capture());
+
+ WsRequest wsRequest = capture.getValue();
+ assertThat(wsRequest.getParams()).containsOnly(
+ entry("organization", "MyOrg"),
+ entry("projectKey", "struts"),
+ entry("characteristic", "incremental=true"));
+ }
}