Browse Source

use git attributes to control line-ends

master
Stefan Bodewig 10 years ago
parent
commit
5ebe693305
14 changed files with 500 additions and 453 deletions
  1. +43
    -0
      .gitattributes
  2. +29
    -29
      .gitignore
  3. +71
    -71
      src/etc/poms/ant-junit4/pom.xml
  4. +1
    -0
      src/etc/testcases/.gitattributes
  5. +9
    -9
      src/etc/testcases/filters/expected/escapeunicode.test
  6. +9
    -9
      src/etc/testcases/filters/input/escapeunicode.test
  7. +19
    -19
      src/etc/testcases/taskdefs/exec/blabla.xml
  8. +2
    -0
      src/script/.gitattributes
  9. +1
    -0
      src/tests/antunit/taskdefs/.gitattributes
  10. +125
    -125
      src/tests/antunit/taskdefs/get-test.xml
  11. +43
    -43
      src/tests/antunit/taskdefs/propertyfile-test.xml
  12. +96
    -96
      src/tests/junit/org/apache/tools/ant/types/selectors/README
  13. +26
    -26
      src/tests/junit/org/example/tasks/antlib.xml
  14. +26
    -26
      src/tests/junit/org/example/tasks/antlib2.xml

+ 43
- 0
.gitattributes View File

@@ -0,0 +1,43 @@
*.bat eol=crlf
*.bz2 binary
*.cmd eol=crlf
*.css text
*.dtd text
*.g text
*.gif binary
*.gz binary
*.html text diff=html
*.ico binary
*.inc text
*.jar binary
*.jpg binary
*.jsp text
*.md text
*.md5 text
*.md5sum text
*.mf text
*.pl text diff=perl
*.properties text
*.py text diff=python
*.result text
*.sample text
*.sh eol=lf
*.tar binary
*.test text
*.txt text
*.wxs text
*.xml text
*.xsd text
*.xsl text
*.zip binary
.gitattributes text
.gitignore text
CONTRIBUTORS text
INSTALL text
KEY text
LICENSE text
NOTICE text
README text
ReleaseInstructions text
STATUS text
WHATSNEW text

+ 29
- 29
.gitignore View File

