-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HV-373 test for group conversions configured in xml
- Loading branch information
1 parent
1076981
commit 54a8cc7
Showing
9 changed files
with
221 additions
and
131 deletions.
There are no files selected for viewing
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
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
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
33 changes: 33 additions & 0 deletions
33
.../validator/test/internal/engine/groups/conversion/AnnotationBasedGroupConversionTest.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,33 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.validator.test.internal.engine.groups.conversion; | ||
|
||
import org.testng.annotations.BeforeMethod; | ||
|
||
import static org.hibernate.validator.testutil.ValidatorUtil.getValidator; | ||
|
||
/** | ||
* Integrative test for annotation based group conversion. | ||
* | ||
* @author Hardy Ferentschik | ||
*/ | ||
public class AnnotationBasedGroupConversionTest extends AbstractGroupConversionTest { | ||
@BeforeMethod | ||
public void setupValidator() { | ||
validator = getValidator(); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...bernate/validator/test/internal/engine/groups/conversion/XmlBasedGroupConversionTest.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,57 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, 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.validator.test.internal.engine.groups.conversion; | ||
|
||
import javax.validation.Configuration; | ||
import javax.validation.ValidatorFactory; | ||
|
||
import org.testng.annotations.BeforeMethod; | ||
|
||
import org.hibernate.validator.testutil.ValidatorUtil; | ||
|
||
/** | ||
* Integrative test for XML configured group conversion. | ||
* | ||
* @author Hardy Ferentschik | ||
*/ | ||
public class XmlBasedGroupConversionTest extends AbstractGroupConversionTest { | ||
@BeforeMethod | ||
public void setupValidator() { | ||
Configuration<?> configuration = ValidatorUtil.getConfiguration(); | ||
configuration.addMapping( | ||
XmlBasedGroupConversionTest.class.getResourceAsStream( | ||
"group-conversion-mapping.xml" | ||
) | ||
); | ||
ValidatorFactory validatorFactory = configuration.buildValidatorFactory(); | ||
validator = validatorFactory.getValidator(); | ||
} | ||
|
||
|
||
public void conversionFromSequenceCausesException() { | ||
Configuration<?> configuration = ValidatorUtil.getConfiguration(); | ||
configuration.addMapping( | ||
XmlBasedGroupConversionTest.class.getResourceAsStream( | ||
"invalid-group-conversion-mapping.xml" | ||
) | ||
); | ||
ValidatorFactory validatorFactory = configuration.buildValidatorFactory(); | ||
validator = validatorFactory.getValidator(); | ||
|
||
super.conversionFromSequenceCausesException(); | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
...al/engine/methodvalidation/IgnoreAnnotationConfiguredConstructorValidationViaXmlTest.java
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
...validator/test/internal/engine/methodvalidation/InvalidConstructorParameterInXmlTest.java
This file was deleted.
Oops, something went wrong.
107 changes: 107 additions & 0 deletions
107
...g/hibernate/validator/test/internal/engine/groups/conversion/group-conversion-mapping.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,107 @@ | ||
<constraint-mappings | ||
xmlns="http://jboss.org/xml/ns/javax/validation/mapping" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation= | ||
"http://jboss.org/xml/ns/javax/validation/mapping validation-mapping-1.1.xsd" version="1.1"> | ||
|
||
<default-package>org.hibernate.validator.test.internal.engine.groups.conversion</default-package> | ||
|
||
<bean class="AbstractGroupConversionTest$User1" ignore-annotations="true"> | ||
<field name="addresses"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicPostal"/> | ||
</field> | ||
</bean> | ||
|
||
<bean class="AbstractGroupConversionTest$User2" ignore-annotations="true"> | ||
<getter name="addresses"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicPostal"/> | ||
</getter> | ||
</bean> | ||
|
||
<bean class="AbstractGroupConversionTest$User3" ignore-annotations="true"> | ||
<getter name="addresses"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicPostal"/> | ||
<convert-group from="AbstractGroupConversionTest$Complete" to="AbstractGroupConversionTest$FullPostal"/> | ||
</getter> | ||
</bean> | ||
|
||
<bean class="AbstractGroupConversionTest$User4" ignore-annotations="true"> | ||
<getter name="addresses"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicPostal"/> | ||
<convert-group from="AbstractGroupConversionTest$Complete" to="AbstractGroupConversionTest$FullPostal"/> | ||
</getter> | ||
</bean> | ||
|
||
<bean class="AbstractGroupConversionTest$User5" ignore-annotations="true"> | ||
<getter name="addresses"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicPostal"/> | ||
</getter> | ||
<getter name="phoneNumber"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicNumber"/> | ||
</getter> | ||
</bean> | ||
|
||
<bean class="AbstractGroupConversionTest$User6" ignore-annotations="true"> | ||
<method name="setAddresses"> | ||
<parameter type="java.util.List"> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicPostal"/> | ||
</parameter> | ||
</method> | ||
</bean> | ||
|
||
<bean class="AbstractGroupConversionTest$User7" ignore-annotations="true"> | ||
<method name="findAddresses"> | ||
<return-value> | ||
<valid/> | ||
<convert-group from="javax.validation.groups.Default" to="AbstractGroupConversionTest$BasicPostal"/> | ||
</return-value> | ||
</method> | ||
</bean> | ||
|
||
<bean class="AbstractGroupConversionTest$Address" ignore-annotations="true"> | ||
<field name="street1"> | ||
<constraint annotation="javax.validation.constraints.NotNull"> | ||
<groups> | ||
<value>AbstractGroupConversionTest$BasicPostal</value> | ||
</groups> | ||
</constraint> | ||
</field> | ||
<field name="street2"> | ||
<constraint annotation="javax.validation.constraints.NotNull"> | ||
</constraint> | ||
</field> | ||
<field name="zipCode"> | ||
<constraint annotation="javax.validation.constraints.Size"> | ||
<groups> | ||
<value>AbstractGroupConversionTest$BasicPostal</value> | ||
</groups> | ||
<element name="min">3</element> | ||
</constraint> | ||
</field> | ||
<field name="doorCode"> | ||
<constraint annotation="javax.validation.constraints.Size"> | ||
<groups> | ||
<value>AbstractGroupConversionTest$FullPostal</value> | ||
</groups> | ||
<element name="max">2</element> | ||
</constraint> | ||
</field> | ||
</bean> | ||
<bean class="AbstractGroupConversionTest$PhoneNumber" ignore-annotations="true"> | ||
<field name="number"> | ||
<constraint annotation="javax.validation.constraints.NotNull"> | ||
<groups> | ||
<value>AbstractGroupConversionTest$BasicNumber</value> | ||
</groups> | ||
</constraint> | ||
</field> | ||
</bean> | ||
|
||
</constraint-mappings> |
Oops, something went wrong.