Skip to content

Commit 26216c1

Browse files
marko-bekhtayrodiere
authored andcommitted
Add a test case template for Hibernate Validator 9.0
1 parent bacc5c9 commit 26216c1

File tree

7 files changed

+164
-0
lines changed

7 files changed

+164
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,6 @@
2121
<module>search/hibernate-search-7/orm-lucene</module>
2222
<module>validator/validator-6</module>
2323
<module>validator/validator-8</module>
24+
<module>validator/validator-9</module>
2425
</modules>
2526
</project>

validator/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ Here's a running list of what's available:
66

77
* [validator-6](validator-6): a test case template for Hibernate Validator 6 based on Jakarta Bean Validation 2.0 and `javax` namespace.
88
* [validator-8](validator-8): a test case template for Hibernate Validator 8 based on Jakarta Bean Validation 3.0 and `jakarta` namespace.
9+
* [validator-9](validator-9): a test case template for Hibernate Validator 9 based on Jakarta Bean Validation 3.1.

validator/validator-9/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Hibernate Test Case Templates: Hibernate Validator
2+
3+
This repo contains a test case template useful for reporting bugs against Hibernate Validator.

validator/validator-9/pom.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.hibernate.testcasetemplate</groupId>
6+
<artifactId>test-case-template-hibernate-validator-9</artifactId>
7+
<version>1.0.0.Final</version>
8+
<name>Hibernate Validator 9 Test Case Template</name>
9+
10+
<properties>
11+
<version.org.hibernate.validator>9.0.0.CR1</version.org.hibernate.validator>
12+
<version.org.glassfish.expressly>6.0.0-M1</version.org.glassfish.expressly>
13+
<version.junit>4.13.2</version.junit>
14+
<version.log4j>2.24.3</version.log4j>
15+
<version.assertj-core>3.26.3</version.assertj-core>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.hibernate.validator</groupId>
21+
<artifactId>hibernate-validator</artifactId>
22+
<version>${version.org.hibernate.validator}</version>
23+
</dependency>
24+
<dependency>
25+
<groupId>org.hibernate.validator</groupId>
26+
<artifactId>hibernate-validator-test-utils</artifactId>
27+
<version>${version.org.hibernate.validator}</version>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.glassfish.expressly</groupId>
32+
<artifactId>expressly</artifactId>
33+
<version>${version.org.glassfish.expressly}</version>
34+
</dependency>
35+
36+
<dependency>
37+
<groupId>junit</groupId>
38+
<artifactId>junit</artifactId>
39+
<version>${version.junit}</version>
40+
<scope>test</scope>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>org.assertj</groupId>
45+
<artifactId>assertj-core</artifactId>
46+
<version>${version.assertj-core}</version>
47+
<scope>test</scope>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>org.apache.logging.log4j</groupId>
52+
<artifactId>log4j-core</artifactId>
53+
<version>${version.log4j}</version>
54+
</dependency>
55+
56+
</dependencies>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.apache.maven.plugins</groupId>
62+
<artifactId>maven-compiler-plugin</artifactId>
63+
<version>3.13.0</version>
64+
<configuration>
65+
<source>17</source>
66+
<target>17</target>
67+
</configuration>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.hibernate.validator.bugs;
2+
3+
import jakarta.validation.constraints.NotNull;
4+
5+
public class YourAnnotatedBean {
6+
7+
@NotNull
8+
private Long id;
9+
10+
private String name;
11+
12+
protected YourAnnotatedBean() {
13+
}
14+
15+
public YourAnnotatedBean(Long id, String name) {
16+
this.id = id;
17+
this.name = name;
18+
}
19+
20+
public Long getId() {
21+
return id;
22+
}
23+
24+
public String getName() {
25+
return name;
26+
}
27+
28+
public void setName(String name) {
29+
this.name = name;
30+
}
31+
32+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package org.hibernate.validator.bugs;
2+
3+
import static org.hibernate.validator.testutil.ConstraintViolationAssert.assertThat;
4+
import static org.hibernate.validator.testutil.ConstraintViolationAssert.pathWith;
5+
import static org.hibernate.validator.testutil.ConstraintViolationAssert.violationOf;
6+
7+
import java.util.Set;
8+
9+
import org.hibernate.validator.testutil.TestForIssue;
10+
11+
import org.junit.BeforeClass;
12+
import org.junit.Test;
13+
14+
import jakarta.validation.ConstraintViolation;
15+
import jakarta.validation.Validation;
16+
import jakarta.validation.Validator;
17+
import jakarta.validation.ValidatorFactory;
18+
import jakarta.validation.constraints.NotNull;
19+
20+
public class YourTestCase {
21+
22+
private static Validator validator;
23+
24+
@BeforeClass
25+
public static void setUp() {
26+
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
27+
validator = factory.getValidator();
28+
}
29+
30+
@Test
31+
@TestForIssue(jiraKey = "HV-NNNNN") // Please fill in the JIRA key of your issue
32+
public void testYourBug() {
33+
YourAnnotatedBean yourEntity1 = new YourAnnotatedBean( null, "example" );
34+
35+
Set<ConstraintViolation<YourAnnotatedBean>> constraintViolations = validator.validate( yourEntity1 );
36+
assertThat( constraintViolations )
37+
.containsOnlyViolations( violationOf( NotNull.class )
38+
.withMessage( "must not be null" )
39+
.withPropertyPath( pathWith().property( "id" ) ) );
40+
}
41+
42+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Set to debug or trace if log4j initialization is failing
2+
status = warn
3+
4+
# Console appender configuration
5+
appender.console.type = Console
6+
appender.console.name = consoleLogger
7+
appender.console.layout.type = PatternLayout
8+
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
9+
10+
# Root logger level
11+
rootLogger.level = info
12+
13+
# Root logger referring to console appender
14+
rootLogger.appenderRef.stdout.ref = consoleLogger

0 commit comments

Comments
 (0)