From 967ec861a2a70977f434a391d5c70f477e4722b0 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Fri, 27 Sep 2002 09:30:38 +0000
Subject: [PATCH] filtersets that are nested into filersets don't work as the
code tries to access nested elements before they have been configured.
PR: 9056
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273381 13f79535-47bb-0310-9956-ffa450edef68
---
WHATSNEW | 2 ++
docs/manual/CoreTypes/filterset.html | 11 ++++++--
src/etc/testcases/types/filterset.xml | 17 +++++++++++
.../org/apache/tools/ant/types/FilterSet.java | 2 +-
.../apache/tools/ant/types/FilterSetTest.java | 28 +++++++++++++++++--
5 files changed, 54 insertions(+), 6 deletions(-)
diff --git a/WHATSNEW b/WHATSNEW
index 86e69357e..685413ea5 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -42,6 +42,8 @@ Fixed bugs:
* now works on OS/400.
+* nested into s didn't work.
+
Other changes:
--------------
diff --git a/docs/manual/CoreTypes/filterset.html b/docs/manual/CoreTypes/filterset.html
index 21bec066f..3611b3dfa 100644
--- a/docs/manual/CoreTypes/filterset.html
+++ b/docs/manual/CoreTypes/filterset.html
@@ -14,9 +14,14 @@ or be read in from a file. FilterSets can appear inside tasks that support this
feature or at the same level as <target>
- i.e., as
children of
<project>
.
-FilterSets support the id
and refid
attributes.
-You can define a FilterSet with an id
attribute and then refer
-to that definition from another FilterSet with a refid
attribute.
+
+
FilterSets support the id
and refid
+attributes. You can define a FilterSet with an id
+attribute and then refer to that definition from another FilterSet
+with a refid
attribute. It is also possible to nest
+filtersets into filtersets to get a set union of the contained
+filters.
+
In addition, FilterSets can specify
begintoken
and/or
endtoken
attributes to define what to match.
diff --git a/src/etc/testcases/types/filterset.xml b/src/etc/testcases/types/filterset.xml
index 12b272c6b..4fa780af4 100644
--- a/src/etc/testcases/types/filterset.xml
+++ b/src/etc/testcases/types/filterset.xml
@@ -31,6 +31,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java
index c63b21602..6c7789bb4 100644
--- a/src/main/org/apache/tools/ant/types/FilterSet.java
+++ b/src/main/org/apache/tools/ant/types/FilterSet.java
@@ -467,7 +467,7 @@ public class FilterSet extends DataType implements Cloneable {
*
* @param filterSet the filterset to be added to this filterset
*/
- public void addFilterSet(FilterSet filterSet) {
+ public void addConfiguredFilterSet(FilterSet filterSet) {
if (isReference()) {
throw noChildrenAllowed();
}
diff --git a/src/testcases/org/apache/tools/ant/types/FilterSetTest.java b/src/testcases/org/apache/tools/ant/types/FilterSetTest.java
index c31dd182e..316c6fbbd 100644
--- a/src/testcases/org/apache/tools/ant/types/FilterSetTest.java
+++ b/src/testcases/org/apache/tools/ant/types/FilterSetTest.java
@@ -62,6 +62,7 @@ import junit.framework.TestCase;
import junit.framework.AssertionFailedError;
import java.io.*;
+import java.util.Hashtable;
/**
* FilterSet testing
@@ -109,7 +110,6 @@ public class FilterSetTest extends BuildFileTest {
* actually resolve.
*/
public void testRecursive() {
- System.out.println("testRecursive");
String result = "it works line";
String line="@test@ line";
FilterSet fs = new FilterSet();
@@ -126,7 +126,6 @@ public class FilterSetTest extends BuildFileTest {
* infinite loop.
*/
public void testInfinite() {
- System.out.println("testInfinite");
String result = "@test@ line testvalue";
String line = "@test@ line @test3@";
FilterSet fs = new FilterSet();
@@ -139,6 +138,31 @@ public class FilterSetTest extends BuildFileTest {
assertEquals(result, fs.replaceTokens(line));
}
+ public void testNestedFilterSets() {
+ executeTarget("test-nested-filtersets");
+
+ FilterSet fs = (FilterSet) getProject().getReference("1");
+ Hashtable filters = fs.getFilterHash();
+ assertEquals(1, filters.size());
+ assertEquals("value1", filters.get("token1"));
+
+ fs = (FilterSet) getProject().getReference("2");
+ filters = fs.getFilterHash();
+ assertEquals(2, filters.size());
+ assertEquals("1111", filters.get("aaaa"));
+ assertEquals("2222", filters.get("bbbb"));
+
+ fs = (FilterSet) getProject().getReference("3");
+ filters = fs.getFilterHash();
+ assertEquals(1, filters.size());
+ assertEquals("value4", filters.get("token4"));
+
+ fs = (FilterSet) getProject().getReference("5");
+ filters = fs.getFilterHash();
+ assertEquals(1, filters.size());
+ assertEquals("value1", filters.get("token1"));
+ }
+
private boolean compareFiles(String name1, String name2) {
File file1 = new File(name1);
File file2 = new File(name2);