You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by cr...@apache.org on 2003/02/07 00:25:02 UTC

cvs commit: jakarta-commons/digester/src/test/org/apache/commons/digester Test9.xml CallMethodRuleTestCase.java

craigmcc    2003/02/06 15:25:01

  Modified:    digester/src/test/org/apache/commons/digester
                        CallMethodRuleTestCase.java
  Added:       digester/src/test/org/apache/commons/digester Test9.xml
  Log:
  Add a unit test to prove that Digester can be used successfully with
  the shortcut CallMethodRule that uses a zero argument count to indicate
  that the value should be taken from the body element.  (As expected,
  Digester already passes this).
  
  Revision  Changes    Path
  1.3       +22 -0     jakarta-commons/digester/src/test/org/apache/commons/digester/CallMethodRuleTestCase.java
  
  Index: CallMethodRuleTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/digester/src/test/org/apache/commons/digester/CallMethodRuleTestCase.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CallMethodRuleTestCase.java	2 Feb 2003 15:53:57 -0000	1.2
  +++ CallMethodRuleTestCase.java	6 Feb 2003 23:25:00 -0000	1.3
  @@ -170,6 +170,28 @@
   
   
       /**
  +     * Test method calls with the CallMethodRule reading from the element
  +     * body, with no CallParamMethod rules added.
  +     */
  +    public void testCallMethodOnly() throws Exception {
  +
  +        // Configure the digester as required
  +        digester.addObjectCreate("employee", Employee.class);
  +        digester.addCallMethod("employee/firstName", "setFirstName", 0);
  +        digester.addCallMethod("employee/lastName", "setLastName", 0);
  +
  +        // Parse our test input
  +        Employee employee = (Employee)
  +            digester.parse(getInputStream("Test9.xml"));
  +        assertNotNull("parsed an employee", employee);
  +
  +        // Validate that the property setters were called
  +        assertEquals("Set first name", "First Name", employee.getFirstName());
  +        assertEquals("Set last name", "Last Name", employee.getLastName());
  +    }
  +
  +
  +    /**
        * Test method calls with the CallMethodRule rule. It should be possible
        * to call any accessible method of the object on the top of the stack,
        * even methods with no arguments.
  
  
  
  1.1                  jakarta-commons/digester/src/test/org/apache/commons/digester/Test9.xml
  
  Index: Test9.xml
  ===================================================================
  <?xml version="1.0"?>
  <employee>
  <firstName>
  First Name
  </firstName>
  <lastName>
  Last Name
  </lastName>
  </employee>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org