Skip to content

Commit 698df7e

Browse files
authored
Update Gozer to use Junit5 (#160)
1 parent 466df8b commit 698df7e

File tree

57 files changed

+417
-430
lines changed

Some content is hidden

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

57 files changed

+417
-430
lines changed

UPGRADE_SUMMARY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Using GitHub Copilot successfully updated the project to use Java 21 with modern
77

88
### Build & Testing Tools
99
- **JaCoCo**: 0.8.2 → 0.8.12 (Java 21 compatibility fix)
10-
- **JUnit**: 4.13.14.13.2 (security patches)
10+
- **JUnit**: 4.13.25.10.1 (Junit 5 migration)
1111
- **Mockito**: 3.12.4 → 5.11.0 (major version upgrade)
1212

1313
### Logging
@@ -52,7 +52,7 @@ Updated for Checkstyle 9.x/10.x compatibility:
5252

5353
## Known Issues & Future Work
5454
1. **Checkstyle Violations**: 157 javadoc-related violations need to be addressed in a separate effort
55-
2. **JUnit 5 Migration**: Attempted but blocked by Eclipse/Takari compiler access restrictions with JUnit 5 annotations
55+
~~2. **JUnit 5 Migration**: Attempted but blocked by Eclipse/Takari compiler access restrictions with JUnit 5 annotations~~
5656
3. **Deprecated API Usage**: Some test code uses deprecated Integer constructor (Java 9+)
5757
4. **Java Agent Warnings**: Dynamic agent loading warnings from Mockito/ByteBuddy (Java 21 feature)
5858

pom.xml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<!-- Checkstyle updated to 10.x - existing javadoc violations need fixing separately -->
1919
<checkstyle.fail.on.violation>false</checkstyle.fail.on.violation>
2020
<checkstyle.fail.on.error>false</checkstyle.fail.on.error>
21-
<junit.version>4.13.2</junit.version>
21+
<junit.version>5.10.1</junit.version>
2222
<mockito.version>5.11.0</mockito.version>
2323
<slf4j.version>2.0.12</slf4j.version>
2424
<logback.version>1.5.3</logback.version>
@@ -67,8 +67,14 @@
6767

6868
<!-- Test -->
6969
<dependency>
70-
<groupId>junit</groupId>
71-
<artifactId>junit</artifactId>
70+
<groupId>org.junit.jupiter</groupId>
71+
<artifactId>junit-jupiter-api</artifactId>
72+
<version>${junit.version}</version>
73+
<scope>test</scope>
74+
</dependency>
75+
<dependency>
76+
<groupId>org.junit.jupiter</groupId>
77+
<artifactId>junit-jupiter-engine</artifactId>
7278
<version>${junit.version}</version>
7379
<scope>test</scope>
7480
</dependency>
@@ -82,6 +88,21 @@
8288

8389
<build>
8490
<plugins>
91+
<!-- Takari lifecycle plugin configuration -->
92+
<!-- Compiler args needed for future JUnit 5 migration -->
93+
<!-- Eclipse ECJ (used by Takari) restricts access to internal JUnit 5 classes -->
94+
<!-- The add-opens flag allows the compiler to access java.base modules -->
95+
<plugin>
96+
<groupId>io.takari.maven.plugins</groupId>
97+
<artifactId>takari-lifecycle-plugin</artifactId>
98+
<extensions>true</extensions>
99+
<configuration>
100+
<compilerId>jdt</compilerId>
101+
<compilerArgs>
102+
<arg>-J--add-opens=java.base/java.lang=ALL-UNNAMED</arg>
103+
</compilerArgs>
104+
</configuration>
105+
</plugin>
85106
<!-- code coverage -->
86107
<plugin>
87108
<groupId>org.jacoco</groupId>
@@ -108,6 +129,12 @@
108129
</excludes>
109130
</configuration>
110131
</plugin>
132+
<!-- maven-surefire-plugin for JUnit 5 support -->
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-surefire-plugin</artifactId>
136+
<version>3.2.5</version>
137+
</plugin>
111138
<!-- checkstyle -->
112139
<plugin>
113140
<groupId>org.apache.maven.plugins</groupId>

src/test/java/com/walmartlabs/x12/SegmentIteratorTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,26 @@
1616

1717
package com.walmartlabs.x12;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

2121
import java.util.ArrayList;
2222
import java.util.Collections;
2323
import java.util.List;
2424
import java.util.NoSuchElementException;
2525

26-
import static org.junit.Assert.assertEquals;
27-
import static org.junit.Assert.assertFalse;
28-
import static org.junit.Assert.assertNotNull;
29-
import static org.junit.Assert.assertTrue;
30-
import static org.junit.Assert.fail;
26+
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
import static org.junit.jupiter.api.Assertions.assertFalse;
28+
import static org.junit.jupiter.api.Assertions.assertNotNull;
29+
import static org.junit.jupiter.api.Assertions.assertTrue;
30+
import static org.junit.jupiter.api.Assertions.fail;
31+
import static org.junit.jupiter.api.Assertions.assertThrows;
3132

3233
public class SegmentIteratorTest {
3334

34-
@Test(expected = IllegalArgumentException.class)
35+
@Test
3536
public void test_with_null_list() {
3637
List<X12Segment> segmentLines = null;
37-
new SegmentIterator(segmentLines);
38+
assertThrows(IllegalArgumentException.class, () -> new SegmentIterator(segmentLines));
3839
}
3940

4041
@Test

src/test/java/com/walmartlabs/x12/X12SegmentTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package com.walmartlabs.x12;
1818

19-
import org.junit.Test;
19+
import org.junit.jupiter.api.Test;
2020

21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertNotNull;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertNotNull;
2323

2424
public class X12SegmentTest {
2525

src/test/java/com/walmartlabs/x12/common/segment/parser/DTMDateTimeReferenceParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import com.walmartlabs.x12.X12Segment;
2020
import com.walmartlabs.x12.common.segment.DTMDateTimeReference;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

23-
import static org.junit.Assert.assertEquals;
24-
import static org.junit.Assert.assertNotNull;
25-
import static org.junit.Assert.assertNull;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertNotNull;
25+
import static org.junit.jupiter.api.Assertions.assertNull;
2626

2727
public class DTMDateTimeReferenceParserTest {
2828

src/test/java/com/walmartlabs/x12/common/segment/parser/FOBRelatedInstructionsParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import com.walmartlabs.x12.X12Segment;
2020
import com.walmartlabs.x12.common.segment.FOBRelatedInstructions;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

23-
import static org.junit.Assert.assertEquals;
24-
import static org.junit.Assert.assertNotNull;
25-
import static org.junit.Assert.assertNull;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertNotNull;
25+
import static org.junit.jupiter.api.Assertions.assertNull;
2626

2727
public class FOBRelatedInstructionsParserTest {
2828

src/test/java/com/walmartlabs/x12/common/segment/parser/LINItemIdentificationParserTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import com.walmartlabs.x12.X12Segment;
2020
import com.walmartlabs.x12.common.segment.LINItemIdentification;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

2323
import java.util.List;
2424

25-
import static org.junit.Assert.assertEquals;
26-
import static org.junit.Assert.assertNotNull;
25+
import static org.junit.jupiter.api.Assertions.assertEquals;
26+
import static org.junit.jupiter.api.Assertions.assertNotNull;
2727

2828
public class LINItemIdentificationParserTest {
2929

src/test/java/com/walmartlabs/x12/common/segment/parser/N1PartyIdentificationParserTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
import com.walmartlabs.x12.common.segment.N1PartyIdentification;
2222
import com.walmartlabs.x12.common.segment.N3PartyLocation;
2323
import com.walmartlabs.x12.common.segment.N4GeographicLocation;
24-
import org.junit.Test;
24+
import org.junit.jupiter.api.Test;
2525

2626
import java.util.ArrayList;
2727
import java.util.List;
2828

29-
import static org.junit.Assert.assertEquals;
30-
import static org.junit.Assert.assertFalse;
31-
import static org.junit.Assert.assertNotNull;
32-
import static org.junit.Assert.assertNull;
33-
import static org.junit.Assert.assertTrue;
29+
import static org.junit.jupiter.api.Assertions.assertEquals;
30+
import static org.junit.jupiter.api.Assertions.assertFalse;
31+
import static org.junit.jupiter.api.Assertions.assertNotNull;
32+
import static org.junit.jupiter.api.Assertions.assertNull;
33+
import static org.junit.jupiter.api.Assertions.assertTrue;
3434

3535
public class N1PartyIdentificationParserTest {
3636

src/test/java/com/walmartlabs/x12/common/segment/parser/PIDPartyIdentificationParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import com.walmartlabs.x12.X12Segment;
2020
import com.walmartlabs.x12.common.segment.PIDProductIdentification;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

23-
import static org.junit.Assert.assertEquals;
24-
import static org.junit.Assert.assertNotNull;
25-
import static org.junit.Assert.assertNull;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertNotNull;
25+
import static org.junit.jupiter.api.Assertions.assertNull;
2626

2727
public class PIDPartyIdentificationParserTest {
2828

src/test/java/com/walmartlabs/x12/common/segment/parser/PKGPackagingParserTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818

1919
import com.walmartlabs.x12.X12Segment;
2020
import com.walmartlabs.x12.common.segment.PKGPackaging;
21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2222

23-
import static org.junit.Assert.assertEquals;
24-
import static org.junit.Assert.assertNotNull;
25-
import static org.junit.Assert.assertNull;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertNotNull;
25+
import static org.junit.jupiter.api.Assertions.assertNull;
2626

2727
public class PKGPackagingParserTest {
2828

0 commit comments

Comments
 (0)