ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/types FilterSetTest.java
Date Fri, 27 Sep 2002 09:30:38 GMT
bodewig     2002/09/27 02:30:38

  Modified:    .        WHATSNEW
               docs/manual/CoreTypes filterset.html
               src/etc/testcases/types filterset.xml
               src/main/org/apache/tools/ant/types FilterSet.java
               src/testcases/org/apache/tools/ant/types FilterSetTest.java
  Log:
  filtersets that are nested into filersets don't work as the code tries
  to access nested elements before they have been configured.
  
  PR: 9056
  
  Revision  Changes    Path
  1.294     +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.293
  retrieving revision 1.294
  diff -u -r1.293 -r1.294
  --- WHATSNEW	27 Sep 2002 08:18:51 -0000	1.293
  +++ WHATSNEW	27 Sep 2002 09:30:37 -0000	1.294
  @@ -42,6 +42,8 @@
   
   * <property environment=... /> now works on OS/400.
   
  +* <filterset> nested into <filterset>s didn't work.
  +
   Other changes:
   --------------
   
  
  
  
  1.11      +8 -3      jakarta-ant/docs/manual/CoreTypes/filterset.html
  
  Index: filterset.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/CoreTypes/filterset.html,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- filterset.html	26 Sep 2002 16:21:23 -0000	1.10
  +++ filterset.html	27 Sep 2002 09:30:37 -0000	1.11
  @@ -14,9 +14,14 @@
   feature or at the same level as <CODE>&lt;target&gt;</CODE> - i.e.,
as
   children of 
   <CODE>&lt;project&gt;</CODE>.</P>
  -<P>FilterSets support the <code>id</code> and <code>refid</code>
attributes.
  -You can define a FilterSet with an <code>id</code> attribute and then refer
  -to that definition from another FilterSet with a <code>refid</code> attribute.
  +
  +<p>FilterSets support the <code>id</code> and <code>refid</code>
  +attributes.  You can define a FilterSet with an <code>id</code>
  +attribute and then refer to that definition from another FilterSet
  +with a <code>refid</code> attribute.  It is also possible to nest
  +filtersets into filtersets to get a set union of the contained
  +filters.</p>
  +
   <p>In addition, FilterSets can specify
   <code>begintoken</code> and/or 
   <code>endtoken</code> attributes to define what to match.</p>
  
  
  
  1.5       +17 -0     jakarta-ant/src/etc/testcases/types/filterset.xml
  
  Index: filterset.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/etc/testcases/types/filterset.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- filterset.xml	6 Nov 2001 13:21:43 -0000	1.4
  +++ filterset.xml	27 Sep 2002 09:30:37 -0000	1.5
  @@ -31,6 +31,23 @@
       </copy>
     </target>
     
  +  <target name="test-nested-filtersets">
  +    <filterset id="1">
  +      <filter token="token1" value="value1"/>
  +    </filterset>
  +    <filterset id="2">
  +      <filterset refid="testset.one"/>
  +    </filterset>
  +    <filterset id="3">
  +      <filterset id="4">
  +        <filter token="token4" value="value4"/>
  +      </filterset>
  +    </filterset>
  +    <filterset id="5">
  +      <filterset refid="1"/>
  +    </filterset>
  +  </target>
  +
     <target name="cleanup">
       <delete file="dest1.txt" quiet="true" />
       <delete file="dest2.txt" quiet="true" />
  
  
  
  1.16      +1 -1      jakarta-ant/src/main/org/apache/tools/ant/types/FilterSet.java
  
  Index: FilterSet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/FilterSet.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- FilterSet.java	25 Jul 2002 15:21:21 -0000	1.15
  +++ FilterSet.java	27 Sep 2002 09:30:37 -0000	1.16
  @@ -467,7 +467,7 @@
       *
       * @param filterSet the filterset to be added to this filterset
       */
  -    public void addFilterSet(FilterSet filterSet) {
  +    public void addConfiguredFilterSet(FilterSet filterSet) {
           if (isReference()) {
               throw noChildrenAllowed();
           }
  
  
  
  1.8       +26 -2     jakarta-ant/src/testcases/org/apache/tools/ant/types/FilterSetTest.java
  
  Index: FilterSetTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/FilterSetTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FilterSetTest.java	12 Jun 2002 14:54:41 -0000	1.7
  +++ FilterSetTest.java	27 Sep 2002 09:30:38 -0000	1.8
  @@ -62,6 +62,7 @@
   import junit.framework.AssertionFailedError;
   
   import java.io.*;
  +import java.util.Hashtable;
   
   /**
    * FilterSet testing
  @@ -109,7 +110,6 @@
        * actually resolve.  
        */
       public void testRecursive() {
  -        System.out.println("testRecursive");
           String result = "it works line";
           String line="@test@ line";
           FilterSet fs = new FilterSet();
  @@ -126,7 +126,6 @@
        * infinite loop.
        */
       public void testInfinite() {
  -        System.out.println("testInfinite");
           String result = "@test@ line testvalue";
           String line = "@test@ line @test3@";
           FilterSet fs = new FilterSet();
  @@ -137,6 +136,31 @@
           fs.setBeginToken("@");
           fs.setEndToken("@");
           assertEquals(result, fs.replaceTokens(line));
  +    }
  +
  +    public void testNestedFilterSets() {
  +        executeTarget("test-nested-filtersets");
  +
  +        FilterSet fs = (FilterSet) getProject().getReference("1");
  +        Hashtable filters = fs.getFilterHash();
  +        assertEquals(1, filters.size());
  +        assertEquals("value1", filters.get("token1"));
  +
  +        fs = (FilterSet) getProject().getReference("2");
  +        filters = fs.getFilterHash();
  +        assertEquals(2, filters.size());
  +        assertEquals("1111", filters.get("aaaa"));
  +        assertEquals("2222", filters.get("bbbb"));
  +
  +        fs = (FilterSet) getProject().getReference("3");
  +        filters = fs.getFilterHash();
  +        assertEquals(1, filters.size());
  +        assertEquals("value4", filters.get("token4"));
  +
  +        fs = (FilterSet) getProject().getReference("5");
  +        filters = fs.getFilterHash();
  +        assertEquals(1, filters.size());
  +        assertEquals("value1", filters.get("token1"));
       }
   
       private boolean compareFiles(String name1, String name2) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message