openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jrba...@apache.org
Subject svn commit: r952730 - in /openjpa/trunk: openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/ openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/ openjpa-persistence/src/main/j...
Date Tue, 08 Jun 2010 16:41:27 GMT
Author: jrbauer
Date: Tue Jun  8 16:41:27 2010
New Revision: 952730

URL: http://svn.apache.org/viewvc?rev=952730&view=rev
Log:
OPENJPA-1685 Updated ValidatorImpl to remove potential whitespace within a comma separated
list of validation groups.

Modified:
    openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationGroups.java
    openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidatorImpl.java

Modified: openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationGroups.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationGroups.java?rev=952730&r1=952729&r2=952730&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationGroups.java
(original)
+++ openjpa/trunk/openjpa-integration/validation/src/test/java/org/apache/openjpa/integration/validation/TestValidationGroups.java
Tue Jun  8 16:41:27 2010
@@ -122,7 +122,20 @@ public class TestValidationGroups extend
     }
     
     /**
-     * 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 extend
                 "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();
             

Modified: openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml?rev=952730&r1=952729&r2=952730&view=diff
==============================================================================
--- openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
(original)
+++ openjpa/trunk/openjpa-integration/validation/src/test/resources/org/apache/openjpa/integration/validation/persistence.xml
Tue Jun  8 16:41:27 2010
@@ -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>

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidatorImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidatorImpl.java?rev=952730&r1=952729&r2=952730&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidatorImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/validation/ValidatorImpl.java
Tue Jun  8 16:41:27 2010
@@ -30,6 +30,7 @@ import javax.validation.ConstraintViolat
 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 Abstr
             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);
                 }
             }            



Mime
View raw message