You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2005/05/18 18:47:26 UTC

cvs commit: ant/src/testcases/org/apache/tools/ant/types PropertySetTest.java

mbenson     2005/05/18 09:47:26

  Modified:    .        WHATSNEW
               src/main/org/apache/tools/ant/types PropertySet.java
               src/etc/testcases/types propertyset.xml
               src/testcases/org/apache/tools/ant/types
                        PropertySetTest.java
  Log:
  propertyset threw NPE with nested, mapped propertysets.
  
  Revision  Changes    Path
  1.824     +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.823
  retrieving revision 1.824
  diff -u -r1.823 -r1.824
  --- WHATSNEW	16 May 2005 22:40:23 -0000	1.823
  +++ WHATSNEW	18 May 2005 16:47:26 -0000	1.824
  @@ -234,6 +234,8 @@
   * <unzip> and <untar> could leave file handles open on invalid
     archives.  Bugzilla report 34893.
   
  +* propertyset threw NPE with nested, mapped propertysets.
  +
   Other changes:
   --------------
   
  
  
  
  1.25      +8 -14     ant/src/main/org/apache/tools/ant/types/PropertySet.java
  
  Index: PropertySet.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/types/PropertySet.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- PropertySet.java	2 Feb 2005 07:59:37 -0000	1.24
  +++ PropertySet.java	18 May 2005 16:47:26 -0000	1.25
  @@ -282,6 +282,12 @@
           Hashtable props =
               prj == null ? getAllSystemProperties() : prj.getProperties();
   
  +        //quick & dirty, to make nested mapped p-sets work:
  +        for (Enumeration e = setRefs.elements(); e.hasMoreElements();) {
  +            PropertySet set = (PropertySet) e.nextElement();
  +            props.putAll(set.getProperties());
  +        }
  +
           if (getDynamic() || cachedNames == null) {
               names = new HashSet();
               addPropertyNames(names, props);
  @@ -382,20 +388,7 @@
        * @return the referenced PropertySet.
        */
       protected PropertySet getRef() {
  -        if (!isChecked()) {
  -            Stack stk = new Stack();
  -            stk.push(this);
  -            dieOnCircularReference(stk, getProject());
  -        }
  -
  -        Object o = getRefid().getReferencedObject(getProject());
  -        if (!(o instanceof PropertySet)) {
  -            String msg = getRefid().getRefId()
  -                + " doesn\'t denote a propertyset";
  -            throw new BuildException(msg);
  -        } else {
  -            return (PropertySet) o;
  -        }
  +        return (PropertySet) getCheckedRef(PropertySet.class, "propertyset");
       }
   
       /**
  @@ -469,4 +462,5 @@
           }
           return b.toString();
       }
  +
   }
  
  
  
  1.2       +39 -0     ant/src/etc/testcases/types/propertyset.xml
  
  Index: propertyset.xml
  ===================================================================
  RCS file: /home/cvs/ant/src/etc/testcases/types/propertyset.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- propertyset.xml	18 Jan 2005 09:41:20 -0000	1.1
  +++ propertyset.xml	18 May 2005 16:47:26 -0000	1.2
  @@ -52,4 +52,43 @@
         exp="barB=BarB, fooA=FooA"
         got="${toString:my-set}"/>
     </target>
  +
  +  <target name="nested-mapped">
  +    <propertyset id="nested-mapped">
  +      <propertyset>
  +        <propertyset refid="properties-starting-with-foo"/>
  +        <globmapper from="foo*" to="boo*" />
  +      </propertyset>
  +      <propertyset>
  +        <propertyset refid="properties-starting-with-bar"/>
  +        <globmapper from="bar*" to="far*" />
  +      </propertyset>
  +    </propertyset>
  +    <expect.equals
  +      test="nested mapped propertysets"
  +      exp="booA=FooA, farB=BarB"
  +      got="${toString:nested-mapped}"/>
  +  </target>
  +
  +  <target name="nested-mapped-mapped">
  +    <propertyset id="nested-mapped-mapped">
  +      <propertyset>
  +        <propertyset refid="properties-starting-with-foo"/>
  +        <globmapper from="foo*" to="boo*" />
  +      </propertyset>
  +      <propertyset>
  +        <propertyset refid="properties-starting-with-bar"/>
  +        <globmapper from="bar*" to="far*" />
  +      </propertyset>
  +      <mapper>
  +        <globmapper from="boo*" to="hoo*" />
  +        <globmapper from="far*" to="near*" />
  +      </mapper>
  +    </propertyset>
  +    <expect.equals
  +      test="nested mapped propertysets"
  +      exp="hooA=FooA, nearB=BarB"
  +      got="${toString:nested-mapped-mapped}"/>
  +  </target>
  +
   </project>
  
  
  
  1.2       +8 -0      ant/src/testcases/org/apache/tools/ant/types/PropertySetTest.java
  
  Index: PropertySetTest.java
  ===================================================================
  RCS file: /home/cvs/ant/src/testcases/org/apache/tools/ant/types/PropertySetTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertySetTest.java	18 Jan 2005 09:41:20 -0000	1.1
  +++ PropertySetTest.java	18 May 2005 16:47:26 -0000	1.2
  @@ -36,4 +36,12 @@
       public void testReferenceToTwoReferences() {
           executeTarget("reference-to-two-references");
       }
  +
  +    public void testNestedMapped() {
  +        executeTarget("nested-mapped");
  +    }
  +
  +    public void testNestedMappedMapped() {
  +        executeTarget("nested-mapped-mapped");
  +    }
   }
  
  
  

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