Skip to content

Commit ce0dc36

Browse files
committed
Migrate from JUnit 4 to JUnit 5
1 parent dbee5ba commit ce0dc36

File tree

63 files changed

+1068
-981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1068
-981
lines changed

pom.xml

Lines changed: 62 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
35

46
<modelVersion>4.0.0</modelVersion>
57
<groupId>org.gitlab4j</groupId>
@@ -50,13 +52,14 @@
5052
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5153
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
5254

53-
<jersey.version>2.30.1</jersey.version>
54-
<jackson.version>2.10.3</jackson.version>
55-
<servlet.version>4.0.3</servlet.version>
55+
<jersey.version>2.34</jersey.version>
56+
<jackson.version>2.12.4</jackson.version>
57+
<servlet.version>4.0.4</servlet.version>
5658
<activation.version>1.2.2</activation.version>
5759

58-
<junit.version>5.6.0</junit.version>
59-
<mockito.version>3.3.0</mockito.version>
60+
<junit.version>5.7.2</junit.version>
61+
<testcontainers.version>1.15.3</testcontainers.version>
62+
<mockito.version>3.12.0</mockito.version>
6063
<hamcrest.version>1.3</hamcrest.version>
6164
<systemRules.version>1.19.0</systemRules.version>
6265

@@ -67,7 +70,7 @@
6770
<gitlab.autoremove-container>true</gitlab.autoremove-container>
6871
<gitlab.skip-docker-start>true</gitlab.skip-docker-start>
6972
<gitlab.port>8090</gitlab.port>
70-
73+
7174
<sonar.projectKey>gitlab4j_gitlab4j-api</sonar.projectKey>
7275
<sonar.organization>gitlab4j</sonar.organization>
7376
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
@@ -121,15 +124,15 @@
121124
</plugin>
122125

123126
<plugin>
124-
<groupId>biz.aQute.bnd</groupId>
125-
<artifactId>bnd-maven-plugin</artifactId>
126-
<executions>
127-
<execution>
128-
<goals>
129-
<goal>bnd-process</goal>
130-
</goals>
131-
</execution>
132-
</executions>
127+
<groupId>biz.aQute.bnd</groupId>
128+
<artifactId>bnd-maven-plugin</artifactId>
129+
<executions>
130+
<execution>
131+
<goals>
132+
<goal>bnd-process</goal>
133+
</goals>
134+
</execution>
135+
</executions>
133136
</plugin>
134137

135138
<plugin>
@@ -179,14 +182,14 @@
179182
</plugin>
180183

181184
<plugin>
182-
<groupId>org.apache.maven.plugins</groupId>
183-
<artifactId>maven-jar-plugin</artifactId>
184-
<version>3.2.0</version>
185-
<configuration>
186-
<archive>
187-
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
188-
</archive>
189-
</configuration>
185+
<groupId>org.apache.maven.plugins</groupId>
186+
<artifactId>maven-jar-plugin</artifactId>
187+
<version>3.2.0</version>
188+
<configuration>
189+
<archive>
190+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
191+
</archive>
192+
</configuration>
190193
</plugin>
191194

192195
<plugin>
@@ -235,35 +238,14 @@
235238
<plugin>
236239
<groupId>org.apache.maven.plugins</groupId>
237240
<artifactId>maven-surefire-plugin</artifactId>
238-
<version>3.0.0-M3</version>
241+
<version>3.0.0-M5</version>
239242
<configuration>
240-
<excludedGroups>org.gitlab4j.api.IntegrationTest</excludedGroups>
241243
<systemPropertyVariables>
242244
<jacoco-agent.destfile>target/jacoco.exec</jacoco-agent.destfile>
243245
</systemPropertyVariables>
244246
</configuration>
245247
</plugin>
246248

