Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CEDC111297 for ; Tue, 6 May 2014 02:09:17 +0000 (UTC) Received: (qmail 20797 invoked by uid 500); 6 May 2014 02:09:17 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 20712 invoked by uid 500); 6 May 2014 02:09:16 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 20702 invoked by uid 99); 6 May 2014 02:09:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 02:09:16 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 06 May 2014 02:09:12 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A1D362388868 for ; Tue, 6 May 2014 02:08:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1592650 - in /ant/site/ant/production/manual: ./ Tasks/ Types/ Date: Tue, 06 May 2014 02:08:50 -0000 To: notifications@ant.apache.org From: antoine@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140506020851.A1D362388868@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: antoine Date: Tue May 6 02:08:50 2014 New Revision: 1592650 URL: http://svn.apache.org/r1592650 Log: release of Apache Ant 1.9.4 Added: ant/site/ant/production/manual/Types/multirootfileset.html - copied unchanged from r1591179, ant/core/trunk/manual/Types/multirootfileset.html Modified: ant/site/ant/production/manual/ (props changed) ant/site/ant/production/manual/Tasks/conditions.html ant/site/ant/production/manual/Tasks/get.html ant/site/ant/production/manual/Tasks/include.html (props changed) ant/site/ant/production/manual/Tasks/javadoc.html ant/site/ant/production/manual/Tasks/junit.html ant/site/ant/production/manual/Tasks/local.html ant/site/ant/production/manual/Tasks/mail.html ant/site/ant/production/manual/Tasks/sql.html ant/site/ant/production/manual/Tasks/sshexec.html ant/site/ant/production/manual/Tasks/style.html ant/site/ant/production/manual/Types/patternset.html ant/site/ant/production/manual/Types/redirector.html ant/site/ant/production/manual/Types/resources.html ant/site/ant/production/manual/Types/selectors-program.html ant/site/ant/production/manual/conceptstypeslist.html ant/site/ant/production/manual/cover.html (contents, props changed) ant/site/ant/production/manual/credits.html ant/site/ant/production/manual/install.html ant/site/ant/production/manual/targets.html ant/site/ant/production/manual/tutorial-tasks-filesets-properties.html ant/site/ant/production/manual/tutorial-writing-tasks.html Propchange: ant/site/ant/production/manual/ ------------------------------------------------------------------------------ Merged /ant/core/tags/ANT_194/manual:r1591180-1592649 Merged /ant/core/trunk/manual:r1553123-1554405,1554407-1554807,1554809-1591179 Modified: ant/site/ant/production/manual/Tasks/conditions.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/conditions.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/conditions.html (original) +++ ant/site/ant/production/manual/Tasks/conditions.html Tue May 6 02:08:50 2014 @@ -255,7 +255,7 @@ TCP/IP listener at the specified host an

filesmatch

Test two files for matching. Nonexistence of one file results in "false", although if neither exists they are considered equal in terms of content. -This test does a byte for byte comparision, so test time scales with +This test does a byte for byte comparison, so test time scales with byte size. NB: if the files are different sizes, one of them is missing or the filenames match the answer is so obvious the detailed test is omitted. @@ -306,7 +306,7 @@ or the filenames match the answer is so casesensitive - Perform a case sensitive comparision. Default is + Perform a case sensitive comparison. Default is true. No @@ -753,7 +753,7 @@ Probe for the maven repository being rea

resourcesmatch

Test resources for matching. Nonexistence of one or more resources results in "false", although if none exists they are considered equal in terms of content. -By default this test does a byte for byte comparision, so test time scales with +By default this test does a byte for byte comparison, so test time scales with byte size. NB: if the files are different sizes, one of them is missing or the filenames match the answer is so obvious the detailed test is omitted. The resources to check are specified as nested @@ -805,7 +805,7 @@ must match. Since Ant 1.7 casesensitive - Perform a case sensitive comparision. Default is + Perform a case sensitive comparison. Default is true. No @@ -1071,7 +1071,7 @@ is redundant and will be ignored.

resourceexists

-

Tests a resource for existance. since Ant 1.8.0

+

Tests a resource for existence. since Ant 1.8.0

The actual resource to test is specified as a nested element.

Modified: ant/site/ant/production/manual/Tasks/get.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/get.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/get.html (original) +++ ant/site/ant/production/manual/Tasks/get.html Tue May 6 02:08:50 2014 @@ -72,6 +72,11 @@ plain text' authentication is used. This No; default "false" + quiet + Log errors only.("true"/"false"). + No; default "false" + + ignoreerrors Log errors but don't treat as fatal. No; default "false" Propchange: ant/site/ant/production/manual/Tasks/include.html ------------------------------------------------------------------------------ Merged /ant/core/tags/ANT_194/manual/Tasks/include.html:r1591180-1592649 Merged /ant/core/trunk/manual/Tasks/include.html:r1553123-1591179 Modified: ant/site/ant/production/manual/Tasks/javadoc.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/javadoc.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/javadoc.html (original) +++ ant/site/ant/production/manual/Tasks/javadoc.html Tue May 6 02:08:50 2014 @@ -428,6 +428,14 @@ to <javadoc> using classpathNo + failonwarning + Stop the buildprocess if a warning is emitted - + i.e. if javadoc's output contains the word "warning". since + Ant 1.9.4 + all + No + + excludepackagenames comma separated list of packages you don't want docs for -- see also the nested excludepackage element. Modified: ant/site/ant/production/manual/Tasks/junit.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/junit.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/junit.html (original) +++ ant/site/ant/production/manual/Tasks/junit.html Tue May 6 02:08:50 2014 @@ -247,7 +247,16 @@ elements).

since Ant 1.8.2 - Ant 1.7.0 to 1.8.1 behave as if this attribute was true by default. No - + + + threads + a number of threads to run the tests in.
+ When this attribute is specified the tests will be split arbitrarily among the threads.
+ requires that the tests be forked with the perTest + option to be operative.
+ since Ant 1.9.4 + No +

By using the errorproperty and failureproperty Modified: ant/site/ant/production/manual/Tasks/local.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/local.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/local.html (original) +++ ant/site/ant/production/manual/Tasks/local.html Tue May 6 02:08:50 2014 @@ -37,7 +37,7 @@ top-level operations are carried out; it in the buildfile. Since Ant 1.8

A property is made local if the <local> task - preceedes its definition. See the examples section.

+ precedes its definition. See the examples section.

Parameters

Modified: ant/site/ant/production/manual/Tasks/mail.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/mail.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/mail.html (original) +++ ant/site/ant/production/manual/Tasks/mail.html Tue May 6 02:08:50 2014 @@ -98,7 +98,19 @@ - + + + + + + + @@ -253,6 +265,17 @@ attributes:

These options are mutually exclusive. + + + + +
File to send as the body of the email. Property values in the file will be expanded.
messagemimetype
messagefileinputencoding + Specifies the encoding of the input file. Please see + + Supported Encodings for a list of possible + values. Defaults to the platform's default character + encoding. Since Ant 1.9.4 + No
messagemimetype The content type of the message. The default is text/plain. No No
inputencoding + Specifies the encoding of the input file. Please see + + Supported Encodings for a list of possible + values. Defaults to the platform's default character + encoding. Since Ant 1.9.4 + No

If the src attribute is not specified, then text can be added Modified: ant/site/ant/production/manual/Tasks/sql.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/sql.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/sql.html (original) +++ ant/site/ant/production/manual/Tasks/sql.html Tue May 6 02:08:50 2014 @@ -91,6 +91,12 @@ and abort execution and transacti No - defaults to default JVM encoding + outputencoding + The encoding of the files holding + results. since 1.9.4 + No - defaults to default JVM encoding + + delimiter String that separates SQL statements No, default ";" Modified: ant/site/ant/production/manual/Tasks/sshexec.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/sshexec.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/sshexec.html (original) +++ ant/site/ant/production/manual/Tasks/sshexec.html Tue May 6 02:08:50 2014 @@ -122,16 +122,35 @@ and won't work with versions of jsch ear No, defaults to false + suppresssystemerr + Whether to suppress system err. + since Ant 1.9.4 + No, defaults to false + + output Name of a file to which to write the output. No + errorOutput + The file to which the standard error of the + command should be redirected. since Ant 1.9.4 + No + + append Whether output file should be appended to or overwritten. Defaults to false, meaning overwrite any existing file. No + errAppend + Whether errorOutput file should be appended to or + overwritten. Defaults to false, meaning overwrite any existing + file. since Ant 1.9.4 + No + + outputproperty The name of a property in which the output of the command should be stored. If you use the commandResource @@ -140,6 +159,19 @@ and won't work with versions of jsch ear No + errorproperty + The name of a property in which the standard error of the + command should be stored. since Ant 1.9.4 + No + + + resultproperty + the name of a property in which the return code + of the command should be stored. Only of interest if + failonerror=false. since Ant 1.9.4 + No + + timeout Stop the command if it doesn't finish within the specified time (given in milliseconds unlike telnet, which @@ -191,6 +223,13 @@ and won't work with versions of jsch ear since Ant 1.8.3 No, defaults to false + + useSystemIn + Whether to pass the current standard input to the + remote process. + since Ant 1.9.4 + No, defaults to false +

Examples

Modified: ant/site/ant/production/manual/Tasks/style.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Tasks/style.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Tasks/style.html (original) +++ ant/site/ant/production/manual/Tasks/style.html Tue May 6 02:08:50 2014 @@ -225,7 +225,7 @@ element which is used to perform Entity No - supressWarnings + suppressWarnings Whether processor warnings shall be suppressed. This option requires support by the processor, it is supported by the trax processor bundled with Ant. Modified: ant/site/ant/production/manual/Types/patternset.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Types/patternset.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Types/patternset.html (original) +++ ant/site/ant/production/manual/Types/patternset.html Tue May 6 02:08:50 2014 @@ -98,7 +98,7 @@ your build file, you should use the incl attributes or elements. Using the attribute, you can only specify a single file of each type, while the nested elements can be specified more than once - the nested elements also support if/unless attributes -you can use to test the existance of a property.

+you can use to test the existence of a property.

Modified: ant/site/ant/production/manual/Types/redirector.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Types/redirector.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Types/redirector.html (original) +++ ant/site/ant/production/manual/Types/redirector.html Tue May 6 02:08:50 2014 @@ -136,6 +136,16 @@ source (input) and destination (output/e + + + + +
Attribute No, default is true
binaryOutputWhen set to true Ant will not try to split the + output into lines - which it will usually do in order to separate + error from normal output. This setting will not prevent binary + output from getting corrupted if you also specify filter chains. + Since Ant 1.9.4. + No, default is false

Parameters specified as nested elements

inputmapper

Modified: ant/site/ant/production/manual/Types/resources.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Types/resources.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Types/resources.html (original) +++ ant/site/ant/production/manual/Types/resources.html Tue May 6 02:08:50 2014 @@ -320,6 +320,7 @@ Ant's "legacy" datatypes have been modif
  • fileset, dirset, + multirootfileset, filelist, and path (and derivative types) expose file resources Modified: ant/site/ant/production/manual/Types/selectors-program.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/Types/selectors-program.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/Types/selectors-program.html (original) +++ ant/site/ant/production/manual/Types/selectors-program.html Tue May 6 02:08:50 2014 @@ -140,78 +140,58 @@

    For a robust component (and selectors are (Project)Components) tests are necessary. For testing Tasks we use JUnit TestCases - more specific - org.apache.tools.ant.BuildFileTest extends junit.framework.TestCase. + org.apache.tools.ant.BuildFileRule extends org.junit.rules.ExternalResource. Some of its features like configure the (test) project by reading its buildfile and - execute targets we need for selector tests also. Therefore we use that BuildFileTest. + execute targets we need for selector tests also. Therefore we use that BuildFileRule. But testing selectors requires some more work: having a set of files, instantiate and configure the selector, check the selection work and more. Because we usually extend BaseExtendSelector its features have to be tested also (e.g. setError()).

    -

    That's why we have a base class for doing our selector tests: - org.apache.tools.ant.types.selectors.BaseSelectorTest.

    +

    That's why we have a test rule for doing our selector tests: + org.apache.tools.ant.types.selectors.BaseSelectorRule.

    -

    This class extends TestCase and therefore can included in the set of Ant's - unit tests. It holds an instance of preconfigured BuildFileTest. Configuration - is done by parsing the src/etc/testcases/types/selectors.xml. BaseSelectorTest +

    This class extends ExternalResource and therefore can included in the set of Ant's + unit tests. It holds an instance of preconfigured BuildFileRule. Configuration + is done by parsing the src/etc/testcases/types/selectors.xml. BaseSelectorRule then gives us helper methods for handling multiple selections.

    Because the term "testcase" or "testenvironment" are so often used, this - special testenvironment got a new name: bed. Like you initialize the - test environment by calling setUp() and cleaning by calling tearDown() (or like - to make your bed before go sleeping) you have to do that work with your - bed by calling makeBed() respective cleanupBed().

    + special testenvironment got a new name: bed. The setup and cleanup of + the bed is all handled by the BaseSelectorRule so any test only has to handle + the actual test scenarios

    -

    A usual test scenario is

      -
    1. make the bed
    2. +

      A usual test scenario is:

      +
      1. instantiate the selector
      2. configure the selector
      3. let the selector do some work
      4. verify the work
      5. -
      6. clean the bed
      7. -
      -

      +
    + -

    For common way of instantiation you have to override the getInstance() - simply by returning a new object of your selector. For easier "selection and verification work" - BaseSelectorTest provides the method performTests() which - iterates over all files (and directories) in the String array filenames - and checks whether the given selector returns the expected result. If an error - occurred (especially the selector does not return the expected result) the test - fails and the failing filenames are logged.

    An example test would be:

     package org.apache.tools.ant.types.selectors;
     
    -public class MySelectorTest extends BaseSelectorTest {
    -
    -    public MySelectorTest(String name) {
    -        super(name);
    -    }
    +public class MySelectorTest {
     
    -    public BaseSelector getInstance() {
    -        return new MySelector();
    -    }
    +    @Rule
    +    public final BaseSelectorRule selectorRule = new BaseSelectorRule();
     
    +    @Test
         public void testCase1() {
    -        try {
    -            // initialize test environment 'bed'
    -            makeBed();
    -
    -            // Configure the selector
    -            MySelector s = (MySelector)getSelector();
    -            s.addParam("key1", "value1");
    -            s.addParam("key2", "value2");
    -            s.setXX(true);
    -            s.setYY("a value");
    -
    -            // do the tests
    -            performTests(s, "FTTTTTTTTTTT");  // First is not selected - rest is
    -
    -        } finally {
    -            // cleanup the environment
    -            cleanupBed();
    -        }
    +
    +
    +        // Configure the selector
    +        MySelector s = new MySelector();
    +        s.addParam("key1", "value1");
    +        s.addParam("key2", "value2");
    +        s.setXX(true);
    +        s.setYY("a value");
    +
    +        // do the tests
    +        assertEquals("FTTTTTTTT", selectorRule.selectionString(s));
         }
     }
         
    Modified: ant/site/ant/production/manual/conceptstypeslist.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/conceptstypeslist.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/conceptstypeslist.html (original) +++ ant/site/ant/production/manual/conceptstypeslist.html Tue May 6 02:08:50 2014 @@ -51,6 +51,7 @@
  • File Mappers
  • FilterChains and FilterReaders
  • FilterSet
  • +
  • MultiRootFileSet
  • PatternSet
  • Path-like Structures
  • Permissions
  • Modified: ant/site/ant/production/manual/cover.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/cover.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/cover.html (original) +++ ant/site/ant/production/manual/cover.html Tue May 6 02:08:50 2014 @@ -19,14 +19,14 @@ -Apache Ant 1.9.3 User Manual +Apache Ant 1.9.4 User Manual

    -

    Apache Ant™ 1.9.3 Manual

    -

    This is the manual for version 1.9.3 of +

    Apache Ant™ 1.9.4 Manual

    +

    This is the manual for version 1.9.4 of Apache Ant. If your version of Ant (as verified with ant -version) is older or newer than this Propchange: ant/site/ant/production/manual/cover.html ------------------------------------------------------------------------------ Merged /ant/core/trunk/manual/cover.html:r1553123-1591179 Merged /ant/core/tags/ANT_194/manual/cover.html:r1591180-1592649 Modified: ant/site/ant/production/manual/credits.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/credits.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/credits.html (original) +++ ant/site/ant/production/manual/credits.html Tue May 6 02:08:50 2014 @@ -62,7 +62,7 @@

-

Version: 1.9.3

+

Version: 1.9.4

Modified: ant/site/ant/production/manual/install.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/install.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/install.html (original) +++ ant/site/ant/production/manual/install.html Tue May 6 02:08:50 2014 @@ -105,7 +105,7 @@ Choose the format that is best supported runtime. Such distributions are usually unsupported by everyone. Particularly troublesome are those products that not only ship with their own Ant release, they add their own version of ANT.BAT or ant.sh to the PATH. If Ant starts - behaving wierdly after installing something, try the + behaving weirdly after installing something, try the diagnostics advice.

Modified: ant/site/ant/production/manual/targets.html URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/targets.html?rev=1592650&r1=1592649&r2=1592650&view=diff ============================================================================== --- ant/site/ant/production/manual/targets.html (original) +++ ant/site/ant/production/manual/targets.html Tue May 6 02:08:50 2014 @@ -94,7 +94,7 @@

Only one propertyname can be specified in the if/unless clause. If you want to check multiple conditions, you can use a - dependend target for computing the result for the check:

+ dependent target for computing the result for the check:

 <target name="myTarget" depends="myTarget.check" if="myTarget.run">

Modified: ant/site/ant/production/manual/tutorial-tasks-filesets-properties.html
URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/tutorial-tasks-filesets-properties.html?rev=1592650&r1=1592649&r2=1592650&view=diff
==============================================================================
--- ant/site/ant/production/manual/tutorial-tasks-filesets-properties.html (original)
+++ ant/site/ant/production/manual/tutorial-tasks-filesets-properties.html Tue May  6 02:08:50 2014
@@ -135,20 +135,28 @@ to them, sorry :-)

we can call that from our testcase:
-import org.apache.tools.ant.BuildFileTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.Assert;
+import org.apache.tools.ant.BuildFileRule;
 
-public class FindTest extends BuildFileTest {
 
-    public FindTest(String name) {
-        super(name);
-    }
+public class FindTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+
+    @Before
     public void setUp() {
         configureProject("build.xml");
     }
 
+    @Test
     public void testSimple() {
-        expectLog("use.simple", "test-value");
+        buildRule.executeTarget("useSimgle");
+        Assert.assertEquals("test-value", buildRule.getLog());
     }
 }
 
@@ -211,10 +219,14 @@ Maybe you find some more testcases. But For each of these points we create a testXX method.

-public class FindTest extends BuildFileTest {
+public class FindTest {
+
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
     ... // constructor, setUp as above
 
+    @Test
     public void testMissingFile() {
         Find find = new Find();
         try {
@@ -227,6 +239,7 @@ public class FindTest extends BuildFileT
         }
     }
 
+    @Test
     public void testMissingLocation() {
         Find find = new Find();
         find.setFile("ant.jar");
@@ -238,6 +251,7 @@ public class FindTest extends BuildFileT
         }
     }
 
+    @Test
     public void testMissingFileset() {
         Find find = new Find();
         find.setFile("ant.jar");
@@ -250,15 +264,17 @@ public class FindTest extends BuildFileT
         }
     }
 
+    @Test
     public void testFileNotPresent() {
-        executeTarget("testFileNotPresent");
-        String result = getProject().getProperty("location.ant-jar");
+        buildRule.executeTarget("testFileNotPresent");
+        String result = buildRule.getProject().getProperty("location.ant-jar");
         assertNull("Property set to wrong value.", result);
     }
 
+    @Test
     public void testFilePresent() {
-        executeTarget("testFilePresent");
-        String result = getProject().getProperty("location.ant-jar");
+        buildRule.executeTarget("testFilePresent");
+        String result = buildRule.getProject().getProperty("location.ant-jar");
         assertNotNull("Property not set.", result);
         assertTrue("Wrong file found.", result.endsWith("ant.jar"));
     }
@@ -301,9 +317,9 @@ can implement our task, so that these te
 is a common way, because we separate the prerequisites from the real work. On //2 we iterate
 over all nested filesets. If we don't want to handle multiple filesets, the addFileset()
 method has to reject the further calls. We can get the result of a fileset via its DirectoryScanner
-like done in //3. After that we create a platform independend String representation of
+like done in //3. After that we create a platform independent String representation of
 the file path (//4, can be done in other ways of course). We have to do the replace(),
-because we work with a simple string comparison. Ant itself is platform independant and can
+because we work with a simple string comparison. Ant itself is platform independent and can
 therefore run on filesystems with slash (/, e.g. Linux) or backslash (\, e.g. Windows) as
 path separator. Therefore we have to unify that. If we found our file we create an absolute
 path representation on //5, so that we can use that information without knowing the basedir.
@@ -906,7 +922,7 @@ entry. For both we need some information
 
 
   attachments
-  all files needed to apply the path
+  all files needed to apply the path
   Archive containing a patch with the new and modified resources
 
 

Modified: ant/site/ant/production/manual/tutorial-writing-tasks.html
URL: http://svn.apache.org/viewvc/ant/site/ant/production/manual/tutorial-writing-tasks.html?rev=1592650&r1=1592649&r2=1592650&view=diff
==============================================================================
--- ant/site/ant/production/manual/tutorial-writing-tasks.html (original)
+++ ant/site/ant/production/manual/tutorial-writing-tasks.html Tue May  6 02:08:50 2014
@@ -17,8 +17,7 @@
 
 
   Tutorial: Writing Tasks
-  
-  
+  
 
 
 

Tutorial: Writing Tasks

@@ -596,12 +595,9 @@ Next step: test ...

Test the Task

We have written a test already: the use.* tasks in the buildfile. But its difficult to test that automatically. Common (and in Ant) used is JUnit for -that. For testing tasks Ant provides a baseclass org.apache.tools.ant.BuildFileTest. -This class extends junit.framework.TestCase and can therefore be integrated -into the unit tests. But this class provides some for testing tasks useful methods: -initialize Ant, load a buildfile, execute targets, -expecting BuildExceptions with a specified text, expect a special text -in the output log ...

+that. For testing tasks Ant provides a JUnit Rule org.apache.tools.ant.BuildFileRule. +This class provides some for testing tasks useful methods: +initialize Ant, load a buildfile, execute targets, capturing debug and run logs ...

In Ant it is usual that the testcase has the same name as the task with a prepending Test, therefore we will create a file HelloWorldTest.java. Because we @@ -677,49 +673,68 @@ and <junitreport>. So ...

-

Back to the src/HelloWorldTest.java. We create a class extending -BuildFileTest with String-constructor (JUnit-standard), a setUp() -method initializing Ant and for each testcase (targets use.*) a testXX() -method invoking that target.

-
-import org.apache.tools.ant.BuildFileTest;
+

Back to the src/HelloWorldTest.java. We create a class with a public +BuildFileRule field annotated with JUnit's @Rule annotation. As per +conventional JUnit4 tests, this class should have no constructors, or a default no-args +constructor, setup methods should be annotated with @Before, tear down methods +annotated with @After and any test method annotated with @Test. +

+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.Rule;
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildException;
 
-public class HelloWorldTest extends BuildFileTest {
+public class HelloWorldTest {
 
-    public HelloWorldTest(String s) {
-        super(s);
-    }
+    @Rule
+    public final BuildFileRule buildRule = new BuildFileRule();
 
+    @Before
     public void setUp() {
         // initialize Ant
-        configureProject("build.xml");
+        buildRule.configureProject("build.xml");
     }
 
+    @Test
     public void testWithout() {
-        executeTarget("use.without");
-        assertEquals("Message was logged but should not.", getLog(), "");
+        buildRule.executeTarget("use.without");
+        assertEquals("Message was logged but should not.", buildRule.getLog(), "");
     }
 
     public void testMessage() {
         // execute target 'use.nestedText' and expect a message
         // 'attribute-text' in the log
-        expectLog("use.message", "attribute-text");
+        buildRule.executeTarget("use.message");
+        Assert.assertEquals("attribute-text", buildRule.getLog());
     }
 
+    @Test
     public void testFail() {
         // execute target 'use.fail' and expect a BuildException
         // with text 'Fail requested.'
-        expectBuildException("use.fail", "Fail requested.");
+        try {
+           buildRule.executeTarget("use.fail");
+           fail("BuildException should have been thrown as task was set to fail");
+        } catch (BuildException ex) {
+            Assert.assertEquals("fail requested", ex.getMessage());
+        }
+
     }
 
+    @Test
     public void testNestedText() {
-        expectLog("use.nestedText", "nested-text");
+        buildRule.executeTarget("use.nestedText");
+        Assert.assertEquals("nested-text", buildRule.getLog());
     }
 
+    @Test
     public void testNestedElement() {
-        executeTarget("use.nestedElement");
-        assertLogContaining("Nested Element 1");
-        assertLogContaining("Nested Element 2");
+        buildRule.executeTarget("use.nestedElement");
+        AntAssert.assertContains("Nested Element 1", buildRule.getLog());
+        AntAssert.assertContains("Nested Element 2", buildRule.getLog());
     }
 }
 
@@ -790,14 +805,14 @@ The ZIP provided there contains