cmlenz      2003/06/09 05:34:26

  Modified:    integration/ant/src/test/org/apache/cactus/integration/ant
                        AntTestCase.java
  Log:
  Add assertion method assertTargetExecuted(targetName)
  
  Revision  Changes    Path
  1.6       +23 -2     
jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/AntTestCase.java
  
  Index: AntTestCase.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/AntTestCase.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AntTestCase.java  26 May 2003 13:27:18 -0000      1.5
  +++ AntTestCase.java  9 Jun 2003 12:34:26 -0000       1.6
  @@ -61,7 +61,9 @@
   import java.io.IOException;
   import java.io.StringReader;
   import java.util.HashMap;
  +import java.util.HashSet;
   import java.util.Map;
  +import java.util.Set;
   
   import junit.framework.AssertionFailedError;
   import junit.framework.TestCase;
  @@ -96,10 +98,17 @@
       private String buildFile;
   
       /**
  -     * Buffer containing all messages logged by Ant. 
  +     * Buffer containing all messages logged by Ant. Keys correspond to the 
  +     * message priority as <code>java.lang.Integer</code>, the values are are
  +     * <code>java.lang.StringBuffer</code>s containing the actual log messages.
        */
       private Map log = new HashMap();
   
  +    /**
  +     * The targets the have been executed.
  +     */
  +    private Set executedTargets = new HashSet();
  +
       // Constructors ------------------------------------------------------------
   
       /**
  @@ -140,6 +149,7 @@
        */
       public void targetFinished(BuildEvent theEvent)
       {
  +        this.executedTargets.add(theEvent.getTarget().getName());
       }
   
       /**
  @@ -269,6 +279,17 @@
           }
           throw new AssertionFailedError(
               "Expected log message containing '" + theSubstring + "'");
  +    }
  +
  +    /**
  +     * Asserts that a named target has been executed.
  +     * 
  +     * @param theName The name of the target
  +     */
  +    protected void assertTargetExecuted(String theName)
  +    {
  +        assertTrue("Target '" + theName + "' should have been executed",
  +            this.executedTargets.contains(theName));
       }
   
       /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to