import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.util.Properties;
+import java.util.concurrent.TimeUnit;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
.url(httpUrl)
.get()
.build();
- Response response = new OkHttpClient().newCall(request).execute();
+ Response response = new OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)
+ .readTimeout(30, TimeUnit.SECONDS)
+ .build()
+ .newCall(request)
+ .execute();
assertThat(response.isSuccessful()).as(httpUrl.toString()).isTrue();
assertThat(response.body().string()).as(httpUrl.toString()).isNotEmpty();
}
import com.sonar.orchestrator.Orchestrator;
import it.Category4Suite;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
import okhttp3.CacheControl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
private static Response call(String url) {
Request request = new Request.Builder().get().url(url).build();
try {
- return new OkHttpClient().newCall(request).execute();
+ // SonarQube ws-client cannot be used as it does not
+ // expose HTTP headers
+ return new OkHttpClient.Builder()
+ .connectTimeout(30, TimeUnit.SECONDS)
+ .readTimeout(30, TimeUnit.SECONDS)
+ .build()
+ .newCall(request).execute();
} catch (IOException e) {
throw Throwables.propagate(e);
}