Author: hardy.ferentschik
Date: 2009-06-18 10:23:51 -0400 (Thu, 18 Jun 2009)
New Revision: 16830
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java
Removed:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Started mapping group tests to audit file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/bootstrap/defaultprovider/BootstrapTest.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -1,4 +1,4 @@
-// $Id:$
+// $Id$
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
@@ -121,7 +121,6 @@
@Test
public void testCustomMessageInterpolatorViaConfiguration() {
- // create a configurtation with a custom message interpolator
Configuration<?> configuration = Validation.byDefaultProvider().configure();
configuration.messageInterpolator( new DummyMessageInterpolator() );
@@ -136,7 +135,6 @@
@SpecAssertion(section = "4.3.2", id = "b")
})
public void testCustomMessageInterpolatorViaValidatorContext() {
- // create a configurtation with a custom message interpolator
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
DummyMessageInterpolator dummyMessageInterpolator = new DummyMessageInterpolator();
Validator validator = factory.usingContext().messageInterpolator(
dummyMessageInterpolator ).getValidator();
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -11,16 +11,16 @@
@GroupSequence({ Address.class, Address.HighLevelCoherence.class })
@ZipCodeCoherenceChecker(groups = Address.HighLevelCoherence.class)
public class Address {
- @NotNull
- @Size(max = 50)
+ @NotNull(groups = Default.class)
+ @Size(max = 50, message = "Streetnames cannot have more than {max}
characters.")
private String street;
- @NotNull
- @Size(max = 5)
+ @NotNull(groups = Default.class)
+ @Size(max = 5, message = "Zipcode cannot have more than {max} characters.")
private String zipcode;
- @NotNull
- @Size(max = 30)
+ @NotNull(groups = Default.class)
+ @Size(max = 30, message = "City cannot have more than {max} characters.")
private String city;
public String getStreet() {
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -1,9 +0,0 @@
-package org.hibernate.jsr303.tck.tests.constraints.groups;
-
-/**
- * Validation group checking whether user is billable.
- *
- * @author Emmanuel Bernard
- */
-public interface Billable {
-}
\ No newline at end of file
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -1,11 +0,0 @@
-package org.hibernate.jsr303.tck.tests.constraints.groups;
-
-import javax.validation.groups.Default;
-
-/**
- * Customer can buy without being harrassed by the checking-out process.
- *
- * @author Emmanuel Bernard
- */
-public interface BuyInOneClick extends Default, Billable {
-}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
(from rev 16812,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultGroupRedefinitionTest.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -0,0 +1,174 @@
+// $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.groups;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * Tests for the group and group sequence feature.
+ *
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class DefaultGroupRedefinitionTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "3.4.3", id = "a")
+ public void testRedefiningDefaultGroup() {
+ Address address = new Address();
+ address.setStreet( "Guldmyntgatan" );
+ address.setCity( "Gothenborg" );
+
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<Address>> constraintViolations =
validator.validate( address );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should only be one violation for zipcode"
+ );
+
+ ConstraintViolation<Address> violation = constraintViolations.iterator().next();
+ TestUtil.assertConstraintViolation( violation, Address.class, null, "zipcode"
);
+
+ address.setZipcode( "41841" );
+
+ // now the second group in the re-defined default group causes an error
+ constraintViolations = validator.validate( address );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should only be one violation for zipcode"
+ );
+
+ violation = constraintViolations.iterator().next();
+ TestUtil.assertConstraintViolation( violation, Address.class, address, "" );
+ }
+
+ @Test(enabled = false)
+ @SpecAssertion(section = "3.4.3", id = "b")
+ public void testConstraintsHostedOnEntityZBelongToGroupZ() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Address.class );
+ assertTrue( beanDescriptor.isBeanConstrained() );
+
+ Address address = new Address();
+ Set<ConstraintViolation<Address>> violations = validator.validate( address
);
+ assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail."
);
+ assertAssertionType( violations );
+
+ violations = validator.validate( address, Default.class );
+ assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail."
);
+ assertAssertionType( violations );
+
+ violations = validator.validate( address, Address.class );
+ assertTrue( violations.size() == 3, "All 3 @NotNull constraints should fail."
);
+ assertAssertionType( violations );
+ }
+
+ @Test
+ public void testRedefiningDefaultGroup2() {
+ Car car = new Car();
+ car.setType( "A" );
+
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<Car>> constraintViolations = validator.validate(
car );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violations due to the re-defintion of the default
group"
+ );
+ assertEquals(
+ "size must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
+ );
+
+ constraintViolations = validator.validateProperty( car, "type" );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violations due to the re-defintion of the default
group"
+ );
+ assertEquals(
+ "size must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
+ );
+
+ constraintViolations = validator.validateValue( Car.class, "type",
"A" );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violations due to the re-defintion of the default
group"
+ );
+ assertEquals(
+ "size must be between 2 and 20",
+ constraintViolations.iterator().next().getMessage(),
+ "Wrong constraint"
+ );
+ }
+
+ @Test
+ public void testInvalidRedefinitionOfDefaultGroup() {
+ Address address = new AddressWithInvalidGroupSequence();
+ Validator validator = TestUtil.getDefaultValidator();
+ try {
+ validator.validate( address );
+ fail( "It shoud not be allowed to have Default.class in the group sequence of a
class." );
+ }
+ catch ( ValidationException e ) {
+ assertEquals(
+ "'Default.class' cannot appear in default group sequence list.",
e.getMessage(), "Wrong message"
+ );
+ }
+ }
+
+ private void assertAssertionType(Set<ConstraintViolation<Address>>
violations) {
+ for ( ConstraintViolation<Address> violation : violations ) {
+ // cast is required for JDK 5 - at least on Mac OS X
+ Annotation ann = (Annotation) violation.getConstraintDescriptor().getAnnotation();
+ assertEquals(
+ NotNull.class,
+ ann.annotationType(),
+ "Wrong assertion type"
+ );
+ }
+ }
+}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -19,24 +19,26 @@
import java.util.Set;
import javax.validation.ConstraintViolation;
-import javax.validation.ValidationException;
+import javax.validation.GroupDefinitionException;
import javax.validation.Validator;
import javax.validation.groups.Default;
import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.metadata.PropertyDescriptor;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-import org.testng.annotations.Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+import org.testng.annotations.Test;
import org.hibernate.jsr303.tck.util.TestUtil;
-
/**
* Tests for the group and group sequence feature.
*
@@ -47,6 +49,115 @@
public class GroupTest extends AbstractTest {
@Test
+ @SpecAssertion(section = "3.4", id = "a")
+ public void testConstraintWithNoExplicitlySpecifiedGroupBelongsToDefault() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertTrue( beanDescriptor.isBeanConstrained() );
+
+ PropertyDescriptor propDesc = beanDescriptor.getConstraintsForProperty(
"firstname" );
+ assertTrue( propDesc.getConstraintDescriptors().size() == 1 );
+
+ ConstraintDescriptor descriptor =
propDesc.getConstraintDescriptors().iterator().next();
+ assertTrue( descriptor.getGroups().size() == 1 );
+ assertEquals(
+ descriptor.getGroups().iterator().next(),
+ Default.class,
+ "Constraint should implicitly belong to the Default group."
+ );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4", id = "b"),
+ @SpecAssertion(section = "3.4", id = "d")
+ })
+ public void testValidateAgainstDifferentGroups() {
+ User user = new User();
+
+ // all fields per default null. Depending on the validation groups there should be a
different amount
+ // of constraint failures.
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
+ assertEquals(
+ constraintViolations.size(),
+ 2,
+ "There should be two violations against the implicit default group"
+ );
+
+ constraintViolations = validator.validate( user, Default.class );
+ assertEquals(
+ constraintViolations.size(),
+ 2,
+ "There should be two violations against the explicit defualt group"
+ );
+
+ constraintViolations = validator.validate( user, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "There should be one violation against Billable"
+ );
+
+ constraintViolations = validator.validate( user, Default.class, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "There should be 3 violation against Default and Billable"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "Three violations expected since BuyInOneClick extends Default and
Billable"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class,
User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "BuyInOneClick already contains all other groups. Adding Billable does not
change the number of violations"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class,
Default.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "BuyInOneClick already contains all other groups. Adding Default does not change
the number of violations"
+ );
+
+ constraintViolations = validator.validate( user, User.BuyInOneClick.class,
Default.class, User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 3,
+ "BuyInOneClick already contains all other groups. Adding Billable and Default
does not change the number of violations"
+ );
+
+ constraintViolations = validator.validate( user, User.Billable.class,
User.Billable.class );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "Adding the same group twice is still only leads to a single violation"
+ );
+ }
+
+ @Test
+ @SpecAssertion(section = "3.4", id = "c")
+ public void testConstraintCanBelongToMoreThanOneGroup() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( User.class );
+ assertTrue( beanDescriptor.isBeanConstrained() );
+
+ PropertyDescriptor propDesc = beanDescriptor.getConstraintsForProperty(
"defaultCreditCard" );
+ assertTrue( propDesc.getConstraintDescriptors().size() == 1 );
+
+ ConstraintDescriptor descriptor =
propDesc.getConstraintDescriptors().iterator().next();
+ assertTrue( descriptor.getGroups().size() == 2 );
+ }
+
+ @Test
public void testGroups() {
Validator validator = TestUtil.getDefaultValidator();
@@ -176,81 +287,6 @@
}
@Test
- public void testValidateAgainstDifferentGroups() {
- User user = new User();
-
- // all fields per default null. Depending on the validation groups there should be a
different amount
- // of constraint failures.
- Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<User>> constraintViolations = validator.validate(
user );
- assertEquals(
- constraintViolations.size(),
- 2,
- "There should be two violations against the implicit default group"
- );
-
- constraintViolations = validator.validate( user, Default.class );
- assertEquals(
- constraintViolations.size(),
- 2,
- "There should be two violations against the explicit defualt group"
- );
-
- constraintViolations = validator.validate( user, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violation against Billable"
- );
-
- constraintViolations = validator.validate( user, Default.class, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "There should be 3 violation against Default and Billable"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "Three violations expected since BuyInOneClick extends Default and
Billable"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class, Billable.class
);
- assertEquals(
- constraintViolations.size(),
- 3,
- "BuyInOneClick already contains all other groups. Adding Billable does not
change the number of violations"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "BuyInOneClick already contains all other groups. Adding Default does not change
the number of violations"
- );
-
- constraintViolations = validator.validate( user, BuyInOneClick.class, Default.class,
Billable.class );
- assertEquals(
- constraintViolations.size(),
- 3,
- "BuyInOneClick already contains all other groups. Adding Billable and Default
does not change the number of violations"
- );
-
- constraintViolations = validator.validate( user, Billable.class, Billable.class );
- assertEquals(
- constraintViolations.size(),
- 1,
- "Adding the same group twice is still only leads to a single violation"
- );
- }
-
- /**
- * HV-85
- */
- @Test
public void testGroupSequenceFollowedByGroup() {
User user = new User();
user.setFirstname( "Foo" );
@@ -260,7 +296,7 @@
Validator validator = TestUtil.getDefaultValidator();
Set<ConstraintViolation<User>> constraintViolations = validator.validate(
- user, BuyInOneClick.class, Optional.class
+ user, User.BuyInOneClick.class, User.Optional.class
);
assertEquals(
constraintViolations.size(),
@@ -291,124 +327,30 @@
}
}
- /**
- * HV-113
- */
@Test
- public void testRedefiningDefaultGroup() {
- Address address = new Address();
- address.setStreet( "Guldmyntgatan" );
- address.setCity( "Gothenborg" );
-
+ @SpecAssertion(section = "3.4.4", id = "a")
+ public void testImplicitGrouping() {
Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<Address>> constraintViolations =
validator.validate( address );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should only be one violation for zipcode"
- );
-
- ConstraintViolation<Address> violation = constraintViolations.iterator().next();
- TestUtil.assertConstraintViolation( violation, Address.class, null, "zipcode"
);
-
- address.setZipcode( "41841" );
-
- // now the second group in the re-defined default group causes an error
- constraintViolations = validator.validate( address );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should only be one violation for zipcode"
- );
-
- violation = constraintViolations.iterator().next();
- TestUtil.assertConstraintViolation( violation, Address.class, address, "" );
- }
-
- /**
- * HV-113
- */
- @Test
- public void testRedefiningDefaultGroup2() {
- Car car = new Car();
- car.setType( "A" );
-
- Validator validator = TestUtil.getDefaultValidator();
-
- Set<ConstraintViolation<Car>> constraintViolations = validator.validate(
car );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violations due to the re-defintion of the default
group"
- );
- assertEquals(
- "size must be between 2 and 20",
- constraintViolations.iterator().next().getMessage(),
- "Wrong constraint"
- );
-
- constraintViolations = validator.validateProperty( car, "type" );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violations due to the re-defintion of the default
group"
- );
- assertEquals(
- "size must be between 2 and 20",
- constraintViolations.iterator().next().getMessage(),
- "Wrong constraint"
- );
-
- constraintViolations = validator.validateValue( Car.class, "type",
"A" );
- assertEquals(
- constraintViolations.size(),
- 1,
- "There should be one violations due to the re-defintion of the default
group"
- );
- assertEquals(
- "size must be between 2 and 20",
- constraintViolations.iterator().next().getMessage(),
- "Wrong constraint"
- );
- }
-
- /**
- * HV-113
- */
- @Test
- public void testInvalidRedefinitionOfDefaultGroup() {
- Address address = new AddressWithInvalidGroupSequence();
- Validator validator = TestUtil.getDefaultValidator();
- try {
- validator.validate( address );
- fail( "It shoud not be allowed to have Default.class in the group sequence of a
class." );
- }
- catch ( ValidationException e ) {
- assertEquals(
- "'Default.class' cannot appear in default group sequence list.",
e.getMessage(), "Wrong message"
- );
- }
- }
-
- /**
- * HV-115
- */
- @Test
- public void testImplicitGroup() {
- Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertTrue( beanDescriptor.isBeanConstrained() );
- Set<PropertyDescriptor> constraintProperties =
beanDescriptor.getConstrainedProperties();
- assertTrue( constraintProperties.size() == 5, "Each of the properties should have
at least one constraint." );
-
+ // validating the Default Group should validate all 5 constraints
Order order = new Order();
Set<ConstraintViolation<Order>> violations = validator.validate( order );
assertTrue( violations.size() == 5, "All 5 NotNull constraints should fail."
);
- // use implicit group Auditable
+ // use implicit group Auditable - only the constraints defined on Auditable should be
validated
violations = validator.validate( order, Auditable.class );
assertTrue( violations.size() == 4, "All 4 NotNull constraints on Auditable should
fail." );
}
+
+ @Test(expectedExceptions = GroupDefinitionException.class)
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4.2", id = "e"),
+ @SpecAssertion(section = "8.4", id = "a")
+ })
+ public void testCyclicGroupSequence() {
+ Validator validator = TestUtil.getDefaultValidator();
+ validator.validate( new Order(), CyclicGroupSequence.class );
+ }
}
\ No newline at end of file
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -1,9 +0,0 @@
-package org.hibernate.jsr303.tck.tests.constraints.groups;
-
-/**
- * Validation group checking whether user is billable.
- *
- * @author Emmanuel Bernard
- */
-public interface Optional {
-}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -55,4 +55,13 @@
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
+
+ public interface BuyInOneClick extends Default, Billable {
+ }
+
+ public interface Billable {
+ }
+
+ public interface Optional {
+ }
}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -20,5 +20,9 @@
/**
* @author Hardy Ferentschik
*/
-public class Bar extends Foo {
+public class Bar extends Foo implements Fubar {
+
+ public String getFubar() {
+ return null;
+ }
}
\ No newline at end of file
Copied:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
(from rev 16812,
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java)
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -0,0 +1,80 @@
+// $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.inheritance;
+
+import java.lang.annotation.Annotation;
+import javax.validation.Validator;
+import javax.validation.constraints.NotNull;
+import javax.validation.metadata.BeanDescriptor;
+import javax.validation.metadata.PropertyDescriptor;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+import static org.testng.Assert.assertTrue;
+import org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class ConstraintInheritanceTest extends AbstractTest {
+
+ @Test
+ @SpecAssertion(section = "3.3", id = "b")
+ public void testConstraintsOnSuperClassAreInherited() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
+
+ String propertyName = "foo";
+ assertTrue( beanDescriptor.getConstraintsForProperty( propertyName ) != null );
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty(
propertyName );
+
+ // cast is required for JDK 5 - at least on Mac OS X
+ Annotation constraintAnnotation = ( Annotation )
propDescriptor.getConstraintDescriptors()
+ .iterator()
+ .next().getAnnotation();
+ assertTrue( constraintAnnotation.annotationType() == NotNull.class );
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.3", id = "a"),
+ @SpecAssertion(section = "3.3", id = "b")
+ })
+ public void testConstraintsOnInterfaceAreInherited() {
+ Validator validator = TestUtil.getDefaultValidator();
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
+
+ String propertyName = "fubar";
+ assertTrue( beanDescriptor.getConstraintsForProperty( propertyName ) != null );
+ PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty(
propertyName );
+
+ // cast is required for JDK 5 - at least on Mac OS X
+ Annotation constraintAnnotation = ( Annotation )
propDescriptor.getConstraintDescriptors()
+ .iterator()
+ .next().getAnnotation();
+ assertTrue( constraintAnnotation.annotationType() == NotNull.class );
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/ConstraintInheritanceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Fubar.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -0,0 +1,28 @@
+// $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.inheritance;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Fubar {
+ @NotNull
+ String getFubar();
+}
Deleted:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -1,60 +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.inheritance;
-
-import java.lang.annotation.Annotation;
-import javax.validation.Validator;
-import javax.validation.constraints.NotNull;
-import javax.validation.metadata.BeanDescriptor;
-import javax.validation.metadata.PropertyDescriptor;
-
-import org.jboss.testharness.AbstractTest;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.jboss.testharness.impl.packaging.ArtifactType;
-import org.jboss.testharness.impl.packaging.Classes;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
-import org.testng.annotations.Test;
-
-import org.hibernate.jsr303.tck.util.TestUtil;
-
-/**
- * @author Hardy Ferentschik
- */
-@Artifact(artifactType = ArtifactType.JSR303)
-(a)Classes(TestUtil.class)
-public class InheritanceTest extends AbstractTest {
-
- @Test
- public void testIsBeanConstrained() {
- Validator validator = TestUtil.getDefaultValidator();
- BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Bar.class );
-
- assertFalse( beanDescriptor.hasConstraints(), "There should be no direct
constraints on the specified bean." );
- assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted
" );
-
- assertTrue( beanDescriptor.getConstraintsForProperty( "foo" ) != null );
- PropertyDescriptor propDescriptor = beanDescriptor.getConstraintsForProperty(
"foo" );
- Annotation constraintAnnotation = ( Annotation )
propDescriptor.getConstraintDescriptors()
- .iterator()
- .next().getAnnotation();
- assertTrue(
- constraintAnnotation.annotationType() == NotNull.class
- );
- }
-}
\ No newline at end of file
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-18
00:29:12 UTC (rev 16829)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/validatorresolution/ValidatorResolutionTest.java 2009-06-18
14:23:51 UTC (rev 16830)
@@ -66,7 +66,8 @@
@Test
@SpecAssertions({
- @SpecAssertion(section = "3.5.3", id = "f")
+ @SpecAssertion(section = "3.5.3", id = "f"),
+ @SpecAssertion(section = "8.3", id = "b")
})
public void testAmbigiousValidatorResolution() {
Validator validator = TestUtil.getDefaultValidator();
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-18
00:29:12 UTC (rev 16829)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-18
14:23:51 UTC (rev 16830)
@@ -334,13 +334,13 @@
</section>
<section id="3.4.2" title="Group sequence ">
- <assertion id="a">
+ <assertion id="a" testable="false">
<text>By default, constraints are evaluated in no particular order and
this regardless
of which groups they belong to</text>
</assertion>
<assertion id="b">
<text>Each group in a group sequence must be processed sequentially in
the order defined
- by @GroupSequence.value when the group defined as a se- quence is
requested</text>
+ by @GroupSequence.value when the group defined as a sequence is
requested</text>
</assertion>
<assertion id="c">
<text>Note that a group member of a sequence can itself be composed of
several groups
@@ -379,7 +379,7 @@
</section>
<section id="3.4.3" title="Redefining the Default group for a
class">
<assertion id="a">
- <text>To redefine Default for a class, place a @GroupSequence
annotation on the class ;
+ <text>To redefine Default for a class, place a @GroupSequence
annotation on the class.
this sequence expresses the sequence of groups that does substitute
Default for this
class.</text>
</assertion>
@@ -400,7 +400,7 @@
<section id="3.4.4" title="Implicit grouping">
<assertion id="a">
<text>Every constraint hosted on an interface Z and part of the Default
group
- (implicitly or expli- citly) belongs to the group Z</text>
+ (implicitly or explicitly) belongs to the group Z</text>
</assertion>
</section>
<section id="3.5" title="Validation routine">