Skip to content

Commit

Permalink
BVTCK-124 Update TCK audit file to BV 2.0.0.Beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet authored and gunnarmorling committed May 19, 2017
1 parent 4e756e1 commit 03a6a54
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
Expand Up @@ -85,7 +85,7 @@ public void testTargetTypeIsClass() {

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "c")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "i")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "m")
public void testTargetedTypeIsField() {
assertEquals(
CustomConstraint.ValidatorForSubClassA.callCounter,
Expand All @@ -103,7 +103,7 @@ public void testTargetedTypeIsField() {

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "d")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "i")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "m")
public void testTargetedTypeIsGetter() {
assertEquals(
CustomConstraint.ValidatorForSubClassB.callCounter,
Expand All @@ -120,7 +120,7 @@ public void testTargetedTypeIsGetter() {
}

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "i")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "m")
public void testClassLevelValidatorForSubTypeHasPredenceOverValidatorForSuperClass() {
assertEquals(
CustomConstraint.ValidatorForAnotherSubClass.callCounter,
Expand All @@ -137,7 +137,7 @@ public void testClassLevelValidatorForSubTypeHasPredenceOverValidatorForSuperCla
}

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "e")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "i")
public void testResolutionOfMultipleSizeValidators() {
Suburb suburb = new Suburb();

Expand Down Expand Up @@ -209,7 +209,7 @@ public void testResolutionOfMultipleSizeValidators() {
}

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "e")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "i")
public void testResolutionOfMinMaxForDifferentTypes() {
MinMax minMax = new MinMax( "5", 5 );
Set<ConstraintViolation<MinMax>> constraintViolations = getValidator().validate( minMax );
Expand All @@ -227,7 +227,7 @@ public void testUnexpectedTypeInValidatorResolution() {
}

@Test(expectedExceptions = UnexpectedTypeException.class)
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "j")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "n")
@SpecAssertion(section = Sections.EXCEPTION_CONSTRAINTDECLARATION, id = "b")
public void testAmbiguousValidatorResolution() {
Foo foo = new Foo( new SerializableBarSubclass() );
Expand All @@ -236,7 +236,7 @@ public void testAmbiguousValidatorResolution() {
}

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "g")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "k")
public void testValidatorForWrapperTypeIsAppliedForPrimitiveType() {
PrimitiveHolder primitiveHolder = new PrimitiveHolder();
Set<ConstraintViolation<PrimitiveHolder>> violations = getValidator().validate( primitiveHolder );
Expand Down Expand Up @@ -317,7 +317,7 @@ public void testCrossParameterValidatorValidatingObject() throws Exception {
}

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "f")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "j")
public void testGenericValidatorIsUsedForConstraintTargetingMethodReturnValue() throws Exception {
Object object = new AnotherCalendarService();
Method method = AnotherCalendarService.class.getMethod( "createEvent", Date.class, Date.class );
Expand All @@ -329,14 +329,14 @@ public void testGenericValidatorIsUsedForConstraintTargetingMethodReturnValue()
}

@Test
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "f")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "j")
public void testGenericValidatorIsUsedForConstraintTargetingField() {
Set<ConstraintViolation<TestBean>> violations = getValidator().validate( new TestBean() );
assertCorrectConstraintViolationMessages( violations, "violation created by generic validator" );
}

