Skip to content

Commit 1d93623

Browse files
marko-bekhtayrodiere
authored andcommitted
Use JUnit 5 for Validator test cases
1 parent 26216c1 commit 1d93623

File tree

6 files changed

+71
-34
lines changed

6 files changed

+71
-34
lines changed

validator/validator-6/pom.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,22 @@
1010
<properties>
1111
<version.org.hibernate.validator>6.2.5.Final</version.org.hibernate.validator>
1212
<version.javax.el>3.0.1-b12</version.javax.el>
13-
<version.junit>4.13.2</version.junit>
1413
<version.log4j>2.24.3</version.log4j>
14+
<version.junit-jupiter>5.11.3</version.junit-jupiter>
1515
</properties>
1616

17+
<dependencyManagement>
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.junit</groupId>
21+
<artifactId>junit-bom</artifactId>
22+
<version>${version.junit-jupiter}</version>
23+
<type>pom</type>
24+
<scope>import</scope>
25+
</dependency>
26+
</dependencies>
27+
</dependencyManagement>
28+
1729
<dependencies>
1830
<dependency>
1931
<groupId>org.hibernate.validator</groupId>
@@ -33,9 +45,8 @@
3345
</dependency>
3446

3547
<dependency>
36-
<groupId>junit</groupId>
37-
<artifactId>junit</artifactId>
38-
<version>${version.junit}</version>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter</artifactId>
3950
<scope>test</scope>
4051
</dependency>
4152

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
package org.hibernate.validator.bugs;
22

3-
import static org.junit.Assert.assertEquals;
43

5-
import java.util.Set;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
65

6+
import java.util.Set;
77
import javax.validation.ConstraintViolation;
88
import javax.validation.Validation;
99
import javax.validation.Validator;
1010
import javax.validation.ValidatorFactory;
1111

1212
import org.hibernate.validator.testutil.TestForIssue;
13-
import org.junit.BeforeClass;
14-
import org.junit.Test;
1513

