Browse Source

And token attribute of <replacefilter> must not be empty either.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268482 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
9f05cd3fd9
3 changed files with 31 additions and 0 deletions
  1. +18
    -0
      src/etc/testcases/taskdefs/replace.xml
  2. +5
    -0
      src/main/org/apache/tools/ant/taskdefs/Replace.java
  3. +8
    -0
      src/testcases/org/apache/tools/ant/taskdefs/ReplaceTest.java

+ 18
- 0
src/etc/testcases/taskdefs/replace.xml View File

@@ -23,4 +23,22 @@
token="dont_want_to_really_replace_something"/> token="dont_want_to_really_replace_something"/>
</target> </target>


<target name="test6">
<replace file="template.xml">
<replacefilter />
</replace>
</target>

<target name="test7">
<replace file="template.xml">
<replacefilter token="" />
</replace>
</target>

<target name="test8">
<replace file="template.xml">
<replacefilter token="dont_want_to_really_replace_something" />
</replace>
</target>

</project> </project>

+ 5
- 0
src/main/org/apache/tools/ant/taskdefs/Replace.java View File

@@ -107,6 +107,11 @@ public class Replace extends MatchingTask {
throw new BuildException(message); throw new BuildException(message);
} }


if ("".equals(token)) {
String message ="The token attribute must not be an empty string.";
throw new BuildException(message);
}

//value and property are mutually exclusive attributes //value and property are mutually exclusive attributes
if ((value != null) && (property != null)) { if ((value != null) && (property != null)) {
String message = "Either value or property " + "can be specified, but a replacefilter " + "element cannot have both."; String message = "Either value or property " + "can be specified, but a replacefilter " + "element cannot have both.";


+ 8
- 0
src/testcases/org/apache/tools/ant/taskdefs/ReplaceTest.java View File

@@ -87,4 +87,12 @@ public class ReplaceTest extends TaskdefsTest {
executeTarget("test5"); executeTarget("test5");
} }


public void test6() {
expectBuildException("test6", "required argument not specified");
}

public void test7() {
expectBuildException("test7", "empty token not allowed");
}

} }

Loading…
Cancel
Save