Skip to content

Commit 81104ba

Browse files
committed
Fix tests
1 parent e211854 commit 81104ba

File tree

10 files changed

+44
-77
lines changed

10 files changed

+44
-77
lines changed

api/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@
4242

4343
<!-- unit tests -->
4444
<dependency>
45-
<groupId>junit</groupId>
46-
<artifactId>junit</artifactId>
45+
<groupId>org.junit.jupiter</groupId>
46+
<artifactId>junit-jupiter-engine</artifactId>
4747
<scope>test</scope>
4848
</dependency>
4949
<dependency>
50-
<groupId>org.mockito</groupId>
51-
<artifactId>mockito-core</artifactId>
50+
<groupId>org.junit.vintage</groupId>
51+
<artifactId>junit-vintage-engine</artifactId>
5252
<scope>test</scope>
5353
</dependency>
5454
<dependency>
5555
<groupId>org.mockito</groupId>
56-
<artifactId>mockito-inline</artifactId>
56+
<artifactId>mockito-core</artifactId>
5757
<scope>test</scope>
5858
</dependency>
5959
<dependency>

api/src/test/java/org/sonarsource/scanner/api/internal/IsolatedClassloaderTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,6 @@ public void add_jars() throws MalformedURLException {
7373
assertThat(classLoader.getURLs()).contains(f.toURI().toURL());
7474
}
7575

