-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
68 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,14 +37,27 @@ | |
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
import javax.validation.constraints.Pattern; | ||
import org.junit.Ignore; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.ExpectedException; | ||
|
||
/** | ||
* Test case for {@link JSR-303} annotations and their implementations. | ||
* @author Yegor Bugayenko ([email protected]) | ||
* @version $Id$ | ||
*/ | ||
public final class JSR303Test { | ||
/** | ||
* The test message. | ||
*/ | ||
private static final String OVERRIDEN_MSG = "this is a message"; | ||
|
||
/** | ||
* Expected exception rule. | ||
*/ | ||
@Rule | ||
public ExpectedException thrown = ExpectedException.none(); | ||
|
||
/** | ||
* NotNull can throw when invalid method parameters. | ||
|
@@ -107,6 +120,25 @@ public void validatesChainedConstructorParameters() { | |
new JSR303Test.ConstructorValidation(null); | ||
} | ||
|
||
/** | ||
* NotNull can override the message. | ||
*/ | ||
@Test | ||
@Ignore | ||
public void overridesMessage() { | ||
this.thrown.expect(ConstraintViolationException.class); | ||
this.thrown.expectMessage(JSR303Test.OVERRIDEN_MSG); | ||
new JSR303Test.Bar().test(null); | ||
} | ||
|
||
/** | ||
* Validator can skip a constraint rule. | ||
*/ | ||
@Test | ||
public void skipsConstraintRule() { | ||
new JSR303Test.Bar().test("value"); | ||
} | ||
|
||
/** | ||
* Annotation. | ||
*/ | ||
|
@@ -176,4 +208,26 @@ public ConstructorValidation(@NotNull final String param) { | |
} | ||
} | ||
|
||
/** | ||
* Dummy interface for testing messages overriding. | ||
*/ | ||
private interface Fum { | ||
/** | ||
* Test method. | ||
* @param value Value | ||
*/ | ||
void test(@NotNull(message = JSR303Test.OVERRIDEN_MSG) String value); | ||
} | ||
|
||
/** | ||
* Dummy class for testing messages overriding. | ||
*/ | ||
@Loggable(Loggable.INFO) | ||
private static class Bar implements JSR303Test.Fum { | ||
@Override | ||
public void test(@NotNull final String value) { | ||
//Nothing to do. | ||
} | ||
} | ||
|
||
} |