mirror of
https://github.com/apache/openjpa.git
synced 2025-02-20 17:05:15 +00:00
OPENJPA-1685 Updated ValidatorImpl to remove potential whitespace within a comma separated list of validation groups.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@952730 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c68f1de780
commit
9d33fe34b8
@ -122,7 +122,20 @@ public class TestValidationGroups extends PersistenceTestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* 2b) verify multiple/mixed validation groups
|
||||
* 2b1) verify multiple/mixed validation groups via persistence.xml
|
||||
* @param flush
|
||||
*/
|
||||
public void testPesistenceXMLMultipleValidationGroups() {
|
||||
|
||||
OpenJPAEntityManagerFactorySPI emf = (OpenJPAEntityManagerFactorySPI)
|
||||
OpenJPAPersistence.createEntityManagerFactory(
|
||||
"multi-validation-group-xml",
|
||||
"org/apache/openjpa/integration/validation/persistence.xml");
|
||||
assertNotNull(emf);
|
||||
verifyMultipleValidationGroups(emf);
|
||||
}
|
||||
/**
|
||||
* 2b2) verify multiple/mixed validation groups via properties
|
||||
* @param flush
|
||||
*/
|
||||
public void testMultipleValidationGroups() {
|
||||
@ -145,10 +158,14 @@ public class TestValidationGroups extends PersistenceTestCase {
|
||||
"org/apache/openjpa/integration/validation/persistence.xml",
|
||||
propMap);
|
||||
assertNotNull(emf);
|
||||
verifyMultipleValidationGroups(emf);
|
||||
}
|
||||
|
||||
private void verifyMultipleValidationGroups(OpenJPAEntityManagerFactorySPI emf) {
|
||||
// create EM
|
||||
OpenJPAEntityManager em = emf.createEntityManager();
|
||||
assertNotNull(em);
|
||||
|
||||
|
||||
try {
|
||||
MixedGrpEntity mge = new MixedGrpEntity();
|
||||
|
||||
|
@ -125,6 +125,23 @@
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
<persistence-unit name="multi-validation-group-xml">
|
||||
<class>org.apache.openjpa.integration.validation.MixedGrpEntity</class>
|
||||
<validation-mode>CALLBACK</validation-mode>
|
||||
<properties>
|
||||
<property name="openjpa.jdbc.SynchronizeMappings"
|
||||
value="buildSchema"/>
|
||||
<!-- OPENJPA-1685 Filter whitespace from group list -->
|
||||
<property name="javax.persistence.validation.group.pre-persist"
|
||||
value="org.apache.openjpa.integration.validation.ValGroup1,
|
||||
org.apache.openjpa.integration.validation.ValGroup2"/>
|
||||
<property name="javax.persistence.validation.group.pre-update"
|
||||
value=""/>
|
||||
<property name="javax.persistence.validation.group.pre-remove"
|
||||
value="org.apache.openjpa.integration.validation.ValGroup2 "/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
<persistence-unit name="ConstraintPU">
|
||||
<class>org.apache.openjpa.integration.validation.ConstraintNull</class>
|
||||
<class>org.apache.openjpa.integration.validation.ConstraintBoolean</class>
|
||||
|
@ -30,6 +30,7 @@ import javax.validation.ConstraintViolationException;
|
||||
import javax.validation.Validator;
|
||||
import javax.validation.ValidatorFactory;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.openjpa.conf.OpenJPAConfiguration;
|
||||
import org.apache.openjpa.event.LifecycleEvent;
|
||||
import org.apache.openjpa.lib.conf.Configuration;
|
||||
@ -219,10 +220,10 @@ public class ValidatorImpl extends AbstractValidator {
|
||||
vgGrp = new Class<?>[strClasses.length];
|
||||
for (int i = 0; i < strClasses.length; i++) {
|
||||
try {
|
||||
vgGrp[i] = Class.forName(strClasses[i]);
|
||||
vgGrp[i] = Class.forName(StringUtils.trim(strClasses[i]));
|
||||
} catch (Throwable t) {
|
||||
throw new IllegalArgumentException(
|
||||
_loc.get("invalid-validation-group", strClasses[i],
|
||||
_loc.get("invalid-validation-group", StringUtils.trim(strClasses[i]),
|
||||
vgName).getMessage(), t);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user