Skip to content

Commit cc178e2

Browse files
committed
Update Ldif Tests to JUnit 5
Issue gh-1058
1 parent dd12143 commit cc178e2

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

ldif/ldif-core/build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,20 @@ dependencies {
66
management platform(project(":spring-ldap-dependencies"))
77
api project(":spring-ldap-core")
88

9+
910
testImplementation platform('org.junit:junit-bom')
10-
testImplementation "org.junit.vintage:junit-vintage-engine"
11-
testImplementation "junit:junit"
1211
testImplementation "org.assertj:assertj-core"
12+
testImplementation "org.junit.jupiter:junit-jupiter-api"
13+
testImplementation "org.junit.jupiter:junit-jupiter-engine"
14+
testImplementation "org.junit.jupiter:junit-jupiter-params"
15+
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
1316
testImplementation ("log4j:log4j:1.2.17") {
1417
exclude group: 'javax.jms'
1518
exclude group: 'com.sun.jdmk'
1619
exclude group: 'com.sun.jmx'
1720
}
1821
}
22+
23+
tasks.withType(Test).configureEach {
24+
useJUnitPlatform()
25+
}

ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/DefaultAttributeValidationPolicyTests.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@
2121
import java.util.Collection;
2222
import java.util.List;
2323

24-
import org.junit.Test;
25-
import org.junit.runner.RunWith;
26-
import org.junit.runners.Parameterized;
27-
import org.junit.runners.Parameterized.Parameters;
24+
import org.junit.jupiter.params.ParameterizedTest;
25+
import org.junit.jupiter.params.provider.MethodSource;
2826
import org.slf4j.Logger;
2927
import org.slf4j.LoggerFactory;
3028

@@ -44,7 +42,6 @@
4442
* @author Keith Barlow
4543
*
4644
*/
47-
@RunWith(Parameterized.class)
4845
public class DefaultAttributeValidationPolicyTests {
4946

5047
private static Logger log = LoggerFactory.getLogger(DefaultAttributeValidationPolicyTests.class);
@@ -75,7 +72,6 @@ private enum AttributeType {
7572
* The data set to parse.
7673
* @return
7774
*/
78-
@Parameters
7975
public static Collection<Object[]> data() {
8076
return Arrays.asList(new Object[][] {
8177
// Format: line, id, options, value, type
@@ -146,7 +142,7 @@ public static Collection<Object[]> data() {
146142
* @param value The value expected from successful parsing.
147143
* @param type The attribute type: one of enum AttributeType.
148144
*/
149-
public DefaultAttributeValidationPolicyTests(String line, String id, String options, String value,
145+
public void initDefaultAttributeValidationPolicyTests(String line, String id, String options, String value,
150146
AttributeType type) {
151147
this.line = line;
152148
this.id = id;
@@ -159,8 +155,10 @@ public DefaultAttributeValidationPolicyTests(String line, String id, String opti
159155
* The test case: parses passed in parameters and validates the outcome against the
160156
* expected results.
161157
*/
162-
@Test
163-
public void parseAttribute() {
158+
@MethodSource("data")
159+
@ParameterizedTest
160+
public void parseAttribute(String line, String id, String options, String value, AttributeType type) {
161+
initDefaultAttributeValidationPolicyTests(line, id, options, value, type);
164162
try {
165163
LdapAttribute attribute = (LdapAttribute) policy.parse(this.line);
166164

ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/Ldap233LdifParserTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import java.io.IOException;
2121
import java.nio.file.Files;
2222

23-
import org.junit.Test;
23+
import org.junit.jupiter.api.Test;
2424

2525
import org.springframework.ldap.ldif.parser.LdifParser;
2626
import org.springframework.ldap.schema.BasicSchemaSpecification;

ldif/ldif-core/src/test/java/org/springframework/ldap/ldif/LdifParserTests.java

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

1919
import java.io.IOException;
2020

21-
import org.junit.After;
22-
import org.junit.Before;
23-
import org.junit.Test;
21+
import org.junit.jupiter.api.AfterEach;
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
2424
import org.slf4j.Logger;
2525
import org.slf4j.LoggerFactory;
2626

@@ -66,7 +66,7 @@ public LdifParserTests() {
6666
/**
6767
* Setup: opens file.
6868
*/
69-
@Before
69+
@BeforeEach
7070
public void openLdif() {
7171
try {
7272
this.parser.open();
@@ -122,7 +122,7 @@ public void parseLdif() {
122122
/**
123123
* Cleanup: closes file.
124124
*/
125-
@After
125+
@AfterEach
126126
public void closeLdif() {
127127
try {
128128
this.parser.close();

0 commit comments

Comments
 (0)