247-
<plugin>
248-
<groupId>org.apache.maven.plugins</groupId>
249-
<artifactId>maven-failsafe-plugin</artifactId>
250-
<version>3.0.0-M3</version>
251-
<configuration>
252-
<groups>org.gitlab4j.api.IntegrationTest</groups>
253-
<includes>
254-
<include>**/IntegrationTestSuite.java</include>
255-
</includes>
256-
</configuration>
257-
<executions>
258-
<execution>
259-
<goals>
260-
<goal>integration-test</goal>
261-
<goal>verify</goal>
262-
</goals>
263-
</execution>
264-
</executions>
265-
</plugin>
266-
267249
<plugin>
268250
<groupId>org.apache.maven.plugins</groupId>
269251
<artifactId>maven-enforcer-plugin</artifactId>
@@ -290,7 +272,7 @@
290272
<dependency>
291273
<groupId>org.codehaus.mojo</groupId>
292274
<artifactId>extra-enforcer-rules</artifactId>
293-
<version>1.2</version>
275+
<version>1.3</version>
294276
</dependency>
295277
</dependencies>
296278
</plugin>
@@ -327,7 +309,8 @@
327309
<run>
328310
<skip>${gitlab.skip-docker-start}</skip>
329311
<env>
330-
<GITLAB_OMNIBUS_CONFIG>gitlab_rails['initial_root_password']="password"; gitlab_rails['lfs_enabled']=false;</GITLAB_OMNIBUS_CONFIG>
312+
<GITLAB_OMNIBUS_CONFIG>gitlab_rails['initial_root_password']="password";
313+
gitlab_rails['lfs_enabled']=false;</GITLAB_OMNIBUS_CONFIG>
331314
</env>
332315
<ports>
333316
<port>${gitlab.port}:80</port>
@@ -359,6 +342,19 @@
359342
</executions>
360343
</plugin>
361344

345+
<plugin>
346+
<groupId>org.owasp</groupId>
347+
<artifactId>dependency-check-maven</artifactId>
348+
<version>6.2.2</version>
349+
<executions>
350+
<execution>
351+
<goals>
352+
<goal>check</goal>
353+
</goals>
354+
</execution>
355+
</executions>
356+
</plugin>
357+
362358
</plugins>
363359

