You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by tv...@apache.org on 2011/08/30 18:50:27 UTC

svn commit: r1163288 - in /turbine/fulcrum/trunk/intake: src/java/org/apache/fulcrum/intake/model/Group.java src/test/org/apache/fulcrum/intake/IntakeTest.java xdocs/changes.xml

Author: tv
Date: Tue Aug 30 16:50:26 2011
New Revision: 1163288

URL: http://svn.apache.org/viewvc?rev=1163288&view=rev
Log:
Groups were not initialized correctly from a parser. Added a test for this.

Modified:
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java
    turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
    turbine/fulcrum/trunk/intake/xdocs/changes.xml

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java?rev=1163288&r1=1163287&r2=1163288&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/model/Group.java Tue Aug 30 16:50:26 2011
@@ -181,6 +181,13 @@ public class Group
         {
             fieldsArray[i].init(pp);
         }
+        for (int i = fieldsArray.length - 1; i >= 0; i--)
+        {
+            if (fieldsArray[i].isSet() && !fieldsArray[i].isValidated())
+            {
+                fieldsArray[i].validate();
+            }
+        }
         return this;
     }
 
@@ -220,7 +227,7 @@ public class Group
                     }
                 }
             }
-            
+
             cls = cls.getSuperclass();
         }
 
@@ -397,11 +404,11 @@ public class Group
                         interfaceFields[i].setProperty(obj);
                     }
                 }
-            }            
+            }
 
             cls = cls.getSuperclass();
         }
-        
+
         log.debug("setProperties() finished");
     }
 
@@ -453,7 +460,7 @@ public class Group
                         }
                     }
                 }
-            }            
+            }
 
             cls = cls.getSuperclass();
         }
@@ -573,7 +580,7 @@ public class Group
     public static class GroupFactory
             extends BaseKeyedPoolableObjectFactory
     {
-        private AppData appData;
+        private final AppData appData;
 
         public GroupFactory(AppData appData)
         {

Modified: turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java?rev=1163288&r1=1163287&r2=1163288&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java (original)
+++ turbine/fulcrum/trunk/intake/src/test/org/apache/fulcrum/intake/IntakeTest.java Tue Aug 30 16:50:26 2011
@@ -50,7 +50,7 @@ public class IntakeTest extends BaseUnit
 
     /*
      * This looks strange to me. A test should not bother with explicit initialization.
-     * That's the task of the container. 
+     * That's the task of the container.
      */
     public void OFFtestFacadeNotConfigured() throws Exception
     {
@@ -81,22 +81,42 @@ public class IntakeTest extends BaseUnit
         IntakeService is = (IntakeService) this.resolve( IntakeService.class.getName() );
         Group group = is.getGroup("LoginIfcGroup");
         assertNotNull(group);
-        
+
         Field userNameField = group.get("Username");
-        
+
         ParserService ps = (ParserService) this.resolve( ParserService.class.getName() );
         ValueParser pp = ps.getParser(DefaultParameterParser.class);
-        
+
         pp.setString(userNameField.getKey(), "Joe");
         userNameField.init(pp);
         userNameField.validate();
-        
+
         LoginForm form = new LoginForm();
         group.setProperties(form);
-        
+
         assertEquals("User names should be equal", "Joe", form.getUsername());
     }
 
+    public void testParserInit() throws Exception
+    {
+        IntakeService is = (IntakeService) this.resolve( IntakeService.class.getName() );
+        Group group = is.getGroup("LoginGroup");
+        assertNotNull(group);
+
+        Field userNameField = group.get("Username");
+
+        ParserService ps = (ParserService) this.resolve( ParserService.class.getName() );
+        ValueParser pp = ps.getParser(DefaultParameterParser.class);
+
+        pp.setString("loginGroupKey_0loginUsernameKey", "Joe");
+        group.init(pp);
+
+        assertTrue("The field should be set", userNameField.isSet());
+        assertTrue("The field should be validated", userNameField.isValidated());
+        assertTrue("The field should be valid", userNameField.isValid());
+        assertEquals("The field should have the value Joe", "Joe", userNameField.getValue());
+    }
+
     public void testEmptyBooleanField() throws Exception
     {
         IntakeService is = (IntakeService) this.resolve( IntakeService.class.getName() );
@@ -132,7 +152,7 @@ public class IntakeTest extends BaseUnit
         assertTrue("The Default Validator of an intake Field type boolean should be BooleanValidator", (booleanField.getValidator() instanceof BooleanValidator));
         assertTrue("An intake Field type boolean, which is required, should be required", booleanField.isRequired());
     }
-    
+
     public void testInvalidNumberMessage() throws Exception // TRB-74
     {
         IntakeService is = (IntakeService) this.resolve( IntakeService.class.getName() );
@@ -148,7 +168,7 @@ public class IntakeTest extends BaseUnit
         {
             assertEquals("Invalid number message is wrong.", "Entry was not a valid Integer", ve.getMessage());
         }
-        
+
         Field longField = group.get("EmptyLongTestField");
         try
         {

Modified: turbine/fulcrum/trunk/intake/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/xdocs/changes.xml?rev=1163288&r1=1163287&r2=1163288&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/xdocs/changes.xml (original)
+++ turbine/fulcrum/trunk/intake/xdocs/changes.xml Tue Aug 30 16:50:26 2011
@@ -26,6 +26,9 @@
 
   <body>
      <release version="1.0.7-SNAPSHOT" date="in Subversion">
+      <action type="fix" dev="tv">
+        Groups were not initialized correctly from a parser.
+      </action>
      </release>
   	 <release version="1.0.6" date="2009-11-02">
       <action type="fix" dev="tv">