Hibernate SVN: r16704 - core/branches/Branch_3_2/doc/reference/en/modules.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2009-06-05 09:51:04 -0400 (Fri, 05 Jun 2009)
New Revision: 16704
Modified:
core/branches/Branch_3_2/doc/reference/en/modules/persistent_classes.xml
Log:
removed inadvertent DOCTYPE decl
Modified: core/branches/Branch_3_2/doc/reference/en/modules/persistent_classes.xml
===================================================================
--- core/branches/Branch_3_2/doc/reference/en/modules/persistent_classes.xml 2009-06-05 12:48:36 UTC (rev 16703)
+++ core/branches/Branch_3_2/doc/reference/en/modules/persistent_classes.xml 2009-06-05 13:51:04 UTC (rev 16704)
@@ -1,5 +1,3 @@
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
-
<chapter id="persistent-classes" revision="2">
<title>Persistent Classes</title>
15 years, 5 months
Hibernate SVN: r16703 - core/trunk/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-06-05 08:48:36 -0400 (Fri, 05 Jun 2009)
New Revision: 16703
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MultiTableTest.java
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java
Log:
HHH-3946 - Added missing 'open transactions' and fixed the assertion failure.
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MultiTableTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MultiTableTest.java 2009-06-05 12:25:08 UTC (rev 16702)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/MultiTableTest.java 2009-06-05 12:48:36 UTC (rev 16703)
@@ -609,6 +609,7 @@
s.close();
s = openSession();
+ s.beginTransaction();
s.delete( s.load(Lower.class, id) );
s.getTransaction().commit();
s.close();
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java 2009-06-05 12:25:08 UTC (rev 16702)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/ParentChildTest.java 2009-06-05 12:48:36 UTC (rev 16703)
@@ -82,6 +82,7 @@
s.close();
s = openSession();
+ s.beginTransaction();
s.replicate(baz, ReplicationMode.OVERWRITE);
// HHH-2378
SessionImpl x = (SessionImpl)s;
@@ -92,6 +93,7 @@
s.close();
s = openSession();
+ s.beginTransaction();
s.replicate(baz, ReplicationMode.IGNORE);
s.getTransaction().commit();
s.close();
@@ -1032,6 +1034,7 @@
if ( (getDialect() instanceof MySQLDialect) ) {
session.connection().setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
}
+ session.getTransaction().begin();
// First, prime the fixture session to think the entity does not exist
try {
15 years, 5 months
Hibernate SVN: r16702 - core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-06-05 08:25:08 -0400 (Fri, 05 Jun 2009)
New Revision: 16702
Modified:
core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
Log:
HHH-3939:
- not creating a join table when the association is not audited
Modified: core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java
===================================================================
--- core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-06-05 12:09:49 UTC (rev 16701)
+++ core/trunk/envers/src/main/java/org/hibernate/envers/configuration/metadata/AuditMetadataGenerator.java 2009-06-05 12:25:08 UTC (rev 16702)
@@ -164,6 +164,19 @@
}
}
+ private boolean checkPropertiesAudited(Iterator<Property> properties, ClassAuditingData auditingData) {
+ while (properties.hasNext()) {
+ Property property = properties.next();
+ String propertyName = property.getName();
+ PropertyAuditingData propertyAuditingData = auditingData.getPropertyAuditingData(propertyName);
+ if (propertyAuditingData == null) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
@SuppressWarnings({"unchecked"})
private void createJoins(PersistentClass pc, Element parent, ClassAuditingData auditingData) {
Iterator<Join> joins = pc.getJoinIterator();
@@ -174,6 +187,11 @@
while (joins.hasNext()) {
Join join = joins.next();
+ // Checking if all of the join properties are audited
+ if (!checkPropertiesAudited(join.getPropertyIterator(), auditingData)) {
+ continue;
+ }
+
// Determining the table name. If there is no entry in the dictionary, just constructing the table name
// as if it was an entity (by appending/prepending configured strings).
String originalTableName = join.getTable().getName();
@@ -210,8 +228,10 @@
Join join = joins.next();
Element joinElement = entitiesJoins.get(entityName).get(join);
- addProperties(joinElement, join.getPropertyIterator(), currentMapper, auditingData, entityName,
- xmlMappingData, firstPass);
+ if (joinElement != null) {
+ addProperties(joinElement, join.getPropertyIterator(), currentMapper, auditingData, entityName,
+ xmlMappingData, firstPass);
+ }
}
}
15 years, 5 months
Hibernate SVN: r16701 - core/trunk/testsuite/src/test/java/org/hibernate/test/legacy.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-06-05 08:09:49 -0400 (Fri, 05 Jun 2009)
New Revision: 16701
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
Log:
HHH-3946 - Added missing 'open transactions' and fixed the assertion failure.
Modified: core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java
===================================================================
--- core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java 2009-06-05 11:57:40 UTC (rev 16700)
+++ core/trunk/testsuite/src/test/java/org/hibernate/test/legacy/FooBarTest.java 2009-06-05 12:09:49 UTC (rev 16701)
@@ -3966,6 +3966,7 @@
s.disconnect();
s.reconnect();
+ s.beginTransaction();
s.delete(foo);
foo2.setFoo(null);
s.getTransaction().commit();
@@ -3973,6 +3974,7 @@
s.disconnect();
s.reconnect();
+ s.beginTransaction();
s.delete(foo2);
s.getTransaction().commit();
s.close();
@@ -4025,17 +4027,18 @@
List results = s.createQuery( "SELECT one FROM " + One.class.getName() + " one ORDER BY one.value ASC" ).list();
assertEquals( 2, results.size() );
assertEquals( "'a' isn't first element", "a", ( (One) results.get(0) ).getValue() );
- assertEquals( "'b' isn't second element", "b", ( (One) results.get(2) ).getValue() );
+ assertEquals( "'b' isn't second element", "b", ( (One) results.get(1) ).getValue() );
s.getTransaction().commit();
s.close();
s = openSession();
+ s.beginTransaction();
results = s.createQuery( "SELECT many.one FROM " + Many.class.getName() + " many ORDER BY many.one.value ASC, many.one.id" )
.list();
assertEquals( 2, results.size() );
assertEquals( 2, results.size() );
assertEquals( "'a' isn't first element", "a", ( (One) results.get(0) ).getValue() );
- assertEquals( "'b' isn't second element", "b", ( (One) results.get(2) ).getValue() );
+ assertEquals( "'b' isn't second element", "b", ( (One) results.get(1) ).getValue() );
s.getTransaction().commit();
s.close();
@@ -4248,6 +4251,7 @@
s.getTransaction().commit();
s.close();
s = openSession();
+ s.beginTransaction();
s.update(v, id);
s.update(v, id);
s.delete(v);
15 years, 5 months
Hibernate SVN: r16700 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-06-05 07:57:40 -0400 (Fri, 05 Jun 2009)
New Revision: 16700
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java
Log:
ANN-840 - Reverted, as we don't want to hide the existing bug
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2009-06-05 10:51:53 UTC (rev 16699)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2009-06-05 11:57:40 UTC (rev 16700)
@@ -5,11 +5,9 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
-import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -18,10 +16,10 @@
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
+import javax.persistence.ElementCollection;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;
-import org.hibernate.annotations.MapKey;
/**
* @author Emmanuel Bernard
@@ -81,7 +79,6 @@
@ElementCollection
@JoinTable(name = "ScorePerNickName", joinColumns = @JoinColumn(name = "BoyId"))
@Column(name = "score", nullable = false)
- @MapKey(columns=@Column( name = "mapkey", nullable=false ))
public Map<String, Integer> getScorePerNickName() {
return scorePerNickName;
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java 2009-06-05 10:51:53 UTC (rev 16699)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java 2009-06-05 11:57:40 UTC (rev 16700)
@@ -33,7 +33,7 @@
new HashMap<String, String>( 1 );
@ElementCollection
- @MapKey( columns = @Column( name = "language_code", nullable=false ) )
+ @MapKey( columns = @Column( name = "language_code" ) )
@Fetch( FetchMode.JOIN )
@Filter( name = "selectedLocale",
condition = " language_code = :param " )
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java 2009-06-05 10:51:53 UTC (rev 16699)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java 2009-06-05 11:57:40 UTC (rev 16700)
@@ -4,8 +4,6 @@
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
-
-import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -25,7 +23,7 @@
@GeneratedValue
private Integer id;
- @MapKey(type = @Type(type="integer"), columns=@Column( name = "mapkey", nullable=false ) )
+ @MapKey(type = @Type(type="integer") )
@ElementCollection
@Sort(type = SortType.NATURAL)
@Type(type = "float")
15 years, 5 months
Hibernate SVN: r16699 - core/branches/envers-hibernate-3.3.
by hibernate-commits@lists.jboss.org
Author: adamw
Date: 2009-06-05 06:51:53 -0400 (Fri, 05 Jun 2009)
New Revision: 16699
Modified:
core/branches/envers-hibernate-3.3/pom.xml
Log:
Updating the version
Modified: core/branches/envers-hibernate-3.3/pom.xml
===================================================================
--- core/branches/envers-hibernate-3.3/pom.xml 2009-06-04 18:27:00 UTC (rev 16698)
+++ core/branches/envers-hibernate-3.3/pom.xml 2009-06-05 10:51:53 UTC (rev 16699)
@@ -16,7 +16,7 @@
<name>Envers</name>
<description>Support for entity auditing</description>
- <version>1.2.0-hibernate-3.3</version>
+ <version>1.2.1-hibernate-3.3</version>
<build>
<plugins>
15 years, 6 months
Hibernate SVN: r16698 - core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement.
by hibernate-commits@lists.jboss.org
Author: jcosta(a)redhat.com
Date: 2009-06-04 14:27:00 -0400 (Thu, 04 Jun 2009)
New Revision: 16698
Modified:
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java
Log:
ANN-840 - Added explicit not-null in foreign keys, as workaround for JBPAPP-1071
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2009-06-04 15:00:42 UTC (rev 16697)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Boy.java 2009-06-04 18:27:00 UTC (rev 16698)
@@ -5,9 +5,11 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
+import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
@@ -16,10 +18,10 @@
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
-import javax.persistence.ElementCollection;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;
+import org.hibernate.annotations.MapKey;
/**
* @author Emmanuel Bernard
@@ -79,6 +81,7 @@
@ElementCollection
@JoinTable(name = "ScorePerNickName", joinColumns = @JoinColumn(name = "BoyId"))
@Column(name = "score", nullable = false)
+ @MapKey(columns=@Column( name = "mapkey", nullable=false ))
public Map<String, Integer> getScorePerNickName() {
return scorePerNickName;
}
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java 2009-06-04 15:00:42 UTC (rev 16697)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/LocalizedString.java 2009-06-04 18:27:00 UTC (rev 16698)
@@ -33,7 +33,7 @@
new HashMap<String, String>( 1 );
@ElementCollection
- @MapKey( columns = @Column( name = "language_code" ) )
+ @MapKey( columns = @Column( name = "language_code", nullable=false ) )
@Fetch( FetchMode.JOIN )
@Filter( name = "selectedLocale",
condition = " language_code = :param " )
Modified: core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java
===================================================================
--- core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java 2009-06-04 15:00:42 UTC (rev 16697)
+++ core/trunk/annotations/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java 2009-06-04 18:27:00 UTC (rev 16698)
@@ -4,6 +4,8 @@
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
+
+import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -23,7 +25,7 @@
@GeneratedValue
private Integer id;
- @MapKey(type = @Type(type="integer") )
+ @MapKey(type = @Type(type="integer"), columns=@Column( name = "mapkey", nullable=false ) )
@ElementCollection
@Sort(type = SortType.NATURAL)
@Type(type = "float")
15 years, 6 months
Hibernate SVN: r16697 - in validator/trunk/hibernate-validator-tck-runner/src/main: resources/META-INF and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-04 11:00:42 -0400 (Thu, 04 Jun 2009)
New Revision: 16697
Removed:
validator/trunk/hibernate-validator-tck-runner/src/main/java/org/
Modified:
validator/trunk/hibernate-validator-tck-runner/src/main/resources/META-INF/jboss-test-harness.properties
Log:
using the standalone container from the tck harness now
Modified: validator/trunk/hibernate-validator-tck-runner/src/main/resources/META-INF/jboss-test-harness.properties
===================================================================
--- validator/trunk/hibernate-validator-tck-runner/src/main/resources/META-INF/jboss-test-harness.properties 2009-06-04 15:00:05 UTC (rev 16696)
+++ validator/trunk/hibernate-validator-tck-runner/src/main/resources/META-INF/jboss-test-harness.properties 2009-06-04 15:00:42 UTC (rev 16697)
@@ -1,2 +1,2 @@
-org.jboss.testharness.spi.StandaloneContainers=org.hibernate.validation.test.StandaloneContainersImpl
+org.jboss.testharness.spi.StandaloneContainers=org.hibernate.jsr303.tck.util.StandaloneContainersImpl
org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.servlet.ServletTestLauncher
15 years, 6 months
Hibernate SVN: r16696 - beanvalidation/trunk/validation-api/src/main/java/javax/validation.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-04 11:00:05 -0400 (Thu, 04 Jun 2009)
New Revision: 16696
Modified:
beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
Log:
javadoc
Modified: beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java
===================================================================
--- beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-06-04 14:59:34 UTC (rev 16695)
+++ beanvalidation/trunk/validation-api/src/main/java/javax/validation/ConstraintDescriptor.java 2009-06-04 15:00:05 UTC (rev 16696)
@@ -41,7 +41,7 @@
/**
* The Set of groups the constraint is applied on.
- * If the constraint declares no group, the <code>Default</code>
+ * If the constraint declares no group, a set with only the <code>Default</code>
* group is returned.
*
* @return The groups the constraint is applied on.
15 years, 6 months
Hibernate SVN: r16695 - in beanvalidation/trunk/validation-tck/src: main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition and 5 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2009-06-04 10:59:34 -0400 (Thu, 04 Jun 2009)
New Revision: 16695
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Address.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchAddress.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanAddress.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcode.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcodeConstraintValidator.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValid.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/Person.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/StandaloneContainersImpl.java
Removed:
beanvalidation/trunk/validation-tck/src/test/java/org/hibernate/jsr303/tck/tests/StandaloneContainersImpl.java
beanvalidation/trunk/validation-tck/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
Modified:
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Added tests for constraint composistion; added a default implementation for the test harness standalone container
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Address.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Address.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/Address.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,73 @@
+// $Id: Address.java 16156 2009-03-13 09:46:38Z hardy.ferentschik $
+/*
+* 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.constraintcomposition;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Address {
+ @NotNull
+ @Size(max = 30)
+ private String addressline1;
+
+ @NotNull
+ @Size(max = 30)
+ private String addressline2;
+
+ private String zipCode;
+
+ private String city;
+
+ public String getAddressline1() {
+ return addressline1;
+ }
+
+ public void setAddressline1(String addressline1) {
+ this.addressline1 = addressline1;
+ }
+
+ public String getAddressline2() {
+ return addressline2;
+ }
+
+ public void setAddressline2(String addressline2) {
+ this.addressline2 = addressline2;
+ }
+
+ public String getZipCode() {
+ return zipCode;
+ }
+
+ public void setZipCode(String zipCode) {
+ this.zipCode = zipCode;
+ }
+
+ @Size(max = 30)
+ @NotNull
+ public String getCity() {
+ return city;
+ }
+
+ public void setCity(String city) {
+ this.city = city;
+ }
+}
+
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/ConstraintCompositionTest.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,130 @@
+// $Id: ConstraintCompositionTest.java 16249 2009-04-02 12:10:40Z hardy.ferentschik $
+/*
+* 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.constraintcomposition;
+
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+
+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.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertConstraintViolation;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+
+/**
+ * Tests for composing constraints.
+ *
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class ConstraintCompositionTest extends AbstractTest {
+
+ @Test
+ public void testComposition() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ FrenchAddress address = new FrenchAddress();
+ address.setAddressline1( "10 rue des Treuils" );
+ address.setAddressline2( "BP 12 " );
+ address.setCity( "Bordeaux" );
+ Set<ConstraintViolation<FrenchAddress>> constraintViolations = validator.validate( address );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ FrenchAddress.class,
+ null,
+ "zipCode"
+ );
+
+
+ address.setZipCode( "abc" );
+ constraintViolations = validator.validate( address );
+ assertCorrectNumberOfViolations( constraintViolations, 3 );
+ for ( ConstraintViolation<FrenchAddress> violation : constraintViolations ) {
+ assertConstraintViolation(
+ violation,
+ FrenchAddress.class,
+ "abc",
+ "zipCode"
+ );
+
+ }
+
+
+ address.setZipCode( "123" );
+ constraintViolations = validator.validate( address );
+ assertCorrectNumberOfViolations( constraintViolations, 2 );
+ for ( ConstraintViolation<FrenchAddress> violation : constraintViolations ) {
+ assertConstraintViolation(
+ violation,
+ FrenchAddress.class,
+ "123",
+ "zipCode"
+ );
+
+ }
+
+ address.setZipCode( "33023" );
+ constraintViolations = validator.validate( address );
+ assertCorrectNumberOfViolations( constraintViolations, 0 );
+ }
+
+ @Test
+ public void testNestedComposition() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ GermanAddress address = new GermanAddress();
+ address.setAddressline1( "Rathausstrasse 5" );
+ address.setAddressline2( "3ter Stock" );
+ address.setCity( "Karlsruhe" );
+ Set<ConstraintViolation<GermanAddress>> constraintViolations = validator.validate( address );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ GermanAddress.class,
+ null,
+ "zipCode"
+ );
+ }
+
+ @Test
+ public void testOnlySingleConstraintViolation() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ GermanAddress address = new GermanAddress();
+ address.setAddressline1( "Rathausstrasse 5" );
+ address.setAddressline2( "3ter Stock" );
+ address.setCity( "Karlsruhe" );
+ address.setZipCode( "abc" );
+ // actually three composing constraints fail, but due to @ReportAsSingleViolation only one will be reported.
+ Set<ConstraintViolation<GermanAddress>> constraintViolations = validator.validate( address );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ assertConstraintViolation(
+ constraintViolations.iterator().next(),
+ GermanAddress.class,
+ "abc",
+ "zipCode"
+ );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchAddress.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchAddress.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchAddress.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,29 @@
+// $Id: FrenchAddress.java 16156 2009-03-13 09:46:38Z hardy.ferentschik $
+/*
+* 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.constraintcomposition;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FrenchAddress extends Address {
+
+ @FrenchZipcode
+ public String getZipCode() {
+ return super.getZipCode();
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcode.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,60 @@
+// $Id: FrenchZipcode.java 16264 2009-04-06 15:10:53Z hardy.ferentschik $
+/*
+* 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.constraintcomposition;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.OverridesAttribute;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+@NotNull
+@Size
+// first pattern just duplicates the length of 5 characters, the second pattern is just to proof that parameters can be overridden.
+(a)Pattern.List({ @Pattern(regexp = "....."), @Pattern(regexp = "bar") })
+@Constraint(validatedBy = FrenchZipcodeConstraintValidator.class)
+@Documented
+@Target({ METHOD, FIELD, TYPE })
+@Retention(RUNTIME)
+public @interface FrenchZipcode {
+ String message() default "Wrong zipcode";
+
+ Class<?>[] groups() default { };
+
+ @OverridesAttribute.List({
+ @OverridesAttribute(constraint = Size.class, name = "min"),
+ @OverridesAttribute(constraint = Size.class, name = "max")
+ }) int size() default 5;
+
+ @OverridesAttribute(constraint = Size.class,
+ name = "message") String sizeMessage() default "A french zip code has a length of 5";
+
+
+ @OverridesAttribute(constraint = Pattern.class, name = "regexp", constraintIndex = 2) String regex() default "\\d*";
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/FrenchZipcodeConstraintValidator.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,34 @@
+// $Id: FrenchZipcodeConstraintValidator.java 15829 2009-01-29 05:20:27Z epbernard $
+/*
+* 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.constraintcomposition;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FrenchZipcodeConstraintValidator implements ConstraintValidator<FrenchZipcode, String> {
+
+ public void initialize(FrenchZipcode parameters) {
+ }
+
+ public boolean isValid(String object, ConstraintValidatorContext constraintValidatorContext) {
+ return true;
+ }
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanAddress.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanAddress.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanAddress.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,29 @@
+// $Id: GermanAddress.java 16156 2009-03-13 09:46:38Z hardy.ferentschik $
+/*
+* 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.constraintcomposition;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class GermanAddress extends Address {
+
+ @GermanZipcode
+ public String getZipCode() {
+ return super.getZipCode();
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcode.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcode.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcode.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,45 @@
+// $Id: GermanZipcode.java 15875 2009-02-03 23:25:10Z epbernard $
+/*
+* 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.constraintcomposition;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.ReportAsSingleViolation;
+
+/**
+ * Constraint used to test nested composing constraints.
+ *
+ * @author Hardy Ferentschik
+ */
+@FrenchZipcode
+@Constraint(validatedBy = GermanZipcodeConstraintValidator.class)
+@Documented
+@Target({ METHOD, FIELD, TYPE })
+@Retention(RUNTIME)
+@ReportAsSingleViolation
+public @interface GermanZipcode {
+ public abstract String message() default "Falsche Postnummer.";
+
+ public abstract Class<?>[] groups() default { };
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcodeConstraintValidator.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcodeConstraintValidator.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintcomposition/GermanZipcodeConstraintValidator.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,34 @@
+// $Id: GermanZipcodeConstraintValidator.java 15829 2009-01-29 05:20:27Z epbernard $
+/*
+* 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.constraintcomposition;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class GermanZipcodeConstraintValidator implements ConstraintValidator<GermanZipcode, String> {
+
+ public void initialize(GermanZipcode parameters) {
+ }
+
+ public boolean isValid(String object, ConstraintValidatorContext constraintValidatorContext) {
+ return true;
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValid.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValid.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValid.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,57 @@
+// $Id: ValidProperty.java 16691 2009-06-04 09:18:14Z hardy.ferentschik $
+/*
+* 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.constraintdefinition;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Documented
+@Constraint(validatedBy = AlwaysValid.StaticConstraintValidator.class)
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+public @interface AlwaysValid {
+ public abstract String message() default "default message";
+
+ public abstract Class<?>[] groups() default { };
+
+ public abstract boolean alwaysValid();
+
+ public class StaticConstraintValidator implements ConstraintValidator<AlwaysValid, Object> {
+
+ boolean valid;
+
+ public void initialize(AlwaysValid parameters) {
+ valid = parameters.alwaysValid();
+ }
+
+ public boolean isValid(Object object, ConstraintValidatorContext constraintValidatorContext) {
+ return valid;
+ }
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/AlwaysValidList.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -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.constraintdefinition;
+
+import java.lang.annotation.Documented;
+import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Target({ METHOD, FIELD, ANNOTATION_TYPE })
+@Retention(RUNTIME)
+@Documented
+ @interface AlwaysValidList {
+ AlwaysValid[] value();
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/ConstraintDefinitionsTest.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,85 @@
+// $Id: InvalidConstraintDefinitionsTest.java 16693 2009-06-04 10:59:42Z hardy.ferentschik $
+/*
+* 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.constraintdefinition;
+
+import java.util.Set;
+import javax.validation.ConstraintDescriptor;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validator;
+import javax.validation.groups.Default;
+
+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 org.testng.annotations.Test;
+
+import org.hibernate.jsr303.tck.util.TestUtil;
+import static org.hibernate.jsr303.tck.util.TestUtil.assertCorrectNumberOfViolations;
+
+/**
+ * @author Hardy Ferentschik
+ */
+@Artifact(artifactType = ArtifactType.JSR303)
+(a)Classes(TestUtil.class)
+public class ConstraintDefinitionsTest extends AbstractTest {
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "2.1.1", id = "a"),
+ @SpecAssertion(section = "2.2", id = "a")
+ })
+ public void testConstraintWithCustomAttributes() {
+
+ Validator validator = TestUtil.getDefaultValidator();
+ Set<ConstraintDescriptor<?>> descriptors = validator.getConstraintsForClass( Person.class )
+ .getConstraintsForProperty( "lastName" )
+ .getConstraintDescriptors();
+
+ assertEquals( descriptors.size(), 2, "There should be two constraints on the lastName property." );
+ for ( ConstraintDescriptor<?> descriptor : descriptors ) {
+ assertEquals(
+ descriptor.getAnnotation().annotationType().getName(),
+ AlwaysValid.class.getName(),
+ "Wrong annotation type."
+ );
+ }
+
+ Set<ConstraintViolation<Person>> constraintViolations = validator.validate( new Person( "John", "Doe" ) );
+ assertCorrectNumberOfViolations( constraintViolations, 1 );
+ }
+
+ @Test
+ @SpecAssertion(section = "2.1.1", id = "f")
+ public void testDefaultGroupAssumedWhenNoGroupsSpecified() {
+
+ Validator validator = TestUtil.getDefaultValidator();
+ ConstraintDescriptor<?> descriptor = validator.getConstraintsForClass( Person.class )
+ .getConstraintsForProperty( "firstName" )
+ .getConstraintDescriptors()
+ .iterator()
+ .next();
+
+ Set<Class<?>> groups = descriptor.getGroups();
+ assertEquals( groups.size(), 1, "The group set should only contain one entry." );
+ assertEquals( groups.iterator().next(), Default.class, "The Default group should be returned." );
+ }
+}
\ No newline at end of file
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/Person.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/Person.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/constraints/constraintdefinition/Person.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,40 @@
+// $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.constraintdefinition;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Person {
+ @NotNull
+ private String firstName;
+
+ // a little bit of a catch 22 here
+ @AlwaysValidList({
+ @AlwaysValid(alwaysValid = true),
+ @AlwaysValid(alwaysValid = false)
+ })
+ private String lastName;
+
+ public Person(String firstName, String lastName) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+}
Added: beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/StandaloneContainersImpl.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/StandaloneContainersImpl.java (rev 0)
+++ beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/util/StandaloneContainersImpl.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -0,0 +1,107 @@
+// $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.util;
+
+import java.io.BufferedInputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.jboss.testharness.api.DeploymentException;
+import org.jboss.testharness.spi.StandaloneContainers;
+
+
+public class StandaloneContainersImpl implements StandaloneContainers {
+
+ public void deploy(Iterable<Class<?>> classes) throws DeploymentException {
+ }
+
+ public void undeploy() {
+ }
+
+ public void setup() {
+ }
+
+ public void cleanup() {
+ }
+
+ public void deploy(Iterable<Class<?>> classes, Iterable<URL> validationXmls) throws DeploymentException {
+ if ( validationXmls == null || !validationXmls.iterator().hasNext() ) {
+ Thread.currentThread()
+ .setContextClassLoader( new IgnoringValidationXmlClassLoader() );
+ return;
+ }
+
+ URL validationXmlUrl = validationXmls.iterator().next();
+ Thread.currentThread()
+ .setContextClassLoader( new CustomValidationXmlClassLoader( validationXmlUrl.getPath() ) );
+ }
+
+
+ private static class CustomValidationXmlClassLoader extends ClassLoader {
+ private final String customValidationXmlPath;
+
+ CustomValidationXmlClassLoader(String pathToCustomValidationXml) {
+ super( CustomValidationXmlClassLoader.class.getClassLoader() );
+ customValidationXmlPath = pathToCustomValidationXml;
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ InputStream in;
+ if ( "META-INF/validation.xml".equals( path ) ) {
+ if ( customValidationXmlPath.contains( ".jar!" ) ) {
+ path = customValidationXmlPath.substring( customValidationXmlPath.indexOf( "!" ) + 2 );
+ in = super.getResourceAsStream( path );
+ }
+ else {
+ in = loadFromDisk();
+ }
+ }
+ else {
+ in = super.getResourceAsStream( path );
+ }
+ return in;
+ }
+
+ private InputStream loadFromDisk() {
+ InputStream in;
+ try {
+ in = new BufferedInputStream( new FileInputStream( customValidationXmlPath ) );
+ }
+ catch ( IOException ioe ) {
+ String msg = "Unble to load " + customValidationXmlPath + " from disk";
+ throw new RuntimeException( msg );
+ }
+ return in;
+ }
+ }
+
+ private static class IgnoringValidationXmlClassLoader extends ClassLoader {
+ IgnoringValidationXmlClassLoader() {
+ super( IgnoringValidationXmlClassLoader.class.getClassLoader() );
+ }
+
+ public InputStream getResourceAsStream(String path) {
+ if ( "META-INF/validation.xml".equals( path ) ) {
+ return null;
+ }
+ return super.getResourceAsStream( path );
+ }
+ }
+}
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04 11:00:14 UTC (rev 16694)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-04 14:59:34 UTC (rev 16695)
@@ -55,7 +55,7 @@
</assertion>
<assertion id="f">
<text>If no group is specified when declaring the constraint on an element, the Default
- group is considered declared. </text>
+ group is considered declared.</text>
</assertion>
</section>
@@ -73,11 +73,11 @@
</section>
<section id="2.3" title="Constraint composition">
<assertion id="a">
- <text>Each constraint annotation hosted on a constraint an- notation is applied to the
+ <text>Each constraint annotation hosted on a constraint annotation is applied to the
target element and this recursively</text>
</assertion>
<assertion id="b">
- <text>Note that the main annotation and its constraint valid- ation implementation is
+ <text>Note that the main annotation and its constraint validation implementation is
also applied</text>
</assertion>
<assertion id="c">
@@ -504,7 +504,7 @@
</assertion>
<assertion id="e">
<text>If no ConstraintValidator compliant with T is found amongst the
- ConstraintValidators listed by the con- straint A, a UnexpectedTypeException is
+ ConstraintValidators listed by the constraint A, a UnexpectedTypeException is
raised</text>
</assertion>
<assertion id="f">
@@ -1167,7 +1167,7 @@
</assertion>
<assertion id="c">
<text>If set to true, the list of ConstraintValidators described in XML are concatenated
- to the list of Con- straintValidator described on the annotation to form a new array
+ to the list of ConstraintValidator described on the annotation to form a new array
of ConstraintValidator evaluated</text>
</assertion>
<assertion id="d">
Deleted: beanvalidation/trunk/validation-tck/src/test/java/org/hibernate/jsr303/tck/tests/StandaloneContainersImpl.java
===================================================================
--- beanvalidation/trunk/validation-tck/src/test/java/org/hibernate/jsr303/tck/tests/StandaloneContainersImpl.java 2009-06-04 11:00:14 UTC (rev 16694)
+++ beanvalidation/trunk/validation-tck/src/test/java/org/hibernate/jsr303/tck/tests/StandaloneContainersImpl.java 2009-06-04 14:59:34 UTC (rev 16695)
@@ -1,40 +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;
-
-import java.net.URL;
-
-import org.jboss.testharness.api.DeploymentException;
-import org.jboss.testharness.spi.StandaloneContainers;
-
-public class StandaloneContainersImpl implements StandaloneContainers {
- public void deploy(Iterable<Class<?>> classes) throws DeploymentException {
- }
-
- public void undeploy() {
- }
-
- public void setup() {
- }
-
- public void cleanup() {
- }
-
- public void deploy(Iterable<Class<?>> classes, Iterable<URL> beansXmls) throws DeploymentException {
- }
-}
Deleted: beanvalidation/trunk/validation-tck/src/test/resources/org/jboss/testharness/impl/packaging/jsr299/default/beans.xml
===================================================================
15 years, 6 months