Author: hardy.ferentschik
Date: 2009-06-16 10:18:22 -0400 (Tue, 16 Jun 2009)
New Revision: 16794
Added:
beanvalidation/trunk/validation-tck/src/main/java/First/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/
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/AddressWithInvalidGroupSequence.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Animal.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Auditable.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Author.java
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/Book.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/Car.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CreditCard.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence1.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence2.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultAlias.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictonary.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/First.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/Last.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/groups/Order.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Second.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/groups/ZipCodeCoherenceChecker.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/
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/Foo.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
Log:
added group tests from hibernat validator implementation.
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java
===================================================================
---
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-06-16
14:17:45 UTC (rev 16793)
+++
beanvalidation/trunk/validation-api/src/main/java/javax/validation/Validator.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -102,15 +102,18 @@
*/
BeanDescriptor getConstraintsForClass(Class<?> clazz);
- /**
+ /**
* Return an object of the specified type to allow access to the
* provider-specific API. If the Bean Validation provider
* implementation does not support the specified class, the
* ValidationException is thrown.
- * @param type the class of the object to be returned.
+ *
+ * @param type the class of the object to be returned.
+ *
* @return an instance of the specified class
+ *
* @throws ValidationException if the provider does not
- * support the call.
+ * support the call.
*/
public <T> T unwrap(Class<T> type);
}
Added:
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
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,64 @@
+package org.hibernate.jsr303.tck.tests.constraints.groups;
+
+import javax.validation.GroupSequence;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@GroupSequence({ Address.class, Address.HighLevelCoherence.class })
+@ZipCodeCoherenceChecker(groups = Address.HighLevelCoherence.class)
+public class Address {
+ @NotNull
+ @Size(max = 50)
+ private String street;
+
+ @NotNull
+ @Size(max = 5)
+ private String zipcode;
+
+ @NotNull
+ @Size(max = 30)
+ private String city;
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public String getZipcode() {
+ return zipcode;
+ }
+
+ public void setZipcode(String zipcode) {
+ this.zipcode = zipcode;
+ }
+
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+
+ /**
+ * Check conherence on the overall object
+ * Needs basic checking to be green first
+ */
+ public interface HighLevelCoherence {
+ }
+
+ /**
+ * Check both basic constraints and high level ones.
+ * High level constraints are not checked if basic constraints fail.
+ */
+ @GroupSequence(value = { Default.class, HighLevelCoherence.class })
+ public interface Complete {
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Address.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/AddressWithInvalidGroupSequence.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/AddressWithInvalidGroupSequence.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/AddressWithInvalidGroupSequence.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,12 @@
+package org.hibernate.jsr303.tck.tests.constraints.groups;
+
+import javax.validation.GroupSequence;
+import javax.validation.groups.Default;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@GroupSequence({ Default.class, AddressWithInvalidGroupSequence.HighLevelCoherence.class
})
+public class AddressWithInvalidGroupSequence extends Address {
+
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/AddressWithInvalidGroupSequence.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Animal.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Animal.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Animal.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,52 @@
+// $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 javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Animal {
+ public enum Domain {
+ PROKARYOTA, EUKARYOTA
+ }
+
+ @Size(min= 1, groups = { First.class, Second.class })
+ private String name;
+
+ @NotNull(groups = First.class)
+ private Domain domain;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Domain getDomain() {
+ return domain;
+ }
+
+ public void setDomain(Domain domain) {
+ this.domain = domain;
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Animal.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Auditable.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Auditable.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Auditable.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,37 @@
+// $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 javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Auditable {
+ @NotNull
+ String getCreationDate();
+
+ @NotNull
+ String getLastUpdate();
+
+ @NotNull
+ String getLastModifier();
+
+ @NotNull
+ String getLastReader();
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Auditable.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Author.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Author.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Author.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,59 @@
+// $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 javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Author {
+
+ @Size(min = 1, groups = Last.class)
+ private String firstName;
+
+ @Size(min = 1, groups = First.class)
+ private String lastName;
+
+ @Size(max = 20, groups = Last.class)
+ private String company;
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getCompany() {
+ return company;
+ }
+
+ public void setCompany(String company) {
+ this.company = company;
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Author.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
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
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,9 @@
+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
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Billable.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Book.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Book.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Book.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,67 @@
+// $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 javax.validation.GroupSequence;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Book {
+ @NotNull(groups = First.class)
+ @Size(min = 1, groups = First.class)
+ private String title;
+
+ @Size(max = 30, groups = Second.class)
+ private String subtitle;
+
+ @Valid
+ @NotNull(groups = First.class)
+ private Author author;
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getSubtitle() {
+ return subtitle;
+ }
+
+ public void setSubtitle(String subtitle) {
+ this.subtitle = subtitle;
+ }
+
+ public Author getAuthor() {
+ return author;
+ }
+
+ public void setAuthor(Author author) {
+ this.author = author;
+ }
+
+ @GroupSequence(value = { First.class, Second.class, Last.class })
+ public interface All {
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Book.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
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
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,11 @@
+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
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/BuyInOneClick.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Car.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Car.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Car.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,29 @@
+package org.hibernate.jsr303.tck.tests.constraints.groups;
+
+import javax.validation.GroupSequence;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+import javax.validation.groups.Default;
+
+/**
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+@GroupSequence({ Car.class, Car.Test.class })
+public class Car {
+ @Pattern(regexp = ".*", groups = Default.class)
+ @Size(min = 2, max = 20, groups = Car.Test.class)
+ private String type;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public interface Test {
+
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Car.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CreditCard.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CreditCard.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CreditCard.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,34 @@
+// $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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class CreditCard {
+
+ private String number;
+
+ public String getNumber() {
+ return number;
+ }
+
+ public void setNumber(String number) {
+ this.number = number;
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CreditCard.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,27 @@
+// $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 javax.validation.GroupSequence;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@GroupSequence(value = CyclicGroupSequence.class)
+public interface CyclicGroupSequence {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence1.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence1.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence1.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,27 @@
+// $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 javax.validation.GroupSequence;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@GroupSequence(value = CyclicGroupSequence2.class)
+public interface CyclicGroupSequence1 {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence1.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence2.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence2.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence2.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,27 @@
+// $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 javax.validation.GroupSequence;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@GroupSequence(value = CyclicGroupSequence1.class)
+public interface CyclicGroupSequence2 {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/CyclicGroupSequence2.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultAlias.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultAlias.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultAlias.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,24 @@
+// $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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface DefaultAlias {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/DefaultAlias.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictonary.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictonary.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictonary.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,56 @@
+// $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 javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Dictonary extends Book {
+ @NotNull(groups = Translate.class)
+ @Size(min = 1, groups = Translate.class)
+ private String translatesTo;
+
+ @NotNull(groups = Translate.class)
+ @Size(min = 1, groups = Translate.class)
+ private String translatesFrom;
+
+ public String getTranslatesTo() {
+ return translatesTo;
+ }
+
+ public void setTranslatesTo(String translatesTo) {
+ this.translatesTo = translatesTo;
+ }
+
+ public String getTranslatesFrom() {
+ return translatesFrom;
+ }
+
+ public void setTranslatesFrom(String translatesFrom) {
+ this.translatesFrom = translatesFrom;
+ }
+
+ /**
+ * Translator related constraints
+ */
+ public interface Translate {
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Dictonary.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/First.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/First.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/First.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,24 @@
+// $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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface First {
+}
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/First.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
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
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,414 @@
+// $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.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.ValidationException;
+import javax.validation.Validator;
+import javax.validation.groups.Default;
+import javax.validation.metadata.BeanDescriptor;
+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.testharness.AbstractTest;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.ArtifactType;
+import org.jboss.testharness.impl.packaging.Classes;
+
+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 GroupTest extends AbstractTest {
+
+ @Test
+ public void testGroups() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Author author = new Author();
+ author.setLastName( "" );
+ author.setFirstName( "" );
+ Book book = new Book();
+ book.setTitle( "" );
+ book.setAuthor( author );
+
+ Set<ConstraintViolation<Book>> constraintViolations = validator.validate(
+ book, First.class, Second.class, Last.class
+ );
+ assertEquals( constraintViolations.size(), 3, "Wrong number of constraints"
);
+
+ author.setFirstName( "Gavin" );
+ author.setLastName( "King" );
+
+ constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
+ ConstraintViolation constraintViolation = constraintViolations.iterator().next();
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
+ assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong
value" );
+ assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong
propertyName" );
+
+ book.setTitle( "Hibernate Persistence with JPA" );
+ book.setSubtitle( "Revised Edition of Hibernate in Action" );
+
+ constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
+ constraintViolation = constraintViolations.iterator().next();
+ assertEquals( "size must be between 0 and 30",
constraintViolation.getMessage(), "Wrong message" );
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
+ assertEquals( constraintViolation.getInvalidValue(), book.getSubtitle(), "Wrong
value" );
+ assertEquals( "subtitle", constraintViolation.getPropertyPath(), "Wrong
propertyName" );
+
+ book.setSubtitle( "Revised Edition" );
+ author.setCompany( "JBoss a divison of RedHat" );
+
+ constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
+ constraintViolation = constraintViolations.iterator().next();
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
+ assertEquals( "size must be between 0 and 20",
constraintViolation.getMessage() );
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
+ assertEquals( constraintViolation.getInvalidValue(), author.getCompany(), "Wrong
value" );
+ assertEquals( "author.company", constraintViolation.getPropertyPath(),
"Wrong propertyName" );
+
+ author.setCompany( "JBoss" );
+
+ constraintViolations = validator.validate( book, First.class, Second.class, Last.class
);
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints"
);
+ }
+
+ @Test
+ public void testGroupSequence() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Author author = new Author();
+ author.setLastName( "" );
+ author.setFirstName( "" );
+ Book book = new Book();
+ book.setAuthor( author );
+
+ Set<ConstraintViolation<Book>> constraintViolations = validator.validate(
book, Book.All.class );
+ assertEquals( constraintViolations.size(), 2, "Wrong number of constraints"
);
+
+ author.setFirstName( "Gavin" );
+ author.setLastName( "King" );
+
+ constraintViolations = validator.validate( book, Book.All.class );
+ ConstraintViolation constraintViolation = constraintViolations.iterator().next();
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
+ assertEquals( "may not be null", constraintViolation.getMessage(),
"Wrong message" );
+ assertEquals( constraintViolation.getRootBean(), book, "Wrong root entity"
);
+ assertEquals( constraintViolation.getInvalidValue(), book.getTitle(), "Wrong
value" );
+ assertEquals( "title", constraintViolation.getPropertyPath(), "Wrong
propertyName" );
+
+ book.setTitle( "Hibernate Persistence with JPA" );
+ book.setSubtitle( "Revised Edition of Hibernate in Action" );
+
+ constraintViolations = validator.validate( book, Book.All.class );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
+
+ book.setSubtitle( "Revised Edition" );
+ author.setCompany( "JBoss a divison of RedHat" );
+
+ constraintViolations = validator.validate( book, Book.All.class );
+ assertEquals( constraintViolations.size(), 1, "Wrong number of constraints"
);
+
+ author.setCompany( "JBoss" );
+
+ constraintViolations = validator.validate( book, Book.All.class );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints"
);
+ }
+
+ @Test
+ public void testGroupSequences() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Dictonary dictonary = new Dictonary();
+ dictonary.setTitle( "English - German" );
+ Author author = new Author();
+ author.setLastName( "-" );
+ author.setFirstName( "-" );
+ author.setCompany( "Langenscheidt Publ." );
+ dictonary.setAuthor( author );
+
+ Set<ConstraintViolation<Dictonary>> constraintViolations =
validator.validate( dictonary, DefaultAlias.class );
+ assertEquals( constraintViolations.size(), 0, "Wrong number of constraints"
);
+ }
+
+ @Test
+ public void testValidationFailureInMultipleGroups() {
+ Validator validator = TestUtil.getDefaultValidator();
+ Animal elepfant = new Animal();
+ elepfant.setName( "" );
+ elepfant.setDomain( Animal.Domain.EUKARYOTA );
+
+ Set<ConstraintViolation<Animal>> constraintViolations =
validator.validate(
+ elepfant, First.class, Second.class
+ );
+ assertEquals(
+ constraintViolations.size(),
+ 1,
+ "The should be two invalid constraints since the same propertyName gets
validated in both groups"
+ );
+ }
+
+ @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" );
+ user.setLastname( "Bar" );
+ user.setPhoneNumber( "+46 123-456" );
+
+ Validator validator = TestUtil.getDefaultValidator();
+
+ Set<ConstraintViolation<User>> constraintViolations = validator.validate(
+ user, BuyInOneClick.class, Optional.class
+ );
+ assertEquals(
+ constraintViolations.size(),
+ 2,
+ "There should be two violations against the implicit default group"
+ );
+
+ for ( ConstraintViolation<User> constraintViolation : constraintViolations ) {
+ if ( constraintViolation.getPropertyPath().equals( "defaultCreditCard" ) )
{
+ TestUtil.assertConstraintViolation(
+ constraintViolation,
+ User.class,
+ null,
+ "defaultCreditCard"
+ );
+ }
+ else if ( constraintViolation.getPropertyPath().equals( "phoneNumber" ) ) {
+ TestUtil.assertConstraintViolation(
+ constraintViolation,
+ User.class,
+ "+46 123-456",
+ "phoneNumber"
+ );
+ }
+ else {
+ fail( "Unexpected violation" );
+ }
+ }
+ }
+
+ /**
+ * HV-113
+ */
+ @Test
+ 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, "" );
+ }
+
+ /**
+ * 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." );
+
+ 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
+ violations = validator.validate( order, Auditable.class );
+ assertTrue( violations.size() == 4, "All 4 NotNull constraints on Auditable should
fail." );
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/GroupTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Last.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Last.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Last.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,24 @@
+// $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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Last {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Last.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
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
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,9 @@
+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
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Optional.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Order.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Order.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Order.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,54 @@
+// $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 javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Order implements Auditable {
+ private String creationDate;
+ private String lastUpdate;
+ private String lastModifier;
+ private String lastReader;
+ private String orderNumber;
+
+ public String getCreationDate() {
+ return this.creationDate;
+ }
+
+ public String getLastUpdate() {
+ return this.lastUpdate;
+ }
+
+ public String getLastModifier() {
+ return this.lastModifier;
+ }
+
+ public String getLastReader() {
+ return this.lastReader;
+ }
+
+ @NotNull
+ @Size(min = 10, max = 10)
+ public String getOrderNumber() {
+ return this.orderNumber;
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Order.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Second.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Second.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Second.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,24 @@
+// $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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public interface Second {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/Second.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
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
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,58 @@
+package org.hibernate.jsr303.tck.tests.constraints.groups;
+
+import javax.validation.GroupSequence;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.groups.Default;
+
+
+/**
+ * @author Emmanuel Bernard
+ * @author Hardy Ferentschik
+ */
+@GroupSequence({ User.class })
+public class User {
+ @NotNull
+ private String firstname;
+
+ @NotNull(groups = Default.class)
+ private String lastname;
+
+ @Pattern(regexp = "[0-9 -]?", groups = Optional.class)
+ private String phoneNumber;
+
+ @NotNull(groups = { Billable.class, BuyInOneClick.class })
+ private CreditCard defaultCreditCard;
+
+ public String getFirstname() {
+ return firstname;
+ }
+
+ public void setFirstname(String firstname) {
+ this.firstname = firstname;
+ }
+
+ public String getLastname() {
+ return lastname;
+ }
+
+ public void setLastname(String lastname) {
+ this.lastname = lastname;
+ }
+
+ public CreditCard getDefaultCreditCard() {
+ return defaultCreditCard;
+ }
+
+ public void setDefaultCreditCard(CreditCard defaultCreditCard) {
+ this.defaultCreditCard = defaultCreditCard;
+ }
+
+ public String getPhoneNumber() {
+ return phoneNumber;
+ }
+
+ public void setPhoneNumber(String phoneNumber) {
+ this.phoneNumber = phoneNumber;
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/User.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceChecker.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceChecker.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceChecker.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,22 @@
+package org.hibernate.jsr303.tck.tests.constraints.groups;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+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;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Target({ TYPE, ANNOTATION_TYPE })
+@Retention(RUNTIME)
+@Documented
+@Constraint(validatedBy = ZipCodeCoherenceValidator.class)
+public @interface ZipCodeCoherenceChecker {
+ public abstract String message() default
"{validator.zipCodeCoherenceChecker}";
+
+ public abstract Class<?>[] groups() default { };
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceChecker.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceValidator.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceValidator.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/groups/ZipCodeCoherenceValidator.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,34 @@
+// $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 javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ZipCodeCoherenceValidator implements
ConstraintValidator<ZipCodeCoherenceChecker, Address> {
+
+ public void initialize(ZipCodeCoherenceChecker parameters) {
+ }
+
+ public boolean isValid(Address value, 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/groups/ZipCodeCoherenceValidator.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/Bar.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,24 @@
+// $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;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Bar extends Foo {
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Bar.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/Foo.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Foo.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Foo.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,36 @@
+// $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 class Foo {
+ @NotNull
+ private String foo;
+
+ public String getFoo() {
+ return foo;
+ }
+
+ public void setFoo(String foo) {
+ this.foo = foo;
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/Foo.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/InheritanceTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java 2009-06-16
14:18:22 UTC (rev 16794)
@@ -0,0 +1,60 @@
+// $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
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/inheritance/InheritanceTest.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native