@Test(expectedExceptions = UnexpectedTypeException.class)
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "j")
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "n")
public void testTwoValidatorsForSameTypeCauseUnexpectedTypeException() {
getValidator().validate( new AnotherBean() );
}
Expand Down
Expand Up @@ -87,7 +87,7 @@ public static WebArchive createTestArchive() {
// UnexpectedTypeException is a subclass of ValidationException
@SpecAssertions({
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_REQUIREMENTS, id = "a"),
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "h"),
@SpecAssertion(section = Sections.CONSTRAINTDECLARATIONVALIDATIONPROCESS_VALIDATIONROUTINE_TYPEVALIDATORRESOLUTION, id = "l"),
@SpecAssertion(section = Sections.CONSTRAINTMETADATA_VALIDATOR, id = "c")
})
public void testUnexpectedTypeException() {
Expand Down
36 changes: 24 additions & 12 deletions tests/src/main/resources/tck-audit.xml
Expand Up @@ -7,7 +7,7 @@
See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>.
-->
<!-- Generated by tck-audit.xsl at 2017-04-26 10:44 -->
<!-- Generated by tck-audit.xsl at 2017-05-18 11:18 -->
<specification xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:xalan="http://xml.apache.org/xslt" xmlns:exslt="http://exslt.org/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://jboss.com/products/weld/tck/audit" xsi:schemaLocation="http://jboss.com/products/weld/tck/audit" name="JSR-380: Bean Validation 2.0" version="2.0.0" id="beanvalidation" generateSectionIds="true">
<section id="introduction" title="Introduction" level="1">
<!-- 1 - INTRODUCTION -->
Expand Down Expand Up @@ -789,24 +789,36 @@
<text>If the constraint is hosted on a class attribute, the type of the attribute is the targeted type.</text>
</assertion>
<assertion id="d">
<text>If the constraint is hosted on a getter, the return type of the getter is the targeted type.</text>
<text>If the constraint is hosted on a method (getter or non-getter) or constructor, the return type is the targeted type.</text>
</assertion>
<assertion id="e">
<text>The ConstraintValidator chosen to validate the generic constraint on a declared type T is the one where the ConstraintValidator targets the annotated element, where the type supported by the ConstraintValidator is a supertype of T and where there is no other ConstraintValidator whose supported type is a supertype of T and not a supertype of the chosen ConstraintValidator supported type.</text>
<text>If the constraint is hosted on a method or constructor parameter, the parameter type is the targeted type.</text>
</assertion>
<assertion id="f">
<text>Only ConstraintValidator implementations targeting annotated elements are considered.</text>
<text>If the constraint is hosted on a type argument of a generic type (i.e. a container element constraint, see 5.5), the type argument's type is the targeted type.</text>
</assertion>
<assertion id="g">
<text>Primitive types are considered equivalent to their respective primitive wrapper class.</text>
<text>If the constraint is subject to implicit unwrapping (see 5.5.1) and the applicable value extractor is defined for a generic type (e.g. javafx.beans.value.ObservableValue), the targeted type is the type captured for the type parameter handled by the value extractor (e.g. String if the constraint is placed on a StringProperty).</text>
</assertion>
<assertion id="h">
<text>If no ConstraintValidator compliant with T is found among the ConstraintValidators listed by the constraint A, an UnexpectedTypeException is raised.</text>
<text>If the constraint is subject to implicit unwrapping and the applicable value extractor is defined for a non-generic type, the targeted type is the type defined by the extractor via @ExtractedValue#type() (e.g. Integer if the constraint is placed on a java.util.OptionalInt).</text>
</assertion>
<assertion id="i">
<text>A ConstraintValidator&lt;A, U&gt; compliant with T is considered strictly more specific than a ConstraintValidator&lt;A, V&gt; compliant with T if U is a strict subtype of V. U is a strict subtype of V if U is a subtype of V and U != V (according to the Java Language Specification 3rd edition chapter 4.10 Subtyping).</text>
<text>The ConstraintValidator chosen to validate the generic constraint on a declared type T is the one where the ConstraintValidator targets the annotated element, where the type supported by the ConstraintValidator is a supertype of T and where there is no other ConstraintValidator whose supported type is a supertype of T and not a supertype of the chosen ConstraintValidator supported type.</text>
</assertion>
<assertion id="j">
<text>Only ConstraintValidator implementations targeting annotated elements are considered.</text>
</assertion>
<assertion id="k">
<text>Primitive types are considered equivalent to their respective primitive wrapper class.</text>
</assertion>
<assertion id="l">
<text>If no ConstraintValidator compliant with T is found among the ConstraintValidators listed by the constraint A, an UnexpectedTypeException is raised.</text>
</assertion>
<assertion id="m">
<text>A ConstraintValidator&lt;A, U&gt; compliant with T is considered strictly more specific than a ConstraintValidator&lt;A, V&gt; compliant with T if U is a strict subtype of V. U is a strict subtype of V if U is a subtype of V and U != V (according to the Java Language Specification 3rd edition chapter 4.10 Subtyping).</text>
</assertion>
<assertion id="n">
<text>If more than one maximally specific ConstraintValidator is found, an UnexpectedTypeException is raised.</text>
</assertion>
</section>
Expand Down Expand Up @@ -1023,7 +1035,7 @@
<text>For all Iterable or Map, the following Node object added is marked as inIterable (isInIterable())</text>
</assertion>
<assertion id="ab">
<text>If the traversed object is of a container type (e.g. a List or Map), the following Node object added returns the type of the traversed container via getContainerClass() and the index of the type argument to which the constraint applies via `getTypeArgumentIndex()</text>
<text>If the traversed object is of a container type (e.g. a List or Map), the following Node object added returns the type of the traversed container via getContainerClass() and the index of the type argument to which the constraint applies via getTypeArgumentIndex()</text>
</assertion>
<assertion id="ac">
<text>For a property level constraint (field and getter) a PropertyNode object is added to Path whose name equals the name of the property (field name or Java Bean property name). The ElementKind of the node is ElementKind.PROPERTY. the property path is considered complete</text>
Expand Down Expand Up @@ -1068,9 +1080,9 @@
<text>For a container element constraint: a ContainerElementNode object is added to Path whose name is the node name produced by the corresponding value extractor (see 4). The ElementKind of the node is ElementKind.CONTAINER_ELEMENT. getContainerClass() returns the type of the container hosting the constraint. getTypeArgumentIndex() returns the index of the type argument hosting the constraint, if the element is stored in a generic container. the property path is considered complete</text>
</assertion>
<assertion id="aq">
<text>If additional path nodes are added in a constraint validator implementation using the node builder API (see 3.4), the following rules apply: if the default path ends with a BeanNode, this node is removed and the first added node (a PropertyNode) inherits its inIterable, key and index values. inIterable, key and index value must not be specified directly on this first node by the user. if the default path ends with a CrossParameterNode, this node is removed. then the additional nodes are appended to the (possibly amended) path generated by the Bean Validation engine as previously described: A PropertyNode is appended in case addPropertyNode(String) is invoked. The node name is equal to the name provided. The ElementKind of the node is ElementKind.PROPERTY. A BeanNode is appended in case addBeanNode() is invoked. The node name is null. The ElementKind of the node is ElementKind.BEAN. A ParameterNode is appended in case addParameterNode(int) is invoked. The node name is equal to the parameter name at the provided index. The name is determined by the current parameter name provider. The ElementKind of the node is ElementKind.PARAMETER. The previous node (removed) must be a CrossParameterNode. if inIterable() is invoked, the node returns true for isInIterable(), false otherwise. if atIndex(Integer) is invoked, the node returns the provided integer for getIndex(), null otherwise. if atKey(Object) is invoked, the node returns the provided object for getKey(), null otherwise.</text>
<text>If additional path nodes are added in a constraint validator implementation using the node builder API (see 3.4), the following rules apply: if the default path ends with a BeanNode, this node is removed and the first added node (a PropertyNode) inherits its inIterable, key and index values. inIterable, key and index value must not be specified directly on this first node by the user. if the default path ends with a CrossParameterNode, this node is removed. then the additional nodes are appended to the (possibly amended) path generated by the Bean Validation engine as previously described: A PropertyNode is appended in case addPropertyNode(String) is invoked. The node name is equal to the name provided. The ElementKind of the node is ElementKind.PROPERTY. A BeanNode is appended in case addBeanNode() is invoked. The node name is null. The ElementKind of the node is ElementKind.BEAN. A ParameterNode is appended in case addParameterNode(int) is invoked. The node name is equal to the parameter name at the provided index. The name is determined by the current parameter name provider. The ElementKind of the node is ElementKind.PARAMETER. The previous node (removed) must be a CrossParameterNode. A ContainerElementNode is appended in case addContainerElementNode(String, Class, Integer) is invoked. The name, container type and type argument index of the node are equal to the values provided. The ElementKind of the node is ElementKind.CONTAINER_ELEMENT. If inIterable() is invoked, the node returns true for isInIterable(), false otherwise. If inContainer(Class, Integer) is invoked, the node returns the passed container type and type argument index from getContainerClass() and getTypeArgumentIndex(), respectively. If atIndex(Integer) is invoked, the node returns the provided integer for getIndex(), null otherwise. If atKey(Object) is invoked, the node returns the provided object for getKey(), null otherwise.</text>
</assertion>
<assertion id="ax" testable="false">
<assertion id="az" testable="false">
<text>Bean Validation implementations should ensure that a ConstraintViolation implementation is Serializable provided that the root bean, the leaf bean, the invalid value and keys in the Path object are Serializable objects.</text>
</assertion>
</section>
Expand Down Expand Up @@ -2154,10 +2166,10 @@
<text>Similar to the Java EE integration via @Resource (see 11.2), a CDI container must support injection of built-in default ValidatorFactory and Validator beans via @Inject. These default beans are injectable via the @Default qualifier.</text>
</assertion>
</section>
<section id="integration-cdi-customconfiguration" title="ConstraintValidatorFactory, MessageInterpolator, ParameterNameProvider, ClockProvider and TraversableResolver" level="3">
<section id="integration-cdi-customconfiguration" title="ConstraintValidatorFactory, MessageInterpolator, ParameterNameProvider, ClockProvider, TraversableResolver and ValueExtractor" level="3">
<!-- 11.3.2 - INTEGRATION_CDI_CUSTOMCONFIGURATION -->
<assertion id="a">
<text>If a custom ConstraintValidatorFactory, MessageInterpolator, ParameterNameProvider, ClockProvider or TraversableResolver class is defined in the XML deployment descriptor (see 6.5.6), the ValidatorFactory must be configured with CDI managed beans representing the requested classes. Services like dependency injection, interception and decoration must thus be made available to these instances by the container.</text>
<text>If custom ConstraintValidatorFactory, MessageInterpolator, ParameterNameProvider, ClockProvider, TraversableResolver or ValueExtractor classes are defined in the XML deployment descriptor (see 6.5.6), the ValidatorFactory must be configured with CDI managed beans representing the requested classes. Services like dependency injection, interception and decoration must thus be made available to these instances by the container.</text>
</assertion>
<assertion id="b">
<text>If no custom ConstraintValidatorFactory is requested by the user, the ValidatorFactory must be configured with a custom ConstraintValidatorFactory instance that returns CDI managed beans representing the requested ConstraintValidator types. The factory creates non-contextual ConstraintValidator instances for each ConstraintValidatorFactory.getInstance() call. To inject dependencies into the ConstraintValidator instance, the CDI InjectionTarget API should be used. Before returning the instance the following calls should be made: InjectionTarget.produce(), InjectionTarget.inject() and InjectionTarget.postConstruct(). calls InjectionTarget.preDestroy() and InjectionTarget.dispose() upon ConstraintValidatorFactory.releaseInstance (see also 3.5 for more information about the lifecycle of a ConstraintValidator).</text>
Expand Down

0 comments on commit 03a6a54

Please sign in to comment.