Author: hardy.ferentschik
Date: 2009-06-04 05:18:14 -0400 (Thu, 04 Jun 2009)
New Revision: 16691
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Added test for default groups parameter
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -0,0 +1,25 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.constraints.invalidconstraintdefinitions;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@InvalidDefaultGroup
+public class DummyEntityInvalidDefaultGroup {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/DummyEntityInvalidDefaultGroup.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-04
09:17:14 UTC (rev 16690)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidConstraintDefinitionsTest.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -41,7 +41,7 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "2.1", id = "d"),
- @SpecAssertion(section = "2.1.1", id = "e"),
+ @SpecAssertion(section = "2.1.1", id = "b"),
@SpecAssertion(section = "8.2", id = "a")
})
public void testConstraintDefinitionWithParamterStartingWithValid() {
@@ -58,6 +58,23 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "2.1", id = "d"),
+ @SpecAssertion(section = "2.1.1", id = "c"),
+ @SpecAssertion(section = "8.2", id = "a")
+ })
+ public void testConstraintDefinitionWithoutMessageParameter() {
+ try {
+ Validator validator = TestUtil.getDefaultValidator();
+ validator.validate( new DummyEntityNoMessage() );
+ fail( "The used constraint does not define a message parameter. The validation
should have failed." );
+ }
+ catch ( ConstraintDefinitionException e ) {
+ // success
+ }
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "2.1", id = "d"),
@SpecAssertion(section = "2.1.1", id = "d"),
@SpecAssertion(section = "8.2", id = "a")
})
@@ -75,14 +92,14 @@
@Test
@SpecAssertions({
@SpecAssertion(section = "2.1", id = "d"),
- @SpecAssertion(section = "2.1.1", id = "c"),
+ @SpecAssertion(section = "2.1.1", id = "e"),
@SpecAssertion(section = "8.2", id = "a")
})
- public void testConstraintDefinitionWithoutMessageParameter() {
+ public void testConstraintDefinitionWithWrongDefaultGroupValue() {
try {
Validator validator = TestUtil.getDefaultValidator();
- validator.validate( new DummyEntityNoMessage() );
- fail( "The used constraint does not define a message parameter. The validation
should have failed." );
+ validator.validate( new DummyEntityInvalidDefaultGroup() );
+ fail( "The default groups paramter is not the empty array. The validation should
have failed." );
}
catch ( ConstraintDefinitionException e ) {
// success
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -0,0 +1,51 @@
+// $Id$
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2008, Red Hat Middleware LLC, and individual contributors
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.hibernate.jsr303.tck.tests.constraints.invalidconstraintdefinitions;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+import javax.validation.groups.Default;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Documented
+@Constraint(validatedBy = InvalidDefaultGroup.InvalidDefaultGroupValidator.class)
+@Target({ TYPE })
+@Retention(RUNTIME)
+public @interface InvalidDefaultGroup {
+ public abstract String message() default "default message";
+
+ public abstract Class<?>[] groups() default Default.class;
+
+ public class InvalidDefaultGroupValidator implements
ConstraintValidator<InvalidDefaultGroup, Object> {
+
+ public void initialize(InvalidDefaultGroup parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
+ return false;
+ }
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/InvalidDefaultGroup.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java 2009-06-04
09:17:14 UTC (rev 16690)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroups.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -23,14 +23,26 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
/**
* @author Hardy Ferentschik
*/
@Documented
-@Constraint(validatedBy = NoGroupsValidator.class)
+@Constraint(validatedBy = NoGroups.NoGroupsValidator.class)
@Target({ TYPE })
@Retention(RUNTIME)
public @interface NoGroups {
String message() default "default message";
+
+ public class NoGroupsValidator implements ConstraintValidator<NoGroups, Object> {
+
+ public void initialize(NoGroups parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
+ return false;
+ }
+ }
}
\ No newline at end of file
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java 2009-06-04
09:17:14 UTC (rev 16690)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoGroupsValidator.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -1,34 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.jsr303.tck.tests.constraints.invalidconstraintdefinitions;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NoGroupsValidator implements ConstraintValidator<NoGroups, Object> {
-
- public void initialize(NoGroups parameters) {
- }
-
- public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
- return false;
- }
-}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java 2009-06-04
09:17:14 UTC (rev 16690)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessage.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -23,14 +23,26 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
/**
* @author Hardy Ferentschik
*/
@Documented
-@Constraint(validatedBy = NoMessageValidator.class)
+@Constraint(validatedBy = NoMessage.NoMessageValidator.class)
@Target({ TYPE })
@Retention(RUNTIME)
public @interface NoMessage {
Class<?>[] groups() default { };
+
+ public class NoMessageValidator implements ConstraintValidator<NoMessage, Object>
{
+
+ public void initialize(NoMessage parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
+ return false;
+ }
+ }
}
\ No newline at end of file
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java 2009-06-04
09:17:14 UTC (rev 16690)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/NoMessageValidator.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -1,34 +0,0 @@
-// $Id$
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2008, Red Hat Middleware LLC, and individual contributors
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
http://www.apache.org/licenses/LICENSE-2.0
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package org.hibernate.jsr303.tck.tests.constraints.invalidconstraintdefinitions;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NoMessageValidator implements ConstraintValidator<NoMessage, Object>
{
-
- public void initialize(NoMessage parameters) {
- }
-
- public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
- return false;
- }
-}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java 2009-06-04
09:17:14 UTC (rev 16690)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/invalidconstraintdefinitions/ValidProperty.java 2009-06-04
09:18:14 UTC (rev 16691)
@@ -23,12 +23,14 @@
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Target;
import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
/**
* @author Hardy Ferentschik
*/
@Documented
-@Constraint(validatedBy = NoGroupsValidator.class)
+@Constraint(validatedBy = ValidProperty.ValidPropertyValidator.class)
@Target({ TYPE })
@Retention(RUNTIME)
public @interface ValidProperty {
@@ -37,4 +39,14 @@
Class<?>[] groups() default { };
int validLength() default 0;
+
+ public class ValidPropertyValidator implements ConstraintValidator<ValidProperty,
Object> {
+
+ public void initialize(ValidProperty parameters) {
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext
constraintValidatorContext) {
+ return false;
+ }
+ }
}
\ No newline at end of file
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04
09:17:14 UTC (rev 16690)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04
09:18:14 UTC (rev 16691)
@@ -43,7 +43,7 @@
constraint is applied to a JavaBean.</text>
</assertion>
<assertion id="b">
- <text>annotation elements starting with valid are not
allowed</text>
+ <text>Annotation elements starting with valid are not
allowed</text>
</assertion>
<assertion id="c">
<text>Every constraint annotation must define a message element of type
String</text>