Compare commits

...

42 Commits

Author SHA1 Message Date
Stefan Bodewig 0ac5d3e1c1
needs Java9+ to build SBOMs 2026-07-26 18:30:50 +02:00
Stefan Bodewig 1a9e1d324e
remove build-system external reference 2026-07-19 10:46:22 +02:00
Stefan Bodewig 6ea9885b3d
pick up Ivy update 2026-07-15 17:59:59 +02:00
Stefan Bodewig 1fcac25cad
import fixes to common build 2026-06-20 12:21:20 +02:00
Stefan Bodewig dd50ea5b41
adjust ivy.xml 2026-06-20 07:54:13 +02:00
Stefan Bodewig 65a5c52cec
CycloneDX Spec prefers .cdx.json
https://cyclonedx.org/specification/overview/#recognized-file-patterns
2026-06-19 21:35:31 +02:00
Stefan Bodewig 3b1b4e4237
upgrade common 2026-06-19 18:52:52 +02:00
Stefan Bodewig 07e56b0e0b
prepare 1.5.0 RC1 2026-06-19 13:08:21 +02:00
Stefan Bodewig cbc1029e61
remove examples again 2026-06-13 17:51:10 +02:00
Stefan Bodewig 1fa380c878
temporary folders with example SBOMs 2026-06-07 07:38:12 +02:00
Stefan Bodewig 35125bfd8d
file no longer needed after using ivy:cachepath directly 2026-06-07 07:37:15 +02:00
Stefan Bodewig 41852f7f6f
learned a nicer way to download build-time dependencies while working on Ivy 2026-06-05 08:34:27 +02:00
Stefan Bodewig 4f3c6626b8
the BSI TR is not binding for the EU CRA, yet. Things may change. 2026-06-05 08:31:13 +02:00
Stefan Bodewig 3763e82971
CRA stuff 2026-06-04 15:43:23 +02:00
Stefan Bodewig 5434c15dbf
more external references 2026-06-04 14:18:35 +02:00
Stefan Bodewig 6bf90e7e12
publish SBOMs to maven repo 2026-06-04 08:48:33 +02:00
Stefan Bodewig e38891055a
archiveUrl is wrong 2026-06-04 08:44:49 +02:00
Stefan Bodewig 55e01c1de1
intial steps at creating SBOMs for AntUnit 2026-06-04 08:36:04 +02:00
Stefan Bodewig c20a3fea1d
bump Ant and JUnit dependencies 2026-06-04 08:35:24 +02:00
Stefan Bodewig 0ed7a52615
fix javadocs 2026-05-22 22:28:06 +02:00
Stefan Bodewig 0d5bb05c19
provide built-in negations for remaining assertions 2026-05-17 13:08:08 +02:00
Stefan Bodewig 3c3cdce66b
upgrade to "more modern" commons 2026-05-17 13:08:08 +02:00
Stefan Bodewig 84d2879715
Merge pull request #2 from apache/infrastructure-ruleset-bot/default-branch-protection
[INFRA] Set up default rulesets for default and release branches
2026-05-16 16:09:18 +00:00
The Apache Software Foundation ffa28cac72 Set up default protection ruleset for default and release branches 2026-05-15 13:50:47 -05:00
Stefan Bodewig d00b9e0833
add a assertPropertyNotSet assertion 2026-05-14 21:35:02 +02:00
Stefan Bodewig 1d98715cab
document changes mad by Matt four years ago 2026-04-26 22:45:01 +02:00
Stefan Bodewig e1275d128c
copy license to root directory 2026-04-26 22:36:48 +02:00
Matt Benson 066ebab434 run antunit with optional classpath (compiles fine for what it's worth but proper functioning requires Ant with ce494e8365) 2022-02-13 14:44:06 -06:00
Matt Benson 35caae04d0 code cleanup/updates 2022-02-12 16:14:33 -06:00
Stefan Bodewig b64de44027 prepare RC1 of AntUnit 1.4.1 2021-07-07 18:42:16 +02:00
Stefan Bodewig e436acf88c next release will be 1.4.1 rather than 1.5 2021-07-03 12:05:12 +02:00
Stefan Bodewig 2d2e4d0dab we should do as we say, use ant:current in antlib descriptor
https://bz.apache.org/bugzilla/show_bug.cgi?id=65315
2021-05-23 10:59:02 +02:00
jkf 2c49ac7f4e also https in NOTICE 2019-05-26 23:54:17 +02:00
jkf 3d4c28fb10 Removed unnecessary http references 2019-05-26 23:52:57 +02:00
jkf 932d318652 Merge branch 'master' of https://gitbox.apache.org/repos/asf/ant-antlibs-antunit 2019-05-26 22:45:04 +02:00
jkf 7b53475312 updated reference to license from http to https using find . -type f -exec sed -i s/http://www.apache.org/licenses/LICENSE-2.0/https://www.apache.org/licenses/LICENSE-2.0/ {} \; 2019-05-26 22:44:16 +02:00
Stefan Bodewig d87b05bcce TLS 2019-05-25 16:12:22 +02:00
Stefan Bodewig cac02039dc moved to gitbox 2018-12-17 09:24:42 +01:00
Stefan Bodewig ee72769dd0 Tagging version 1.4 of AntUnit
-----BEGIN PGP SIGNATURE-----
 
 iHEEABECADEWIQTOgHWiUVR77iSbwVGiEVrhX2uLcgUCWzBxkBMcYm9kZXdpZ0Bh
 cGFjaGUub3JnAAoJEKIRWuFfa4tyFgcAn2m21w7zVQD0xuNhl19BLeEsKia+AJ97
 px5k88sqIing0vOfttvWU8p8Aw==
 =5sOU
 -----END PGP SIGNATURE-----

Merge tag 'rel/1.4' and prepare for next iteration

Tagging version 1.4 of AntUnit
2018-06-25 06:41:53 +02:00
Stefan Bodewig 1015e0a32a compile target is set to Java5 2018-06-22 11:43:46 +02:00
Stefan Bodewig fd04cd6899 prepare RC3 of AntUnit 1.4 2018-06-22 07:23:35 +02:00
Stefan Bodewig f66f1178dc AntUnit now requires Ant 1.8.1 2018-06-22 06:44:05 +02:00
107 changed files with 1795 additions and 928 deletions

14
.asf.yaml Normal file
View File

@ -0,0 +1,14 @@
github:
rulesets:
- name: "Default Branch Protection"
type: branch
branches:
includes:
- "~DEFAULT_BRANCH"
- "release/*"
- "rel/*"
excludes: []
bypass_teams:
- root
restrict_deletion: true
restrict_force_push: true

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/ivy/ /ivy/
/lib/ /lib/
/target/ /target/
distribution

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "common"] [submodule "common"]
path = common path = common
url = https://git-wip-us.apache.org/repos/asf/ant-antlibs-common.git url = https://gitbox.apache.org/repos/asf/ant-antlibs-common.git

203
LICENSE Normal file
View File

@ -0,0 +1,203 @@
/*
* Apache License
* Version 2.0, January 2004
* http://www.apache.org/licenses/
*
* TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
*
* 1. Definitions.
*
* "License" shall mean the terms and conditions for use, reproduction,
* and distribution as defined by Sections 1 through 9 of this document.
*
* "Licensor" shall mean the copyright owner or entity authorized by
* the copyright owner that is granting the License.
*
* "Legal Entity" shall mean the union of the acting entity and all
* other entities that control, are controlled by, or are under common
* control with that entity. For the purposes of this definition,
* "control" means (i) the power, direct or indirect, to cause the
* direction or management of such entity, whether by contract or
* otherwise, or (ii) ownership of fifty percent (50%) or more of the
* outstanding shares, or (iii) beneficial ownership of such entity.
*
* "You" (or "Your") shall mean an individual or Legal Entity
* exercising permissions granted by this License.
*
* "Source" form shall mean the preferred form for making modifications,
* including but not limited to software source code, documentation
* source, and configuration files.
*
* "Object" form shall mean any form resulting from mechanical
* transformation or translation of a Source form, including but
* not limited to compiled object code, generated documentation,
* and conversions to other media types.
*
* "Work" shall mean the work of authorship, whether in Source or
* Object form, made available under the License, as indicated by a
* copyright notice that is included in or attached to the work
* (an example is provided in the Appendix below).
*
* "Derivative Works" shall mean any work, whether in Source or Object
* form, that is based on (or derived from) the Work and for which the
* editorial revisions, annotations, elaborations, or other modifications
* represent, as a whole, an original work of authorship. For the purposes
* of this License, Derivative Works shall not include works that remain
* separable from, or merely link (or bind by name) to the interfaces of,
* the Work and Derivative Works thereof.
*
* "Contribution" shall mean any work of authorship, including
* the original version of the Work and any modifications or additions
* to that Work or Derivative Works thereof, that is intentionally
* submitted to Licensor for inclusion in the Work by the copyright owner
* or by an individual or Legal Entity authorized to submit on behalf of
* the copyright owner. For the purposes of this definition, "submitted"
* means any form of electronic, verbal, or written communication sent
* to the Licensor or its representatives, including but not limited to
* communication on electronic mailing lists, source code control systems,
* and issue tracking systems that are managed by, or on behalf of, the
* Licensor for the purpose of discussing and improving the Work, but
* excluding communication that is conspicuously marked or otherwise
* designated in writing by the copyright owner as "Not a Contribution."
*
* "Contributor" shall mean Licensor and any individual or Legal Entity
* on behalf of whom a Contribution has been received by Licensor and
* subsequently incorporated within the Work.
*
* 2. Grant of Copyright License. Subject to the terms and conditions of
* this License, each Contributor hereby grants to You a perpetual,
* worldwide, non-exclusive, no-charge, royalty-free, irrevocable
* copyright license to reproduce, prepare Derivative Works of,
* publicly display, publicly perform, sublicense, and distribute the
* Work and such Derivative Works in Source or Object form.
*
* 3. Grant of Patent License. Subject to the terms and conditions of
* this License, each Contributor hereby grants to You a perpetual,
* worldwide, non-exclusive, no-charge, royalty-free, irrevocable
* (except as stated in this section) patent license to make, have made,
* use, offer to sell, sell, import, and otherwise transfer the Work,
* where such license applies only to those patent claims licensable
* by such Contributor that are necessarily infringed by their
* Contribution(s) alone or by combination of their Contribution(s)
* with the Work to which such Contribution(s) was submitted. If You
* institute patent litigation against any entity (including a
* cross-claim or counterclaim in a lawsuit) alleging that the Work
* or a Contribution incorporated within the Work constitutes direct
* or contributory patent infringement, then any patent licenses
* granted to You under this License for that Work shall terminate
* as of the date such litigation is filed.
*
* 4. Redistribution. You may reproduce and distribute copies of the
* Work or Derivative Works thereof in any medium, with or without
* modifications, and in Source or Object form, provided that You
* meet the following conditions:
*
* (a) You must give any other recipients of the Work or
* Derivative Works a copy of this License; and
*
* (b) You must cause any modified files to carry prominent notices
* stating that You changed the files; and
*
* (c) You must retain, in the Source form of any Derivative Works
* that You distribute, all copyright, patent, trademark, and
* attribution notices from the Source form of the Work,
* excluding those notices that do not pertain to any part of
* the Derivative Works; and
*
* (d) If the Work includes a "NOTICE" text file as part of its
* distribution, then any Derivative Works that You distribute must
* include a readable copy of the attribution notices contained
* within such NOTICE file, excluding those notices that do not
* pertain to any part of the Derivative Works, in at least one
* of the following places: within a NOTICE text file distributed
* as part of the Derivative Works; within the Source form or
* documentation, if provided along with the Derivative Works; or,
* within a display generated by the Derivative Works, if and
* wherever such third-party notices normally appear. The contents
* of the NOTICE file are for informational purposes only and
* do not modify the License. You may add Your own attribution
* notices within Derivative Works that You distribute, alongside
* or as an addendum to the NOTICE text from the Work, provided
* that such additional attribution notices cannot be construed
* as modifying the License.
*
* You may add Your own copyright statement to Your modifications and
* may provide additional or different license terms and conditions
* for use, reproduction, or distribution of Your modifications, or
* for any such Derivative Works as a whole, provided Your use,
* reproduction, and distribution of the Work otherwise complies with
* the conditions stated in this License.
*
* 5. Submission of Contributions. Unless You explicitly state otherwise,
* any Contribution intentionally submitted for inclusion in the Work
* by You to the Licensor shall be under the terms and conditions of
* this License, without any additional terms or conditions.
* Notwithstanding the above, nothing herein shall supersede or modify
* the terms of any separate license agreement you may have executed
* with Licensor regarding such Contributions.
*
* 6. Trademarks. This License does not grant permission to use the trade
* names, trademarks, service marks, or product names of the Licensor,
* except as required for reasonable and customary use in describing the
* origin of the Work and reproducing the content of the NOTICE file.
*
* 7. Disclaimer of Warranty. Unless required by applicable law or
* agreed to in writing, Licensor provides the Work (and each
* Contributor provides its Contributions) on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied, including, without limitation, any warranties or conditions
* of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
* PARTICULAR PURPOSE. You are solely responsible for determining the
* appropriateness of using or redistributing the Work and assume any
* risks associated with Your exercise of permissions under this License.
*
* 8. Limitation of Liability. In no event and under no legal theory,
* whether in tort (including negligence), contract, or otherwise,
* unless required by applicable law (such as deliberate and grossly
* negligent acts) or agreed to in writing, shall any Contributor be
* liable to You for damages, including any direct, indirect, special,
* incidental, or consequential damages of any character arising as a
* result of this License or out of the use or inability to use the
* Work (including but not limited to damages for loss of goodwill,
* work stoppage, computer failure or malfunction, or any and all
* other commercial damages or losses), even if such Contributor
* has been advised of the possibility of such damages.
*
* 9. Accepting Warranty or Additional Liability. While redistributing
* the Work or Derivative Works thereof, You may choose to offer,
* and charge a fee for, acceptance of support, warranty, indemnity,
* or other liability obligations and/or rights consistent with this
* License. However, in accepting such obligations, You may act only
* on Your own behalf and on Your sole responsibility, not on behalf
* of any other Contributor, and only if You agree to indemnify,
* defend, and hold each Contributor harmless for any liability
* incurred by, or claims asserted against, such Contributor by reason
* of your accepting any such warranty or additional liability.
*
* END OF TERMS AND CONDITIONS
*
* APPENDIX: How to apply the Apache License to your work.
*
* To apply the Apache License to your work, attach the following
* boilerplate notice, with the fields enclosed by brackets "[]"
* replaced with your own identifying information. (Don't include
* the brackets!) The text should be enclosed in the appropriate
* comment syntax for the file format. We also recommend that a
* file or class name and description of purpose be included on the
* same "printed page" as the copyright notice for easier
* identification within third-party archives.
*
* Copyright [yyyy] [name of copyright owner]
*
* Licensed 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.
*/

4
NOTICE
View File

