Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6e7394
commit 9ecaa56
Showing
7 changed files
with
281 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...ava/org/hibernate/beanvalidation/tck/tests/xmlconfiguration/groupconversion/ConvertA.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, 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.beanvalidation.tck.tests.xmlconfiguration.groupconversion; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
public interface ConvertA { | ||
} |
23 changes: 23 additions & 0 deletions
23
...ava/org/hibernate/beanvalidation/tck/tests/xmlconfiguration/groupconversion/ConvertB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, 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.beanvalidation.tck.tests.xmlconfiguration.groupconversion; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
public interface ConvertB { | ||
} |
23 changes: 23 additions & 0 deletions
23
...ava/org/hibernate/beanvalidation/tck/tests/xmlconfiguration/groupconversion/ConvertC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, 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.beanvalidation.tck.tests.xmlconfiguration.groupconversion; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
public interface ConvertC { | ||
} |
126 changes: 126 additions & 0 deletions
126
...ernate/beanvalidation/tck/tests/xmlconfiguration/groupconversion/GroupConversionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, 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.beanvalidation.tck.tests.xmlconfiguration.groupconversion; | ||
|
||
import java.util.List; | ||
import java.util.Set; | ||
import javax.validation.metadata.ConstructorDescriptor; | ||
import javax.validation.metadata.GroupConversionDescriptor; | ||
import javax.validation.metadata.MethodDescriptor; | ||
import javax.validation.metadata.ParameterDescriptor; | ||
import javax.validation.metadata.PropertyDescriptor; | ||
import javax.validation.metadata.ReturnValueDescriptor; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.testng.Arquillian; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.test.audit.annotations.SpecAssertion; | ||
import org.jboss.test.audit.annotations.SpecAssertions; | ||
import org.jboss.test.audit.annotations.SpecVersion; | ||
import org.testng.annotations.Test; | ||
|
||
import org.hibernate.beanvalidation.tck.util.TestUtil; | ||
import org.hibernate.beanvalidation.tck.util.shrinkwrap.WebArchiveBuilder; | ||
|
||
import static org.testng.Assert.assertNotNull; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
@SpecVersion(spec = "beanvalidation", version = "1.1.0") | ||
public class GroupConversionTest extends Arquillian { | ||
|
||
@Deployment | ||
public static WebArchive createTestArchive() { | ||
return new WebArchiveBuilder() | ||
.withTestClassPackage( GroupConversionTest.class ) | ||
.withValidationXml( "validation-GroupConversionTest.xml" ) | ||
.withResource( "GroupConversionTest.xml" ) | ||
.build(); | ||
} | ||
|
||
@Test | ||
@SpecAssertions({ | ||
@SpecAssertion(section = "8.1.1.7 ", id = "a"), | ||
@SpecAssertion(section = "8.1.1.7 ", id = "b") | ||
}) | ||
public void testGroupConversionsAppliedOnMethod() throws Exception { | ||
MethodDescriptor methodDescriptor = TestUtil.getMethodDescriptor( | ||
Groups.class, | ||
"convert", | ||
String.class | ||
); | ||
assertNotNull( methodDescriptor, "the specified method should be configured in xml" ); | ||
|
||
ReturnValueDescriptor returnValueDescriptor = methodDescriptor.getReturnValueDescriptor(); | ||
Set<GroupConversionDescriptor> groupConversionDescriptors = returnValueDescriptor.getGroupConversions(); | ||
assertTrue( groupConversionDescriptors.size() == 2 ); | ||
|
||
List<ParameterDescriptor> parameterDescriptors = methodDescriptor.getParameterDescriptors(); | ||
assertTrue( parameterDescriptors.size() == 1 ); | ||
|
||
ParameterDescriptor parameterDescriptor = parameterDescriptors.get( 0 ); | ||
groupConversionDescriptors = parameterDescriptor.getGroupConversions(); | ||
assertTrue( groupConversionDescriptors.size() == 1 ); | ||
} | ||
|
||
@Test | ||
@SpecAssertions({ | ||
@SpecAssertion(section = "8.1.1.7", id = "a"), | ||
@SpecAssertion(section = "8.1.1.7", id = "b") | ||
}) | ||
public void testGroupConversionsAppliedOnConstructor() throws Exception { | ||
ConstructorDescriptor constructorDescriptor = TestUtil.getConstructorDescriptor( | ||
Groups.class | ||
); | ||
assertNotNull( constructorDescriptor, "the specified constructor should be configured in xml" ); | ||
ReturnValueDescriptor returnValueDescriptor = constructorDescriptor.getReturnValueDescriptor(); | ||
Set<GroupConversionDescriptor> groupConversionDescriptors = returnValueDescriptor.getGroupConversions(); | ||
assertTrue( groupConversionDescriptors.size() == 1 ); | ||
} | ||
|
||
@Test | ||
@SpecAssertions({ | ||
@SpecAssertion(section = "8.1.1.7", id = "a"), | ||
@SpecAssertion(section = "8.1.1.7", id = "b") | ||
}) | ||
public void testGroupConversionsAppliedOnField() throws Exception { | ||
PropertyDescriptor propertyDescriptor = TestUtil.getPropertyDescriptor( | ||
Groups.class, "foo" | ||
); | ||
assertNotNull( propertyDescriptor, "the specified property should be configured in xml" ); | ||
|
||
Set<GroupConversionDescriptor> groupConversionDescriptors = propertyDescriptor.getGroupConversions(); | ||
assertTrue( groupConversionDescriptors.size() == 2 ); | ||
} | ||
|
||
@Test | ||
@SpecAssertions({ | ||
@SpecAssertion(section = "8.1.1.7", id = "a"), | ||
@SpecAssertion(section = "8.1.1.7", id = "b") | ||
}) | ||
public void testGroupConversionsAppliedOnGetter() throws Exception { | ||
PropertyDescriptor propertyDescriptor = TestUtil.getPropertyDescriptor( | ||
Groups.class, "snafu" | ||
); | ||
assertNotNull( propertyDescriptor, "the specified property should be configured in xml" ); | ||
|
||
Set<GroupConversionDescriptor> groupConversionDescriptors = propertyDescriptor.getGroupConversions(); | ||
assertTrue( groupConversionDescriptors.size() == 3 ); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
.../java/org/hibernate/beanvalidation/tck/tests/xmlconfiguration/groupconversion/Groups.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, 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.beanvalidation.tck.tests.xmlconfiguration.groupconversion; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
public class Groups { | ||
|
||
private String foo; | ||
|
||
private String snafu; | ||
|
||
public String getSnafu() { | ||
return snafu; | ||
} | ||
private String convert(String s) { | ||
return null; | ||
} | ||
} | ||
|
||
|
44 changes: 44 additions & 0 deletions
44
...bernate/beanvalidation/tck/tests/xmlconfiguration/groupconversion/GroupConversionTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<constraint-mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.1.xsd" | ||
xmlns="http://jboss.org/xml/ns/javax/validation/mapping" version="1.1"> | ||
<default-package>org.hibernate.beanvalidation.tck.tests.xmlconfiguration.groupconversion</default-package> | ||
<bean class="Groups"> | ||
|
||
<field name="foo"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="ConvertA"/> | ||
<convert-group from="org.hibernate.beanvalidation.tck.tests.xmlconfiguration.groupconversion.ConvertB" | ||
to="ConvertC"/> | ||
</field> | ||
|
||
<getter name="snafu"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="ConvertA"/> | ||
<convert-group from="ConvertA" to="ConvertB"/> | ||
<convert-group from="org.hibernate.beanvalidation.tck.tests.xmlconfiguration.groupconversion.ConvertB" | ||
to="ConvertC"/> | ||
</getter> | ||
|
||
<constructor> | ||
<return-value> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="ConvertA"/> | ||
</return-value> | ||
</constructor> | ||
|
||
<method name="convert"> | ||
<parameter type="java.lang.String"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="ConvertA"/> | ||
</parameter> | ||
<return-value> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" | ||
to="org.hibernate.beanvalidation.tck.tests.xmlconfiguration.groupconversion.ConvertB"/> | ||
<convert-group from="org.hibernate.beanvalidation.tck.tests.xmlconfiguration.groupconversion.ConvertB" | ||
to="ConvertC"/> | ||
</return-value> | ||
</method> | ||
</bean> | ||
</constraint-mappings> |
6 changes: 6 additions & 0 deletions
6
...nvalidation/tck/tests/xmlconfiguration/groupconversion/validation-GroupConversionTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<validation-config xmlns="http://jboss.org/xml/ns/javax/validation/configuration" | ||
xsi:schemaLocation="http://jboss.org/xml/ns/javax/validation/configuration validation-configuration-1.0.xsd" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<constraint-mapping>org/hibernate/beanvalidation/tck/tests/xmlconfiguration/groupconversion/GroupConversionTest.xml</constraint-mapping> | ||
</validation-config> |