/grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/validation/ConstrainedPropertyTests.java

https://github.com/roongr2k7/grails-core · Java · 384 lines · 284 code · 71 blank · 29 comment · 4 complexity · b37b5e90d3c44860daa47203c0f2b866 MD5 · raw file

  1. package org.codehaus.groovy.grails.validation;
  2. import groovy.lang.GroovyClassLoader;
  3. import groovy.lang.GroovyObject;
  4. import groovy.lang.IntRange;
  5. import groovy.lang.ObjectRange;
  6. import java.math.BigDecimal;
  7. import java.math.BigInteger;
  8. import java.util.Collection;
  9. import java.util.Date;
  10. import java.util.Iterator;
  11. import java.util.Map;
  12. import junit.framework.TestCase;
  13. import org.codehaus.groovy.grails.commons.DefaultGrailsDomainClass;
  14. import org.codehaus.groovy.grails.commons.GrailsDomainClass;
  15. import org.codehaus.groovy.grails.plugins.MockGrailsPluginManager;
  16. import org.codehaus.groovy.grails.plugins.PluginManagerHolder;
  17. import org.codehaus.groovy.grails.test.support.MockHibernatePluginHelper;
  18. import org.springframework.validation.BindException;
  19. import org.springframework.validation.Errors;
  20. public class ConstrainedPropertyTests extends TestCase {
  21. private int testValidatorValue = 0;
  22. @Override
  23. protected void setUp() throws Exception {
  24. super.setUp();
  25. MockGrailsPluginManager pluginManager = new MockGrailsPluginManager();
  26. PluginManagerHolder.setPluginManager(pluginManager);
  27. pluginManager.registerMockPlugin(MockHibernatePluginHelper.FAKE_HIBERNATE_PLUGIN);
  28. }
  29. @Override
  30. protected void tearDown() throws Exception {
  31. super.tearDown();
  32. PluginManagerHolder.setPluginManager(null);
  33. }
  34. public int getTestValidatorValue() {
  35. return testValidatorValue;
  36. }
  37. public void setTestValidatorValue(int testValidatorValue) {
  38. this.testValidatorValue = testValidatorValue;
  39. }
  40. public void testGetSetURL() {
  41. ConstrainedProperty cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", String.class);
  42. cp.setUrl(true);
  43. assertTrue("should be an url", cp.isUrl());
  44. }
  45. public void testGetSetEmail() {
  46. ConstrainedProperty cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", String.class);
  47. cp.setEmail(true);
  48. assertTrue("should be an email", cp.isEmail());
  49. }
  50. public void testGetSetBlank() {
  51. ConstrainedProperty cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", String.class);
  52. cp.setBlank(true);
  53. assertTrue("should be blank", cp.isBlank());
  54. }
  55. public void testGetSetMatches() {
  56. ConstrainedProperty cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", String.class);
  57. cp.setMatches("\\.+");
  58. assertEquals("should match expression","\\.+", cp.getMatches());
  59. }
  60. public void testGetSetCreditCart() {
  61. ConstrainedProperty cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", String.class);
  62. cp.setCreditCard(true);
  63. assertTrue("should be credit cart", cp.isCreditCard());
  64. }
  65. /*
  66. * Test method for 'org.codehaus.groovy.grails.validation.ConstrainedProperty.supportsContraint(String)'
  67. */
  68. public void testSupportsContraint() {
  69. ConstrainedProperty cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", String.class);
  70. assertTrue(cp.supportsContraint(ConstrainedProperty.BLANK_CONSTRAINT));
  71. assertTrue(cp.supportsContraint(ConstrainedProperty.EMAIL_CONSTRAINT));
  72. assertTrue(cp.supportsContraint(ConstrainedProperty.MATCHES_CONSTRAINT));
  73. assertTrue(cp.supportsContraint(ConstrainedProperty.IN_LIST_CONSTRAINT));
  74. assertTrue(cp.supportsContraint(ConstrainedProperty.MAX_CONSTRAINT));
  75. assertTrue(cp.supportsContraint(ConstrainedProperty.MIN_CONSTRAINT));
  76. assertTrue(cp.supportsContraint(ConstrainedProperty.NOT_EQUAL_CONSTRAINT));
  77. assertTrue(cp.supportsContraint(ConstrainedProperty.NULLABLE_CONSTRAINT));
  78. assertTrue(cp.supportsContraint(ConstrainedProperty.RANGE_CONSTRAINT));
  79. assertTrue(cp.supportsContraint(ConstrainedProperty.URL_CONSTRAINT));
  80. assertTrue(cp.supportsContraint(ConstrainedProperty.VALIDATOR_CONSTRAINT));
  81. assertTrue(cp.supportsContraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT));
  82. assertTrue(cp.supportsContraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT));
  83. assertTrue(cp.supportsContraint(ConstrainedProperty.SIZE_CONSTRAINT));
  84. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  85. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Collection.class);
  86. assertTrue(cp.supportsContraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT));
  87. assertTrue(cp.supportsContraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT));
  88. assertTrue(cp.supportsContraint(ConstrainedProperty.SIZE_CONSTRAINT));
  89. assertTrue(cp.supportsContraint(ConstrainedProperty.IN_LIST_CONSTRAINT));
  90. assertTrue(cp.supportsContraint(ConstrainedProperty.NOT_EQUAL_CONSTRAINT));
  91. assertTrue(cp.supportsContraint(ConstrainedProperty.NULLABLE_CONSTRAINT));
  92. assertTrue(cp.supportsContraint(ConstrainedProperty.VALIDATOR_CONSTRAINT));
  93. assertFalse(cp.supportsContraint(ConstrainedProperty.BLANK_CONSTRAINT));
  94. assertFalse(cp.supportsContraint(ConstrainedProperty.EMAIL_CONSTRAINT));
  95. assertFalse(cp.supportsContraint(ConstrainedProperty.MATCHES_CONSTRAINT));
  96. assertFalse(cp.supportsContraint(ConstrainedProperty.MAX_CONSTRAINT));
  97. assertFalse(cp.supportsContraint(ConstrainedProperty.MIN_CONSTRAINT));
  98. assertFalse(cp.supportsContraint(ConstrainedProperty.RANGE_CONSTRAINT));
  99. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  100. assertFalse(cp.supportsContraint(ConstrainedProperty.URL_CONSTRAINT));
  101. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Number.class);
  102. assertTrue(cp.supportsContraint(ConstrainedProperty.IN_LIST_CONSTRAINT));
  103. assertTrue(cp.supportsContraint(ConstrainedProperty.NOT_EQUAL_CONSTRAINT));
  104. assertTrue(cp.supportsContraint(ConstrainedProperty.NULLABLE_CONSTRAINT));
  105. assertTrue(cp.supportsContraint(ConstrainedProperty.MAX_CONSTRAINT));
  106. assertTrue(cp.supportsContraint(ConstrainedProperty.MIN_CONSTRAINT));
  107. assertTrue(cp.supportsContraint(ConstrainedProperty.RANGE_CONSTRAINT));
  108. assertTrue(cp.supportsContraint(ConstrainedProperty.VALIDATOR_CONSTRAINT));
  109. assertFalse(cp.supportsContraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT));
  110. assertFalse(cp.supportsContraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT));
  111. assertFalse(cp.supportsContraint(ConstrainedProperty.SIZE_CONSTRAINT));
  112. assertFalse(cp.supportsContraint(ConstrainedProperty.BLANK_CONSTRAINT));
  113. assertFalse(cp.supportsContraint(ConstrainedProperty.EMAIL_CONSTRAINT));
  114. assertFalse(cp.supportsContraint(ConstrainedProperty.MATCHES_CONSTRAINT));
  115. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  116. assertFalse(cp.supportsContraint(ConstrainedProperty.URL_CONSTRAINT));
  117. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Date.class);
  118. assertTrue(cp.supportsContraint(ConstrainedProperty.MAX_CONSTRAINT));
  119. assertTrue(cp.supportsContraint(ConstrainedProperty.MIN_CONSTRAINT));
  120. assertTrue(cp.supportsContraint(ConstrainedProperty.RANGE_CONSTRAINT));
  121. assertTrue(cp.supportsContraint(ConstrainedProperty.IN_LIST_CONSTRAINT));
  122. assertTrue(cp.supportsContraint(ConstrainedProperty.NOT_EQUAL_CONSTRAINT));
  123. assertTrue(cp.supportsContraint(ConstrainedProperty.NULLABLE_CONSTRAINT));
  124. assertTrue(cp.supportsContraint(ConstrainedProperty.VALIDATOR_CONSTRAINT));
  125. assertFalse(cp.supportsContraint(ConstrainedProperty.BLANK_CONSTRAINT));
  126. assertFalse(cp.supportsContraint(ConstrainedProperty.EMAIL_CONSTRAINT));
  127. assertFalse(cp.supportsContraint(ConstrainedProperty.MATCHES_CONSTRAINT));
  128. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  129. assertFalse(cp.supportsContraint(ConstrainedProperty.URL_CONSTRAINT));
  130. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Object.class);
  131. assertTrue(cp.supportsContraint(ConstrainedProperty.IN_LIST_CONSTRAINT));
  132. assertTrue(cp.supportsContraint(ConstrainedProperty.NOT_EQUAL_CONSTRAINT));
  133. assertTrue(cp.supportsContraint(ConstrainedProperty.NULLABLE_CONSTRAINT));
  134. assertTrue(cp.supportsContraint(ConstrainedProperty.VALIDATOR_CONSTRAINT));
  135. assertFalse(cp.supportsContraint(ConstrainedProperty.MAX_CONSTRAINT));
  136. assertFalse(cp.supportsContraint(ConstrainedProperty.MIN_CONSTRAINT));
  137. assertFalse(cp.supportsContraint(ConstrainedProperty.RANGE_CONSTRAINT));
  138. assertFalse(cp.supportsContraint(ConstrainedProperty.BLANK_CONSTRAINT));
  139. assertFalse(cp.supportsContraint(ConstrainedProperty.EMAIL_CONSTRAINT));
  140. assertFalse(cp.supportsContraint(ConstrainedProperty.MATCHES_CONSTRAINT));
  141. assertFalse(cp.supportsContraint(ConstrainedProperty.URL_CONSTRAINT));
  142. assertFalse(cp.supportsContraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT));
  143. assertFalse(cp.supportsContraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT));
  144. assertFalse(cp.supportsContraint(ConstrainedProperty.SIZE_CONSTRAINT));
  145. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  146. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Comparable.class);
  147. assertTrue(cp.supportsContraint(ConstrainedProperty.IN_LIST_CONSTRAINT));
  148. assertTrue(cp.supportsContraint(ConstrainedProperty.NOT_EQUAL_CONSTRAINT));
  149. assertTrue(cp.supportsContraint(ConstrainedProperty.NULLABLE_CONSTRAINT));
  150. assertTrue(cp.supportsContraint(ConstrainedProperty.MAX_CONSTRAINT));
  151. assertTrue(cp.supportsContraint(ConstrainedProperty.MIN_CONSTRAINT));
  152. assertTrue(cp.supportsContraint(ConstrainedProperty.RANGE_CONSTRAINT));
  153. assertFalse(cp.supportsContraint(ConstrainedProperty.BLANK_CONSTRAINT));
  154. assertFalse(cp.supportsContraint(ConstrainedProperty.EMAIL_CONSTRAINT));
  155. assertFalse(cp.supportsContraint(ConstrainedProperty.MATCHES_CONSTRAINT));
  156. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  157. assertFalse(cp.supportsContraint(ConstrainedProperty.URL_CONSTRAINT));
  158. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Float.class);
  159. assertTrue(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  160. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Double.class);
  161. assertTrue(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  162. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", BigDecimal.class);
  163. assertTrue(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  164. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Integer.class);
  165. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  166. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", Long.class);
  167. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  168. cp = new ConstrainedProperty(ConstrainedPropertyTests.class,"testProperty", BigInteger.class);
  169. assertFalse(cp.supportsContraint(ConstrainedProperty.SCALE_CONSTRAINT));
  170. }
  171. public void testGetMin() {
  172. // validate that getMin returns null if the property has no min constraint and no range constraint
  173. ConstrainedProperty cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  174. assertNull(cp.getMin());
  175. // validate that getMin returns the correct value when the min constraint is defined for the property (but no range constraint is defined)
  176. cp.applyConstraint(ConstrainedProperty.MIN_CONSTRAINT, 123.45d);
  177. assertEquals(123.45d, cp.getMin());
  178. // validate that getMin returns the correct value when the range constraint is defined for the property (but no min constraint is defined)
  179. cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  180. cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(123.45d, 678.9d));
  181. assertEquals(123.45d, cp.getMin());
  182. // validate that getMin returns the maximum of the min constraint and the lower bound of the range constraint
  183. // 1) validate where the lower bound of the range constraint is greater than the min constraint
  184. cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  185. cp.applyConstraint(ConstrainedProperty.MIN_CONSTRAINT, 1.23d);
  186. cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(4.56d, 7.89d));
  187. assertEquals(4.56d, cp.getMin());
  188. // 2) validate where the min constraint is greater than the lower bound of the range constraint
  189. cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  190. cp.applyConstraint(ConstrainedProperty.MIN_CONSTRAINT, 4.56d);
  191. cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(1.23d, 7.89d));
  192. assertEquals(4.56d, cp.getMin());
  193. }
  194. public void testGetMinSize() {
  195. // validate that getMinSize returns null if the property has no minSize constraint and no size constraint
  196. ConstrainedProperty cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  197. assertNull(cp.getMinSize());
  198. // validate that getMinSize returns the correct value when the minSize constraint is defined for the property (but no size constraint is defined)
  199. cp.applyConstraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT, 5);
  200. assertEquals(5, cp.getMinSize().intValue());
  201. // validate that getMinSize returns the correct value when the size constraint is defined for the property (but no minSize constraint is defined)
  202. cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  203. cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(10, 20));
  204. assertEquals(10, cp.getMinSize().intValue());
  205. // validate that getMinSize returns the maximum of the minSize constraint and the lower bound of the size constraint
  206. // 1) validate where the lower bound of the size constraint is greater than the minSize constraint
  207. cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  208. cp.applyConstraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT, 6);
  209. cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(11, 21));
  210. assertEquals(11, cp.getMinSize().intValue());
  211. // 2) validate where the minSize constraint is greater than the lower bound of the size constraint
  212. cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  213. cp.applyConstraint(ConstrainedProperty.MIN_SIZE_CONSTRAINT, 12);
  214. cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(9, 22));
  215. assertEquals(12, cp.getMinSize().intValue());
  216. }
  217. public void testGetMax() {
  218. // validate that getMax returns null if the property has no max constraint and no range constraint
  219. ConstrainedProperty cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  220. assertNull(cp.getMax());
  221. // validate that getMax returns the correct value when the max constraint is defined for the property (but no range constraint is defined)
  222. cp.applyConstraint(ConstrainedProperty.MAX_CONSTRAINT, 123.45d);
  223. assertEquals(123.45d, cp.getMax());
  224. // validate that getMax returns the correct value when the range constraint is defined for the property (but no max constraint is defined)
  225. cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  226. cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(123.45d, 678.9d));
  227. assertEquals(678.9d, cp.getMax());
  228. // validate that getMax returns the minimum of the max constraint and the upper bound of the range constraint
  229. // 1) validate where the upper bound of the range constraint is less than the max constraint
  230. cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  231. cp.applyConstraint(ConstrainedProperty.MAX_CONSTRAINT, 7.89d);
  232. cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(1.23d, 4.56d));
  233. assertEquals(4.56d, cp.getMax());
  234. // 2) validate where the max constraint is less than the upper bound of the range constraint
  235. cp = new ConstrainedProperty(TestClass.class, "testDouble", Double.class);
  236. cp.applyConstraint(ConstrainedProperty.MAX_CONSTRAINT, 4.56d);
  237. cp.applyConstraint(ConstrainedProperty.RANGE_CONSTRAINT, new ObjectRange(1.23d, 7.89d));
  238. assertEquals(4.56d, cp.getMax());
  239. }
  240. public void testGetMaxSize() {
  241. // validate that getMaxSize returns null if the property has no maxSize constraint and no size constraint
  242. ConstrainedProperty cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  243. assertNull(cp.getMaxSize());
  244. // validate that getMaxSize returns the correct value when the maxSize constraint is defined for the property (but no size constraint is defined)
  245. cp.applyConstraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT, 5);
  246. assertEquals(5, cp.getMaxSize().intValue());
  247. // validate that getMaxSize returns the correct value when the size constraint is defined for the property (but no maxSize constraint is defined)
  248. cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  249. cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(10, 20));
  250. assertEquals(20, cp.getMaxSize().intValue());
  251. // validate that getMaxSize returns the minimum of the maxSize constraint and the upper bound of the size constraint
  252. // 1) validate where the upper bound of the size constraint is less than the maxSize constraint
  253. cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  254. cp.applyConstraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT, 29);
  255. cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(11, 21));
  256. assertEquals(21, cp.getMaxSize().intValue());
  257. // 2) validate where the maxSize constraint is less than the upper bound of the size constraint
  258. cp = new ConstrainedProperty(getClass(), "testURL", String.class);
  259. cp.applyConstraint(ConstrainedProperty.MAX_SIZE_CONSTRAINT, 12);
  260. cp.applyConstraint(ConstrainedProperty.SIZE_CONSTRAINT, new IntRange(9, 22));
  261. assertEquals(12, cp.getMaxSize().intValue());
  262. }
  263. @SuppressWarnings("rawtypes")
  264. public void testConstraintBuilder() throws Exception {
  265. GroovyClassLoader gcl = new GroovyClassLoader();
  266. Class groovyClass = gcl.parseClass("class TestClass {\n" +
  267. "Long id\n" +
  268. "Long version\n" +
  269. "String login\n" +
  270. "String other\n" +
  271. "String email\n" +
  272. "static constraints = {\n" +
  273. "login(size:5..15,nullable:false,blank:false)\n" +
  274. "other(blank:false,size:5..15,nullable:false)\n" +
  275. "email(email:true)\n" +
  276. "}\n" +
  277. "}");
  278. GrailsDomainClass domainClass = new DefaultGrailsDomainClass(groovyClass);
  279. Map constrainedProperties = domainClass.getConstrainedProperties();
  280. assertTrue(constrainedProperties.size() == 3);
  281. ConstrainedProperty loginConstraint = (ConstrainedProperty)constrainedProperties.get("login");
  282. Collection appliedConstraints = loginConstraint.getAppliedConstraints();
  283. assertTrue(appliedConstraints.size() == 3);
  284. // Check the order of the constraints for the 'login' property...
  285. int index = 0;
  286. String[] constraintNames = new String[] { "size", "nullable", "blank" };
  287. for (Iterator iter = appliedConstraints.iterator(); iter.hasNext();) {
  288. Constraint c = (Constraint) iter.next();
  289. assertEquals(constraintNames[index], c.getName());
  290. index++;
  291. }
  292. // ...and for the 'other' property.
  293. appliedConstraints = ((ConstrainedProperty) constrainedProperties.get("other")).getAppliedConstraints();
  294. index = 0;
  295. constraintNames = new String[] { "blank", "size", "nullable" };
  296. for (Iterator iter = appliedConstraints.iterator(); iter.hasNext();) {
  297. Constraint c = (Constraint) iter.next();
  298. assertEquals(constraintNames[index], c.getName());
  299. index++;
  300. }
  301. ConstrainedProperty emailConstraint = (ConstrainedProperty)constrainedProperties.get("email");
  302. assertEquals(2,emailConstraint.getAppliedConstraints().size());
  303. GroovyObject go = (GroovyObject)groovyClass.newInstance();
  304. go.setProperty("email", "rubbish_email");
  305. Errors errors = new BindException(go, "TestClass");
  306. emailConstraint.validate(go, go.getProperty("email"), errors);
  307. assertTrue(errors.hasErrors());
  308. go.setProperty("email", "valid@email.com");
  309. errors = new BindException(go, "TestClass");
  310. emailConstraint.validate(go, go.getProperty("email"), errors);
  311. assertFalse(errors.hasErrors());
  312. }
  313. }