DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12024>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12024

[PATCH] Enable junit to inherit Ant properties as system properties





------- Additional Comments From [EMAIL PROTECTED]  2003-05-09 13:48 -------
Hi Stefan,

I already have my own copy of SubAnt (I like to think of it as the original ;-) 
covered. Trivial Change:

Index: SubAnt.java
===================================================================
RCS 
file: /cm3/cvs/buildtools/buildmagic/buildmagic/src/com/lgc/buildmagic/SubAnt.ja
va,v
retrieving revision 1.3
retrieving revision 1.4
diff -r1.3 -r1.4
6a7
> import java.util.Map;
7a9,10
> import java.util.Iterator;
> import java.util.Properties;
41a45
>     private PropertySet propertySet;
53a58,70
>         // Inject all System properties defined by <propertyset>, if any.
>         if (this.propertySet != null) {
>             Properties properties = propertySet.getProperties();
>             for (Iterator i = properties.entrySet().iterator(); i.hasNext();) 
{
>                 Map.Entry p = (Map.Entry)i.next();
>                 Property property = new Property();
>                 property.setProject(getProject());
>                 property.setName((String)p.getKey());
>                 property.setValue((String)p.getValue());
>                 addProperty(property);
>             }
>         }
>
268a286,300
>     }
>
>     public void setPropertySetRef(String reference) {
>         if (this.propertySet != null) {
>             throw new BuildException("too many nested <propertyset>s");
>         }
>         propertySet = (PropertySet)TaskUtils.getReferencedObject(getProject(),
>                                reference, PropertySet.class, "<propertyset>");
>     }
>
>     public void addPropertySet(PropertySet propertySet) {
>         if (this.propertySet != null) {
>             throw new BuildException("too many nested <propertyset>s");
>         }
>         this.propertySet = propertySet;

Here's the test:

    public void testPropertySet() {
        // User-properties seem to be always passed down...
        getProject().setUserProperty("U", "u");
        expectLog("test-propertyset",
                  "p.A=a, p.B=${p.B}, p.C=c, p.D=dd, p.E=eee, U=u");
    }

Here's the test:

  <target name="test-propertyset">
    <property name="p.A" value="a" />
    <property name="p.B" value="b" />
    <property name="p.C" value="c" />
    <subant target="test-propertyset-level2">
      <buildpath>
        <pathelement location="${ant.file}" />
      </buildpath>
      <propertyset>
        <!-- Should pass in p.A, and p.C only! -->
        <propertyref name="p.A" />
        <propertyref name="p.D" /> <!-- Not defined yet, so not passed! -->
        <propertyref regex=".\.C" /> <!-- should match p.C -->
      </propertyset>
    </subant>
  </target>

  <target name="test-propertyset-level2">
    <property name="p.D" value="dd" />
    <propertyset id="propertyset-level2">
      <!-- Should pass in p.A, p.C, and p.D only! -->
      <propertyref prefix="p." />
    </propertyset>
    <subant target="test-propertyset-level3"
            propertysetref="propertyset-level2">
      <buildpath>
        <pathelement location="${ant.file}" />
      </buildpath>
    </subant>
  </target>

  <target name="test-propertyset-level3">
    <property name="p.A" value="aaa" />
    <property name="p.D" value="ddd" />
    <property name="p.E" value="eee" />
    <!--  Expecting the following string literall (minus extra spaces):
          p.A=a,      p.B=${p.B}, p.C=c,      p.D=dd,     p.E=eee   , U=u -->
    <echo>p.A=${p.A}, p.B=${p.B}, p.C=${p.C}, p.D=${p.D}, p.E=${p.E}, U=${U}
</echo>
  </target>

Something I've been thinking is that Env. Vars. for <junit>/<java>/<exec> could 
(and I think should) be passed down in a similar fashion.

Sorry, I haven't documented this stuff so far... --DD

Reply via email to