File tree Expand file tree Collapse file tree 4 files changed +45
-192
lines changed
validation/custom-constraint/src
java/org/javaee7/validation/custom/constraint
test/java/org/javaee7/validation/custom/constraint Expand file tree Collapse file tree 4 files changed +45
-192
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ package org .javaee7 .validation .custom .constraint ;
2+
3+ import javax .inject .Inject ;
4+ import javax .validation .ConstraintViolationException ;
5+
6+ import org .jboss .arquillian .container .test .api .Deployment ;
7+ import org .jboss .arquillian .junit .Arquillian ;
8+ import org .jboss .shrinkwrap .api .Archive ;
9+ import org .jboss .shrinkwrap .api .ShrinkWrap ;
10+ import org .jboss .shrinkwrap .api .asset .EmptyAsset ;
11+ import org .jboss .shrinkwrap .api .spec .JavaArchive ;
12+ import org .junit .Rule ;
13+ import org .junit .Test ;
14+ import org .junit .rules .ExpectedException ;
15+ import org .junit .runner .RunWith ;
16+
17+ @ RunWith (Arquillian .class )
18+ public class CustomConstraintTest {
19+
20+ @ Inject
21+ MyBean bean ;
22+
23+ @ Rule
24+ public ExpectedException thrown = ExpectedException .none ();
25+
26+ @ Deployment
27+ public static Archive <?> deployment () {
28+ return ShrinkWrap .create (JavaArchive .class ).addClasses (MyBean .class )
29+ .addAsManifestResource (EmptyAsset .INSTANCE , "beans.xml" );
30+ }
31+
32+ @ Test
33+ public void saveZipCodeforUs () {
34+ bean .saveZip ("95051" );
35+ }
36+
37+ @ Test
38+ public void saveZipCodeForIndia () {
39+ thrown .equals (ConstraintViolationException .class );
40+ thrown .expectMessage ("javaee7.validation.custom.constraint.ZipCode" );
41+ thrown .expectMessage ("saveZipIndia.arg0" );
42+ bean .saveZipIndia ("95051" );
43+ }
44+
45+ }
You can’t perform that action at this time.
0 commit comments