@ -1,6 +1,6 @@
Apache AntUnit Apache AntUnit
Copyright 2005-2018 The Apache Software Foundation Copyright 2005-2018,2021-2022,2026 The Apache Software Foundation
This product includes software developed at This product includes software developed at
The Apache Software Foundation (http://www.apache.org/). The Apache Software Foundation (https://www.apache.org/).

8
README
View File

@ -11,16 +11,16 @@ Learn more
The documentation is included in the docs subdirectory of this The documentation is included in the docs subdirectory of this
distribution. The home of this library is distribution. The home of this library is
<http://ant.apache.org/antlibs/antunit/index.html>. <https://ant.apache.org/antlibs/antunit/index.html>.
Building Building
======== ========
This Ant Library requires Ant 1.7.0 or later to build, some of This Ant Library requires Ant 1.8.1 or later to build, some of
the test use JUnit 3 (3.8.2 recommended). the test use JUnit 4 (4.12 recommended).
It should work with any Java(TM) Runtime (and compile with any Java(TM) It should work with any Java(TM) Runtime (and compile with any Java(TM)
Developer Kit) starting with version 1.2. Developer Kit) starting with version 5.
Using Using
===== =====

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -22,11 +22,24 @@ under the License.
<!-- easy way to override properties --> <!-- easy way to override properties -->
<property file="build.properties"/> <property file="build.properties"/>
<!-- don't fork junit; regexp classes not available --> <!-- we don't want the build to look for a packaged AntUnit -->
<property name="junit.fork" value="false" /> <target name="setup-for-antunit-tests" depends="setup,determine-test-types,resolve"
unless="skip-antunit">
<typedef uri="antlib:org.apache.ant.antunit"
resource="org/apache/ant/antunit/antlib.xml">
<classpath>
<path refid="classpath.test"/>
<pathelement location="${build.classes}"/>
<pathelement location="${antlib.location}"/>
</classpath>
</typedef>
</target>
<property name="javac.test-source" value="1.5"/> <target name="ready-for-bin-dist" depends="create-antlib-sbom,common.ready-for-bin-dist"/>
<property name="javac.test-target" value="1.5"/>
<target name="after-src-dist" depends="src-sboms"/>
<target name="after-bin-dist" depends="bin-sboms"/>
<import file="common/build.xml"/> <import file="common/build.xml"/>
<import file="cyclonedx.xml"/>
</project> </project>

View File

@ -7,7 +7,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -37,7 +37,32 @@
<title>Apache AntUnit</title> <title>Apache AntUnit</title>
</properties> </properties>
<release version="1.4" date="unreleased"> <release version="1.5.1" date="unreleased">
</release>
<release version="1.5.0" date="2026-07-19">
<action type="add">
Allow the AntUnit task to use a different classloader when
running the test by means of a nested classpath or a
classpathrefid attribute.
Only works properly with Ant 1.10.13 or later.
</action>
<action type="add">
Add new assertNotEquals, assertPropertyNotSet,
assertPropertyNotEquals, assertPropertyDoesntContain and
assertReferenceIsNotSet assertions.
</action>
</release>
<release version="1.4.1" date="2021-07-07">
<action type="fix" issue="65315">
We didn't follow our own best practice and hard-coded the
AntUnit URI inside the Antlib descriptor instead of using
ant:current.
</action>
</release>
<release version="1.4" date="2018-06-25">
<action type="update" breaks-bwc="true"> <action type="update" breaks-bwc="true">
The coordinates inside the Ivy file have been changed to match The coordinates inside the Ivy file have been changed to match
those of the POM. those of the POM.
@ -47,6 +72,9 @@
for reports could cause stack overflows or out-of-memory errors for reports could cause stack overflows or out-of-memory errors
when applied to big outputs. when applied to big outputs.
</action> </action>
<action type="update" breaks-bwc="true">
AntUnit now requires at least Ant 1.8.1 at runtime.
</action>
</release> </release>
<release version="1.3" date="2014-05-14"> <release version="1.3" date="2014-05-14">

2
common

@ -1 +1 @@
Subproject commit 3c6caed623736b021d3615df6376ec554640d61e Subproject commit 08aa3efdbec177de04e5a9d7f9a5ca787d612a4e

View File

@ -7,7 +7,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

255
cyclonedx.xml Normal file
View File

@ -0,0 +1,255 @@
<?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
https://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="cyclonedx" xmlns:ivy="antlib:org.apache.ivy.ant">
<target name="define-cyclonedx-components"
depends="define-core-ant-components"
if="can.use.cyclonedx">
<cdx:externalreferenceset
id="antlib-ext-refs"
xmlns:cdx="antlib:org.apache.ant.cyclonedx">
<externalReference
type="VCS"
url="https://gitbox.apache.org/repos/asf/ant-antlibs-antunit.git"/>
<externalReference
type="ISSUE_TRACKER"
url="https://bz.apache.org/bugzilla/buglist.cgi?component=AntUnit&amp;product=Ant"/>
</cdx:externalreferenceset>
</target>
<target name="create-antlib-sbom"
depends="define-cyclonedx-components,antlib"
if="can.use.cyclonedx">
<uptodate property="antlib-sbom-ok"
targetfile="${build.lib}/${artifact.stub}.cdx.json">
<srcresources>
<file file="${jarname}"/>
<file file="ivy.xml"/>
<file file="cyclonedx.xml"/>
</srcresources>
</uptodate>
<cdx:componentbom
bomName="${artifact.stub}.cdx"
outputdirectory="${build.lib}"
format="all"
useComponentSupplier="true"
useComponentManufacturer="true"
unless:set="antlib-sbom-ok"
xmlns:unless="ant:unless"
xmlns:cdx="antlib:org.apache.ant.cyclonedx">
<component
name="${artifact.name}"
group="org.apache.ant"
version="${artifact.version}"
description="Apache AntUnit"
publisher="The Apache Software Foundation"
supplierIsManufacturer="true">
<file file="${jarname}"/>
<supplier refid="ant-pmc"/>
<license refid="apache-2"/>
<externalReferenceSet refid="ant-common-refs"/>
<externalReferenceSet refid="antlibs-common-ext-refs"/>
<externalReferenceSet refid="antlib-ext-refs"/>
<dependency componentRef="ant"/>
<dependency componentRef="junit"/>
</component>
<additionalComponent refid="ant"/>
<additionalComponent refid="ant-launcher"/>
<additionalComponent
id="junit"
name="junit"
group="junit"
version="4.13.2"
description="JUnit is a unit testing framework for Java, created by Erich Gamma and Kent Beck."
scope="optional"
publisher="JUnit">
<license licenseId="EPL-1.0">
<url url="http://www.eclipse.org/legal/epl-v10.html"/>
</license>
<externalReference
type="WEBSITE"
url="http://junit.org"/>
<dependency componentRef="hamcrest"/>
</additionalComponent>
<additionalComponent
id="hamcrest"
name="hamcrest-core"
group="org.hamcrest"
version="1.3"
description="Core API and libraries of hamcrest matcher framework."
scope="optional">
<license licenseId="BSD-3-Clause">
<url url="https://raw.githubusercontent.com/hamcrest/JavaHamcrest/master/LICENSE"/>
</license>
<externalReference
type="WEBSITE"
url="http://hamcrest.org/JavaHamcrest/"/>
</additionalComponent>
<license refid="apache-2"/>
</cdx:componentbom>
</target>
<target name="after-dist"
depends="define-cyclonedx-components"
if="can.use.cyclonedx">
<macrodef name="distributionbom" backtrace="false">
<attribute name="version"/>
<attribute name="archiveName"/>
<attribute name="archiveUrl"/>
<attribute name="archiveLocation" default=""/>
<attribute name="outputDirectory"/>
<attribute name="description"/>
<attribute name="publisher"/>
<attribute name="componentType" default="file"/>
<attribute name="format" default="all"/>
<attribute name="useComponentManufacturer" default="true"/>
<attribute name="useComponentSupplier" default="true"/>
<attribute name="supplierIsManufacturer" default="true"/>
<element name="archiveContent"/>
<element name="componentChildren" optional="true"/>
<element name="additionalBomContent" optional="true"/>
<sequential
xmlns:cdx="antlib:org.apache.ant.cyclonedx">
<cdx:componentbom
bomName="@{archiveName}.cdx"
outputdirectory="@{outputDirectory}"
format="@{format}"
useComponentManufacturer="@{useComponentManufacturer}"
useComponentSupplier="@{useComponentSupplier}">
<component
version="@{version}"
purl="@{archiveUrl}"
name="@{archiveUrl}"
description="@{description}"
publisher="@{publisher}"
type="@{componentType}"
supplierIsManufacturer="@{supplierIsManufacturer}">
<file file="@{archiveLocation}"
unless:blank="@{archiveLocation}" xmlns:unless="ant:unless"/>
<componentChildren/>
</component>
<pureFileComponents>
<archiveContent/>
</pureFileComponents>
<additionalBomContent/>
</cdx:componentbom>
</sequential>
</macrodef>
<macrodef name="create-tarball-bom">
<attribute name="distdir"/>
<attribute name="distbase"/>
<attribute name="subdir"/>
<attribute name="binsrc"/>
<attribute name="binarysource"/>
<attribute name="ext"/>
<element name="moreComponentChildren" implicit="true" optional="true"/>
<sequential>
<distributionbom
outputdirectory="@{distbase}"
version="${artifact.version}"
archiveName="${dist.name}-@{binsrc}.@{ext}"
archiveUrl="https://archive.apache.org/dist/ant/antlibs/antunit/@{subdir}/${dist.name}-@{binsrc}.@{ext}"
archiveLocation="@{distbase}/${dist.name}-@{binsrc}.@{ext}"
description="Apache AntUnit @{binarysource}"
publisher="The Apache Software Foundation"
xmlns:cdx="antlib:org.apache.ant.cyclonedx">
<componentChildren>
<supplier refid="ant-pmc"/>
<license refid="apache-2"/>
<externalReferenceSet refid="ant-common-refs"/>
<externalReferenceSet refid="antlibs-common-ext-refs"/>
<externalReferenceSet refid="antlib-ext-refs"/>
<moreComponentChildren/>
</componentChildren>
<archiveContent>
<fileset dir="@{distdir}/..">
<include name="${dist.name}/**"/>
</fileset>
</archiveContent>
<additionalBomContent>
<license refid="apache-2"/>
</additionalBomContent>
</distributionbom>
</sequential>
</macrodef>
<macrodef name="create-tarball-boms">
<attribute name="distdir"/>
<attribute name="distbase"/>
<attribute name="subdir"/>
<attribute name="binsrc"/>
<attribute name="binarysource"/>
<element name="componentChildren" implicit="true" optional="true"/>
<sequential>
<create-tarball-bom
distdir="@{distdir}"
distbase="@{distbase}"
subdir="@{subdir}"
binsrc="@{binsrc}"
binarysource="@{binarysource}"
ext="tar.gz">
<componentChildren/>
</create-tarball-bom>
<create-tarball-bom
distdir="@{distdir}"
distbase="@{distbase}"
subdir="@{subdir}"
binsrc="@{binsrc}"
binarysource="@{binarysource}"
ext="tar.bz2">
<componentChildren/>
</create-tarball-bom>
<create-tarball-bom
distdir="@{distdir}"
distbase="@{distbase}"
subdir="@{subdir}"
binsrc="@{binsrc}"
binarysource="@{binarysource}"
ext="zip">
<componentChildren/>
</create-tarball-bom>
</sequential>
</macrodef>
</target>
<target name="src-sboms" depends="after-dist" if="can.use.cyclonedx">
<create-tarball-boms
distdir="${src.dist.dir}"
distbase="${dist.base}"
subdir="source"
binsrc="src"
binarysource="Source Distribution"/>
</target>
<target name="bin-sboms" depends="after-dist" if="can.use.cyclonedx">
<create-tarball-boms
distdir="${bin.dist.dir}"
distbase="${dist.base}"
subdir="binaries"
binsrc="bin"
binarysource="Binary Distribution">
<component>
<sbomLink>
<file file="${bin.dist.dir}/${artifact.stub}.cdx.json"/>
</sbomLink>
<file file="${bin.dist.dir}/${artifact.stub}.jar"/>
</component>
</create-tarball-boms>
</target>
</project>

View File

@ -7,7 +7,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -79,7 +79,7 @@ under the License.
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -145,6 +145,14 @@ public class LogCapturer {
attribute is set to false.</td> attribute is set to false.</td>
<td align="center">No.</td> <td align="center">No.</td>
</tr> </tr>
<tr>
<td valign="top">classpathrefid</td>
<td valign="top">Specify the classpath to use when running the
tests - specified as a reference to an existing path.<br/>
<em>since AntUnit 1.5</em>
</td>
<td align="center">No.</td>
</tr>
</table> </table>
<h3>Parameters specified as nested elements</h3> <h3>Parameters specified as nested elements</h3>
@ -174,7 +182,7 @@ public class LogCapturer {
<h4>propertyset</h4> <h4>propertyset</h4>
<p><a <p><a
href="http://ant.apache.org/manual/Types/propertyset.html">&lt;propertyset&gt;</a>s href="https://ant.apache.org/manual/Types/propertyset.html">&lt;propertyset&gt;</a>s
can be used to pass properties to the build files under test.</p> can be used to pass properties to the build files under test.</p>
<h4>reference</h4> <h4>reference</h4>
@ -210,7 +218,7 @@ public class LogCapturer {
<a name="referenceset"/><h4>referenceset</h4> <a name="referenceset"/><h4>referenceset</h4>
<p>References can be grouped inside a &lt;referenceset&gt; element for clarity. Additionally, &lt;referenceset&gt; <p>References can be grouped inside a &lt;referenceset&gt; element for clarity. Additionally, &lt;referenceset&gt;
elements may contain exactly one nested <a href="http://ant.apache.org/manual/CoreTypes/mapper.html">&lt;mapper&gt;</a> elements may contain exactly one nested <a href="https://ant.apache.org/manual/CoreTypes/mapper.html">&lt;mapper&gt;</a>
element, which defines how source reference IDs are translated into target reference IDs. For example, element, which defines how source reference IDs are translated into target reference IDs. For example,
<pre> <pre>
@ -224,6 +232,12 @@ public class LogCapturer {
</pre> </pre>
</p> </p>
<h4>classpath</h4>
<p>Nested path-like structure. Specifies the classpath to use
when running the tests. Requires Ant 1.10.13 or later to work
properly. <em>since AntUnit 1.5</em>.</p>
<h3>Examples</h3> <h3>Examples</h3>
<p>This build file snippet (from src/etc/testcases/antunit/base.xml)</p> <p>This build file snippet (from src/etc/testcases/antunit/base.xml)</p>

View File

@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -89,7 +89,54 @@
<pre> <pre>
&lt;assertEquals message="foo is not bar" expected="bar" &lt;assertEquals message="foo is not bar" expected="bar"
actual="${foo}" casesensitive="false"/&gt; actual="${foo}" casesensitive="false"/&gt;
</pre>
<h2><a name="assertNotEquals">assertNotEquals</a></h2>
<p>Asserts that its two arguments are not equal.</p>
<p><em>Since AntUnit 1.5</em></p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">notExpected</td>
<td valign="top">First string to test.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">actual</td>
<td valign="top">Second string to test.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">message</td>
<td valign="top">Message for the exception if the condition
doesn't hold true. Defaults to "Didn't expect
'<em>notExpected</em>' to be '<em>actual</em>'".</td>
<td align="center">No.</td>
</tr>
<tr>
<td valign="top">casesensitive</td>
<td valign="top">Perform a case sensitive comparision.
Default is true.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Examples</h3>
<p>Make the build fail with the message "foo is bar" if the
property foo doesn't hold the value bar regardless of case:</p>
<pre>
&lt;assertNotEquals message="foo is bar" notExpected="bar"
actual="${foo}" casesensitive="false"/&gt;
</pre> </pre>
<h2><a name="assertPropertySet">assertPropertySet</a></h2> <h2><a name="assertPropertySet">assertPropertySet</a></h2>
@ -125,6 +172,42 @@
&lt;assertPropertySet name="foo"/&gt; &lt;assertPropertySet name="foo"/&gt;
</pre> </pre>
<h2><a name="assertPropertyNotSet">assertPropertyNotSet</a></h2>
<p><em>Since AntUnit 1.5</em></p>
<p>Asserts that a property hasn't got a value.</p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">name</td>
<td valign="top">Name of the property.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">message</td>
<td valign="top">Message for the exception if the condition
doesn't hold true. Defaults to "Didn't expect property
'<em>name</em>' to be set but was '<em>actual value</em>'".</td>
<td align="center">No.</td>
</tr>
</table>
<h3>Examples</h3>
<p>Make the build fail with the message "Didn't expect property
'foo' but was 'bar'" if the property foo is defined and has
value bar:</p>
<pre>
&lt;assertPropertyNotSet name="foo"/&gt;
</pre>
<h2><a name="assertPropertyEquals">assertPropertyEquals</a></h2> <h2><a name="assertPropertyEquals">assertPropertyEquals</a></h2>
<p>Asserts that a given property is set and holds a certain <p>Asserts that a given property is set and holds a certain
@ -169,7 +252,54 @@
<pre> <pre>
&lt;assertPropertyEquals message="foo is not bar" value="bar" &lt;assertPropertyEquals message="foo is not bar" value="bar"
name="foo" casesensitive="false"/&gt; name="foo" casesensitive="false"/&gt;
</pre>
<h2><a name="assertPropertyNotEquals">assertPropertyNotEquals</a></h2>
<p><em>Since AntUnit 1.5</em></p>
<p>Asserts that a given property is set but doesn't hold a certain
value.</p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">name</td>
<td valign="top">Name of the property.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">value</td>
<td valign="top">Not expected value.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">message</td>
<td valign="top">Message for the exception if the condition
doesn't hold true. Defaults to "Didn't expect property '<em>name</em>' to have value '<em>value</em>'".</td>
<td align="center">No.</td>
</tr>
<tr>
<td valign="top">casesensitive</td>
<td valign="top">Perform a case sensitive comparision.
Default is true.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Examples</h3>
<p>Make the build fail with the message "foo is bar" if the
property foo holds the value bar regardless of case:</p>
<pre>
&lt;assertPropertyNotEquals message="foo is bar" value="bar"
name="foo" casesensitive="false"/&gt;
</pre> </pre>
<h2><a name="assertPropertyContains">assertPropertyContains</a></h2> <h2><a name="assertPropertyContains">assertPropertyContains</a></h2>
@ -219,6 +349,55 @@
name="foo" casesensitive="false"/&gt; name="foo" casesensitive="false"/&gt;
</pre> </pre>
<h2><a name="assertPropertyDoesntContain">assertPropertyDoesntContain</a></h2>
<p>Asserts that a given property is set and doesn't hold a certain
value as substring.</p>
<p><em>Since AntUnit 1.5</em></p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">name</td>
<td valign="top">Name of the property.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">value</td>
<td valign="top">Not expected substring value.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">message</td>
<td valign="top">Message for the exception if the condition
doesn't hold true. Defaults to "Didn't expect property
'<em>name</em>' to contain value '<em>value</em>' but was
'<em>value of property name</em>'".</td>
<td align="center">No.</td>
</tr>
<tr>
<td valign="top">casesensitive</td>
<td valign="top">Perform a case sensitive comparision.
Default is true.</td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Examples</h3>
<p>Make the build fail with the message "foo contains bar" if the
property foo contains the value bar regardless of case:</p>
<pre>
&lt;assertPropertyDoesntContain message="foo contains bar" value="bar"
name="foo" casesensitive="false"/&gt;
</pre>
<h2><a name="assertFileExists">assertFileExists</a></h2> <h2><a name="assertFileExists">assertFileExists</a></h2>
<p>Asserts that a given file exists.</p> <p>Asserts that a given file exists.</p>
@ -325,21 +504,6 @@
&lt;assertResourceExists resource="${ant.home}/lib/ant.jar"/&gt; &lt;assertResourceExists resource="${ant.home}/lib/ant.jar"/&gt;
</pre> </pre>
<h3>Ant 1.7.x Note</h3>
<p><code>assertResourceExists</code> relies on Ant 1.8.0 or later,
it doesn't work with Ant 1.7.x. You can simulate the assertion
using the <code>resourceExists</code> condition
and <code>assertTrue</code>, for example</p>
<pre>
&lt;au:assertTrue message="Expected resource '${ant.home}/lib/ant.jar' to exist"&gt;
&lt;au:resourceExists&gt;
&lt;file file="${ant.home}/lib/ant.jar"/&gt;
&lt;/au:resourceExists&gt;
&lt;/au:assertTrue&gt;
</pre>
<h2><a name="assertRefResourceExists">assertRefResourceExists</a></h2> <h2><a name="assertRefResourceExists">assertRefResourceExists</a></h2>
<p><em>Since AntUnit 1.3</em></p> <p><em>Since AntUnit 1.3</em></p>
@ -376,11 +540,6 @@
&lt;assertRefResourceExists refid="ant.jar"/&gt; &lt;assertRefResourceExists refid="ant.jar"/&gt;
</pre> </pre>
<h3>Ant 1.7.x Note</h3>
<p><code>assertRefResourceExists</code> relies on Ant 1.8.0 or later,
it doesn't work with Ant 1.7.x.</p>
<h2><a name="assertNestedResourceExists">assertNestedResourceExists</a></h2> <h2><a name="assertNestedResourceExists">assertNestedResourceExists</a></h2>
<p><em>Since AntUnit 1.3</em></p> <p><em>Since AntUnit 1.3</em></p>
@ -412,11 +571,6 @@
&lt;/assertNestedResourceExists&gt; &lt;/assertNestedResourceExists&gt;
</pre> </pre>
<h3>Ant 1.7.x Note</h3>
<p><code>assertNestedResourceExists</code> relies on Ant 1.8.0 or later,
it doesn't work with Ant 1.7.x.</p>
<h2><a name="assertResourceDoesntExist">assertResourceDoesntExist</a></h2> <h2><a name="assertResourceDoesntExist">assertResourceDoesntExist</a></h2>
<p><em>Since AntUnit 1.2</em></p> <p><em>Since AntUnit 1.2</em></p>
@ -458,21 +612,6 @@
&lt;assertResourceDoesntExist resource="${ant.home}/lib/ant.jar"/&gt; &lt;assertResourceDoesntExist resource="${ant.home}/lib/ant.jar"/&gt;
</pre> </pre>
<h3>Ant 1.7.x Note</h3>
<p><code>assertResourceDoesntExist</code> relies on Ant 1.8.0 or later,
it doesn't work with Ant 1.7.x. You can simulate the assertion
using the <code>resourceExists</code> condition
and <code>assertFalse</code>, for example</p>
<pre>
&lt;au:assertFalse message="Didn't expect resource '${ant.home}/lib/ant.jar' to exist"&gt;
&lt;au:resourceExists&gt;
&lt;file file="${ant.home}/lib/ant.jar"/&gt;
&lt;/au:resourceExists&gt;
&lt;/au:assertFalse&gt;
</pre>
<h2><a name="assertRefResourceDoesntExist">assertRefResourceDoesntExist</a></h2> <h2><a name="assertRefResourceDoesntExist">assertRefResourceDoesntExist</a></h2>
<p><em>Since AntUnit 1.3</em></p> <p><em>Since AntUnit 1.3</em></p>
@ -509,11 +648,6 @@
&lt;assertRefResourceDoesntExist refid="ant.jar"/&gt; &lt;assertRefResourceDoesntExist refid="ant.jar"/&gt;
</pre> </pre>
<h3>Ant 1.7.x Note</h3>
<p><code>assertRefResourceDoesntExist</code> relies on Ant 1.8.0 or later,
it doesn't work with Ant 1.7.x.</p>
<h2><a name="assertNestedResourceDoesntExist">assertNestedResourceDoesntExist</a></h2> <h2><a name="assertNestedResourceDoesntExist">assertNestedResourceDoesntExist</a></h2>
<p><em>Since AntUnit 1.3</em></p> <p><em>Since AntUnit 1.3</em></p>
@ -546,11 +680,6 @@
&lt;/assertNestedResourceDoesntExist&gt; &lt;/assertNestedResourceDoesntExist&gt;
</pre> </pre>
<h3>Ant 1.7.x Note</h3>
<p><code>assertNestedResourceDoesntExist</code> relies on Ant 1.8.0 or later,
it doesn't work with Ant 1.7.x.</p>
<h2><a name="assertDestIsUptodate">assertDestIsUptodate</a></h2> <h2><a name="assertDestIsUptodate">assertDestIsUptodate</a></h2>
<p>Asserts that a dest file is more recent than the source <p>Asserts that a dest file is more recent than the source
@ -657,7 +786,7 @@
<td align="center">No.</td> <td align="center">No.</td>
</tr> </tr>
</table> </table>
<h3>Example</h3> <h3>Example</h3>
<p>Make the build fail if the file build.xml and backups/build.xml <p>Make the build fail if the file build.xml and backups/build.xml
@ -695,7 +824,7 @@
<td align="center">No.</td> <td align="center">No.</td>
</tr> </tr>
</table> </table>
<h3>Example</h3> <h3>Example</h3>
<p>Make the build fail if the file build.xml and backups/build.xml <p>Make the build fail if the file build.xml and backups/build.xml
@ -738,6 +867,41 @@
&lt;assertReferenceSet name="foo"/&gt; &lt;assertReferenceSet name="foo"/&gt;
</pre> </pre>
<h2><a name="assertReferenceIsNotSet">assertReferenceIsNotSet</a></h2>
<p>Asserts that a reference hasn't got any value.</p>
<p><em>Since AntUnit 1.5</em></p>
<table border="1" cellpadding="2" cellspacing="0">
<tr>
<td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td>
</tr>
<tr>
<td valign="top">refid</td>
<td valign="top">Id of the reference.</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">message</td>
<td valign="top">Message for the exception if the condition
doesn't hold true. Defaults to "Didn't expect reference
'<em>id</em>'".</td>
<td align="center">No.</td>
</tr>
</table>
<h3>Examples</h3>
<p>Make the build fail with the message "Didn't expect reference 'foo'"
if the reference foo is defined:</p>
<pre>
&lt;assertReferenceIsNotSet name="foo"/&gt;
</pre>
<h2><a name="assertReferenceIsType">assertReferenceIsType</a></h2> <h2><a name="assertReferenceIsType">assertReferenceIsType</a></h2>
<p>Asserts that a reference has a value of a given type.</p> <p>Asserts that a reference has a value of a given type.</p>

View File

@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -1,61 +1,61 @@
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<html> <html>
<head> <head>
<meta http-equiv="Content-Language" content="en-us"></meta> <meta http-equiv="Content-Language" content="en-us"></meta>
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<title>XMLListener AntUnit Listener</title> <title>XMLListener AntUnit Listener</title>
</head> </head>
<body> <body>
<h2><a name="xmllistener">Failure AntUnit Listener</a></h2> <h2><a name="xmllistener">Failure AntUnit Listener</a></h2>
<h3>Description</h3> <h3>Description</h3>
<p>Writes reports similar to the &quot;failure&quot; JUnit formatter.</p><p>This AntUnitListener creates a new buildfile with a target for each failed test target in the AntUnit run. The generated target calls the failed target (with setUp and tearDown if present in the called project). <br></p><p>This is intended for rerunning just failed tests.<br></p> <p>Writes reports similar to the &quot;failure&quot; JUnit formatter.</p><p>This AntUnitListener creates a new buildfile with a target for each failed test target in the AntUnit run. The generated target calls the failed target (with setUp and tearDown if present in the called project). <br></p><p>This is intended for rerunning just failed tests.<br></p>
<h3>Parameters</h3> <h3>Parameters</h3>
<table border="1" cellpadding="2" cellspacing="0"> <table border="1" cellpadding="2" cellspacing="0">
<tr> <tr>
<td valign="top"><b>Attribute</b></td> <td valign="top"><b>Attribute</b></td>
<td valign="top"><b>Description</b></td> <td valign="top"><b>Description</b></td>
<td align="center" valign="top"><b>Required</b></td> <td align="center" valign="top"><b>Required</b></td>
</tr> </tr>
<tr> <tr>
<td valign="top">file</td> <td valign="top">file</td>
<td valign="top">Where to write the generated buildfile.<br></td> <td valign="top">Where to write the generated buildfile.<br></td>
<td align="center">Yes.</td> <td align="center">Yes.</td>
</tr> </tr>
</table> </table>
<h3>Examples</h3> <h3>Examples</h3>
<pre> <br> &lt;au:antunit&gt; <pre> <br> &lt;au:antunit&gt;
&lt;fileset dir=&quot;${tests}&quot; includes=&quot;*.xml&quot;/&gt; &lt;fileset dir=&quot;${tests}&quot; includes=&quot;*.xml&quot;/&gt;
&lt;au:failurelistener file=&quot;${build.dir}/failed-tests/failed.xml&quot;/&gt; &lt;au:failurelistener file=&quot;${build.dir}/failed-tests/failed.xml&quot;/&gt;
&lt;/au:antunit&gt; <br> &lt;/au:antunit&gt; <br>
</pre> </pre>
<p>Runs AntUnit on all XML files in the directory <p>Runs AntUnit on all XML files in the directory
<code>${tests}</code> and collecting all failed tests. If there was a failure the file <code>${build.dir}/failed-tests/failed.xml</code> is created and has a <em>textXXX </em>target for each failed test. Additionally it has a default target <em>antunit</em> which runs all these failed tests.<br> </p> <code>${tests}</code> and collecting all failed tests. If there was a failure the file <code>${build.dir}/failed-tests/failed.xml</code> is created and has a <em>textXXX </em>target for each failed test. Additionally it has a default target <em>antunit</em> which runs all these failed tests.<br> </p>
</body> </body>
</html> </html>

View File

@ -6,7 +6,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -29,13 +29,13 @@
<h2>Requirements</h2> <h2>Requirements</h2>
<p>The current version requires Ant 1.7.0 or later.</p> <p>The current version requires Ant 1.8.1 or later.</p>
<h2>Where is it?</h2> <h2>Where is it?</h2>
<p>The source code for the library lives in the <p>The source code for the library lives in the
ant-antlibs-antunit git repository - <a ant-antlibs-antunit git repository - <a
href="https://git1-us-west.apache.org/repos/asf?p=ant-antlibs-antunit.git">https://git-wip-us.apache.org/repos/asf/ant-antlibs-antunit.git</a>.</p> href="https://gitbox.apache.org/repos/asf?p=ant-antlibs-antunit.git">https://gitbox.apache.org/repos/asf/ant-antlibs-antunit.git</a>.</p>
<h2>Installation</h2> <h2>Installation</h2>

View File

@ -7,7 +7,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

24
ivy.xml
View File

@ -8,7 +8,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -23,10 +23,10 @@
revision="${artifact.version}" revision="${artifact.version}"
publication="${artifact.publication.datetime}"> publication="${artifact.publication.datetime}">
<license name="Apache Software License 2.0" <license name="Apache Software License 2.0"
url="http://www.apache.org/licenses/LICENSE-2.0"/> url="https://www.apache.org/licenses/LICENSE-2.0"/>
<ivyauthor name="Apache Ant Development Team" <ivyauthor name="Apache Ant Development Team"
url="http://ant.apache.org/"/> url="https://ant.apache.org/"/>
<description homepage="http://ant.apache.org/antlibs/antunit/"> <description homepage="https://ant.apache.org/antlibs/antunit/">
This library contains tasks that enables Ant task developers to test This library contains tasks that enables Ant task developers to test
their tasks with Ant and without JUnit. It contains a few assertion their tasks with Ant and without JUnit. It contains a few assertion
tasks and an antunit task that runs build files instead of test tasks and an antunit task that runs build files instead of test
@ -34,9 +34,9 @@
</description> </description>
</info> </info>
<configurations> <configurations>
<conf name="default" description="full antlib with all dependencies"/> <conf name="default" description="full antlib with all dependencies"/>
<conf name="provided" description="Ant must be present at runtime"/> <conf name="provided" description="Ant must be present at runtime"/>
<conf name="test" description="dependencies used for JUnit tests of the antlib" transitive="false" visibility="private"/> <conf name="test" description="dependencies used for JUnit tests of the antlib" transitive="false" visibility="private"/>
</configurations> </configurations>
<publications xmlns:e="urn:ant.apache.org:ivy-extras"> <publications xmlns:e="urn:ant.apache.org:ivy-extras">
<artifact name="${artifact.name}" type="pom" ext="pom"/> <artifact name="${artifact.name}" type="pom" ext="pom"/>
@ -55,10 +55,14 @@
e:classifier="ivy"/> e:classifier="ivy"/>
<artifact name="${artifact.name}" type="ivy.asc" ext="xml.asc" <artifact name="${artifact.name}" type="ivy.asc" ext="xml.asc"
e:classifier="ivy"/> e:classifier="ivy"/>
<artifact name="${artifact.name}" type="cyclonedx.xml" ext="cdx.xml"/>
<artifact name="${artifact.name}" type="cyclonedx.xml.asc" ext="cdx.xml.asc"/>
<artifact name="${artifact.name}" type="cyclonedx.json" ext="cdx.json"/>
<artifact name="${artifact.name}" type="cyclonedx.json.asc" ext="cdx.json.asc"/>
</publications> </publications>
<dependencies> <dependencies>
<dependency org="junit" name="junit" rev="4.12" conf="default"/> <dependency org="junit" name="junit" rev="4.13.2" conf="default"/>
<dependency org="org.apache.ant" name="ant" rev="1.8.1" conf="provided->default"/> <dependency org="org.apache.ant" name="ant" rev="1.10.13" conf="provided->default"/>
<dependency org="org.apache.ant" name="ant-testutil" rev="1.8.1" conf="test->default"/> <dependency org="org.apache.ant" name="ant-testutil" rev="1.10.13" conf="test->default"/>
</dependencies> </dependencies>
</ivy-module> </ivy-module>

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -27,7 +27,7 @@ The original of this snippet is maintained in the antlib-common project.
<!-- Which released version of AntUnit to use, where to download, where to store. --> <!-- Which released version of AntUnit to use, where to download, where to store. -->
<property name="antunit.version" value="1.3"/> <property name="antunit.version" value="1.3"/>
<property name="antunit.url" value="http://repo1.maven.org/maven2/org/apache/ant/ant-antunit/${antunit.version}/ant-antunit-${antunit.version}.jar"/> <property name="antunit.url" value="https://repo1.maven.org/maven2/org/apache/ant/ant-antunit/${antunit.version}/ant-antunit-${antunit.version}.jar"/>
<property name="antunit.file" value="ant-antunit.jar"/> <property name="antunit.file" value="ant-antunit.jar"/>
<!-- Skip unnecessary tasks. --> <!-- Skip unnecessary tasks. -->

View File

@ -7,7 +7,7 @@
2.0 (the "License"); you may not use this file except in compliance 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 with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 Unless required by https://www.apache.org/licenses/LICENSE-2.0 Unless required by
applicable law or agreed to in writing, software distributed under the applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See the License for CONDITIONS OF ANY KIND, either express or implied. See the License for
@ -17,7 +17,7 @@
<!-- <!--
This POM has been created manually by the Ant Development Team. Please 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 contact us if you are not satisfied with the data contained in this
POM . URL : http://ant.apache.org POM . URL : https://ant.apache.org
--> -->
<project> <project>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -28,19 +28,19 @@
<licenses> <licenses>
<license> <license>
<name>The Apache Software License, Version 2.0</name> <name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url> <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution> <distribution>repo</distribution>
</license> </license>
</licenses> </licenses>
<organization> <organization>
<name>The Apache Software Foundation</name> <name>The Apache Software Foundation</name>
<url>http://www.apache.org/</url> <url>https://www.apache.org/</url>
</organization> </organization>
<!-- <!--
Test doesn't work from maven, you have to fight with tricky classpath Test doesn't work from maven, you have to fight with tricky classpath
issue to solve that See http://markmail.org/thread/6giwzqproxidcwyc issue to solve that See https://markmail.org/thread/6giwzqproxidcwyc
And http://markmail.org/thread/5bbknx6hm7liqvi6 (until it is solved, I And https://markmail.org/thread/5bbknx6hm7liqvi6 (until it is solved, I
comment test setting) comment test setting)
--> -->
<properties> <properties>
@ -75,7 +75,7 @@
<dependency> <dependency>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId> <artifactId>ant</artifactId>
<version>1.7.1</version> <version>1.10.13</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -87,20 +87,20 @@
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.12</version> <version>4.13.2</version>
<scope>compile</scope> <scope>compile</scope>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant-launcher</artifactId> <artifactId>ant-launcher</artifactId>
<version>1.8.1</version> <version>1.10.13</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.ant</groupId> <groupId>org.apache.ant</groupId>
<artifactId>ant-testutil</artifactId> <artifactId>ant-testutil</artifactId>
<version>1.8.1</version> <version>1.10.13</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -15,7 +15,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -709,7 +709,7 @@ h6 {
<table width="100%"> <table width="100%">
<tr> <tr>
<td align="left"></td> <td align="left"></td>
<td align="right">Designed for use with <a href="http://ant.apache.org/antlibs/antunit/">AntUnit</a> and <a href="http://ant.apache.org/">Ant</a>.</td> <td align="right">Designed for use with <a href="https://ant.apache.org/antlibs/antunit/">AntUnit</a> and <a href="https://ant.apache.org/">Ant</a>.</td>
</tr> </tr>
</table> </table>
<hr size="1"/> <hr size="1"/>

View File

@ -13,7 +13,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -317,7 +317,7 @@ under the License.
<table width="100%"> <table width="100%">
<tr> <tr>
<td align="left"></td> <td align="left"></td>
<td align="right">Designed for use with <a href='http://ant.apache.org/antlibs/antunit/'>AntUnit</a> and <a href='http://ant.apache.org/'>Ant</a>.</td> <td align="right">Designed for use with <a href='https://ant.apache.org/antlibs/antunit/'>AntUnit</a> and <a href='https://ant.apache.org/'>Ant</a>.</td>
</tr> </tr>
</table> </table>
<hr size="1"/> <hr size="1"/>

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -43,7 +43,7 @@ under the License.
<target name="nonFile"> <target name="nonFile">
<au:antunit> <au:antunit>
<url url="http://ant.apache.org/"/> <url url="https://ant.apache.org/"/>
</au:antunit> </au:antunit>
</target> </target>

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -1,55 +1,55 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<project name="setup-and-teardown" <project name="setup-and-teardown"
default="all" default="all"
xmlns:au="antlib:org.apache.ant.antunit"> xmlns:au="antlib:org.apache.ant.antunit">
<target name="all"> <target name="all">
<fail message="These are not standalone tests." /> <fail message="These are not standalone tests." />
</target> </target>
<target name="setUp"> <target name="setUp">
<fail message="outputfile property is not set." unless="outputfile" /> <fail message="outputfile property is not set." unless="outputfile" />
<echo file="${outputfile}" append="true" message="S" /> <echo file="${outputfile}" append="true" message="S" />
</target> </target>
<target name="test1"> <target name="test1">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test2"> <target name="test2">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test3"> <target name="test3">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test4"> <target name="test4">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="tearDown"> <target name="tearDown">
<echo file="${outputfile}" append="true" message="T" /> <echo file="${outputfile}" append="true" message="T" />
</target> </target>
</project> </project>

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -1,43 +1,43 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<project name="failed-test" <project name="failed-test"
default="all" default="all"
xmlns:au="antlib:org.apache.ant.antunit"> xmlns:au="antlib:org.apache.ant.antunit">
<target name="all"> <target name="all">
<fail message="These are not standalone tests." /> <fail message="These are not standalone tests." />
</target> </target>
<target name="setUp"> <target name="setUp">
<echo file="${outputfile}" append="true" message="S" /> <echo file="${outputfile}" append="true" message="S" />
<fail message="Expected failure" /> <fail message="Expected failure" />
</target> </target>
<target name="test1"> <target name="test1">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="tearDown"> <target name="tearDown">
<echo file="${outputfile}" append="true" message="T" /> <echo file="${outputfile}" append="true" message="T" />
</target> </target>
</project> </project>

View File

@ -1,43 +1,43 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<project name="failed-test" <project name="failed-test"
default="all" default="all"
xmlns:au="antlib:org.apache.ant.antunit"> xmlns:au="antlib:org.apache.ant.antunit">
<target name="all"> <target name="all">
<fail message="These are not standalone tests." /> <fail message="These are not standalone tests." />
</target> </target>
<target name="setUp"> <target name="setUp">
<echo file="${outputfile}" append="true" message="S" /> <echo file="${outputfile}" append="true" message="S" />
</target> </target>
<target name="test1"> <target name="test1">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="tearDown"> <target name="tearDown">
<echo file="${outputfile}" append="true" message="T" /> <echo file="${outputfile}" append="true" message="T" />
<fail message="Expected failure" /> <fail message="Expected failure" />
</target> </target>
</project> </project>

View File

@ -1,44 +1,44 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<project name="failed-test" <project name="failed-test"
default="all" default="all"
xmlns:au="antlib:org.apache.ant.antunit"> xmlns:au="antlib:org.apache.ant.antunit">
<target name="all"> <target name="all">
<fail message="These are not standalone tests." /> <fail message="These are not standalone tests." />
</target> </target>
<target name="setUp"> <target name="setUp">
<fail message="outputfile property is not set." unless="outputfile" /> <fail message="outputfile property is not set." unless="outputfile" />
<echo file="${outputfile}" append="true" message="S" /> <echo file="${outputfile}" append="true" message="S" />
</target> </target>
<target name="test1"> <target name="test1">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
<fail message="Expected failure" /> <fail message="Expected failure" />
</target> </target>
<target name="tearDown"> <target name="tearDown">
<echo file="${outputfile}" append="true" message="T" /> <echo file="${outputfile}" append="true" message="T" />
</target> </target>
</project> </project>

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -1,50 +1,50 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<project name="no-setup" <project name="no-setup"
default="all" default="all"
xmlns:au="antlib:org.apache.ant.antunit"> xmlns:au="antlib:org.apache.ant.antunit">
<target name="all"> <target name="all">
<fail message="These are not standalone tests." /> <fail message="These are not standalone tests." />
</target> </target>
<target name="test1"> <target name="test1">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test2"> <target name="test2">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test3"> <target name="test3">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test4"> <target name="test4">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="tearDown"> <target name="tearDown">
<echo file="${outputfile}" append="true" message="T" /> <echo file="${outputfile}" append="true" message="T" />
</target> </target>
</project> </project>

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -1,51 +1,51 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
distributed with this work for additional information distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<project name="no-teardown" <project name="no-teardown"
default="all" default="all"
xmlns:au="antlib:org.apache.ant.antunit"> xmlns:au="antlib:org.apache.ant.antunit">
<target name="all"> <target name="all">
<fail message="These are not standalone tests." /> <fail message="These are not standalone tests." />
</target> </target>
<target name="setUp"> <target name="setUp">
<fail message="outputfile property is not set." unless="outputfile" /> <fail message="outputfile property is not set." unless="outputfile" />
<echo file="${outputfile}" append="true" message="S" /> <echo file="${outputfile}" append="true" message="S" />
</target> </target>
<target name="test1"> <target name="test1">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test2"> <target name="test2">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test3"> <target name="test3">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
<target name="test4"> <target name="test4">
<echo file="${outputfile}" append="true" message="E" /> <echo file="${outputfile}" append="true" message="E" />
</target> </target>
</project> </project>

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -77,6 +77,22 @@ under the License.
<au:assertEquals expected="bar" actual="BAR"/> <au:assertEquals expected="bar" actual="BAR"/>
</target> </target>
<target name="assertNotEqualsPass1">
<au:assertNotEquals notexpected="bar" actual="baz"/>
</target>
<target name="assertNotEqualsPass2">
<au:assertNotEquals notexpected="bar" actual="BAR"/>
</target>
<target name="assertNotEqualsFail">
<au:assertNotEquals notexpected="bar" actual="bar"/>
</target>
<target name="assertNotEqualsCaseFail">
<au:assertNotEquals notexpected="bar" actual="BAR" casesensitive="false"/>
</target>
<target name="assertPropertySetPass"> <target name="assertPropertySetPass">
<property name="foo" value="bar"/> <property name="foo" value="bar"/>
<au:assertPropertySet name="foo"/> <au:assertPropertySet name="foo"/>
@ -86,6 +102,15 @@ under the License.
<au:assertPropertySet name="foo"/> <au:assertPropertySet name="foo"/>
</target> </target>
<target name="assertPropertyNotSetPass">
<au:assertPropertyNotSet name="foo"/>
</target>
<target name="assertPropertyNotSetFail">
<property name="foo" value="bar"/>
<au:assertPropertyNotSet name="foo"/>
</target>
<target name="assertPropertyEqualsPass"> <target name="assertPropertyEqualsPass">
<property name="foo" value="bar"/> <property name="foo" value="bar"/>
<au:assertPropertyEquals name="foo" value="bar"/> <au:assertPropertyEquals name="foo" value="bar"/>
@ -110,6 +135,30 @@ under the License.
<au:assertPropertyEquals name="foo" value="BAR"/> <au:assertPropertyEquals name="foo" value="BAR"/>
</target> </target>
<target name="assertPropertyNotEqualsPass1">
<property name="foo" value="bar"/>
<au:assertPropertyNotEquals name="foo" value="baz"/>
</target>
<target name="assertPropertyNotEqualsPass2">
<property name="foo" value="bar"/>
<au:assertPropertyNotEquals name="foo" value="BAR"/>
</target>
<target name="assertPropertyNotEqualsFail1">
<au:assertPropertyNotEquals name="foo" value="bar"/>
</target>
<target name="assertPropertyNotEqualsFail2">
<property name="foo" value="bar"/>
<au:assertPropertyNotEquals name="foo" value="bar"/>
</target>
<target name="assertPropertyNotEqualsCaseFail">
<property name="foo" value="bar"/>
<au:assertPropertyNotEquals name="foo" value="BAR" casesensitive="false"/>
</target>
<target name="assertPropertyContains"> <target name="assertPropertyContains">
<property name="foo" value="bar"/> <property name="foo" value="bar"/>
<au:assertPropertyContains name="foo" value="ba"/> <au:assertPropertyContains name="foo" value="ba"/>
@ -120,6 +169,16 @@ under the License.
<au:assertPropertyContains name="foo" value="foo"/> <au:assertPropertyContains name="foo" value="foo"/>
</target> </target>
<target name="assertPropertyDoesntContain">
<property name="foo" value="bar"/>
<au:assertPropertyDoesntContain name="foo" value="foo"/>
</target>
<target name="assertPropertyDoesntContainFail">
<property name="foo" value="bar"/>
<au:assertPropertyDoesntContain name="foo" value="ba"/>
</target>
<target name="assertFileExistsPass"> <target name="assertFileExistsPass">
<au:assertFileExists file="assert.xml"/> <au:assertFileExists file="assert.xml"/>
</target> </target>
@ -205,6 +264,15 @@ under the License.
<au:assertReferenceSet refid="foo2"/> <au:assertReferenceSet refid="foo2"/>
</target> </target>
<target name="assertReferenceIsNotSetPass">
<au:assertReferenceIsNotSet refid="foo3"/>
</target>
<target name="assertReferenceIsNotSetFail">
<path id="foo4"/>
<au:assertReferenceIsNotSet refid="foo4"/>
</target>
<target name="assertReferenceIsTypePass"> <target name="assertReferenceIsTypePass">
<path id="foo3"/> <path id="foo3"/>
<au:assertReferenceIsType refid="foo3" type="path"/> <au:assertReferenceIsType refid="foo3" type="path"/>

View File

@ -9,7 +9,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -27,10 +27,11 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildEvent; import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.BuildListener;
@ -41,7 +42,9 @@ import org.apache.tools.ant.ProjectHelper;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Ant; import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.types.Mapper; import org.apache.tools.ant.types.Mapper;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.PropertySet; import org.apache.tools.ant.types.PropertySet;
import org.apache.tools.ant.types.Resource;
import org.apache.tools.ant.types.ResourceCollection; import org.apache.tools.ant.types.ResourceCollection;
import org.apache.tools.ant.types.resources.FileResource; import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.Union; import org.apache.tools.ant.types.resources.Union;
@ -107,24 +110,24 @@ public class AntUnit extends Task {
* The object responsible for the execution of the unit test. * The object responsible for the execution of the unit test.
* scriptRunner is invoked to executes the targets and keep the * scriptRunner is invoked to executes the targets and keep the
* reference to the project. scriptRunner is defined only when the * reference to the project. scriptRunner is defined only when the
* antunit script is running. * antunit script is running.
*/ */
private AntUnitScriptRunner scriptRunner; private AntUnitScriptRunner scriptRunner;
/** /**
* listeners. * listeners.
*/ */
private ArrayList listeners = new ArrayList(); private ArrayList<AntUnitListener> listeners = new ArrayList<AntUnitListener>();
/** /**
* propertysets. * propertysets.
*/ */
private ArrayList propertySets = new ArrayList(); private ArrayList<PropertySet> propertySets = new ArrayList<PropertySet>();
/** /**
* Holds references to be inherited by the test project * Holds references to be inherited by the test project
*/ */
private ArrayList referenceSets = new ArrayList(); private ArrayList<ReferenceSet> referenceSets = new ArrayList<ReferenceSet>();
/** /**
* has a failure occured? * has a failure occured?
@ -146,6 +149,10 @@ public class AntUnit extends Task {
*/ */
private String errorProperty = null; private String errorProperty = null;
private Path classpath;
private AntClassLoader subprojectCoreLoader;
/** /**
* Add build files to run as tests. * Add build files to run as tests.
* @param rc the ResourceCollection to add. * @param rc the ResourceCollection to add.
@ -210,6 +217,28 @@ public class AntUnit extends Task {
this.failOnError = failOnError; this.failOnError = failOnError;
} }
/**
* Create the nested classpath element.
* @return {@link Path}
*/
public Path createClasspath() {
if (classpath != null) {
throw new BuildException("Can only set classpath once");
}
return classpath = new Path(getProject());
}
/**
* Set the test classpath as a reference to a {@link Path} defined elsewhere.
* @param classpathRefid
*/
public void setClasspathRefid(String classpathRefid) {
if (classpathRefid == null || classpathRefid.trim().length() == 0) {
throw new BuildException("Null/empty/blank @classpathrefid specified");
}
createClasspath().setRefid(new org.apache.tools.ant.types.Reference(getProject(), classpathRefid));
}
/** /**
* Execute the tests. * Execute the tests.
*/ */
@ -217,6 +246,9 @@ public class AntUnit extends Task {
if (buildFiles == null) { if (buildFiles == null) {
throw new BuildException(ERROR_NO_TESTS); throw new BuildException(ERROR_NO_TESTS);
} }
if (classpath != null && classpath.size() > 0) {
subprojectCoreLoader = getProject().createClassLoader(classpath);
}
doResourceCollection(buildFiles); doResourceCollection(buildFiles);
if (failures > 0 || errors > 0) { if (failures > 0 || errors > 0) {
if (errorProperty != null) { if (errorProperty != null) {
@ -241,15 +273,15 @@ public class AntUnit extends Task {
if (!rc.isFilesystemOnly()) { if (!rc.isFilesystemOnly()) {
throw new BuildException(ERROR_NON_FILES); throw new BuildException(ERROR_NON_FILES);
} }
@SuppressWarnings("unchecked")
Iterable<Resource> iterable = (Iterable<Resource>) rc;
Iterator i = rc.iterator(); for (Resource resource : iterable) {
while (i.hasNext()) { FileResource r = (FileResource) resource;
FileResource r = (FileResource) i.next();
if (r.isExists()) { if (r.isExists()) {
doFile(r.getFile()); doFile(r.getFile());
} else { } else {
log("Skipping " + r + " since it doesn't exist", log("Skipping " + r + " since it doesn't exist", Project.MSG_VERBOSE);
Project.MSG_VERBOSE);
} }
} }
} }
@ -266,20 +298,19 @@ public class AntUnit extends Task {
}; };
try { try {
scriptRunner = new AntUnitScriptRunner(prjFactory); scriptRunner = new AntUnitScriptRunner(prjFactory);
List testTargets = scriptRunner.getTestTartgets(); List<String> testTargets = scriptRunner.getTestTargets();
scriptRunner.runSuite(testTargets, notifier); scriptRunner.runSuite(testTargets, notifier);
} finally { } finally {
scriptRunner=null; scriptRunner=null;
} }
} }
/** /**
* Redirect output to new project instance. * Redirect output to new project instance.
* @param outputToHandle the output to handle. * @param outputToHandle the output to handle.
*/ */
public void handleOutput(String outputToHandle) { public void handleOutput(String outputToHandle) {
if (scriptRunner!=null) { if (scriptRunner != null) {
scriptRunner.getCurrentProject().demuxOutput(outputToHandle, false); scriptRunner.getCurrentProject().demuxOutput(outputToHandle, false);
} else { } else {
super.handleOutput(outputToHandle); super.handleOutput(outputToHandle);
@ -294,7 +325,7 @@ public class AntUnit extends Task {
*/ */
public int handleInput(byte[] buffer, int offset, int length) public int handleInput(byte[] buffer, int offset, int length)
throws IOException { throws IOException {
if (scriptRunner!=null) { if (scriptRunner != null) {
return scriptRunner.getCurrentProject().demuxInput(buffer, offset, length); return scriptRunner.getCurrentProject().demuxInput(buffer, offset, length);
} }
return super.handleInput(buffer, offset, length); return super.handleInput(buffer, offset, length);
@ -305,7 +336,7 @@ public class AntUnit extends Task {
* @param toFlush the output String to flush. * @param toFlush the output String to flush.
*/ */
public void handleFlush(String toFlush) { public void handleFlush(String toFlush) {
if (scriptRunner!=null) { if (scriptRunner != null) {
scriptRunner.getCurrentProject().demuxFlush(toFlush, false); scriptRunner.getCurrentProject().demuxFlush(toFlush, false);
} else { } else {
super.handleFlush(toFlush); super.handleFlush(toFlush);
@ -317,7 +348,7 @@ public class AntUnit extends Task {
* @param errorOutputToHandle the error output to handle. * @param errorOutputToHandle the error output to handle.
*/ */
public void handleErrorOutput(String errorOutputToHandle) { public void handleErrorOutput(String errorOutputToHandle) {
if (scriptRunner!=null) { if (scriptRunner != null) {
scriptRunner.getCurrentProject().demuxOutput(errorOutputToHandle, true); scriptRunner.getCurrentProject().demuxOutput(errorOutputToHandle, true);
} else { } else {
super.handleErrorOutput(errorOutputToHandle); super.handleErrorOutput(errorOutputToHandle);
@ -329,7 +360,7 @@ public class AntUnit extends Task {
* @param errorOutputToFlush the error output to flush. * @param errorOutputToFlush the error output to flush.
*/ */
public void handleErrorFlush(String errorOutputToFlush) { public void handleErrorFlush(String errorOutputToFlush) {
if (scriptRunner!=null) { if (scriptRunner != null) {
scriptRunner.getCurrentProject().demuxFlush(errorOutputToFlush, true); scriptRunner.getCurrentProject().demuxFlush(errorOutputToFlush, true);
} else { } else {
super.handleErrorFlush(errorOutputToFlush); super.handleErrorFlush(errorOutputToFlush);
@ -342,24 +373,23 @@ public class AntUnit extends Task {
*/ */
private Project createProjectForFile(File f) { private Project createProjectForFile(File f) {
Project p = new Project(); Project p = new Project();
if (subprojectCoreLoader != null) {
p.setCoreLoader(subprojectCoreLoader);
}
p.setDefaultInputStream(getProject().getDefaultInputStream()); p.setDefaultInputStream(getProject().getDefaultInputStream());
p.initProperties(); p.initProperties();
p.setInputHandler(getProject().getInputHandler()); p.setInputHandler(getProject().getInputHandler());
getProject().initSubProject(p); getProject().initSubProject(p);
//pass through inherited properties //pass through inherited properties
for (Iterator outer = propertySets.iterator(); outer.hasNext(); ) { for (PropertySet set : propertySets) {
PropertySet set = (PropertySet) outer.next(); @SuppressWarnings({ "unchecked", "rawtypes" })
Map props = set.getProperties(); Map<String,Object> props = (Map) set.getProperties();
for (Iterator keys = props.keySet().iterator(); for (String key : props.keySet()) {
keys.hasNext(); ) { if (MagicNames.PROJECT_BASEDIR.equals(key) || MagicNames.ANT_FILE.equals(key)) {
String key = keys.next().toString();
if (MagicNames.PROJECT_BASEDIR.equals(key)
|| MagicNames.ANT_FILE.equals(key)) {
continue; continue;
} }
Object value = props.get(key); Object value = props.get(key);
if (value != null && value instanceof String if (value instanceof String && p.getProperty(key) == null) {
&& p.getProperty(key) == null) {
p.setNewProperty(key, (String) value); p.setNewProperty(key, (String) value);
} }
} }
@ -369,8 +399,7 @@ public class AntUnit extends Task {
//with significant modification from taskdefs.Ant in Ant core. //with significant modification from taskdefs.Ant in Ant core.
//unfortunately the only way we can share the code directly //unfortunately the only way we can share the code directly
//would be to extend Ant (which might not be a bad idea?) //would be to extend Ant (which might not be a bad idea?)
for (int i = 0; i < referenceSets.size(); ++i) { for (ReferenceSet set : referenceSets) {
ReferenceSet set = (ReferenceSet) referenceSets.get(i);
set.copyReferencesInto(p); set.copyReferencesInto(p);
} }
@ -390,12 +419,8 @@ public class AntUnit extends Task {
* @param p the Project to attach to. * @param p the Project to attach to.
*/ */
private void attachListeners(File buildFile, Project p) { private void attachListeners(File buildFile, Project p) {
Iterator it = listeners.iterator(); for (AntUnitListener al : listeners) {
while (it.hasNext()) { p.addBuildListener(new BuildToAntUnitListener(buildFile.getAbsolutePath(), al));
AntUnitListener al = (AntUnitListener) it.next();
p.addBuildListener(new BuildToAntUnitListener(buildFile
.getAbsolutePath(),
al));
al.setCurrentTestProject(p); al.setCurrentTestProject(p);
} }
} }
@ -405,9 +430,7 @@ public class AntUnit extends Task {
* @param targetName the name of the target. * @param targetName the name of the target.
*/ */
private void fireStartTest(String targetName) { private void fireStartTest(String targetName) {
Iterator it = listeners.iterator(); for (AntUnitListener al : listeners) {
while (it.hasNext()) {
AntUnitListener al = (AntUnitListener) it.next();
al.startTest(targetName); al.startTest(targetName);
} }
} }
@ -419,9 +442,7 @@ public class AntUnit extends Task {
*/ */
private void fireFail(String targetName, AssertionFailedException ae) { private void fireFail(String targetName, AssertionFailedException ae) {
failures++; failures++;
Iterator it = listeners.iterator(); for (AntUnitListener al : listeners) {
while (it.hasNext()) {
AntUnitListener al = (AntUnitListener) it.next();
al.addFailure(targetName, ae); al.addFailure(targetName, ae);
} }
} }
@ -433,9 +454,7 @@ public class AntUnit extends Task {
*/ */
private void fireError(String targetName, Throwable t) { private void fireError(String targetName, Throwable t) {
errors++; errors++;
Iterator it = listeners.iterator(); for (AntUnitListener al : listeners) {
while (it.hasNext()) {
AntUnitListener al = (AntUnitListener) it.next();
al.addError(targetName, t); al.addError(targetName, t);
} }
} }
@ -445,9 +464,7 @@ public class AntUnit extends Task {
* @param targetName the name of the current target. * @param targetName the name of the current target.
*/ */
private void fireEndTest(String targetName) { private void fireEndTest(String targetName) {
Iterator it = listeners.iterator(); for (AntUnitListener al : listeners) {
while (it.hasNext()) {
AntUnitListener al = (AntUnitListener) it.next();
al.endTest(targetName); al.endTest(targetName);
} }
} }
@ -461,7 +478,7 @@ public class AntUnit extends Task {
/** /**
* references inherited from parent project by antunit scripts * references inherited from parent project by antunit scripts
*/ */
private ArrayList references = new ArrayList(); private List<Reference> references = new ArrayList<Reference>();
/** /**
* maps source reference ID to target reference ID * maps source reference ID to target reference ID
*/ */
@ -471,13 +488,16 @@ public class AntUnit extends Task {
references.add(reference); references.add(reference);
} }
/**
* Create a nested mapper element.
* @return {@link Mapper}
*/
public Mapper createMapper() { public Mapper createMapper() {
if (mapper == null) { if (mapper == null) {
return mapper = new Mapper(getProject()); return mapper = new Mapper(getProject());
} else {
throw new BuildException("Only one mapper element is allowed"
+ " per referenceSet", getLocation());
} }
throw new BuildException("Only one mapper element is allowed per referenceSet",
getLocation());
} }
/** /**
@ -503,19 +523,16 @@ public class AntUnit extends Task {
* @param newProject the target project to copy references into * @param newProject the target project to copy references into
*/ */
public void copyReferencesInto(Project newProject) { public void copyReferencesInto(Project newProject) {
FileNameMapper mapper = this.mapper == null FileNameMapper mapper = this.mapper == null ? null : this.mapper.getImplementation();
? null : this.mapper.getImplementation(); Set<String> matches = new HashSet<String>();
HashSet matches = new HashSet(); @SuppressWarnings("unchecked")
Hashtable src = getProject().getReferences(); Hashtable<String,Object> src = getProject().getReferences();
for (Iterator it = references.iterator(); it.hasNext(); ) {
Reference ref = (Reference) it.next();
for (Reference ref : references) {
matches.clear(); matches.clear();
ref.addMatchingReferences(src, matches); ref.addMatchingReferences(src, matches);
for (Iterator ids = matches.iterator(); ids.hasNext(); ) { for (String refid : matches) {
String refid = (String) ids.next();
String toRefid = ref.getToRefid(); String toRefid = ref.getToRefid();
//transform the refid with the mapper if necessary //transform the refid with the mapper if necessary
@ -556,12 +573,12 @@ public class AntUnit extends Task {
return; return;
} }
Class c = orig.getClass(); Class<?> c = orig.getClass();
Object copy = orig; Object copy = orig;
try { try {
Method cloneM = c.getMethod("clone", new Class[0]); Method cloneM = c.getMethod("clone");
if (cloneM != null) { if (cloneM != null) {
copy = cloneM.invoke(orig, new Object[0]); copy = cloneM.invoke(orig);
log("Adding clone of reference " + oldKey, log("Adding clone of reference " + oldKey,
Project.MSG_DEBUG); Project.MSG_DEBUG);
} }
@ -569,15 +586,14 @@ public class AntUnit extends Task {
// not Clonable // not Clonable
} }
if (copy instanceof ProjectComponent) { if (copy instanceof ProjectComponent) {
((ProjectComponent) copy).setProject(newProject); ((ProjectComponent) copy).setProject(newProject);
} else { } else {
try { try {
Method setProjectM = Method setProjectM =
c.getMethod("setProject", new Class[] {Project.class}); c.getMethod("setProject", Project.class);
if (setProjectM != null) { if (setProjectM != null) {
setProjectM.invoke(copy, new Object[] {newProject}); setProjectM.invoke(copy, newProject);
} }
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
// ignore this if the class being referenced does not have // ignore this if the class being referenced does not have
@ -590,8 +606,6 @@ public class AntUnit extends Task {
} }
newProject.addReference(newKey, copy); newProject.addReference(newKey, copy);
} }
} }
public static class Reference extends Ant.Reference { public static class Reference extends Ant.Reference {
@ -620,22 +634,21 @@ public class AntUnit extends Task {
* @param src table of references to check * @param src table of references to check
* @param dest set of reference IDs matching this reference pattern * @param dest set of reference IDs matching this reference pattern
*/ */
public void addMatchingReferences(Hashtable src, Collection dest) { public void addMatchingReferences(Hashtable<String, Object> src, Collection<String> dest) {
String id = getRefId(); String id = getRefId();
if (id != null) { if (id != null) {
if (src.containsKey(id)) { if (src.containsKey(id)) {
dest.add(id); dest.add(id);
} }
} else if (matcher != null) { } else if (matcher != null) {
for (Iterator it = src.keySet().iterator(); it.hasNext(); ) { for (String refid : src.keySet()) {
String refid = (String)it.next();
if (matcher.matches(refid)) { if (matcher.matches(refid)) {
dest.add(refid); dest.add(refid);
} }
} }
} else { } else {
throw new BuildException("either the refid or regex attribute " throw new BuildException(
+ "is required for reference elements"); "either the refid or regex attribute is required for reference elements");
} }
} }
} }
@ -658,10 +671,8 @@ public class AntUnit extends Task {
public void buildFinished(BuildEvent event) { public void buildFinished(BuildEvent event) {
a.endTestSuite(event.getProject(), buildFile); a.endTestSuite(event.getProject(), buildFile);
} }
public void targetStarted(BuildEvent event) { public void targetStarted(BuildEvent event) {}
} public void targetFinished(BuildEvent event) {}
public void targetFinished(BuildEvent event) {
}
public void taskStarted(BuildEvent event) {} public void taskStarted(BuildEvent event) {}
public void taskFinished(BuildEvent event) {} public void taskFinished(BuildEvent event) {}
public void messageLogged(BuildEvent event) {} public void messageLogged(BuildEvent event) {}

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -21,7 +21,7 @@
package org.apache.ant.antunit; package org.apache.ant.antunit;
/** /**
* Provides methods that allow the AntUnitScriptRunner to notify the test progress. * Provides methods that allow the AntUnitScriptRunner to notify the test progress.
* @since 1.2 * @since 1.2
*/ */
@ -31,26 +31,26 @@ public interface AntUnitExecutionNotifier {
* invokes start on all registered test listeners. * invokes start on all registered test listeners.
* @param targetName the name of the target. * @param targetName the name of the target.
*/ */
public void fireStartTest(String targetName); void fireStartTest(String targetName);
/** /**
* invokes addFailure on all registered test listeners. * invokes addFailure on all registered test listeners.
* @param targetName the name of the failed target. * @param targetName the name of the failed target.
* @param ae the associated AssertionFailedException. * @param ae the associated AssertionFailedException.
*/ */
public void fireFail(String targetName, AssertionFailedException ae); void fireFail(String targetName, AssertionFailedException ae);
/** /**
* invokes addError on all registered test listeners. * invokes addError on all registered test listeners.
* @param targetName the name of the failed target. * @param targetName the name of the failed target.
* @param t the associated Throwable. * @param t the associated Throwable.
*/ */
public void fireError(String targetName, Throwable t); void fireError(String targetName, Throwable t);
/** /**
* invokes endTest on all registered test listeners. * invokes endTest on all registered test listeners.
* @param targetName the name of the current target. * @param targetName the name of the current target.
*/ */
public void fireEndTest(String targetName); void fireEndTest(String targetName);
} }

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -20,7 +20,6 @@
package org.apache.ant.antunit; package org.apache.ant.antunit;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -28,15 +27,16 @@ import java.util.Vector;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;
/** /**
* Run antunit tests suites. This AntUnitScriptRunner is responsible for the * Run antunit tests suites. This AntUnitScriptRunner is responsible for the
* management of the ant project and the correct invocation the target (taking * management of the ant project and the correct invocation the target (taking
* into account properly the [case]setUp and [case]tearDown targets). * into account properly the [case]setUp and [case]tearDown targets).
* The user can however provide the order of the test targets and or can filter * The user can however provide the order of the test targets and or can filter
* the list of test targets to execute. * the list of test targets to execute.
* The user must also provide its ProjectFactory and an AntUnitExecutionNotifier. * The user must also provide its ProjectFactory and an AntUnitExecutionNotifier.
* @since 1.2 * @since 1.2
*/ */
public class AntUnitScriptRunner { public class AntUnitScriptRunner {
@ -69,13 +69,13 @@ public class AntUnitScriptRunner {
* Object used to create projects in order to support test isolation. * Object used to create projects in order to support test isolation.
*/ */
private final ProjectFactory prjFactory; private final ProjectFactory prjFactory;
/** /**
* Indicates if the startSuite method has been invoked. Use to fail fast if the * Indicates if the startSuite method has been invoked. Use to fail fast if the
* the caller forget to call the startSuite method * the caller forget to call the startSuite method
*/ */
private boolean isSuiteStarted; private boolean isSuiteStarted;
/** /**
* Does that script have a setUp target (defined when scanning the script) * Does that script have a setUp target (defined when scanning the script)
*/ */
@ -99,20 +99,20 @@ public class AntUnitScriptRunner {
/** /**
* List of target names * List of target names
*/ */
private final List testTargets; private final List<String> testTargets = new LinkedList<String>();
/** /**
* The project currently used. * The project currently used.
*/ */
private Project project = null; private Project project = null;
/** /**
* Indicates if a target has already be executed using this project. * Indicates if a target has already be executed using this project.
* Value is undefined when project is null. * Value is undefined when project is null.
*/ */
private boolean projectIsDirty; private boolean projectIsDirty;
/** /**
* Create a new AntScriptRunner on the given environment. * Create a new AntScriptRunner on the given environment.
* @param prjFactory A factory for the ant project that will contains the antunit test to execute. * @param prjFactory A factory for the ant project that will contains the antunit test to execute.
@ -122,17 +122,16 @@ public class AntUnitScriptRunner {
public AntUnitScriptRunner(ProjectFactory prjFactory) throws BuildException { public AntUnitScriptRunner(ProjectFactory prjFactory) throws BuildException {
this.prjFactory = prjFactory; this.prjFactory = prjFactory;
Project newProject = getCurrentProject(); Project newProject = getCurrentProject();
Map targets = newProject.getTargets(); @SuppressWarnings("unchecked")
Map<String, Target> targets = newProject.getTargets();
hasSetUp = targets.containsKey(SETUP); hasSetUp = targets.containsKey(SETUP);
hasTearDown = targets.containsKey(TEARDOWN); hasTearDown = targets.containsKey(TEARDOWN);
hasSuiteSetUp = targets.containsKey(SUITESETUP); hasSuiteSetUp = targets.containsKey(SUITESETUP);
hasSuiteTearDown = targets.containsKey(SUITETEARDOWN); hasSuiteTearDown = targets.containsKey(SUITETEARDOWN);
testTargets = new LinkedList();
Iterator it = targets.keySet().iterator(); for (String name : targets.keySet()) {
while (it.hasNext()) { if (name.startsWith(TEST) && !TEST.equals(name)) {
String name = (String) it.next(); getTestTargets().add(name);
if (name.startsWith(TEST) && !name.equals(TEST)) {
testTargets.add(name);
} }
} }
} }
@ -160,7 +159,7 @@ public class AntUnitScriptRunner {
project = prjFactory.createProject(); project = prjFactory.createProject();
} }
//we already set isDirty to true in order to make sure we didn't reuse //we already set isDirty to true in order to make sure we didn't reuse
//this project next time getCleanProject is called. //this project next time getCleanProject is called.
projectIsDirty = true; projectIsDirty = true;
return project; return project;
} }
@ -168,7 +167,16 @@ public class AntUnitScriptRunner {
/** /**
* @return List&lt;String&gt; List of test targets of the script file * @return List&lt;String&gt; List of test targets of the script file
*/ */
public List getTestTartgets() { @Deprecated
public List<String> getTestTartgets() {
return getTestTargets();
}
/**
* Get the (names of the) test targets to execute.
* @return {@link List} of {@link String}
*/
public List<String> getTestTargets() {
return testTargets; return testTargets;
} }
@ -184,7 +192,7 @@ public class AntUnitScriptRunner {
* Executes the suiteSetUp target if presents and report any execution error. * Executes the suiteSetUp target if presents and report any execution error.
* <p>A failure is reported to the notifier and by returning false. * <p>A failure is reported to the notifier and by returning false.
* Note that if the method return false, you are not allowed to run targets.</p> * Note that if the method return false, you are not allowed to run targets.</p>
* @return false in case of execution failure. true in case of success. * @return false in case of execution failure. true in case of success.
*/ */
private boolean startSuite(AntUnitExecutionNotifier notifier) { private boolean startSuite(AntUnitExecutionNotifier notifier) {
getCurrentProject().fireBuildStarted(); getCurrentProject().fireBuildStarted();
@ -202,7 +210,7 @@ public class AntUnitScriptRunner {
return true; return true;
} }
/** /**
* Run the specific test target, possibly between the setUp and tearDown targets if * Run the specific test target, possibly between the setUp and tearDown targets if
* it exists. Exception or failures are reported to the notifier. * it exists. Exception or failures are reported to the notifier.
* @param name name of the test target to execute. * @param name name of the test target to execute.
@ -214,13 +222,13 @@ public class AntUnitScriptRunner {
throw new AssertionError(); throw new AssertionError();
} }
Project newProject = getCleanProject(); Project newProject = getCleanProject();
Vector v = new Vector(); Vector<String> v = new Vector<String>();
if (hasSetUp) { if (hasSetUp) {
v.add(SETUP); v.add(SETUP);
} }
v.add(name); v.add(name);
// create and register a logcapturer on the newProject // create and register a logcapturer on the newProject
LogCapturer lc = new LogCapturer(newProject); new LogCapturer(newProject);
try { try {
notifier.fireStartTest(name); notifier.fireStartTest(name);
newProject.executeTargets(v); newProject.executeTargets(v);
@ -246,8 +254,8 @@ public class AntUnitScriptRunner {
/** /**
* Executes the suiteTearDown target if presents and report any execution error. * Executes the suiteTearDown target if presents and report any execution error.
* @param caught Any internal exception triggered (and caught) by the caller indicating that * @param caught Any internal exception triggered (and caught) by the caller indicating that
* the execution could not be invoked as expected. * the execution could not be invoked as expected.
* @param notifier will receive execution notifications. * @param notifier will receive execution notifications.
*/ */
private void endSuite(Throwable caught, AntUnitExecutionNotifier notifier) { private void endSuite(Throwable caught, AntUnitExecutionNotifier notifier) {
@ -266,14 +274,14 @@ public class AntUnitScriptRunner {
/** /**
* Try to see whether the BuildException e is an AssertionFailedException * Try to see whether the BuildException e is an AssertionFailedException
* or is caused by an AssertionFailedException. If so, fire a failure for * or is caused by an AssertionFailedException. If so, fire a failure for
* given targetName. Otherwise fire an error. * given targetName. Otherwise fire an error.
*/ */
private void fireFailOrError(String targetName, BuildException e, private void fireFailOrError(String targetName, BuildException e,
AntUnitExecutionNotifier notifier) { AntUnitExecutionNotifier notifier) {
boolean failed = false; boolean failed = false;
Throwable t = e; Throwable t = e;
while (t != null && t instanceof BuildException) { while (t instanceof BuildException) {
if (t instanceof AssertionFailedException) { if (t instanceof AssertionFailedException) {
failed = true; failed = true;
notifier.fireFail(targetName, (AssertionFailedException) t); notifier.fireFail(targetName, (AssertionFailedException) t);
@ -293,15 +301,13 @@ public class AntUnitScriptRunner {
* @param suiteTargets An ordered list of test targets. It must be a sublist of getTestTargets * @param suiteTargets An ordered list of test targets. It must be a sublist of getTestTargets
* @param notifier is notified on test progress * @param notifier is notified on test progress
*/ */
public void runSuite(List suiteTargets, AntUnitExecutionNotifier notifier) { public void runSuite(List<String> suiteTargets, AntUnitExecutionNotifier notifier) {
Throwable caught = null; Throwable caught = null;
try { try {
if (!startSuite(notifier)) { if (!startSuite(notifier)) {
return; return;
} }
Iterator iter = suiteTargets.iterator(); for (String name : suiteTargets) {
while (iter.hasNext()) {
String name = (String) iter.next();
runTarget(name, notifier); runTarget(name, notifier);
} }
} catch (Throwable e) { } catch (Throwable e) {
@ -310,5 +316,4 @@ public class AntUnitScriptRunner {
endSuite(caught, notifier); endSuite(caught, notifier);
} }
} }
} }

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,8 +7,8 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -20,7 +20,6 @@
package org.apache.ant.antunit; package org.apache.ant.antunit;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Collections; import java.util.Collections;
@ -41,7 +40,7 @@ import org.apache.tools.ant.util.StringUtils;
public class LogCapturer implements BuildListener { public class LogCapturer implements BuildListener {
public static final String REFERENCE_ID = "ant.antunit.log"; public static final String REFERENCE_ID = "ant.antunit.log";
private List/*<BuildEvent>*/ events = Collections.synchronizedList(new LinkedList()); private List<BuildEvent> events = Collections.synchronizedList(new LinkedList<BuildEvent>());
private Project p; private Project p;
public LogCapturer(Project p) { public LogCapturer(Project p) {
@ -184,15 +183,14 @@ public class LogCapturer implements BuildListener {
} }
private String getLog(int minPriority, boolean mergeLines) { private String getLog(int minPriority, boolean mergeLines) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
for (Iterator/*<BuildEvent>*/ it = new LinkedList(events).iterator(); for (BuildEvent buildEvent : new LinkedList<BuildEvent>(events)) {
it.hasNext(); ) { append(sb, buildEvent, minPriority, mergeLines);
append(sb, (BuildEvent) it.next(), minPriority, mergeLines);
} }
return sb.toString(); return sb.toString();
} }
private static void append(StringBuffer sb, BuildEvent event, private static void append(StringBuilder sb, BuildEvent event,
int minPriority, boolean mergeLines) { int minPriority, boolean mergeLines) {
if (event.getPriority() <= minPriority) { if (event.getPriority() <= minPriority) {
sb.append(event.getMessage()); sb.append(event.getMessage());

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -8,7 +8,7 @@ to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an software distributed under the License is distributed on an
@ -17,7 +17,7 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<antlib xmlns:au="antlib:org.apache.ant.antunit"> <antlib xmlns:au="ant:current">
<taskdef name="antunit" <taskdef name="antunit"
classname="org.apache.ant.antunit.AntUnit"/> classname="org.apache.ant.antunit.AntUnit"/>
@ -88,6 +88,22 @@ under the License.
</sequential> </sequential>
</macrodef> </macrodef>
<macrodef name="assertNotEquals" backtrace="false">
<attribute name="notExpected"/>
<attribute name="actual"/>
<attribute name="casesensitive" default="true"/>
<attribute name="message"
default="Didn't expect '@{notExpected}' to be '@{actual}'"/>
<sequential>
<au:fail message="@{message}">
<not>
<equals arg1="@{notExpected}" arg2="@{actual}"
casesensitive="@{casesensitive}"/>
</not>
</au:fail>
</sequential>
</macrodef>
<macrodef name="assertPropertySet" backtrace="false"> <macrodef name="assertPropertySet" backtrace="false">
<attribute name="name"/> <attribute name="name"/>
<attribute name="message" <attribute name="message"
@ -99,6 +115,19 @@ under the License.
</sequential> </sequential>
</macrodef> </macrodef>
<macrodef name="assertPropertyNotSet" backtrace="false">
<attribute name="name"/>
<attribute name="message"
default="Didn't expect property '@{name}' to be set but was '${@{name}}'"/>
<sequential>
<au:fail message="@{message}">
<not>
<isset property="@{name}"/>
</not>
</au:fail>
</sequential>
</macrodef>
<macrodef name="assertPropertyEquals" backtrace="false"> <macrodef name="assertPropertyEquals" backtrace="false">
<attribute name="name"/> <attribute name="name"/>
<attribute name="value"/> <attribute name="value"/>
@ -112,6 +141,19 @@ under the License.
</sequential> </sequential>
</macrodef> </macrodef>
<macrodef name="assertPropertyNotEquals" backtrace="false">
<attribute name="name"/>
<attribute name="value"/>
<attribute name="casesensitive" default="true"/>
<attribute name="message"
default="Didn't expect property '@{name}' to have value '@{value}'"/>
<sequential>
<au:assertPropertySet message="@{message}" name="@{name}"/>
<au:assertNotEquals message="@{message}" notexpected="@{value}"
actual="${@{name}}" casesensitive="@{casesensitive}"/>
</sequential>
</macrodef>
<macrodef name="assertPropertyContains" backtrace="false"> <macrodef name="assertPropertyContains" backtrace="false">
<attribute name="name"/> <attribute name="name"/>
<attribute name="value"/> <attribute name="value"/>
@ -126,7 +168,24 @@ under the License.
</au:fail> </au:fail>
</sequential> </sequential>
</macrodef> </macrodef>
<macrodef name="assertPropertyDoesntContain" backtrace="false">
<attribute name="name"/>
<attribute name="value"/>
<attribute name="casesensitive" default="true"/>
<attribute name="message"
default="Didn't expect property '@{name}' to contain value '@{value}' but was '${@{name}}'"/>
<sequential>
<au:assertPropertySet message="@{message}" name="@{name}"/>
<au:fail message="@{message}">
<not>
<contains string="${@{name}}" substring="@{value}"
casesensitive="@{casesensitive}"/>
</not>
</au:fail>
</sequential>
</macrodef>
<macrodef name="assertFileExists" backtrace="false"> <macrodef name="assertFileExists" backtrace="false">
<attribute name="file"/> <attribute name="file"/>
<attribute name="message" <attribute name="message"
@ -176,11 +235,11 @@ under the License.
<attribute name="value"/> <attribute name="value"/>
<attribute name="casesensitive" default="true"/> <attribute name="casesensitive" default="true"/>
<attribute name="message" <attribute name="message"
default="Expected resource '@{resource}' to contain value '@{value}' but was '${@{resource}}'"/> default="Expected resource '@{resource}' to contain value '@{value}' but was '${@{resource}}'"/>
<sequential> <sequential>
<au:assertResourceExists resource="@{resource}"/> <au:assertResourceExists resource="@{resource}"/>
<au:fail message="@{message}"> <au:fail message="@{message}">
<resourcecontains resource="@{resource}" substring="@{value}" <resourcecontains resource="@{resource}" substring="@{value}"
casesensitive="@{casesensitive}"/> casesensitive="@{casesensitive}"/>
</au:fail> </au:fail>
</sequential> </sequential>
@ -191,10 +250,10 @@ under the License.
<attribute name="value"/> <attribute name="value"/>
<attribute name="casesensitive" default="true"/> <attribute name="casesensitive" default="true"/>
<attribute name="message" <attribute name="message"
default="Didn't expect resource '@{resource}' to contain value '@{value}' but was '${@{resource}}'"/> default="Didn't expect resource '@{resource}' to contain value '@{value}' but was '${@{resource}}'"/>
<sequential> <sequential>
<au:assertFalse message="@{message}"> <au:assertFalse message="@{message}">
<resourcecontains resource="@{resource}" substring="@{value}" <resourcecontains resource="@{resource}" substring="@{value}"
casesensitive="@{casesensitive}"/> casesensitive="@{casesensitive}"/>
</au:assertFalse> </au:assertFalse>
</sequential> </sequential>
@ -251,11 +310,11 @@ under the License.
<attribute name="value"/> <attribute name="value"/>
<attribute name="casesensitive" default="true"/> <attribute name="casesensitive" default="true"/>
<attribute name="message" <attribute name="message"
default="Expected resource '@{refid}' to contain value '@{value}'"/> default="Expected resource '@{refid}' to contain value '@{value}'"/>
<sequential> <sequential>
<au:assertRefResourceExists refid="@{refid}"/> <au:assertRefResourceExists refid="@{refid}"/>
<au:fail message="@{message}"> <au:fail message="@{message}">
<resourcecontains refid="@{refid}" substring="@{value}" <resourcecontains refid="@{refid}" substring="@{value}"
casesensitive="@{casesensitive}"/> casesensitive="@{casesensitive}"/>
</au:fail> </au:fail>
</sequential> </sequential>
@ -266,10 +325,10 @@ under the License.
<attribute name="value"/> <attribute name="value"/>
<attribute name="casesensitive" default="true"/> <attribute name="casesensitive" default="true"/>
<attribute name="message" <attribute name="message"
default="Didn't expect resource '@{refid}' to contain value '@{value}'"/> default="Didn't expect resource '@{refid}' to contain value '@{value}'"/>
<sequential> <sequential>
<au:assertFalse message="@{message}"> <au:assertFalse message="@{message}">
<resourcecontains refid="@{refid}" substring="@{value}" <resourcecontains refid="@{refid}" substring="@{value}"
casesensitive="@{casesensitive}"/> casesensitive="@{casesensitive}"/>
</au:assertFalse> </au:assertFalse>
</sequential> </sequential>
@ -334,6 +393,19 @@ under the License.
</sequential> </sequential>
</macrodef> </macrodef>
<macrodef name="assertReferenceIsNotSet" backtrace="false">
<attribute name="refid"/>
<attribute name="message"
default="Didn't expect reference '@{refid}'"/>
<sequential>
<au:fail message="@{message}">
<not>
<isreference refid="@{refid}"/>
</not>
</au:fail>
</sequential>
</macrodef>
<macrodef name="assertReferenceIsType" backtrace="false"> <macrodef name="assertReferenceIsType" backtrace="false">
<attribute name="refid"/> <attribute name="refid"/>
<attribute name="type"/> <attribute name="type"/>
@ -385,7 +457,7 @@ under the License.
default="Expected '@{string}' to match pattern '@{pattern}'"/> default="Expected '@{string}' to match pattern '@{pattern}'"/>
<sequential> <sequential>
<au:fail message="@{message}"> <au:fail message="@{message}">
<matches string="@{string}" pattern="@{pattern}" <matches string="@{string}" pattern="@{pattern}"
casesensitive="@{casesensitive}" casesensitive="@{casesensitive}"
singleline="@{singleline}" singleline="@{singleline}"
multiline="@{multiline}"/> multiline="@{multiline}"/>

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -23,7 +23,6 @@ package org.apache.ant.antunit.junit3;
import java.io.File; import java.io.File;
import java.io.PrintStream; import java.io.PrintStream;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import junit.framework.Test; import junit.framework.Test;
@ -57,16 +56,16 @@ public class AntUnitSuite extends TestSuite {
* File reference. Namely, if the File is a relative file, it will * File reference. Namely, if the File is a relative file, it will
* be resolve relatively to the execution directory (which might be * be resolve relatively to the execution directory (which might be
* different different from the project root directory).</p> * different different from the project root directory).</p>
* *
* @param scriptFile * @param scriptFile
* AntUnit script file * AntUnit script file
* @param rootClass * @param rootClass
* The test class that creates this suite. This is used to give * The test class that creates this suite. This is used to give
* a name to the suite so that an IDE can reexecute this suite. * a name to the suite so that an IDE can reexecute this suite.
*/ */
public AntUnitSuite(File scriptFile, Class rootClass) { public AntUnitSuite(File scriptFile, Class<?> rootClass) {
setName(rootClass.getName()); //This name allows eclipse to reexecute the test setName(rootClass.getName()); //This name allows eclipse to reexecute the test
AntUnitScriptRunner createdScriptRunner = null; final AntUnitScriptRunner createdScriptRunner;
try { try {
MyProjectFactory prjFactory = new MyProjectFactory(scriptFile); MyProjectFactory prjFactory = new MyProjectFactory(scriptFile);
createdScriptRunner = new AntUnitScriptRunner(prjFactory); createdScriptRunner = new AntUnitScriptRunner(prjFactory);
@ -82,11 +81,8 @@ public class AntUnitSuite extends TestSuite {
initializationReportingTest = null; initializationReportingTest = null;
stdout = new MultiProjectDemuxOutputStream(antScriptRunner, false); stdout = new MultiProjectDemuxOutputStream(antScriptRunner, false);
stderr = new MultiProjectDemuxOutputStream(antScriptRunner, true); stderr = new MultiProjectDemuxOutputStream(antScriptRunner, true);
List testTargets = antScriptRunner.getTestTartgets(); for (String target : antScriptRunner.getTestTargets()) {
for (Iterator it = testTargets.iterator(); it.hasNext();) { addTest(new AntUnitTestCase(this, scriptFile, target));
String target = (String) it.next();
AntUnitTestCase tc = new AntUnitTestCase(this, scriptFile, target);
addTest(tc);
} }
} }
@ -100,28 +96,28 @@ public class AntUnitSuite extends TestSuite {
MyProjectFactory prjFactory = new MyProjectFactory(scriptFile); MyProjectFactory prjFactory = new MyProjectFactory(scriptFile);
antScriptRunner = new AntUnitScriptRunner(prjFactory); antScriptRunner = new AntUnitScriptRunner(prjFactory);
//the exception is throwed, and it is up to the AntUnitTestCase to handle it. //the exception is throwed, and it is up to the AntUnitTestCase to handle it.
initializationReportingTest = null; initializationReportingTest = null;
stdout = new MultiProjectDemuxOutputStream(antScriptRunner, false); stdout = new MultiProjectDemuxOutputStream(antScriptRunner, false);
stderr = new MultiProjectDemuxOutputStream(antScriptRunner, true); stderr = new MultiProjectDemuxOutputStream(antScriptRunner, true);
setName(antScriptRunner.getName() + "[" + scriptFile + "]"); setName(antScriptRunner.getName() + "[" + scriptFile + "]");
addTest(singleTc); addTest(singleTc);
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* <p>Run the full AntUnit suite.</p> * <p>Run the full AntUnit suite.</p>
*/ */
public void run(TestResult testResult) { public void run(TestResult testResult) {
if (initializationReportingTest!=null) { if (initializationReportingTest != null) {
initializationReportingTest.run(testResult); initializationReportingTest.run(testResult);
} else { } else {
List testTartgets = antScriptRunner.getTestTartgets(); List<String> testTargets = antScriptRunner.getTestTargets();
JUnitNotificationAdapter notifier = new JUnitNotificationAdapter( JUnitNotificationAdapter notifier = new JUnitNotificationAdapter(
testResult, tests()); testResult, tests());
runInContainer(testTartgets, notifier); runInContainer(testTargets, notifier);
} }
} }
/** /**
* {@inheritDoc} * {@inheritDoc}
* <p>Run a single test target of the AntUnit suite. suiteSetUp, * <p>Run a single test target of the AntUnit suite. suiteSetUp,
@ -132,7 +128,7 @@ public class AntUnitSuite extends TestSuite {
initializationReportingTest.run(result); initializationReportingTest.run(result);
} else { } else {
String targetName = ((AntUnitTestCase) test).getTarget(); String targetName = ((AntUnitTestCase) test).getTarget();
List singleTargetList = Collections.singletonList(targetName); List<String> singleTargetList = Collections.singletonList(targetName);
JUnitNotificationAdapter notifier = new JUnitNotificationAdapter( JUnitNotificationAdapter notifier = new JUnitNotificationAdapter(
result, tests()); result, tests());
runInContainer(singleTargetList, notifier); runInContainer(singleTargetList, notifier);
@ -144,13 +140,13 @@ public class AntUnitSuite extends TestSuite {
* <p>When ant executes a project it redirect the input and the output. In this * <p>When ant executes a project it redirect the input and the output. In this
* context we will only redirect output (unit test are not supposed to be * context we will only redirect output (unit test are not supposed to be
* interactive).</p> * interactive).</p>
* *
* @param targetList * @param targetList
* The list of test target to execute * The list of test target to execute
* @param notifier * @param notifier
* The AntUnit notifier that will receive execution notifications * The AntUnit notifier that will receive execution notifications
*/ */
public void runInContainer(List targetList, AntUnitExecutionNotifier notifier) { public void runInContainer(List<String> targetList, AntUnitExecutionNotifier notifier) {
PrintStream savedErr = System.err; PrintStream savedErr = System.err;
PrintStream savedOut = System.out; PrintStream savedOut = System.out;
try { try {
@ -176,7 +172,7 @@ public class AntUnitSuite extends TestSuite {
this.scriptFile = scriptFile; this.scriptFile = scriptFile;
} }
public Project createProject() { public Project createProject() {
ProjectHelper prjHelper = ProjectHelper.getProjectHelper(); ProjectHelper prjHelper = ProjectHelper.getProjectHelper();
Project prj = new Project(); Project prj = new Project();
DefaultLogger logger = new DefaultLogger(); DefaultLogger logger = new DefaultLogger();
@ -198,8 +194,6 @@ public class AntUnitSuite extends TestSuite {
} }
public BuildException getAntInitialisationException() { public BuildException getAntInitialisationException() {
return hasAntInitError() ? return hasAntInitError() ? initializationReportingTest.getAntScriptError() : null;
initializationReportingTest.getAntScriptError() :
null;
} }
} }

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -28,16 +28,16 @@ import junit.framework.TestCase;
import junit.framework.TestResult; import junit.framework.TestResult;
/** /**
* JUnit TestCase that will executes a single AntUnit target. * JUnit TestCase that executes a single AntUnit target.
* <p>This class is not * <p>This class is not
* supposed to be used directly.</p> * supposed to be used directly.</p>
* <p>It is public only because junit must access it as a public.</p> * <p>It is public only because junit must access it as a public.</p>
*/ */
public class AntUnitTestCase extends TestCase { public class AntUnitTestCase extends TestCase {
// We have to extends TestCase, and not implements Test because otherwise // We have to extends TestCase, and not implements Test because otherwise
// JUnit4 will derive the Description composing the suite description from // JUnit4 will derive the Description composing the suite description from
// this className only (AntUnitTestCase), and not from the name. // this className only (AntUnitTestCase), and not from the name.
// However, during execution it use the right Description (base on the // However, during execution it use the right Description (base on the
// toString) // toString)
/** /**
@ -56,25 +56,25 @@ public class AntUnitTestCase extends TestCase {
* class has been created directly by the IDE from its name. * class has been created directly by the IDE from its name.
* In case of initialisation problem when the test is build from the suite, * In case of initialisation problem when the test is build from the suite,
* the problem is handled at the level of the suite (and this object is never * the problem is handled at the level of the suite (and this object is never
* created) * created)
*/ */
private final BuildException initialisationException; private final BuildException initialisationException;
/** /**
* Prepare an AntUnitTestCase that will be executed alone. * Prepare an AntUnitTestCase that will be executed alone.
* <p>This constructor * <p>This constructor
* is typically used by a junit 3 runner that will reexecute a specific * is typically used by a junit 3 runner that will reexecute a specific
* test.</p> * test.</p>
* <p>The execution of this test will be embed in a suiteSetUp and * <p>The execution of this test will be embed in a suiteSetUp and
* suiteTearDown.</p> * suiteTearDown.</p>
* @param name The name of the AntUnitTestCase, normally obtained from a * @param name The name of the AntUnitTestCase, normally obtained from a
* previous execution. * previous execution.
*/ */
public AntUnitTestCase(String name) { public AntUnitTestCase(String name) {
super(name); super(name);
BuildException catchedEx = null; BuildException catchedEx = null;
AntUnitSuite createdSuite = null; AntUnitSuite createdSuite = null;
TestCaseName nameParser = new TestCaseName(name); TestCaseName nameParser = new TestCaseName(name);
try { try {
createdSuite = new AntUnitSuite(this, nameParser.getScript()); createdSuite = new AntUnitSuite(this, nameParser.getScript());
} catch (BuildException e) { } catch (BuildException e) {
@ -92,8 +92,8 @@ public class AntUnitTestCase extends TestCase {
* suite that prepare the antScriptRunner and the JUnitExcutionPlatform. It * suite that prepare the antScriptRunner and the JUnitExcutionPlatform. It
* is the responsibility of the suite to execute the suiteSetUp and the * is the responsibility of the suite to execute the suiteSetUp and the
* suiteTearDown. * suiteTearDown.
* *
* @param target test target * @param target test target
* @param suite test suite * @param suite test suite
* @param scriptFile test file * @param scriptFile test file
*/ */
@ -113,7 +113,7 @@ public class AntUnitTestCase extends TestCase {
return target; return target;
} }
/** /**
* Called by a Junit Runner that want to executes specifically * Called by a Junit Runner that want to executes specifically
* this test target. * this test target.
* <p>This implementation delegates the call to the suite.</p> * <p>This implementation delegates the call to the suite.</p>
@ -139,7 +139,7 @@ public class AntUnitTestCase extends TestCase {
protected void runTest() throws BuildException { protected void runTest() throws BuildException {
throw initialisationException; throw initialisationException;
} }
/** /**
* Handle the serialization and the parsing of the name of a TestCase. The * Handle the serialization and the parsing of the name of a TestCase. The
* name of the TestCase contains the filename of the script and the target, * name of the TestCase contains the filename of the script and the target,

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -36,9 +36,9 @@ import org.apache.ant.antunit.AssertionFailedException;
class JUnitNotificationAdapter implements AntUnitExecutionNotifier { class JUnitNotificationAdapter implements AntUnitExecutionNotifier {
private final TestResult junitTestResult; private final TestResult junitTestResult;
private Map testByTarget = new HashMap(); private Map<String, AntUnitTestCase> testByTarget = new HashMap<String, AntUnitTestCase>();
public JUnitNotificationAdapter(TestResult testResult, Enumeration tests) { public JUnitNotificationAdapter(TestResult testResult, Enumeration<Test> tests) {
this.junitTestResult = testResult; this.junitTestResult = testResult;
while(tests.hasMoreElements()) { while(tests.hasMoreElements()) {
AntUnitTestCase test = (AntUnitTestCase) tests.nextElement(); AntUnitTestCase test = (AntUnitTestCase) tests.nextElement();
@ -48,22 +48,22 @@ class JUnitNotificationAdapter implements AntUnitExecutionNotifier {
public void fireStartTest(String targetName) { public void fireStartTest(String targetName) {
//TODO : if it is null, eclipse stop the unit test (add a unit test) //TODO : if it is null, eclipse stop the unit test (add a unit test)
junitTestResult.startTest((Test) testByTarget.get(targetName)); junitTestResult.startTest(testByTarget.get(targetName));
} }
public void fireEndTest(String targetName) { public void fireEndTest(String targetName) {
junitTestResult.endTest((Test) testByTarget.get(targetName)); junitTestResult.endTest(testByTarget.get(targetName));
} }
public void fireError(String targetName, Throwable t) { public void fireError(String targetName, Throwable t) {
junitTestResult.addError((Test) testByTarget.get(targetName), t); junitTestResult.addError(testByTarget.get(targetName), t);
} }
public void fireFail(String targetName, AssertionFailedException ae) { public void fireFail(String targetName, AssertionFailedException ae) {
//I don't see how to transform the AntUnit assertion exception into //I don't see how to transform the AntUnit assertion exception into
//junit assertion exception (we would loose the stack trace). //junit assertion exception (we would loose the stack trace).
//So failures will be reported as errors //So failures will be reported as errors
junitTestResult.addError((Test) testByTarget.get(targetName), ae); junitTestResult.addError(testByTarget.get(targetName), ae);
} }
} }

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -8,7 +8,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -20,7 +20,6 @@
package org.apache.ant.antunit.junit4; package org.apache.ant.antunit.junit4;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -33,8 +32,8 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry;
import junit.framework.Test;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.ant.antunit.AntUnitExecutionNotifier; import org.apache.ant.antunit.AntUnitExecutionNotifier;
@ -60,43 +59,40 @@ import org.junit.runner.notification.RunNotifier;
* around every test target). Also, more features are available when this runner * around every test target). Also, more features are available when this runner
* is used (filtering &amp; sorting) * is used (filtering &amp; sorting)
*/ */
@SuppressWarnings("deprecation")
public class AntUnitSuiteRunner extends Runner implements Filterable, Sortable { public class AntUnitSuiteRunner extends Runner implements Filterable, Sortable {
private final AntUnitSuite junit3Suite; private final AntUnitSuite junit3Suite;
private final Map/*<String, Description>*/ targetDescriptions = new HashMap(); private final Map<String, Description> targetDescriptions = new HashMap<String, Description>();
private final List/*<String>*/ targetsOrder = new LinkedList(); private final List<String> targetsOrder = new LinkedList<String>();
private AntUnitSuiteRunner(AntUnitSuite suite, Class junitTestClass) throws InitializationError { private AntUnitSuiteRunner(AntUnitSuite suite, Class<?> junitTestClass) throws InitializationError {
junit3Suite = suite; junit3Suite = suite;
if (suite.hasAntInitError()) { if (suite.hasAntInitError()) {
throw new InitializationError( throw new InitializationError(suite.getAntInitialisationException());
new Throwable[] { suite.getAntInitialisationException() } }
); for (Enumeration<Test> tests = suite.tests(); tests.hasMoreElements();) {
} else { TestCase nextTc = (TestCase) tests.nextElement();
Enumeration tests = suite.tests(); //TODO Handle the possibility for the user to define suite of AntUnit scripts
while (tests.hasMoreElements()) { AntUnitTestCase tc = (AntUnitTestCase) nextTc;
TestCase nextTc = (TestCase) tests.nextElement(); Description tc_desc = Description.createTestDescription(junitTestClass, tc.getName());
//TODO Handle the possibility for the user to define suite of AntUnit scripts targetDescriptions.put(tc.getTarget(), tc_desc);
AntUnitTestCase tc = (AntUnitTestCase) nextTc; targetsOrder.add(tc.getTarget());
Description tc_desc = Description.createTestDescription(junitTestClass, tc.getName());
targetDescriptions.put(tc.getTarget(), tc_desc);
targetsOrder.add(tc.getTarget());
}
} }
} }
public AntUnitSuiteRunner(Class testCaseClass) throws InitializationError { public AntUnitSuiteRunner(Class<?> testCaseClass) throws InitializationError {
this(getJUnit3AntSuite(testCaseClass), testCaseClass); this(getJUnit3AntSuite(testCaseClass), testCaseClass);
} }
private static AntUnitSuite getJUnit3AntSuite(Class testCaseClass) private static AntUnitSuite getJUnit3AntSuite(Class<?> testCaseClass)
throws InitializationError { throws InitializationError {
try { try {
Method suiteMethod = testCaseClass.getMethod("suite", new Class[0]); Method suiteMethod = testCaseClass.getMethod("suite");
if (!Modifier.isStatic(suiteMethod.getModifiers())) { if (!Modifier.isStatic(suiteMethod.getModifiers())) {
throw new InitializationError("suite method must be static"); throw new InitializationError("suite method must be static");
} }
Object suite = suiteMethod.invoke(null, new Object[0]); Object suite = suiteMethod.invoke(null);
if (suite == null) { if (suite == null) {
throw new InitializationError("suite method can not return null"); throw new InitializationError("suite method can not return null");
} }
@ -105,11 +101,11 @@ public class AntUnitSuiteRunner extends Runner implements Filterable, Sortable {
} }
return (AntUnitSuite) suite; return (AntUnitSuite) suite;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
throw new InitializationError(new Throwable[] { e }); throw new InitializationError(e);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new InitializationError(new Throwable[] { e }); throw new InitializationError(e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
throw new InitializationError(new Throwable[] { e }); throw new InitializationError(e);
} }
} }
@ -117,11 +113,13 @@ public class AntUnitSuiteRunner extends Runner implements Filterable, Sortable {
* Filterable implementation * Filterable implementation
*/ */
public void filter(Filter filter) throws NoTestsRemainException { public void filter(Filter filter) throws NoTestsRemainException {
for (Iterator iter= targetDescriptions.entrySet().iterator(); iter.hasNext();) { for (Iterator<Map.Entry<String, Description>> iter =
Map.Entry mapEntry = (Entry) iter.next(); targetDescriptions.entrySet().iterator(); iter.hasNext();) {
if (!filter.shouldRun((Description) mapEntry.getValue())) Map.Entry<String, Description> mapEntry = iter.next();
if (!filter.shouldRun(mapEntry.getValue())) {
iter.remove(); iter.remove();
targetsOrder.remove(mapEntry.getKey()); targetsOrder.remove(mapEntry.getKey());
}
} }
} }
@ -129,28 +127,23 @@ public class AntUnitSuiteRunner extends Runner implements Filterable, Sortable {
* Sortable implementation * Sortable implementation
*/ */
public void sort(final Sorter sorter) { public void sort(final Sorter sorter) {
Collections.sort(targetsOrder, new Comparator/*<String>*/() { Collections.sort(targetsOrder, new Comparator<String>() {
public int compare(Object target1, Object target2) { public int compare(String target1, String target2) {
Description d2 = (Description)targetDescriptions.get(target2); Description d2 = targetDescriptions.get(target2);
Description d1 = (Description)targetDescriptions.get(target1); Description d1 = targetDescriptions.get(target1);
return sorter.compare(d1, d2); return sorter.compare(d1, d2);
} }
}); });
/*for (Runner each : fRunners)
sorter.apply(each);
*/
} }
/** /**
* Runner implementation * Runner implementation
*/ */
public Description getDescription() { public Description getDescription() {
Description r = Description.createSuiteDescription( Description r = Description.createSuiteDescription(junit3Suite.getName());
junit3Suite.getName(), new Annotation[0]);
Collection<Description> childDesc = targetDescriptions.values();
Collection childDesc = targetDescriptions.values(); for (Description desc : childDesc) {
for (Iterator iterator = childDesc.iterator(); iterator.hasNext();) {
Description desc = (Description) iterator.next();
r.addChild(desc); r.addChild(desc);
} }
return r; return r;
@ -160,14 +153,14 @@ public class AntUnitSuiteRunner extends Runner implements Filterable, Sortable {
* Runner implementation * Runner implementation
*/ */
public void run(final RunNotifier junitNotifier) { public void run(final RunNotifier junitNotifier) {
LinkedList targetList = new LinkedList(targetDescriptions.keySet()); List<String> targetList = new LinkedList<String>(targetDescriptions.keySet());
AntUnitExecutionNotifier antUnitNotifier = new AntUnitExecutionNotifier() { AntUnitExecutionNotifier antUnitNotifier = new AntUnitExecutionNotifier() {
public void fireStartTest(String targetName) { public void fireStartTest(String targetName) {
junitNotifier.fireTestStarted(getDescription(targetName)); junitNotifier.fireTestStarted(getDescription(targetName));
} }
public void fireEndTest(String targetName) { public void fireEndTest(String targetName) {
junitNotifier.fireTestFinished(getDescription(targetName)); junitNotifier.fireTestFinished(getDescription(targetName));
} }
public void fireError(String targetName, Throwable t) { public void fireError(String targetName, Throwable t) {
Failure failure = new Failure(getDescription(targetName), t); Failure failure = new Failure(getDescription(targetName), t);
@ -176,12 +169,12 @@ public class AntUnitSuiteRunner extends Runner implements Filterable, Sortable {
public void fireFail(String targetName, AssertionFailedException ae) { public void fireFail(String targetName, AssertionFailedException ae) {
Failure failure = new Failure(getDescription(targetName), ae); Failure failure = new Failure(getDescription(targetName), ae);
junitNotifier.fireTestFailure(failure); junitNotifier.fireTestFailure(failure);
} }
private Description getDescription(String targetName) { private Description getDescription(String targetName) {
return (Description) targetDescriptions.get(targetName); return targetDescriptions.get(targetName);
} }
}; };
junit3Suite.runInContainer(targetList, antUnitNotifier); junit3Suite.runInContainer(targetList, antUnitNotifier);
} }

View File

@ -8,7 +8,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -7,8 +7,8 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -37,27 +37,31 @@ import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.LogOutputStream; import org.apache.tools.ant.taskdefs.LogOutputStream;
import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;
import org.apache.tools.ant.util.KeepAliveOutputStream;
import org.apache.tools.ant.util.TeeOutputStream; import org.apache.tools.ant.util.TeeOutputStream;
/** /**
* A test listener for &lt;antunit&gt; modeled aftern the Plain JUnit * A test listener for &lt;antunit&gt; modeled aftern the Plain JUnit
* test listener that is part of Ant. * test listener that is part of Ant.
*/ */
public abstract class BaseAntUnitListener public abstract class BaseAntUnitListener implements AntUnitListener {
implements AntUnitListener {
protected BaseAntUnitListener(SendLogTo defaultReportTarget,
String extension) {
logTo = defaultReportTarget;
this.extension = extension;
logLevel = BaseAntUnitListener.AntUnitLogLevel.NONE;
}
/** /**
* Formatter for timings. * Formatter for timings.
*/ */
protected static final NumberFormat nf = NumberFormat.getInstance(); protected static final NumberFormat nf = NumberFormat.getInstance();
/**
* Create a new {@link BaseAntUnitListener} instance.
* @param defaultReportTarget
* @param extension
*/
protected BaseAntUnitListener(SendLogTo defaultReportTarget, String extension) {
logTo = defaultReportTarget;
this.extension = extension;
logLevel = BaseAntUnitListener.AntUnitLogLevel.NONE;
}
/** /**
* Directory to write reports to. * Directory to write reports to.
*/ */
@ -118,9 +122,7 @@ public abstract class BaseAntUnitListener
} }
protected final void close(OutputStream out) { protected final void close(OutputStream out) {
if (out != System.out && out != System.err) { FileUtils.close(out);
FileUtils.close(out);
}
} }
public void startTest(String target) { public void startTest(String target) {
@ -135,36 +137,43 @@ public abstract class BaseAntUnitListener
} }
protected final OutputStream getOut(String buildFile) { protected final OutputStream getOut(String buildFile) {
OutputStream l, f; final String dest = logTo.getValue();
l = f = null;
if (logTo.getValue().equals(SendLogTo.ANT_LOG) if (logTo.getIndex() < 0) {
|| logTo.getValue().equals(SendLogTo.BOTH)) { throw new BuildException(String.format("Invalid @sendlogto value '%s'", dest));
}
OutputStream l;
if (SendLogTo.ANT_LOG.equals(dest) || SendLogTo.BOTH.equals(dest)) {
if (parentTask != null) { if (parentTask != null) {
l = new LogOutputStream(parentTask, Project.MSG_INFO); l = new LogOutputStream(parentTask, Project.MSG_INFO);
} else { } else {
l = System.out; l = new KeepAliveOutputStream(System.out);
} }
if (logTo.getValue().equals(SendLogTo.ANT_LOG)) { if (SendLogTo.ANT_LOG.equals(dest)) {
return l; return l;
} }
} else {
l = null;
} }
if (logTo.getValue().equals(SendLogTo.FILE) OutputStream f;
|| logTo.getValue().equals(SendLogTo.BOTH)) {
String fileName = "TEST-" + normalize(buildFile) + "." + extension; String fileName = "TEST-" + normalize(buildFile) + "." + extension;
File file = toDir == null File file;
? (parentTask != null if (toDir != null) {
? parentTask.getProject().resolveFile(fileName) file = new File(toDir, fileName);
: new File(fileName)) } else if (parentTask == null) {
: new File(toDir, fileName); file = new File(fileName);
try { } else {
f = new FileOutputStream(file); file = parentTask.getProject().resolveFile(fileName);
} catch (IOException e) { }
throw new BuildException(e); try {
} f = new FileOutputStream(file);
if (logTo.getValue().equals(SendLogTo.FILE)) { } catch (IOException e) {
return f; throw new BuildException(e);
} }
if (SendLogTo.FILE.equals(dest)) {
return f;
} }
return new TeeOutputStream(l, f); return new TeeOutputStream(l, f);
} }
@ -177,18 +186,13 @@ public abstract class BaseAntUnitListener
* @return the normalized name * @return the normalized name
*/ */
protected final String normalize(String buildFile) { protected final String normalize(String buildFile) {
File base = parentTask != null File base = parentTask != null ? parentTask.getProject().getBaseDir()
? parentTask.getProject().getBaseDir()
: new File(System.getProperty("user.dir")); : new File(System.getProperty("user.dir"));
buildFile = FileUtils.getFileUtils() buildFile = FileUtils.getFileUtils().removeLeadingPath(base, new File(buildFile));
.removeLeadingPath(base, new File(buildFile)); if (buildFile.length() > 0 && buildFile.charAt(0) == File.separatorChar) {
if (buildFile.length() > 0
&& buildFile.charAt(0) == File.separatorChar) {
buildFile = buildFile.substring(1); buildFile = buildFile.substring(1);
} }
return buildFile.replace('.', '_').replace(':', '_').replace(File.separatorChar, '.');
return buildFile.replace('.', '_').replace(':', '_')
.replace(File.separatorChar, '.');
} }
protected final Location getLocation(Throwable t) { protected final Location getLocation(Throwable t) {

View File

@ -7,8 +7,8 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -38,27 +38,27 @@ import org.apache.tools.ant.util.FileUtils;
* This AntUnitListener creates a new buildfile with a target for each * This AntUnitListener creates a new buildfile with a target for each
* failed test target in the AntUnit run. The generated target calls * failed test target in the AntUnit run. The generated target calls
* the failed target (with setUp and tearDown if present in the called * the failed target (with setUp and tearDown if present in the called
* project). * project).
* This is intended for rerunning just failed tests. * This is intended for rerunning just failed tests.
*/ */
public class FailureAntUnitListener extends BaseAntUnitListener { public class FailureAntUnitListener extends BaseAntUnitListener {
/** LineSeparator just for beautifying the output. */ /** LineSeparator just for beautifying the output. */
private static final String BR = System.getProperty("line.separator"); private static final String BR = System.getProperty("line.separator");
/** A sorted list (without duplicates) of failed tests. */ /** A sorted list (without duplicates) of failed tests. */
private static SortedSet failedTests = new TreeSet(); private static SortedSet<TestInfos> failedTests = new TreeSet<TestInfos>();
/** Where to write the generated buildfile. */ /** Where to write the generated buildfile. */
private static File failureBuildfile; private static File failureBuildfile;
/** The current running test project. Needed for addError()/addFailure(). */ /** The current running test project. Needed for addError()/addFailure(). */
private Project currentTestProject; private Project currentTestProject;
/** The current running build file. Needed for addError()/addFailure(). */ /** The current running build file. Needed for addError()/addFailure(). */
private String currentBuildFile; private String currentBuildFile;
/** No-arg constructor. */ /** No-arg constructor. */
public FailureAntUnitListener() { public FailureAntUnitListener() {
super(new BaseAntUnitListener.SendLogTo(SendLogTo.ANT_LOG), "txt"); super(new BaseAntUnitListener.SendLogTo(SendLogTo.ANT_LOG), "txt");
@ -73,23 +73,23 @@ public class FailureAntUnitListener extends BaseAntUnitListener {
currentTestProject = testProject; currentTestProject = testProject;
currentBuildFile = buildFile; currentBuildFile = buildFile;
} }
public void addError(String target, Throwable ae) { public void addError(String target, Throwable ae) {
super.addError(target, ae); super.addError(target, ae);
failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage())); failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage()));
} }
public void addFailure(String target, AssertionFailedException ae) { public void addFailure(String target, AssertionFailedException ae) {
super.addFailure(target, ae); super.addFailure(target, ae);
failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage())); failedTests.add(new TestInfos(currentTestProject, currentBuildFile, target, ae.getMessage()));
} }
/** not in use */ /** not in use */
public void endTest(String target) { public void endTest(String target) {
} }
public void endTestSuite(Project testProject, String buildFile) { public void endTestSuite(Project testProject, String buildFile) {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
// <project> and antunit-target for direct run // <project> and antunit-target for direct run
sb.append("<project default=\"antunit\" xmlns:au=\"antlib:org.apache.ant.antunit\">"); sb.append("<project default=\"antunit\" xmlns:au=\"antlib:org.apache.ant.antunit\">");
sb.append(BR); sb.append(BR);
@ -102,23 +102,23 @@ public class FailureAntUnitListener extends BaseAntUnitListener {
sb.append(" </target>").append(BR); sb.append(" </target>").append(BR);
sb.append(BR); sb.append(BR);
sb.append(BR); sb.append(BR);
// one target for each failed test // one target for each failed test
int testNumber = 0; int testNumber = 0;
NumberFormat f = NumberFormat.getIntegerInstance(); NumberFormat f = NumberFormat.getIntegerInstance();
for (Iterator it = failedTests.iterator(); it.hasNext();) { for (Iterator<TestInfos> it = failedTests.iterator(); it.hasNext();) {
sb.append(" <target name=\"test"); sb.append(" <target name=\"test");
sb.append(f.format(testNumber++)); sb.append(f.format(testNumber++));
sb.append("\">").append(BR); sb.append("\">").append(BR);
TestInfos testInfos = (TestInfos) it.next(); TestInfos testInfos = it.next();
sb.append(testInfos); sb.append(testInfos);
sb.append(" </target>").append(BR); sb.append(" </target>").append(BR);
sb.append(BR); sb.append(BR);
} }
// close the <project> // close the <project>
sb.append("</project>").append(BR); sb.append("</project>").append(BR);
// write the whole file // write the whole file
try { try {
FileOutputStream fos = new FileOutputStream(failureBuildfile); FileOutputStream fos = new FileOutputStream(failureBuildfile);
@ -130,41 +130,40 @@ public class FailureAntUnitListener extends BaseAntUnitListener {
throw new BuildException(e); throw new BuildException(e);
} }
} }
/** /**
* Class for collecting needed information about failed tests. * Class for collecting needed information about failed tests.
*/ */
public class TestInfos implements Comparable { public class TestInfos implements Comparable<TestInfos> {
/** Does the project has a setUp target? */ /** Does the project has a setUp target? */
boolean projectHasSetup = false; boolean projectHasSetup = false;
/** Does the project has a tearDown target? */ /** Does the project has a tearDown target? */
boolean projectHasTearDown = false; boolean projectHasTearDown = false;
/** The called target. */ /** The called target. */
String target; String target;
/** The buildfile of the project. */ /** The buildfile of the project. */
String buildfile; String buildfile;
/** The error message which was shown. */ /** The error message which was shown. */
String errorMessage; String errorMessage;
public TestInfos(Project project, String buildfile, String target, String errorMessage) { public TestInfos(Project project, String buildfile, String target, String errorMessage) {
projectHasSetup = project.getTargets().containsKey("setUp"); projectHasSetup = project.getTargets().containsKey("setUp");
projectHasTearDown = project.getTargets().containsKey("tearDown"); projectHasTearDown = project.getTargets().containsKey("tearDown");
this.buildfile = buildfile; this.buildfile = buildfile;
this.target = target; this.target = target;
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }
/** /**
* Creates an &lt;ant&gt; call according to the stored information. * Creates an &lt;ant&gt; call according to the stored information.
* @see java.lang.Object#toString() * @see java.lang.Object#toString()
*/ */
public String toString() { public String toString() {
StringBuffer sb = new StringBuffer(); StringBuilder sb = new StringBuilder();
// make the reader of the buildfile happy // make the reader of the buildfile happy
sb.append(" <!-- "); sb.append(" <!-- ");
sb.append(errorMessage); sb.append(errorMessage);
@ -191,15 +190,10 @@ public class FailureAntUnitListener extends BaseAntUnitListener {
sb.append(" </ant>").append(BR); sb.append(" </ant>").append(BR);
return sb.toString(); return sb.toString();
} }
// Needed, so that a SortedSet could sort this class into the list. // Needed, so that a SortedSet could sort this class into the list.
public int compareTo(Object other) { public int compareTo(TestInfos other) {
if (!(other instanceof TestInfos)) { return this.toString().compareTo((other).toString());
return -1;
} else {
TestInfos that = (TestInfos)other;
return this.toString().compareTo(that.toString());
}
} }
} }

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,8 +7,8 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -37,7 +37,7 @@ import org.apache.tools.ant.Project;
* test listener that is part of Ant. * test listener that is part of Ant.
*/ */
public class PlainAntUnitListener extends BaseAntUnitListener { public class PlainAntUnitListener extends BaseAntUnitListener {
private OutputStream out = null; private OutputStream out;
/** /**
* Helper to store intermediate output. * Helper to store intermediate output.
*/ */
@ -69,9 +69,7 @@ public class PlainAntUnitListener extends BaseAntUnitListener {
inner = new StringWriter(); inner = new StringWriter();
wri = new PrintWriter(inner); wri = new PrintWriter(inner);
out = getOut(buildFile); out = getOut(buildFile);
StringBuffer sb = new StringBuffer("Build File: "); StringBuilder sb = new StringBuilder("Build File: ").append(buildFile).append(NEW_LINE);
sb.append(buildFile);
sb.append(NEW_LINE);
try { try {
out.write(sb.toString().getBytes()); out.write(sb.toString().getBytes());
out.flush(); out.flush();
@ -82,7 +80,7 @@ public class PlainAntUnitListener extends BaseAntUnitListener {
public void endTestSuite(Project testProject, String buildFile) { public void endTestSuite(Project testProject, String buildFile) {
long runTime = System.currentTimeMillis() - start; long runTime = System.currentTimeMillis() - start;
StringBuffer sb = new StringBuffer("Tests run: "); StringBuilder sb = new StringBuilder("Tests run: ");
sb.append(runCount); sb.append(runCount);
sb.append(", Failures: "); sb.append(", Failures: ");
sb.append(failureCount); sb.append(failureCount);

View File

@ -7,8 +7,8 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -96,14 +96,15 @@ public class XMLAntUnitListener extends BaseAntUnitListener {
Element propertiesElement = Element propertiesElement =
DOMUtils.createChildElement(root, XMLConstants.PROPERTIES); DOMUtils.createChildElement(root, XMLConstants.PROPERTIES);
Hashtable propertiesMap = testProject.getProperties(); @SuppressWarnings("unchecked")
for (final Iterator iterator = propertiesMap.entrySet().iterator(); Hashtable<String,Object> propertiesMap = testProject.getProperties();
for (final Iterator<Map.Entry<String, Object>> iterator = propertiesMap.entrySet().iterator();
iterator.hasNext();) { iterator.hasNext();) {
final Map.Entry property = (Map.Entry) iterator.next(); final Map.Entry<String, Object> property = iterator.next();
Element e = DOMUtils.createChildElement(propertiesElement, Element e = DOMUtils.createChildElement(propertiesElement,
XMLConstants.PROPERTY); XMLConstants.PROPERTY);
e.setAttribute(XMLConstants.ATTR_NAME, e.setAttribute(XMLConstants.ATTR_NAME,
property.getKey().toString()); property.getKey());
e.setAttribute(XMLConstants.ATTR_VALUE, e.setAttribute(XMLConstants.ATTR_VALUE,
property.getValue().toString()); property.getValue().toString());
} }
@ -122,7 +123,7 @@ public class XMLAntUnitListener extends BaseAntUnitListener {
log.setLength(0); log.setLength(0);
domWri.write(e, wri, 1, INDENT); domWri.write(e, wri, 1, INDENT);
} }
e = DOMUtils.createChildElement(root, XMLConstants.ATTR_TESTS); e = DOMUtils.createChildElement(root, XMLConstants.ATTR_TESTS);
DOMUtils.appendText(e, String.valueOf(runCount)); DOMUtils.appendText(e, String.valueOf(runCount));
domWri.write(e, wri, 1, INDENT); domWri.write(e, wri, 1, INDENT);
e = DOMUtils.createChildElement(root, XMLConstants.ATTR_FAILURES); e = DOMUtils.createChildElement(root, XMLConstants.ATTR_FAILURES);

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -22,8 +22,8 @@ package org.apache.ant.antunit.listener;
/** /**
* <p> Interface groups XML constants. * <p> Interface groups XML constants.
* Interface that groups all constants used throughout the <tt>XML</tt> * Interface that groups all constants used throughout the <code>XML</code>
* documents that are generated by the <tt>XMLJUnitResultFormatter</tt> * documents that are generated by the <code>XMLJUnitResultFormatter</code>
* As of now the DTD is: * As of now the DTD is:
* <pre> * <pre>
* &lt;----------------- @todo describe DTDs ----------------------&gt; * &lt;----------------- @todo describe DTDs ----------------------&gt;

View File

@ -7,7 +7,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -7,7 +7,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,

View File

@ -7,7 +7,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -19,7 +19,7 @@
<import file="antunit-base.xml"/> <import file="antunit-base.xml"/>
<url url="http://ant.apache.org/index.html" id="antsite"/> <url url="https://ant.apache.org/index.html" id="antsite"/>
<target name="testURLUsingRef" <target name="testURLUsingRef"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=53383"> description="https://issues.apache.org/bugzilla/show_bug.cgi?id=53383">

View File

@ -7,7 +7,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -19,8 +19,8 @@
<import file="antunit-base.xml"/> <import file="antunit-base.xml"/>
<property name="existing-url" value="http://ant.apache.org/index.html"/> <property name="existing-url" value="https://ant.apache.org/index.html"/>
<property name="not-existing-url" value="http://ant.apache.org/foo.html"/> <property name="not-existing-url" value="https://ant.apache.org/foo.html"/>
<!-- some strange proxy setups hide the 404 results --> <!-- some strange proxy setups hide the 404 results -->
<target name="-checkWhetherUrlsThatDontExistAreFound"> <target name="-checkWhetherUrlsThatDontExistAreFound">

View File

@ -7,7 +7,7 @@
(the "License"); you may not use this file except in compliance with (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0 https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
@ -52,13 +52,13 @@
<target name="testURL"> <target name="testURL">
<au:assertTrue> <au:assertTrue>
<au:resourceExists> <au:resourceExists>
<url url="http://ant.apache.org/index.html"/> <url url="https://ant.apache.org/index.html"/>
</au:resourceExists> </au:resourceExists>
</au:assertTrue> </au:assertTrue>
</target> </target>
<target name="testURLAttributeUsingRef"> <target name="testURLAttributeUsingRef">
<url url="http://ant.apache.org/index.html" id="antsite"/> <url url="https://ant.apache.org/index.html" id="antsite"/>
<au:assertTrue> <au:assertTrue>
<au:resourceExists resource="${ant.refid:antsite}"/> <au:resourceExists resource="${ant.refid:antsite}"/>
</au:assertTrue> </au:assertTrue>

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -49,15 +49,36 @@ public class AssertTest extends BuildFileTest {
public void testEqualsCasePass() { public void testEqualsCasePass() {
testPass("assertEqualsCasePass"); testPass("assertEqualsCasePass");
} }
public void testNotEqualsPass1() {
testPass("assertNotEqualsPass1");
}
public void testNotEqualsPass2() {
testPass("assertNotEqualsPass2");
}
public void testPropertySetPass() { public void testPropertySetPass() {
testPass("assertPropertySetPass"); testPass("assertPropertySetPass");
} }
public void testPropertyNotSetPass() {
testPass("assertPropertyNotSetPass");
}
public void testPropertyEqualsPass() { public void testPropertyEqualsPass() {
testPass("assertPropertyEqualsPass"); testPass("assertPropertyEqualsPass");
} }
public void testPropertyEqualsCasePass() { public void testPropertyEqualsCasePass() {
testPass("assertPropertyEqualsCasePass"); testPass("assertPropertyEqualsCasePass");
} }
public void testPropertyNotEqualsPass1() {
testPass("assertPropertyNotEqualsPass1");
}
public void testPropertyNotEqualsPass2() {
testPass("assertPropertyNotEqualsPass2");
}
public void testPropertyContains() {
testPass("assertPropertyContains");
}
public void testPropertyDoesntContain() {
testPass("assertPropertyDoesntContain");
}
public void testFileExistsPass() { public void testFileExistsPass() {
testPass("assertFileExistsPass"); testPass("assertFileExistsPass");
} }
@ -85,6 +106,9 @@ public class AssertTest extends BuildFileTest {
public void testReferenceSetPass() { public void testReferenceSetPass() {
testPass("assertReferenceSetPass"); testPass("assertReferenceSetPass");
} }
public void testReferenceIsNotSetPass() {
testPass("assertReferenceIsNotSetPass");
}
public void testReferenceIsTypePass() { public void testReferenceIsTypePass() {
testPass("assertReferenceIsTypePass"); testPass("assertReferenceIsTypePass");
} }
@ -101,9 +125,18 @@ public class AssertTest extends BuildFileTest {
public void testEqualsFail2() { public void testEqualsFail2() {
testFail("assertEqualsFail2", "Expected 'bar' but was 'BAR'"); testFail("assertEqualsFail2", "Expected 'bar' but was 'BAR'");
} }
public void testNotEqualsFail() {
testFail("assertNotEqualsFail", "Didn't expect 'bar' to be 'bar'");
}
public void testNotEqualsCaseFail() {
testFail("assertNotEqualsCaseFail", "Didn't expect 'bar' to be 'BAR'");
}
public void testPropertySetFail() { public void testPropertySetFail() {
testFail("assertPropertySetFail", "Expected property 'foo'"); testFail("assertPropertySetFail", "Expected property 'foo'");
} }
public void testPropertyNotSetFail() {
testFail("assertPropertyNotSetFail", "Didn't expect property 'foo' to be set but was 'bar'");
}
public void testPropertyEqualsFail1() { public void testPropertyEqualsFail1() {
testFail("assertPropertyEqualsFail1", "Expected property 'foo' to have value 'bar' but was '${foo}'"); testFail("assertPropertyEqualsFail1", "Expected property 'foo' to have value 'bar' but was '${foo}'");
} }
@ -113,12 +146,21 @@ public class AssertTest extends BuildFileTest {
public void testPropertyEqualsFail3() { public void testPropertyEqualsFail3() {
testFail("assertPropertyEqualsFail3", "Expected property 'foo' to have value 'BAR' but was 'bar'"); testFail("assertPropertyEqualsFail3", "Expected property 'foo' to have value 'BAR' but was 'bar'");
} }
public void testPropertyContains() { public void testPropertyNotEqualsFail1() {
testPass("assertPropertyContains"); testFail("assertPropertyNotEqualsFail1", "Didn't expect property 'foo' to have value 'bar'");
}
public void testPropertyNotEqualsFail2() {
testFail("assertPropertyNotEqualsFail2", "Didn't expect property 'foo' to have value 'bar'");
}
public void testPropertyNotEqualsCaseFail() {
testFail("assertPropertyNotEqualsCaseFail", "Didn't expect property 'foo' to have value 'BAR'");
} }
public void testPropertyContainsFail() { public void testPropertyContainsFail() {
testFail("assertPropertyContainsFail", "Expected property 'foo' to contain value 'foo' but was 'bar'"); testFail("assertPropertyContainsFail", "Expected property 'foo' to contain value 'foo' but was 'bar'");
} }
public void testPropertyDoesntContainFail() {
testFail("assertPropertyDoesntContainFail", "Didn't expect property 'foo' to contain value 'ba' but was 'bar'");
}
public void testFileExistsFail() { public void testFileExistsFail() {
testFail("assertFileExistsFail", testFail("assertFileExistsFail",
"Expected file 'assert.txt' to exist"); "Expected file 'assert.txt' to exist");
@ -154,6 +196,9 @@ public class AssertTest extends BuildFileTest {
public void testReferenceSetFail() { public void testReferenceSetFail() {
testFail("assertReferenceSetFail", "Expected reference 'foo2'"); testFail("assertReferenceSetFail", "Expected reference 'foo2'");
} }
public void testReferenceIsNotSetFail() {
testFail("assertReferenceIsNotSetFail", "Didn't expect reference 'foo4'");
}
public void testReferenceIsTypeFailNotSet() { public void testReferenceIsTypeFailNotSet() {
testFail("assertReferenceIsTypeFailNotSet", testFail("assertReferenceIsTypeFailNotSet",
"Expected reference 'foo4'"); "Expected reference 'foo4'");

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

View File

@ -7,8 +7,8 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -42,8 +42,8 @@ public class LogCapturerTest extends TestCase {
Project p = new Project(); Project p = new Project();
LogCapturer c = new LogCapturer(p); LogCapturer c = new LogCapturer(p);
String[] messages = new String[] {"err", "warn", "info", "verbose", String[] messages = new String[] { "err", "warn", "info", "verbose", "debug" };
"debug"};
for (int i = 0; i < messages.length; i++) { for (int i = 0; i < messages.length; i++) {
BuildEvent be = new BuildEvent(p); BuildEvent be = new BuildEvent(p);
be.setMessage(messages[i], i); be.setMessage(messages[i], i);
@ -66,8 +66,7 @@ public class LogCapturerTest extends TestCase {
c.messageLogged(be); c.messageLogged(be);
} }
Assert.assertEquals(c.getErrLog(false), Assert.assertEquals(c.getErrLog(false),
"0" + StringUtils.LINE_SEP "0" + StringUtils.LINE_SEP + "1" + StringUtils.LINE_SEP);
+ "1" + StringUtils.LINE_SEP);
} }
public void testWithMerge() { public void testWithMerge() {

View File

@ -7,8 +7,8 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -52,23 +52,18 @@ public class LogContentTest extends TestCase {
Project p = new Project(); Project p = new Project();
LogCapturer c = new LogCapturer(p); LogCapturer c = new LogCapturer(p);
String[] msgs = new String[] {"err", "warn", "info", "verbose", String[] msgs = new String[] { "err", "warn", "info", "verbose", "debug" };
"debug"};
for (int i = 0; i < msgs.length; i++) { for (int i = 0; i < msgs.length; i++) {
BuildEvent be = new BuildEvent(p); BuildEvent be = new BuildEvent(p);
be.setMessage(msgs[i], i); be.setMessage(msgs[i], i);
c.messageLogged(be); c.messageLogged(be);
} }
assertMessages(new LogContent(p, LogLevel.ERR), msgs, assertMessages(new LogContent(p, LogLevel.ERR), msgs, Project.MSG_ERR);
Project.MSG_ERR); assertMessages(new LogContent(p, LogLevel.WARN), msgs, Project.MSG_WARN);
assertMessages(new LogContent(p, LogLevel.WARN), msgs, assertMessages(new LogContent(p, LogLevel.INFO), msgs, Project.MSG_INFO);
Project.MSG_WARN); assertMessages(new LogContent(p, LogLevel.VERBOSE), msgs, Project.MSG_VERBOSE);
assertMessages(new LogContent(p, LogLevel.INFO), msgs, assertMessages(new LogContent(p, LogLevel.DEBUG), msgs, Project.MSG_DEBUG);
Project.MSG_INFO);
assertMessages(new LogContent(p, LogLevel.VERBOSE), msgs,
Project.MSG_VERBOSE);
assertMessages(new LogContent(p, LogLevel.DEBUG), msgs,
Project.MSG_DEBUG);
} }
public void testWithoutMerge() throws IOException { public void testWithoutMerge() throws IOException {
@ -85,9 +80,7 @@ public class LogContentTest extends TestCase {
StringResource s = new StringResource(); StringResource s = new StringResource();
ResourceUtils.copyResource(content, s); ResourceUtils.copyResource(content, s);
Assert.assertEquals(s.getValue(), Assert.assertEquals(s.getValue(), "0" + StringUtils.LINE_SEP + "1" + StringUtils.LINE_SEP);
"0" + StringUtils.LINE_SEP
+ "1" + StringUtils.LINE_SEP);
} }
public void testWithExplicitMerge() throws IOException { public void testWithExplicitMerge() throws IOException {
@ -132,11 +125,11 @@ public class LogContentTest extends TestCase {
String actual = s.getValue(); String actual = s.getValue();
for (int i = 0; i <= upTo && i < messages.length; i++) { for (int i = 0; i <= upTo && i < messages.length; i++) {
Assert.assertTrue("checking for " + messages[i] + " in " + actual, Assert.assertTrue("checking for " + messages[i] + " in " + actual,
actual.indexOf(messages[i]) > -1); actual.indexOf(messages[i]) > -1);
} }
for (int i = upTo + 1; i < messages.length; i++) { for (int i = upTo + 1; i < messages.length; i++) {
Assert.assertTrue("checking for " + messages[i] + " in " + actual, Assert.assertTrue("checking for " + messages[i] + " in " + actual,
actual.indexOf(messages[i]) == -1); actual.indexOf(messages[i]) == -1);
} }
} }
} }

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
@ -30,10 +30,10 @@ import org.apache.tools.ant.BuildFileTest;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
public class SetUpAndTearDownTest extends BuildFileTest { public class SetUpAndTearDownTest extends BuildFileTest {
public static class TestReportListener extends BaseAntUnitListener { public static class TestReportListener extends BaseAntUnitListener {
private OutputStream out = null; private OutputStream out;
/** /**
* Helper to store intermediate output. * Helper to store intermediate output.
*/ */
@ -82,12 +82,12 @@ public class SetUpAndTearDownTest extends BuildFileTest {
super.addFailure(target, ae); super.addFailure(target, ae);
wri.println("failure:" + target + "(" + ae.getMessage() + ")"); wri.println("failure:" + target + "(" + ae.getMessage() + ")");
} }
public void addError(String target, Throwable ae) { public void addError(String target, Throwable ae) {
super.addError(target, ae); super.addError(target, ae);
wri.println("error:" + target + "(" + ae.getMessage() + ")"); wri.println("error:" + target + "(" + ae.getMessage() + ")");
} }
public void messageLogged(int level, String message) {} public void messageLogged(int level, String message) {}
} }
@ -124,7 +124,7 @@ public class SetUpAndTearDownTest extends BuildFileTest {
int index = log.indexOf("Tests run: 3, Failures: 3, Errors: 0,"); int index = log.indexOf("Tests run: 3, Failures: 3, Errors: 0,");
assertTrue("summary", index > -1); assertTrue("summary", index > -1);
} }
public void testErrorSetup() { public void testErrorSetup() {
executeTarget("testErrorSetup"); executeTarget("testErrorSetup");
String log = getLog(); String log = getLog();
@ -138,7 +138,7 @@ public class SetUpAndTearDownTest extends BuildFileTest {
int index = log.indexOf("Tests run: 3, Failures: 3, Errors: 0,"); int index = log.indexOf("Tests run: 3, Failures: 3, Errors: 0,");
assertTrue("summary", index > -1); assertTrue("summary", index > -1);
} }
public void testErrorTeardown() { public void testErrorTeardown() {
executeTarget("testErrorTeardown"); executeTarget("testErrorTeardown");
String log = getLog(); String log = getLog();
@ -180,7 +180,7 @@ public class SetUpAndTearDownTest extends BuildFileTest {
index = log.indexOf("error:suiteSetUp(Expected error)"); index = log.indexOf("error:suiteSetUp(Expected error)");
assertTrue("testname", index > -1); assertTrue("testname", index > -1);
} }
public void testFailureSuiteTearDown() { public void testFailureSuiteTearDown() {
executeTarget("testFailureSuiteTearDown"); executeTarget("testFailureSuiteTearDown");
String log = getLog(); String log = getLog();
@ -189,7 +189,7 @@ public class SetUpAndTearDownTest extends BuildFileTest {
index = log.indexOf("failure:suiteTearDown(Expected failure)"); index = log.indexOf("failure:suiteTearDown(Expected failure)");
assertTrue("testname", index > -1); assertTrue("testname", index > -1);
} }
public void testErrorSuiteTearDown() { public void testErrorSuiteTearDown() {
executeTarget("testErrorSuiteTearDown"); executeTarget("testErrorSuiteTearDown");
String log = getLog(); String log = getLog();

View File

@ -7,7 +7,7 @@
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * https://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an

Some files were not shown because too many files have changed in this diff Show More