@@ -1,29 +1,29 @@
*.el
*.ipr
*.iws
*.pif
.ant.properties
.classpath
.project
.settings
bin
apache-ant-1.*
bootstrap
build
dist
distribution
java-repository
patch.tar.gz
patch.txt
target
velocity.log*
lib/optional/*.jar
src/tests/antunit/core/output
.idea
*.iml
/src/GPATH
/src/GRTAGS
/src/GSYMS
/src/GTAGS
/log.xml
lib/optional/license.txt
*.el
*.ipr
*.iws
*.pif
.ant.properties
.classpath
.project
.settings
bin
apache-ant-1.*
bootstrap
build
dist
distribution
java-repository
patch.tar.gz
patch.txt
target
velocity.log*
lib/optional/*.jar
src/tests/antunit/core/output
.idea
*.iml
/src/GPATH
/src/GRTAGS
/src/GSYMS
/src/GTAGS
/log.xml
lib/optional/license.txt

+ 71
- 71
src/etc/poms/ant-junit4/pom.xml View File

@@ -1,71 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
This POM has been created manually by the Ant Development Team.
Please contact us if you are not satisfied with the data contained in this POM.
URL : http://ant.apache.org
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.9.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-junit4</artifactId>
<version>1.9.5-SNAPSHOT</version>
<name>Apache Ant + JUnit 4</name>
<description>contains JUnit 4.x support</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter*</include>
<include>org/apache/tools/ant/taskdefs/optional/junit/CustomJUnit4TestAdapterCache*</include>
</includes>
</configuration>
</plugin>
</plugins>
<sourceDirectory>../../../../src/main</sourceDirectory>
<testSourceDirectory>../../../../src/testcases</testSourceDirectory>
<outputDirectory>../../../../target/${project.artifactId}/classes</outputDirectory>
<testOutputDirectory>../../../../target/${project.artifactId}/testcases</testOutputDirectory>
<directory>../../../../target/${project.artifactId}</directory>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
This POM has been created manually by the Ant Development Team.
Please contact us if you are not satisfied with the data contained in this POM.
URL : http://ant.apache.org
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.ant</groupId>
<artifactId>ant-parent</artifactId>
<relativePath>../pom.xml</relativePath>
<version>1.9.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<url>http://ant.apache.org/</url>
<groupId>org.apache.ant</groupId>
<artifactId>ant-junit4</artifactId>
<version>1.9.5-SNAPSHOT</version>
<name>Apache Ant + JUnit 4</name>
<description>contains JUnit 4.x support</description>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.5-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<includes>
<include>org/apache/tools/ant/taskdefs/optional/junit/JUnit4TestMethodAdapter*</include>
<include>org/apache/tools/ant/taskdefs/optional/junit/CustomJUnit4TestAdapterCache*</include>
</includes>
</configuration>
</plugin>
</plugins>
<sourceDirectory>../../../../src/main</sourceDirectory>
<testSourceDirectory>../../../../src/testcases</testSourceDirectory>
<outputDirectory>../../../../target/${project.artifactId}/classes</outputDirectory>
<testOutputDirectory>../../../../target/${project.artifactId}/testcases</testOutputDirectory>
<directory>../../../../target/${project.artifactId}</directory>
</build>
</project>

+ 1
- 0
src/etc/testcases/.gitattributes View File

@@ -0,0 +1 @@
input.stdin text

+ 9
- 9
src/etc/testcases/filters/expected/escapeunicode.test View File

@@ -1,9 +1,9 @@
#hebrew shalom olam (hello world)
text.hebrew=\u05e9\u05dc\u05d5\u05dd \u05e2\u05d5\u05dc\u05dd
#goethe gingko biloba
text.german.1=Sp\u00fcrst du nicht an meinen Liedern,
text.german.2=Da\u00df ich eins und doppelt bin ?
# Francois Villon Ballade des Pendus
text.french=Fr\u00e8res humains qui apr\u00e8s nous vivez
# Usual IT example
text.basic.latin=Hello World
#hebrew shalom olam (hello world)
text.hebrew=\u05e9\u05dc\u05d5\u05dd \u05e2\u05d5\u05dc\u05dd
#goethe gingko biloba
text.german.1=Sp\u00fcrst du nicht an meinen Liedern,
text.german.2=Da\u00df ich eins und doppelt bin ?
# Francois Villon Ballade des Pendus
text.french=Fr\u00e8res humains qui apr\u00e8s nous vivez
# Usual IT example
text.basic.latin=Hello World

+ 9
- 9
src/etc/testcases/filters/input/escapeunicode.test View File

@@ -1,9 +1,9 @@
#hebrew shalom olam (hello world)
text.hebrew=שלום עולם
#goethe gingko biloba
text.german.1=Spürst du nicht an meinen Liedern,
text.german.2=Daß ich eins und doppelt bin ?
# Francois Villon Ballade des Pendus
text.french=Frères humains qui après nous vivez
# Usual IT example
text.basic.latin=Hello World
#hebrew shalom olam (hello world)
text.hebrew=שלום עולם
#goethe gingko biloba
text.german.1=Spürst du nicht an meinen Liedern,
text.german.2=Daß ich eins und doppelt bin ?
# Francois Villon Ballade des Pendus
text.french=Frères humains qui après nous vivez
# Usual IT example
text.basic.latin=Hello World

+ 19
- 19
src/etc/testcases/taskdefs/exec/blabla.xml View File

@@ -1,19 +1,19 @@
<project name="blabla" default="doit">
<target name="blabla">
<exec executable="sh">
<arg value="blabla.sh" />
</exec>
</target>
<target name="doit">
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
</target>
</project>
<project name="blabla" default="doit">
<target name="blabla">
<exec executable="sh">
<arg value="blabla.sh" />
</exec>
</target>
<target name="doit">
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
<antcall target="blabla"/>
</target>
</project>

+ 2
- 0
src/script/.gitattributes View File

@@ -0,0 +1,2 @@
ant eol=lf
anrRun eol=lf

+ 1
- 0
src/tests/antunit/taskdefs/.gitattributes View File

@@ -0,0 +1 @@
utf-16.* binary

+ 125
- 125
src/tests/antunit/taskdefs/get-test.xml View File

@@ -1,125 +1,125 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="get-test" default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
<property name="location" value="http://ant.apache.org/webtest/gettest" />
<target name="setUp">
<mkdir dir="${output}" />
</target>
<target name="testSeeOtherRedirect">
<get src="${location}/other.txt" dest="${output}/other.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/other.tmp" />
<contains text="seeother redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="other.txt moved to http" />
</target>
<target name="testPermanentRedirect">
<get src="${location}/permanent.txt" dest="${output}/permanent.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/permanent.tmp" />
<contains text="permanent redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="permanent.txt permanently moved to http" />
</target>
<target name="testTemporaryRedirect">
<get src="${location}/temp.txt" dest="${output}/temp.txt"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/temp.txt" />
<contains text="temporary redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="temp.txt moved to http" />
</target>
<target name="testStatusCode307Redirect">
<get src="${location}/307.txt" dest="${output}/307.txt"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/307.txt" />
<contains text="307 status code redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="307.txt moved to http" />
</target>
<target name="test5LevelsOfRedirect">
<get src="${location}/redir5.txt" dest="${output}/redir5.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/redir5.tmp" />
<contains text="5 levels of redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="redir5.txt moved to http" />
<au:assertLogContains text="redir5-4.txt moved to http" />
</target>
<target name="testInfiniteRedirect">
<au:expectfailure expectedmessage="More than 25 times redirected, giving up">
<get src="${location}/infinite.txt" dest="${output}/infinite.tmp"/>
</au:expectfailure>
</target>
<target name="testNestedResources">
<get dest="${output}/downloads">
<url url="http://ant.apache.org/index.html"/>
<url url="http://ant.apache.org/faq.html"/>
</get>
<au:assertFileExists file="${output}/downloads/index.html"/>
<au:assertFileExists file="${output}/downloads/faq.html"/>
</target>
<target name="XtestRelativeRedirect">
<get src="${location}/local.cgi" dest="${output}/other.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/other.tmp" />
<contains text="local redirect succeeded"/>
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="local.cgi moved to http" />
</target>
</project>
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="get-test" default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
<property name="location" value="http://ant.apache.org/webtest/gettest" />
<target name="setUp">
<mkdir dir="${output}" />
</target>
<target name="testSeeOtherRedirect">
<get src="${location}/other.txt" dest="${output}/other.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/other.tmp" />
<contains text="seeother redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="other.txt moved to http" />
</target>
<target name="testPermanentRedirect">
<get src="${location}/permanent.txt" dest="${output}/permanent.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/permanent.tmp" />
<contains text="permanent redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="permanent.txt permanently moved to http" />
</target>
<target name="testTemporaryRedirect">
<get src="${location}/temp.txt" dest="${output}/temp.txt"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/temp.txt" />
<contains text="temporary redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="temp.txt moved to http" />
</target>
<target name="testStatusCode307Redirect">
<get src="${location}/307.txt" dest="${output}/307.txt"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/307.txt" />
<contains text="307 status code redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="307.txt moved to http" />
</target>
<target name="test5LevelsOfRedirect">
<get src="${location}/redir5.txt" dest="${output}/redir5.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/redir5.tmp" />
<contains text="5 levels of redirect succeeded" />
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="redir5.txt moved to http" />
<au:assertLogContains text="redir5-4.txt moved to http" />
</target>
<target name="testInfiniteRedirect">
<au:expectfailure expectedmessage="More than 25 times redirected, giving up">
<get src="${location}/infinite.txt" dest="${output}/infinite.tmp"/>
</au:expectfailure>
</target>
<target name="testNestedResources">
<get dest="${output}/downloads">
<url url="http://ant.apache.org/index.html"/>
<url url="http://ant.apache.org/faq.html"/>
</get>
<au:assertFileExists file="${output}/downloads/index.html"/>
<au:assertFileExists file="${output}/downloads/faq.html"/>
</target>
<target name="XtestRelativeRedirect">
<get src="${location}/local.cgi" dest="${output}/other.tmp"/>
<au:assertTrue>
<resourcecount count="1">
<restrict>
<file file="${output}/other.tmp" />
<contains text="local redirect succeeded"/>
</restrict>
</resourcecount>
</au:assertTrue>
<au:assertLogContains text="local.cgi moved to http" />
</target>
</project>

+ 43
- 43
src/tests/antunit/taskdefs/propertyfile-test.xml View File

@@ -1,44 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
<target name="-fileResourceSetup">
<mkdir dir="${output}"/>
</target>
<target name="testInternationalText" depends="-fileResourceSetup"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50515">
<property name="line1" value="萬 利 食 品 批 發 公 司" />
<property name="line2" value="TEL: (123)123-1234" />
<propertyfile file="${output}/test.properties">
<entry key="line1" value="${line1}" />
<entry key="line2" value="${line2}" />
</propertyfile>
<loadproperties prefix="rereading" srcfile="${output}/test.properties"/>
<au:assertTrue message="${line2}">
<equals arg1="${line2}" arg2="${rereading.line2}" />
</au:assertTrue>
<au:assertTrue message="${line1}">
<equals arg1="${line1}" arg2="${rereading.line1}" />
</au:assertTrue>
</target>
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
<target name="-fileResourceSetup">
<mkdir dir="${output}"/>
</target>
<target name="testInternationalText" depends="-fileResourceSetup"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50515">
<property name="line1" value="萬 利 食 品 批 發 公 司" />
<property name="line2" value="TEL: (123)123-1234" />
<propertyfile file="${output}/test.properties">
<entry key="line1" value="${line1}" />
<entry key="line2" value="${line2}" />
</propertyfile>
<loadproperties prefix="rereading" srcfile="${output}/test.properties"/>
<au:assertTrue message="${line2}">
<equals arg1="${line2}" arg2="${rereading.line2}" />
</au:assertTrue>
<au:assertTrue message="${line1}">
<equals arg1="${line1}" arg2="${rereading.line1}" />
</au:assertTrue>
</target>
</project>

+ 96
- 96
src/tests/junit/org/apache/tools/ant/types/selectors/README View File

@@ -1,96 +1,96 @@
A DESCRIPTION OF THE SELECTOR TEST FRAMEWORK
When writing tests for selectors, I found that I wanted to have some
standard way of working with a set of files and testing whether one or
another of them was selected. To that end, I created a base class called
BaseSelectorTest that does most of the heavy lifting. Of course, you can
test your selectors any way you want, but if you want to reuse this code,
read on.
What BaseSelectorTest does is use an ant build file
"src/etc/testcases/types/selector.xml" to copy a tree of files out of
"src/etc/testcases/taskdefs/expected" into a "selectortest" directories.
Then it takes a list of 12 of the files and directories in this tree, and
applies whatever selector you pass in to each one. It passes back to your
test a 12 character long string indicating which of the 12 files and
directories was selected, using 'T' for selected and 'F' for not selected.
In the Test class for your selector, you override the getInstance() method
to create your own type of selector, and set the elements of your selector
a variety of ways to ensure that the string of T's and F's returned when
the selector is applied to those 12 files is correct.
So, for example, DepthSelectorTest.java extends BaseSelectorTest and has
the following code:
public BaseSelector getInstance() {
return new DepthSelector();
}
public void testSelectionBehaviour() {
DepthSelector s;
String results;
try {
makeBed();
s = (DepthSelector)getInstance();
s.setMin(20);
s.setMax(25);
results = selectionString(s);
assertEquals("FFFFFFFFFFFF", results);
s = (DepthSelector)getInstance();
s.setMin(0);
results = selectionString(s);
assertEquals("TTTTTTTTTTTT", results);
s = (DepthSelector)getInstance();
s.setMin(1);
results = selectionString(s);
assertEquals("FFFFFTTTTTTT", results);
The first test says that none of the 12 files or directories will match if
the depth range for the selector is between 20 and 25 (that would be one
deep directory tree!). The second says that all files and directories
match if the minimum depth is set to 0 and the maximum isn't specified. The
third test says that if the minumum depth is 1, the first 5 entries in the
list of 12 will not be selected and the rest will.
You can find the 12 files and directories that are tested for selection in
the BaseSelectorTest class. I used a fixed list so that if someone added
new files to the src/etc/testcases/types directory it wouldn't break my
tests:
protected String[] filenames = {".","asf-logo.gif.md5","asf-
logo.gif.bz2",
"asf-logo.gif.gz","copy.filterset.filtered","zip/asf-
logo.gif.zip",
"tar/asf-logo.gif.tar","tar/asf-logo-huge.tar.gz",
"tar/gz/asf-logo.gif.tar.gz","tar/bz2/asf-logo.gif.tar.bz2",
"tar/bz2/asf-logo-huge.tar.bz2","tar/bz2"};
If you wish to use this set of files and directories to test your selector,
you can reuse the BaseSelectorTest with no change to it.
You may find you need to alter the build file so that you get some
variation in the files that your selector can work with. Most of the core
selectors have required that kind of modification. If you do that, make
sure that it doesn't alter the output strings on the other selector test,
or if it does that you update their expected return results.
You may also want to alter the set of files you look at in a particular
selector test. Since the filelist in BaseSelectorTest is protected, you
should be able to override it as you need to. Or you can alter the fileset
in BaseSelectorTest itself, provided you update the test strings in all the
other unit tests.
A DESCRIPTION OF THE SELECTOR TEST FRAMEWORK
When writing tests for selectors, I found that I wanted to have some
standard way of working with a set of files and testing whether one or
another of them was selected. To that end, I created a base class called
BaseSelectorTest that does most of the heavy lifting. Of course, you can
test your selectors any way you want, but if you want to reuse this code,
read on.
What BaseSelectorTest does is use an ant build file
"src/etc/testcases/types/selector.xml" to copy a tree of files out of
"src/etc/testcases/taskdefs/expected" into a "selectortest" directories.
Then it takes a list of 12 of the files and directories in this tree, and
applies whatever selector you pass in to each one. It passes back to your
test a 12 character long string indicating which of the 12 files and
directories was selected, using 'T' for selected and 'F' for not selected.
In the Test class for your selector, you override the getInstance() method
to create your own type of selector, and set the elements of your selector
a variety of ways to ensure that the string of T's and F's returned when
the selector is applied to those 12 files is correct.
So, for example, DepthSelectorTest.java extends BaseSelectorTest and has
the following code:
public BaseSelector getInstance() {
return new DepthSelector();
}
public void testSelectionBehaviour() {
DepthSelector s;
String results;
try {
makeBed();
s = (DepthSelector)getInstance();
s.setMin(20);
s.setMax(25);
results = selectionString(s);
assertEquals("FFFFFFFFFFFF", results);
s = (DepthSelector)getInstance();
s.setMin(0);
results = selectionString(s);
assertEquals("TTTTTTTTTTTT", results);
s = (DepthSelector)getInstance();
s.setMin(1);
results = selectionString(s);
assertEquals("FFFFFTTTTTTT", results);
The first test says that none of the 12 files or directories will match if
the depth range for the selector is between 20 and 25 (that would be one
deep directory tree!). The second says that all files and directories
match if the minimum depth is set to 0 and the maximum isn't specified. The
third test says that if the minumum depth is 1, the first 5 entries in the
list of 12 will not be selected and the rest will.
You can find the 12 files and directories that are tested for selection in
the BaseSelectorTest class. I used a fixed list so that if someone added
new files to the src/etc/testcases/types directory it wouldn't break my
tests:
protected String[] filenames = {".","asf-logo.gif.md5","asf-
logo.gif.bz2",
"asf-logo.gif.gz","copy.filterset.filtered","zip/asf-
logo.gif.zip",
"tar/asf-logo.gif.tar","tar/asf-logo-huge.tar.gz",
"tar/gz/asf-logo.gif.tar.gz","tar/bz2/asf-logo.gif.tar.bz2",
"tar/bz2/asf-logo-huge.tar.bz2","tar/bz2"};
If you wish to use this set of files and directories to test your selector,
you can reuse the BaseSelectorTest with no change to it.
You may find you need to alter the build file so that you get some
variation in the files that your selector can work with. Most of the core
selectors have required that kind of modification. If you do that, make
sure that it doesn't alter the output strings on the other selector test,
or if it does that you update their expected return results.
You may also want to alter the set of files you look at in a particular
selector test. Since the filelist in BaseSelectorTest is protected, you
should be able to override it as you need to. Or you can alter the fileset
in BaseSelectorTest itself, provided you update the test strings in all the
other unit tests.

+ 26
- 26
src/tests/junit/org/example/tasks/antlib.xml View File

@@ -1,26 +1,26 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<antlib>
<macrodef name="simple">
<element name="some-tasks" optional="yes" implicit="yes"/>
<sequential>
<some-tasks/>
</sequential>
</macrodef>
</antlib>
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<antlib>
<macrodef name="simple">
<element name="some-tasks" optional="yes" implicit="yes"/>
<sequential>
<some-tasks/>
</sequential>
</macrodef>
</antlib>

+ 26
- 26
src/tests/junit/org/example/tasks/antlib2.xml View File

@@ -1,26 +1,26 @@
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<antlib>
<macrodef name="simple">
<element name="some-tasks" optional="yes" implicit="yes"/>
<sequential>
<some-tasks/>
</sequential>
</macrodef>
</antlib>
<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<antlib>
<macrodef name="simple">
<element name="some-tasks" optional="yes" implicit="yes"/>
<sequential>
<some-tasks/>
</sequential>
</macrodef>
</antlib>

Loading…
Cancel
Save