Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HV-1091 Using iterative instead of recursive approach for message par…
…sing
- Loading branch information
1 parent
c63c057
commit 7204953
Showing
9 changed files
with
103 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
engine/src/test/java/org/hibernate/validator/bugs/TooBigMessageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.bugs; | ||
|
||
import static org.hibernate.validator.testutil.ConstraintViolationAssert.assertCorrectConstraintViolationMessages; | ||
import static org.hibernate.validator.testutil.ConstraintViolationAssert.assertNumberOfViolations; | ||
|
||
import java.util.Set; | ||
|
||
import javax.validation.ConstraintViolation; | ||
import javax.validation.Validator; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import org.hibernate.validator.testutil.TestForIssue; | ||
import org.hibernate.validator.testutils.ValidatorUtil; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Ensure large error messages can be interpolated. | ||
* | ||
* @author Gunnar Morling | ||
*/ | ||
public class TooBigMessageTest { | ||
|
||
/** | ||
* Large enough to trigger a stack overflow with the recursive scheme, assuming default settings | ||
*/ | ||
private static final String LARGE_MESSAGE = | ||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890" | ||
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"; | ||
|
||
@Test | ||
@TestForIssue(jiraKey = "HV-1091") | ||
public void largeMessageCanBeInterpolated() { | ||
Validator validator = ValidatorUtil.getValidator(); | ||
GoldFish fish = new GoldFish(); | ||
|
||
Set<ConstraintViolation<GoldFish>> constraintViolations = validator.validate( fish ); | ||
assertNumberOfViolations( constraintViolations, 1 ); | ||
assertCorrectConstraintViolationMessages( constraintViolations, LARGE_MESSAGE ); | ||
} | ||
|
||
private static class GoldFish { | ||
|
||
@NotNull(message = LARGE_MESSAGE) | ||
String name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters