Return-Path:
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
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
filesmatch
@@ -753,7 +753,7 @@ Probe for the maven repository being rea
casesensitive
- Perform a case sensitive comparision. Default is
+ Perform a case sensitive comparison. Default is
true.
No
resourcesmatch
@@ -1071,7 +1071,7 @@ is redundant and will be ignored.casesensitive
- Perform a case sensitive comparision. Default is
+ Perform a case sensitive comparison. Default is
true.
No
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. Thisexcludepackage
element.perTest
+ option to be operative.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.
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 | @@ -253,6 +265,17 @@ attributes: These options are mutually exclusive.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
Attribute | 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/eNo, default is true |
|
binaryOutput | +When 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 |
+
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
A usual test scenario is:
+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 @@
This is the manual for version 1.9.3 of +
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
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
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
Used Links:
- [1] http://ant.apache.org/manual/properties.html#built-in-props
- [2] http://ant.apache.org/manual/Tasks/taskdef.html
- [3] http://ant.apache.org/manual/develop.html#set-magic
- [4] http://ant.apache.org/manual/develop.html#nested-elements
- [5] http://gump.covalent.net/jars/latest/ant/ant-testutil.jar
- [6] http://issues.apache.org/bugzilla/show_bug.cgi?id=22570
- [7] tutorial-writing-tasks-src.zip
+
Used Links:
+ [1] http://ant.apache.org/manual/properties.html#built-in-props
+ [2] http://ant.apache.org/manual/Tasks/taskdef.html
+ [3] http://ant.apache.org/manual/develop.html#set-magic
+ [4] http://ant.apache.org/manual/develop.html#nested-elements
+ [5] http://gump.covalent.net/jars/latest/ant/ant-testutil.jar
+ [6] http://issues.apache.org/bugzilla/show_bug.cgi?id=22570
+ [7] tutorial-writing-tasks-src.zip