aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorMatteo Mara <matteo.mara@sonarsource.com>2024-10-08 10:31:31 +0200
committersonartech <sonartech@sonarsource.com>2024-10-14 20:03:04 +0000
commit1e315cf59823550446594a03ca13a6b175341d80 (patch)
tree50f00f41249ae09f11f574c5a4e60ecc3f455586 /sonar-ws
parent1ad3667d30dd82213ae47bea2c267188f003b2c7 (diff)
downloadsonarqube-1e315cf59823550446594a03ca13a6b175341d80.tar.gz
sonarqube-1e315cf59823550446594a03ca13a6b175341d80.zip
NO-JIRA Remove new code issues resulting from the update of the deprecated methods.
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/build.gradle31
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/HttpConnectorTest.java18
2 files changed, 31 insertions, 18 deletions
diff --git a/sonar-ws/build.gradle b/sonar-ws/build.gradle
index 4c8f23c9e5d..e33277140ef 100644
--- a/sonar-ws/build.gradle
+++ b/sonar-ws/build.gradle
@@ -21,21 +21,22 @@ dependencies {
compileOnlyApi 'com.github.spotbugs:spotbugs-annotations'
compileOnlyApi 'javax.annotation:javax.annotation-api'
- testImplementation 'com.squareup.okhttp3:mockwebserver'
- testImplementation 'commons-io:commons-io'
- testImplementation 'org.apache.commons:commons-lang3'
- testImplementation 'junit:junit'
- testImplementation 'org.assertj:assertj-core'
- testImplementation 'org.hamcrest:hamcrest'
- testImplementation 'org.mockito:mockito-core'
- testImplementation project(':sonar-testing-harness')
-
- testFixturesApi 'junit:junit'
- testFixturesApi 'com.google.guava:guava'
- testFixturesApi 'org.assertj:assertj-core'
- testFixturesApi 'org.junit.jupiter:junit-jupiter-api'
- testFixturesApi 'org.sonarsource.orchestrator:sonar-orchestrator-junit4'
- testFixturesApi 'commons-io:commons-io'
+ testImplementation 'com.squareup.okhttp3:mockwebserver'
+ testImplementation 'com.tngtech.java:junit-dataprovider'
+ testImplementation 'commons-io:commons-io'
+ testImplementation 'org.apache.commons:commons-lang3'
+ testImplementation 'junit:junit'
+ testImplementation 'org.assertj:assertj-core'
+ testImplementation 'org.hamcrest:hamcrest'
+ testImplementation 'org.mockito:mockito-core'
+ testImplementation project(':sonar-testing-harness')
+
+ testFixturesApi 'junit:junit'
+ testFixturesApi 'com.google.guava:guava'
+ testFixturesApi 'org.assertj:assertj-core'
+ testFixturesApi 'org.junit.jupiter:junit-jupiter-api'
+ testFixturesApi 'org.sonarsource.orchestrator:sonar-orchestrator-junit4'
+ testFixturesApi 'commons-io:commons-io'
}
artifactoryPublish.skip = false
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 411dd9b9bbc..c0320cbde02 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
@@ -19,6 +19,9 @@
*/
package org.sonarqube.ws.client;
+import com.tngtech.java.junit.dataprovider.DataProvider;
+import com.tngtech.java.junit.dataprovider.DataProviderRunner;
+import com.tngtech.java.junit.dataprovider.UseDataProvider;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
@@ -26,7 +29,6 @@ import java.net.Proxy;
import java.net.SocketTimeoutException;
import java.util.Base64;
import java.util.List;
-import java.util.Random;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPOutputStream;
import javax.net.ssl.SSLSocketFactory;
@@ -45,6 +47,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.junit.runner.RunWith;
import org.sonarqube.ws.MediaTypes;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -56,6 +59,7 @@ import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.sonarqube.ws.client.HttpConnector.newBuilder;
+@RunWith(DataProviderRunner.class)
public class HttpConnectorTest {
@Rule
@@ -249,9 +253,9 @@ public class HttpConnectorTest {
}
@Test
- public void systemPassCode_sets_header_when_value_is_not_null() throws InterruptedException {
+ @UseDataProvider("nonNullPasswords")
+ public void systemPassCode_sets_header_when_value_is_not_null(String systemPassCode) throws InterruptedException {
answerHelloWorld();
- String systemPassCode = new Random().nextBoolean() ? "" : RandomStringUtils.secure().nextAlphanumeric(21);
underTest = HttpConnector.newBuilder()
.url(serverUrl)
.systemPassCode(systemPassCode)
@@ -557,6 +561,14 @@ public class HttpConnectorTest {
assertThat(connectionSpecs.get(1).isTls()).isFalse();
}
+ @DataProvider()
+ public static Object[][] nonNullPasswords() {
+ return new Object[][] {
+ {""},
+ {RandomStringUtils.secure().nextAlphanumeric(21)}
+ };
+ }
+
private void answerHelloWorld() {
server.enqueue(new MockResponse().setBody("hello, world!").setHeader("header", "value"));
}