Author: hardy.ferentschik
Date: 2009-06-17 16:57:08 -0400 (Wed, 17 Jun 2009)
New Revision: 16824
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java
beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
Log:
Added @SpecAssertions
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java 2009-06-17
20:28:59 UTC (rev 16823)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Account.java 2009-06-17
20:57:08 UTC (rev 16824)
@@ -17,8 +17,6 @@
*/
package org.hibernate.jsr303.tck.tests.metadata;
-import javax.validation.Valid;
-
/**
* Class with no constraints but with a cascade @Valid annotation
*/
@@ -35,7 +33,6 @@
this.accountLogin = accountLogin;
}
- @Valid
public Customer getCustomer() {
return customer;
}
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-06-17
20:28:59 UTC (rev 16823)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/BeanDescriptorTest.java 2009-06-17
20:57:08 UTC (rev 16824)
@@ -18,10 +18,12 @@
package org.hibernate.jsr303.tck.tests.metadata;
import java.util.Set;
+import javax.validation.Validator;
import javax.validation.metadata.BeanDescriptor;
import javax.validation.metadata.PropertyDescriptor;
-import javax.validation.Validator;
+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;
@@ -44,26 +46,51 @@
public class BeanDescriptorTest extends AbstractTest {
@Test
- public void testIsBeanConstrained() {
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToValidAnnotation() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
// constraint via @Valid
assertFalse( beanDescriptor.hasConstraints(), "There should be no direct
constraints on the specified bean." );
assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due
to @valid " );
+ }
+ @Test
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToConstraintOnEntity() {
+ Validator validator = TestUtil.getDefaultValidator();
+
// constraint hosted on bean itself
- beanDescriptor = validator.getConstraintsForClass( Account.class );
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Account.class );
assertTrue( beanDescriptor.hasConstraints(), "There should be direct constraints
on the specified bean." );
assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due
to @valid" );
+ }
+ @Test
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToConstraintProperty() {
+ Validator validator = TestUtil.getDefaultValidator();
+
// constraint on bean property
- beanDescriptor = validator.getConstraintsForClass( Order.class );
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
assertFalse( beanDescriptor.hasConstraints(), "There should be no direct
constraints on the specified bean." );
assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due
to @NotNull" );
}
@Test
+ @SpecAssertion(section = "5.3", id = "a")
+ public void testIsBeanConstrainedDueToConstraintOnInterface() {
+ Validator validator = TestUtil.getDefaultValidator();
+
+ // constraint on implemented interface
+ BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Man.class );
+ assertFalse( beanDescriptor.hasConstraints(), "There should be no direct
constraints on the specified bean." );
+ assertTrue( beanDescriptor.isBeanConstrained(), "Bean should be constrainted due
to constraints on Person." );
+ }
+
+ @Test
+ @SpecAssertion(section = "5.3", id = "a")
public void testUnconstraintClass() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass(
UnconstraintEntity.class );
@@ -72,23 +99,21 @@
}
@Test
- public void testGetConstraintForExistingConstrainedProperty() {
+ @SpecAssertion(section = "5.3", id = "b")
+ public void testGetConstraintForConstrainedProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
"orderNumber" );
assertEquals(
propertyDescriptor.getConstraintDescriptors().size(), 1, "There should be one
constraint descriptor"
);
-
- beanDescriptor = validator.getConstraintsForClass( Customer.class );
- propertyDescriptor = beanDescriptor.getConstraintsForProperty( "orderList"
);
- assertEquals(
- propertyDescriptor.getConstraintDescriptors().size(), 0, "There should be no
constraint descriptors"
- );
- assertTrue( propertyDescriptor.isCascaded(), "The property should be
cascaded" );
}
@Test
+ @SpecAssertions({
+ @SpecAssertion(section = "5.3", id = "b"),
+ @SpecAssertion(section = "5.4", id = "a")
+ })
public void testGetConstraintForUnConstrainedProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Customer.class );
@@ -100,6 +125,7 @@
}
@Test
+ @SpecAssertion(section = "5.3", id = "b")
public void testGetConstraintsForNonExistingProperty() {
Validator validator = TestUtil.getDefaultValidator();
BeanDescriptor beanDescriptor = validator.getConstraintsForClass( Order.class );
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-17
20:28:59 UTC (rev 16823)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/ConstraintDescriptorTest.java 2009-06-17
20:57:08 UTC (rev 16824)
@@ -20,10 +20,11 @@
import java.lang.annotation.Annotation;
import java.util.Map;
import java.util.Set;
-import javax.validation.metadata.ConstraintDescriptor;
import javax.validation.constraints.NotNull;
import javax.validation.groups.Default;
+import javax.validation.metadata.ConstraintDescriptor;
+import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.testharness.AbstractTest;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
@@ -116,7 +117,8 @@
}
@Test
- public void testDefaultGroupIsReturned() {
+ @SpecAssertion(section = "5.5", id = "e")
+ public void testDefaultGroupIsReturnedIfNoGroupSpecifiedInDeclaration() {
ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class,
"orderNumber" );
Set<Class<?>> groups = descriptor.getGroups();
assertTrue( groups.size() == 1 );
@@ -132,7 +134,8 @@
// }
@Test
- public void testGetAttributes() {
+ @SpecAssertion(section = "5.5", id = "b")
+ public void testGetAttributesFromConstraintDescriptor() {
ConstraintDescriptor<?> descriptor = getConstraintDescriptor( Order.class,
"orderNumber" );
Map<String, Object> attributes = descriptor.getAttributes();
assertTrue( attributes.containsKey( "message" ) );
Added:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java
(rev 0)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java 2009-06-17
20:57:08 UTC (rev 16824)
@@ -0,0 +1,53 @@
+// $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.metadata;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class Man implements Person {
+
+ private String firstName;
+ private String middleName;
+ private String lastName;
+
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getMiddleName() {
+ return middleName;
+ }
+
+ public void setMiddleName(String middleName) {
+ this.middleName = middleName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+}
\ No newline at end of file
Property changes on:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/metadata/Man.java
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified:
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java
===================================================================
---
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java 2009-06-17
20:28:59 UTC (rev 16823)
+++
beanvalidation/trunk/validation-tck/src/main/java/org/hibernate/jsr303/tck/tests/validation/ValidatorImplTest.java 2009-06-17
20:57:08 UTC (rev 16824)
@@ -30,6 +30,7 @@
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactType;
import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.test.audit.annotations.SpecAssertion;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -132,6 +133,7 @@
}
@Test
+ @SpecAssertion(section = "5.1", id="a")
public void testBasicValidation() {
Validator validator = TestUtil.getDefaultValidator();
Modified: beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml
===================================================================
--- beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-17
20:28:59 UTC (rev 16823)
+++ beanvalidation/trunk/validation-tck/src/main/resources/tck-audit.xml 2009-06-17
20:57:08 UTC (rev 16824)
@@ -871,20 +871,20 @@
<section id="5.1" title="Validator">
<assertion id="a">
<text>If a constraint definition or declaration hosted by the requested
class (or any of
- it's superclasses and interfaces ac- cording to the constraint
propagation rules) is
+ it's superclasses and interfaces according to the constraint
propagation rules) is
invalid, a ValidationException is raised</text>
</assertion>
</section>
<section id="5.3" title="BeanDescriptor">
<assertion id="a">
<text>isBeanConstrained returns true if the given class (and
superclasses and
- interfaces) host at least one validation de- claration (either constraint
or @Valid
+ interfaces) host at least one validation declaration (either constraint
or @Valid
annotation)</text>
</assertion>
<assertion id="b">
<text>getConstraintsForProperty returns a PropertyDescriptor object
describing the
property level constraints (See Section 3.1.2). The property is uniquely
identified
- by its name as per the JavaBeans convention: field level and get- ter
level
+ by its name as per the JavaBeans convention: field level and getter
level
constraints of the given name are all returned</text>
</assertion>
</section>
@@ -900,7 +900,7 @@
</assertion>
<assertion id="b">
<text>getAttributes returns a map containing the annotation attribute
names as a key,
- and the annotation attribute val- ues as a value</text>
+ and the annotation attribute values as a value</text>
</assertion>
<assertion id="c">
<text>If ConstraintDescriptor represents a composing annotation (see
Section 2.3), the
@@ -910,7 +910,7 @@
<text>getGroups returns the groups the constraint is supposed to be
applied upon</text>
</assertion>
<assertion id="e">
- <text>If no group is set on the constraint de- claration, the Default
group is
+ <text>If no group is set on the constraint declaration, the Default
group is
returned</text>
</assertion>
<assertion id="f">