16-
public class YourTestCase {
14+
import org.junit.jupiter.api.BeforeAll;
15+
import org.junit.jupiter.api.Test;
16+
17+
class YourTestCase {
1718

1819
private static Validator validator;
1920

20-
@BeforeClass
21+
@BeforeAll
2122
public static void setUp() {
2223
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
2324
validator = factory.getValidator();
2425
}
2526

2627
@Test
2728
@TestForIssue(jiraKey = "HV-NNNNN") // Please fill in the JIRA key of your issue
28-
public void testYourBug() {
29+
void testYourBug() {
2930
YourAnnotatedBean yourEntity1 = new YourAnnotatedBean( null, "example" );
3031

3132
Set<ConstraintViolation<YourAnnotatedBean>> constraintViolations = validator.validate( yourEntity1 );
3233
assertEquals( 1, constraintViolations.size() );
3334
assertEquals(
3435
"must not be null",
35-
constraintViolations.iterator().next().getMessage() );
36+
constraintViolations.iterator().next().getMessage()
37+
);
3638
}
3739

3840
}

validator/validator-8/pom.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,22 @@
1010
<properties>
1111
<version.org.hibernate.validator>8.0.2.Final</version.org.hibernate.validator>
1212
<version.org.glassfish.expressly>5.0.0</version.org.glassfish.expressly>
13-
<version.junit>4.13.2</version.junit>
1413
<version.log4j>2.24.3</version.log4j>
14+
<version.junit-jupiter>5.11.3</version.junit-jupiter>
1515
</properties>
1616

17+
<dependencyManagement>
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.junit</groupId>
21+
<artifactId>junit-bom</artifactId>
22+
<version>${version.junit-jupiter}</version>
23+
<type>pom</type>
24+
<scope>import</scope>
25+
</dependency>
26+
</dependencies>
27+
</dependencyManagement>
28+
1729
<dependencies>
1830
<dependency>
1931
<groupId>org.hibernate.validator</groupId>
@@ -33,9 +45,8 @@
3345
</dependency>
3446

3547
<dependency>
36-
<groupId>junit</groupId>
37-
<artifactId>junit</artifactId>
38-
<version>${version.junit}</version>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter</artifactId>
3950
<scope>test</scope>
4051
</dependency>
4152

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
package org.hibernate.validator.bugs;
22

3-
import static org.junit.Assert.assertEquals;
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
44

55
import java.util.Set;
66

7+
import org.hibernate.validator.testutil.TestForIssue;
8+
9+
import org.junit.jupiter.api.BeforeAll;
10+
import org.junit.jupiter.api.Test;
11+
712
import jakarta.validation.ConstraintViolation;
813
import jakarta.validation.Validation;
914
import jakarta.validation.Validator;
1015
import jakarta.validation.ValidatorFactory;
1116

12-
import org.hibernate.validator.testutil.TestForIssue;
13-
import org.junit.BeforeClass;
14-
import org.junit.Test;
15-
16-
public class YourTestCase {
17+
class YourTestCase {
1718

1819
private static Validator validator;
1920

20-
@BeforeClass
21+
@BeforeAll
2122
public static void setUp() {
2223
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
2324
validator = factory.getValidator();
2425
}
2526

2627
@Test
2728
@TestForIssue(jiraKey = "HV-NNNNN") // Please fill in the JIRA key of your issue
28-
public void testYourBug() {
29+
void testYourBug() {
2930
YourAnnotatedBean yourEntity1 = new YourAnnotatedBean( null, "example" );
3031

3132
Set<ConstraintViolation<YourAnnotatedBean>> constraintViolations = validator.validate( yourEntity1 );
3233
assertEquals( 1, constraintViolations.size() );
3334
assertEquals(
3435
"must not be null",
35-
constraintViolations.iterator().next().getMessage() );
36+
constraintViolations.iterator().next().getMessage()
37+
);
3638
}
3739

3840
}

validator/validator-9/pom.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,23 @@
1010
<properties>
1111
<version.org.hibernate.validator>9.0.0.CR1</version.org.hibernate.validator>
1212
<version.org.glassfish.expressly>6.0.0-M1</version.org.glassfish.expressly>
13-
<version.junit>4.13.2</version.junit>
1413
<version.log4j>2.24.3</version.log4j>
1514
<version.assertj-core>3.26.3</version.assertj-core>
15+
<version.junit-jupiter>5.11.3</version.junit-jupiter>
1616
</properties>
1717

18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.junit</groupId>
22+
<artifactId>junit-bom</artifactId>
23+
<version>${version.junit-jupiter}</version>
24+
<type>pom</type>
25+
<scope>import</scope>
26+
</dependency>
27+
</dependencies>
28+
</dependencyManagement>
29+
1830
<dependencies>
1931
<dependency>
2032
<groupId>org.hibernate.validator</groupId>
@@ -34,9 +46,8 @@
3446
</dependency>
3547

3648
<dependency>
37-
<groupId>junit</groupId>
38-
<artifactId>junit</artifactId>
39-
<version>${version.junit}</version>
49+
<groupId>org.junit.jupiter</groupId>
50+
<artifactId>junit-jupiter</artifactId>
4051
<scope>test</scope>
4152
</dependency>
4253

validator/validator-9/src/test/java/org/hibernate/validator/bugs/YourTestCase.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,28 @@
88

99
import org.hibernate.validator.testutil.TestForIssue;
1010

11-
import org.junit.BeforeClass;
12-
import org.junit.Test;
11+
import org.junit.jupiter.api.BeforeAll;
12+
import org.junit.jupiter.api.Test;
1313

1414
import jakarta.validation.ConstraintViolation;
1515
import jakarta.validation.Validation;
1616
import jakarta.validation.Validator;
1717
import jakarta.validation.ValidatorFactory;
1818
import jakarta.validation.constraints.NotNull;
1919

20-
public class YourTestCase {
20+
class YourTestCase {
2121

2222
private static Validator validator;
2323

24-
@BeforeClass
24+
@BeforeAll
2525
public static void setUp() {
2626
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
2727
validator = factory.getValidator();
2828
}
2929

3030
@Test
3131
@TestForIssue(jiraKey = "HV-NNNNN") // Please fill in the JIRA key of your issue
32-
public void testYourBug() {
32+
void testYourBug() {
3333
YourAnnotatedBean yourEntity1 = new YourAnnotatedBean( null, "example" );
3434

3535
Set<ConstraintViolation<YourAnnotatedBean>> constraintViolations = validator.validate( yourEntity1 );

0 commit comments

Comments
 (0)