76-
@Test
77-
public void error_add_jars() throws MalformedURLException {
78-
File f = mock(File.class);
79-
URI uri = mock(URI.class);
80-
when(f.toURI()).thenReturn(uri);
81-
when(uri.toURL()).thenThrow(MalformedURLException.class);
82-
File[] files = {f};
83-
84-
thrown.expect(IllegalStateException.class);
85-
thrown.expectMessage("Fail to create classloader");
86-
87-
classLoader.addFiles(Arrays.asList(files));
88-
}
89-
9076
@Test
9177
public void dont_get_resource_from_parent() {
9278
URL resource2 = classLoader.getParent().getResource("fake.jar");

batch/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,13 @@
4141
</exclusions>
4242
</dependency>
4343
<dependency>
44-
<groupId>junit</groupId>
45-
<artifactId>junit</artifactId>
44+
<groupId>org.junit.jupiter</groupId>
45+
<artifactId>junit-jupiter-engine</artifactId>
46+
<scope>test</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.junit.vintage</groupId>
50+
<artifactId>junit-vintage-engine</artifactId>
4651
<scope>test</scope>
4752
</dependency>
4853
<dependency>

its/it-tests/pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<description>Integration tests</description>
1212

1313
<properties>
14-
<jetty.version>9.4.41.v20210516</jetty.version>
15-
<logback.version>1.2.9</logback.version>
14+
<jetty.version>10.0.25</jetty.version>
15+
<logback.version>1.3.15</logback.version>
1616
<sonar.skip>true</sonar.skip>
1717
<skipTests>true</skipTests>
1818
</properties>
@@ -26,8 +26,8 @@
2626

2727
<dependency>
2828
<groupId>org.sonarsource.orchestrator</groupId>
29-
<artifactId>sonar-orchestrator</artifactId>
30-
<version>3.40.0.183</version>
29+
<artifactId>sonar-orchestrator-junit4</artifactId>
30+
<version>5.1.0.2254</version>
3131
<scope>test</scope>
3232
<exclusions>
3333
<exclusion>

its/it-tests/src/test/java/com/sonar/scanner/api/it/PropertiesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
package com.sonar.scanner.api.it;
1818

19-
import com.sonar.orchestrator.Orchestrator;
2019
import com.sonar.orchestrator.build.BuildResult;
20+
import com.sonar.orchestrator.junit4.OrchestratorRule;
2121
import com.sonar.scanner.api.it.tools.SimpleScanner;
2222
import java.io.IOException;
2323
import java.nio.file.Files;
@@ -32,7 +32,7 @@
3232

3333
public class PropertiesTest {
3434
@ClassRule
35-
public static final Orchestrator ORCHESTRATOR = ScannerApiTestSuite.ORCHESTRATOR;
35+
public static final OrchestratorRule ORCHESTRATOR = ScannerApiTestSuite.ORCHESTRATOR;
3636

3737
@Test
3838
public void testRuntimeEnvironmentPassedAsUserAgent() throws IOException {

its/it-tests/src/test/java/com/sonar/scanner/api/it/ProxyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
package com.sonar.scanner.api.it;
1818

19-
import com.sonar.orchestrator.Orchestrator;
2019
import com.sonar.orchestrator.build.BuildResult;
20+
import com.sonar.orchestrator.junit4.OrchestratorRule;
2121
import com.sonar.orchestrator.util.NetworkUtils;
2222
import com.sonar.scanner.api.it.tools.ProxyAuthenticator;
2323
import com.sonar.scanner.api.it.tools.SimpleScanner;
@@ -65,7 +65,7 @@ public class ProxyTest {
6565
private static int httpProxyPort;
6666

6767
@ClassRule
68-
public static final Orchestrator ORCHESTRATOR = ScannerApiTestSuite.ORCHESTRATOR;
68+
public static final OrchestratorRule ORCHESTRATOR = ScannerApiTestSuite.ORCHESTRATOR;
6969

7070
private static ConcurrentLinkedDeque<String> seenByProxy = new ConcurrentLinkedDeque<>();
7171

its/it-tests/src/test/java/com/sonar/scanner/api/it/SSLTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
package com.sonar.scanner.api.it;
1818

19-
import com.sonar.orchestrator.Orchestrator;
2019
import com.sonar.orchestrator.build.BuildResult;
20+
import com.sonar.orchestrator.junit4.OrchestratorRule;
2121
import com.sonar.orchestrator.util.NetworkUtils;
2222
import com.sonar.scanner.api.it.tools.SimpleScanner;
2323
import java.net.InetAddress;
@@ -70,7 +70,7 @@ public class SSLTest {
7070
private static int httpsPort;
7171

7272
@ClassRule
73-
public static final Orchestrator ORCHESTRATOR = ScannerApiTestSuite.ORCHESTRATOR;
73+
public static final OrchestratorRule ORCHESTRATOR = ScannerApiTestSuite.ORCHESTRATOR;
7474

7575
@Before
7676
public void deleteData() {

its/it-tests/src/test/java/com/sonar/scanner/api/it/ScannerApiTestSuite.java

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
*/
1717
package com.sonar.scanner.api.it;
1818

19-
import com.sonar.orchestrator.Orchestrator;
19+
import com.sonar.orchestrator.container.Edition;
2020
import com.sonar.orchestrator.http.HttpMethod;
21-
import com.sonar.orchestrator.locator.MavenLocation;
21+
import com.sonar.orchestrator.junit4.OrchestratorRule;
2222
import java.time.Instant;
2323
import java.time.ZoneId;
2424
import java.time.format.DateTimeFormatter;
25-
import org.apache.commons.lang.StringUtils;
2625
import org.junit.ClassRule;
2726
import org.junit.runner.RunWith;
2827
import org.junit.runners.Suite;
@@ -35,23 +34,21 @@
3534
public class ScannerApiTestSuite {
3635
private static final String SONAR_RUNTIME_VERSION = "sonar.runtimeVersion";
3736

37+
public static final String LATEST_RELEASE = "LATEST_RELEASE";
3838
@ClassRule
39-
public static final Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
40-
.setSonarVersion(getSystemPropertyOrFail(SONAR_RUNTIME_VERSION))
39+
public static final OrchestratorRule ORCHESTRATOR = OrchestratorRule.builderEnv()
40+
.setSonarVersion(getServerVersion())
41+
.setEdition(getServerVersion().equals(LATEST_RELEASE) ? Edition.COMMUNITY : Edition.DEVELOPER)
4142
.useDefaultAdminCredentialsForBuilds(true)
42-
// The scanner api should still be compatible with 7.9
43-
.addPlugin(MavenLocation.of("org.sonarsource.javascript", "sonar-javascript-plugin", "7.0.1.14561"))
43+
.defaultForceAuthentication()
44+
.addBundledPluginToKeep("sonar-javascript")
4445
.build();
4546

46-
private static String getSystemPropertyOrFail(String orchestratorPropertiesSource) {
47-
String propertyValue = System.getProperty(orchestratorPropertiesSource);
48-
if (StringUtils.isEmpty(propertyValue)) {
49-
fail(orchestratorPropertiesSource + " system property must be defined");
50-
}
51-
return propertyValue;
47+
private static String getServerVersion() {
48+
return System.getProperty(SONAR_RUNTIME_VERSION, LATEST_RELEASE);
5249
}
5350

54-
public static void resetData(Orchestrator orchestrator) {
51+
public static void resetData(OrchestratorRule orchestrator) {
5552
Instant instant = Instant.now();
5653

5754
// The expected format is yyyy-MM-dd.

its/it-tests/src/test/java/com/sonar/scanner/api/it/tools/ProxyAuthenticator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import java.io.IOException;
3838
import java.nio.charset.StandardCharsets;
39+
import java.util.Base64;
3940
import javax.servlet.ServletRequest;
4041
import javax.servlet.ServletResponse;
4142
import javax.servlet.http.HttpServletRequest;
@@ -49,7 +50,6 @@
4950
import org.eclipse.jetty.server.Authentication;
5051
import org.eclipse.jetty.server.Authentication.User;
5152
import org.eclipse.jetty.server.UserIdentity;
52-
import org.eclipse.jetty.util.B64Code;
5353
import org.eclipse.jetty.util.security.Constraint;
5454

5555
/**
@@ -89,7 +89,7 @@ public Authentication validateRequest(ServletRequest req, ServletResponse res, b
8989
String method = credentials.substring(0, space);
9090
if ("basic".equalsIgnoreCase(method)) {
9191
credentials = credentials.substring(space + 1);
92-
credentials = B64Code.decode(credentials, StandardCharsets.ISO_8859_1);
92+
credentials = new String(Base64.getDecoder().decode(credentials), StandardCharsets.ISO_8859_1);
9393
int i = credentials.indexOf(':');
9494
if (i > 0) {
9595
String username = credentials.substring(0, i);

pom.xml

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,27 @@
9494
<artifactId>jsr305</artifactId>
9595
<version>3.0.2</version>
9696
</dependency>
97-
<dependency>
98-
<groupId>junit</groupId>
99-
<artifactId>junit</artifactId>
100-
<version>4.13.1</version>
101-
</dependency>
97+
<dependency>
98+
<groupId>org.junit</groupId>
99+
<artifactId>junit-bom</artifactId>
100+
<version>5.11.3</version>
101+
<type>pom</type>
102+
<scope>import</scope>
103+
</dependency>
102104
<dependency>
103105
<groupId>org.mockito</groupId>
104106
<artifactId>mockito-core</artifactId>
105107
<version>${mockito.version}</version>
106108
</dependency>
107109
<dependency>
108110
<groupId>org.mockito</groupId>
109-
<artifactId>mockito-inline</artifactId>
111+
<artifactId>mockito-junit-jupiter</artifactId>
110112
<version>${mockito.version}</version>
111113
</dependency>
112114
<dependency>
113115
<groupId>org.assertj</groupId>
114116
<artifactId>assertj-core</artifactId>
115-
<version>3.11.1</version>
117+
<version>3.26.3</version>
116118
</dependency>
117119
<dependency>
118120
<groupId>commons-codec</groupId>
@@ -123,29 +125,6 @@
123125
</dependencyManagement>
124126

125127
<profiles>
126-
<profile>
127-
<id>release</id>
128-
<build>
129-
<plugins>
130-
<plugin>
131-
<groupId>org.apache.maven.plugins</groupId>
132-
<artifactId>maven-javadoc-plugin</artifactId>
133-
<version>3.1.0</version>
134-
<configuration>
135-
<source>8</source>
136-
</configuration>
137-
<executions>
138-
<execution>
139-
<id>attach-javadocs</id>
140-
<goals>
141-
<goal>jar</goal>
142-
</goals>
143-
</execution>
144-
</executions>
145-
</plugin>
146-
</plugins>
147-
</build>
148-
</profile>
149128
<profile>
150129
<id>its</id>
151130
<modules>

0 commit comments

Comments
 (0)