aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src/test/java/org/sonarqube/ws/client
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-02-26 12:06:31 -0600
committersonartech <sonartech@sonarsource.com>2021-03-03 20:12:50 +0000
commita3ab233a6c989f6bea8eab0f859282bb4246970f (patch)
treef5a7ca25a868712295cf1f348c88772ede90d648 /sonar-ws/src/test/java/org/sonarqube/ws/client
parent9ac1ecab6661c86069e5e63e8cb31a885022e91a (diff)
downloadsonarqube-a3ab233a6c989f6bea8eab0f859282bb4246970f.tar.gz
sonarqube-a3ab233a6c989f6bea8eab0f859282bb4246970f.zip
SONAR-14527 Use 30s write timeout when submitting scanner report
Diffstat (limited to 'sonar-ws/src/test/java/org/sonarqube/ws/client')
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/BaseRequestTest.java7
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java10
2 files changed, 17 insertions, 0 deletions
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseRequestTest.java
index 5e1a0f99d6a..01cf250ef94 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseRequestTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/BaseRequestTest.java
@@ -45,6 +45,13 @@ public class BaseRequestTest {
assertThat(underTest.getParams()).isEmpty();
assertThat(underTest.getMediaType()).isEqualTo(MediaTypes.JSON);
assertThat(underTest.getPath()).isEqualTo("api/foo");
+ assertThat(underTest.getWriteTimeOutInMs()).isEmpty();
+ }
+
+ @Test
+ public void set_write_timeout() {
+ underTest.setWriteTimeOutInMs(30_000);
+ assertThat(underTest.getWriteTimeOutInMs()).hasValue(30_000);
}
@Test
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java
index 97f6f9b2ad1..b95f9a8afb5 100644
--- a/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java
@@ -30,6 +30,7 @@ import java.util.Random;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLSocketFactory;
import okhttp3.ConnectionSpec;
+import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
import okhttp3.mockwebserver.RecordedRequest;
@@ -290,6 +291,15 @@ public class HttpConnectorTest {
}
@Test
+ public void override_timeouts_with_request() {
+ OkHttpClient client = new OkHttpClient.Builder().build();
+ WsRequest request = new PostRequest("abc").setWriteTimeOutInMs(123).setTimeOutInMs(234);
+ client = underTest.prepareOkHttpClient(client, request);
+ assertThat(client.writeTimeoutMillis()).isEqualTo(123);
+ assertThat(client.readTimeoutMillis()).isEqualTo(234);
+ }
+
+ @Test
public void send_user_agent() throws Exception {
answerHelloWorld();
underTest = HttpConnector.newBuilder()