364360
<pluginManagement>
@@ -382,14 +378,14 @@
382378
</executions>
383379
</plugin>
384380
<plugin>
385-
<groupId>biz.aQute.bnd</groupId>
386-
<artifactId>bnd-maven-plugin</artifactId>
387-
<version>${bnd.version}</version>
388-
<configuration>
389-
<bnd><![CDATA[
381+
<groupId>biz.aQute.bnd</groupId>
382+
<artifactId>bnd-maven-plugin</artifactId>
383+
<version>${bnd.version}</version>
384+
<configuration>
385+
<bnd><![CDATA[
390386
Export-Package: org.gitlab4j.api.*
391387
]]></bnd>
392-
</configuration>
388+
</configuration>
393389
</plugin>
394390
</plugins>
395391
</pluginManagement>
@@ -436,8 +432,8 @@
436432
</dependency>
437433

438434
<dependency>
439-
<groupId>org.junit.vintage</groupId>
440-
<artifactId>junit-vintage-engine</artifactId>
435+
<groupId>org.junit.jupiter</groupId>
436+
<artifactId>junit-jupiter</artifactId>
441437
<version>${junit.version}</version>
442438
<scope>test</scope>
443439
</dependency>
@@ -447,29 +443,28 @@
447443
<version>${mockito.version}</version>
448444
<scope>test</scope>
449445
</dependency>
446+
<dependency>
447+
<groupId>org.mockito</groupId>
448+
<artifactId>mockito-junit-jupiter</artifactId>
449+
<version>${mockito.version}</version>
450+
<scope>test</scope>
451+
</dependency>
450452
<dependency>
451453
<groupId>org.hamcrest</groupId>
452454
<artifactId>hamcrest-all</artifactId>
453455
<version>${hamcrest.version}</version>
454456
<scope>test</scope>
455457
</dependency>
456458
<dependency>
457-
<groupId>com.github.stefanbirkner</groupId>
458-
<artifactId>system-rules</artifactId>
459-
<version>${systemRules.version}</version>
460-
<scope>test</scope>
461-
</dependency>
462-
<dependency>
463-
<groupId>com.googlecode.junit-toolbox</groupId>
464-
<artifactId>junit-toolbox</artifactId>
465-
<version>2.4</version>
466-
<scope>test</scope>
459+
<groupId>uk.org.webcompere</groupId>
460+
<artifactId>system-stubs-jupiter</artifactId>
461+
<version>1.2.0</version>
467462
</dependency>
468463
</dependencies>
469464

470465
<dependencyManagement>
471466
<dependencies>
472-
<!-- Needed for animal-sniffer -->
467+
<!-- Needed for animal-sniffer -->
473468
<dependency>
474469
<groupId>org.codehaus.mojo.signature</groupId>
475470
<artifactId>java18</artifactId>

src/test/java/org/gitlab4j/api/IntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* <p>To mark a test class as an integration test add the following lines before the class declaration:</p>
1212
*
1313
* <pre><code>
14-
* import org.junit.experimental.categories.Category;
14+
* import org.junit.jupiter.api.Tag;
1515
*
1616
* @Category(org.gitlab4j.api.IntegrationTest.class)
1717
* </code></pre>

src/test/java/org/gitlab4j/api/PagerSpliteratorTest.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
package org.gitlab4j.api;
22

3+
import static java.util.Arrays.asList;
4+
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
5+
import static org.junit.jupiter.api.Assertions.assertEquals;
6+
import static org.junit.jupiter.api.Assertions.assertFalse;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
import static org.junit.jupiter.api.Assertions.fail;
9+
import static org.mockito.Mockito.when;
10+
311
import java.util.Collections;
412
import java.util.stream.StreamSupport;
513

6-
import org.junit.Assert;
7-
import org.junit.Before;
8-
import org.junit.Test;
9-
import org.junit.runner.RunWith;
14+
import org.junit.jupiter.api.BeforeEach;
15+
import org.junit.jupiter.api.Test;
16+
import org.junit.jupiter.api.extension.ExtendWith;
1017
import org.mockito.Mock;
11-
import org.mockito.junit.MockitoJUnitRunner;
18+
import org.mockito.junit.jupiter.MockitoExtension;
1219

13-
import static java.util.Arrays.asList;
14-
import static org.junit.Assert.assertArrayEquals;
15-
import static org.junit.Assert.assertEquals;
16-
import static org.junit.Assert.assertFalse;
17-
import static org.junit.Assert.assertTrue;
18-
import static org.mockito.Mockito.when;
19-
20-
@RunWith(MockitoJUnitRunner.class)
20+
@ExtendWith(MockitoExtension.class)
2121
public class PagerSpliteratorTest {
2222

2323
PagerSpliterator<Integer> pagerSpliterator;
2424

2525
@Mock
2626
Pager<Integer> pager;
2727

28-
@Before
28+
@BeforeEach
2929
public void setUp() {
3030
pagerSpliterator = new PagerSpliterator<>(pager);
3131
}
@@ -46,7 +46,7 @@ public void shouldDoNotFailOnEmptySource() {
4646

4747
assertFalse(success);
4848
}
49-
49+
5050
@Test
5151
public void shouldReturnFalseIfNextPagerItemMissing() {
5252
when(pager.hasNext()).thenReturn(true);
@@ -61,7 +61,7 @@ public void shouldReturnFalseIfNextPagerItemMissing() {
6161
public void shouldThrowNullPointerExceptionWhenActionIsMissing() {
6262
try {
6363
pagerSpliterator.tryAdvance(null);
64-
Assert.fail("Missing NullPointerException");
64+
fail("Missing NullPointerException");
6565
} catch (Throwable e) {
6666
assertEquals(NullPointerException.class, e.getClass());
6767
}

0 commit comments

Comments
 (0)