You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by mc...@apache.org on 2014/04/18 23:00:43 UTC
svn commit: r1588563 [1/16] - in /ant/core/trunk: ./ manual/ manual/Types/
src/etc/testcases/taskdefs/ src/etc/testcases/taskdefs/optional/
src/etc/testcases/taskdefs/optional/antlr/
src/etc/testcases/taskdefs/optional/depend/ src/etc/testcases/taskdef...
Author: mclarke
Date: Fri Apr 18 21:00:38 2014
New Revision: 1588563
URL: http://svn.apache.org/r1588563
Log:
Test improvements: convert to JUnit4, improved error testing and remove sleeps
Added:
ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntAssert.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/FileUtilities.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorRule.java
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/manual/Types/selectors-program.html
ant/core/trunk/manual/tutorial-tasks-filesets-properties.html
ant/core/trunk/manual/tutorial-writing-tasks.html
ant/core/trunk/src/etc/testcases/taskdefs/copy.xml
ant/core/trunk/src/etc/testcases/taskdefs/jar.xml
ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml
ant/core/trunk/src/etc/testcases/taskdefs/optional/depend/depend.xml
ant/core/trunk/src/etc/testcases/taskdefs/optional/junit.xml
ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml
ant/core/trunk/src/etc/testcases/taskdefs/optional/unix/symlink.xml
ant/core/trunk/src/etc/testcases/taskdefs/uptodate.xml
ant/core/trunk/src/etc/testcases/taskdefs/zip.xml
ant/core/trunk/src/etc/testcases/types/selectors.xml
ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderPerformance.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/CaseTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/DispatchTaskTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExecutorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/ExtendedTaskdefTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/ImmutableTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/IncludeTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/LoaderRefTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/LocationTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/MockBuildListener.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectComponentTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectHelperRepositoryTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/ProjectTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyExpansionTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/PropertyFileCLITest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/TaskContainerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/TopLevelTaskTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/UnknownElementTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ConcatFilterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/DynamicFilterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/EscapeUnicodeTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/HeadTailTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/LineContainsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/NoNewLineTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/ReplaceTokensTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/StripJavaCommentsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/filters/TokenFilterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/launch/LocatorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/loader/AntClassLoader5Test.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntStructureTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AntlibTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/AvailableTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BUnzip2Test.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BZip2Test.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/BasenameTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CVSPassTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CallTargetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ChecksumTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConcatTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ConditionTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopydirTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/CopyfileTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DeleteTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DeltreeTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DirnameTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/DynamicTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/EchoTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/EchoXMLTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ExecTaskTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/FailTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/FilterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/FixCrLfTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/GUnzipTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/GetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/GzipTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ImportTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/InitializeClassTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/InputTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JarTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JavaTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JavacTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/JavadocTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/LoadFileTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/MacroDefTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/MakeUrlTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ManifestTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/MkdirTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/MoveTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/MultiMapTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/NiceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ParallelTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/PathConvertTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/PreSetDefTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ProcessDestroyerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/PropertyTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ProtectedJarMethodsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RecorderTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RenameTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ReplaceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/RmicTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SQLExecTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SignJarTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SleepTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/StyleTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SubAntTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/SyncTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TStampTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TarTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TaskdefsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TestProcess.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TouchTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypeAdapterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/TypedefTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UntarTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UnzipTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/UpToDateTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/WarTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/WhichResourceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/XmlPropertyTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/XmlnsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ZipExtraFieldTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/ZipTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ContainsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/EqualsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/HttpTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFailureTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsFileSelectedTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/IsSignedTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/TypeFoundTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/condition/XorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParserTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailAddressTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/email/MessageTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JavahTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/JspcTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/PvcsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/RpmTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/XsltTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/BatchTestTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/DOMUtilTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Printer.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/TearDownOnVmCrashTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregatorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/splash/SplashScreenTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/AbstractFileSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/AddTypeTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/AssertionsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/CommandlineJavaTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/DescriptionTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/DirSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/EnumeratedAttributeTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/FileListTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/FileSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/FilterSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/FlexIntegerTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/MapperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PathTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PatternSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PermissionsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/PolyTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/RedirectorElementTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/ResourceOutputTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/TarFileSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogBuildFileTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/XMLCatalogTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/ZipFileSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/mappers/GlobMapperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/mappers/RegexpPatternMapperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/optional/ScriptMapperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/optional/ScriptSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/FileResourceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/JavaResourceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/LazyResourceCollectionTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/MultiRootFileSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/ResourceListTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/resources/TarResourceTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/BaseSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ContainsSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DateSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DependSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/DepthSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/PresentSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/SignedSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/SizeSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/TokenizedPatternTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/selectors/TypeSelectorTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/Base64ConverterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ClasspathUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/CollectionUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/DOMElementWriterTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/DateUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/DeweyDecimalTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/FileUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/GlobPatternMapperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/JAXPUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/JavaEnvUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/LayoutPreservingPropertiesTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/LazyFileOutputStreamTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/LinkedHashtableTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/LoaderUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/PackageNameMapperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ReaderInputStreamTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/ResourceUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/StringUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/SymlinkUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/UnPackageNameMapperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/UnicodeUtilTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/VectorSetTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/XMLFragmentTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/bzip2/CBZip2StreamTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/mail/MailMessageTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarEntryTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarOutputStreamTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/tar/TarRoundTripTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/AsiExtraFieldTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/ExtraFieldUtilsTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/UTF8ZipFilesTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipEncodingTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipEntryTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipLongTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipOutputStreamTest.java
ant/core/trunk/src/tests/junit/org/apache/tools/zip/ZipShortTest.java
ant/core/trunk/src/tests/junit/org/example/junit/Timeout.java
ant/core/trunk/src/tests/junit/org/example/junit/XmlParserTest.java
Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Apr 18 21:00:38 2014
@@ -26,6 +26,16 @@ Changes that could break older environme
might lead to blocking or other undefined behavior.
Bugzilla Report 56149
+ * BuildFileTest and BaseSelectorTest have both been deprecated in
+ favour of BuildFileRule and BaseSelectorRule respectively, and the
+ tests that previously extended these base tests have been converted to
+ JUnit 4 tests using the new "rule"s. Any external test that sub-classed
+ a test in the Ant workspace, rather than BuildFileTest, will need
+ changed to either use JUnit4's annotations, or be modified to
+ extend BuildFileTest directly. This will not affect any tests that are
+ being executed by Ant's junit or batchtest tasks that are not specifically
+ testing Ant's code.
+
Fixed bugs:
-----------
Modified: ant/core/trunk/manual/Types/selectors-program.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/Types/selectors-program.html?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/manual/Types/selectors-program.html (original)
+++ ant/core/trunk/manual/Types/selectors-program.html Fri Apr 18 21:00:38 2014
@@ -140,78 +140,58 @@
<p>For a robust component (and selectors are (Project)Components) tests are
necessary. For testing Tasks we use JUnit TestCases - more specific
- <tt>org.apache.tools.ant.BuildFileTest extends junit.framework.TestCase</tt>.
+ <tt>org.apache.tools.ant.BuildFileRule extends org.junit.rules.ExternalResource</tt>.
Some of its features like configure the (test) project by reading its buildfile and
- execute targets we need for selector tests also. Therefore we use that BuildFileTest.
+ execute targets we need for selector tests also. Therefore we use that BuildFileRule.
But testing selectors requires some more work: having a set of files, instantiate
and configure the selector, check the selection work and more. Because we usually
extend <tt>BaseExtendSelector</tt> its features have to be tested also (e.g. setError()).
</p>
- <p>That's why we have a base class for doing our selector tests:
- <tt>org.apache.tools.ant.types.selectors.BaseSelectorTest</tt>.</p>
+ <p>That's why we have a test rule for doing our selector tests:
+ <tt>org.apache.tools.ant.types.selectors.BaseSelectorRule</tt>.</p>
- <p>This class extends TestCase and therefore can included in the set of Ant's
- unit tests. It holds an instance of preconfigured BuildFileTest. Configuration
- is done by parsing the src/etc/testcases/types/selectors.xml. BaseSelectorTest
+ <p>This class extends ExternalResource and therefore can included in the set of Ant's
+ unit tests. It holds an instance of preconfigured BuildFileRule. Configuration
+ is done by parsing the src/etc/testcases/types/selectors.xml. BaseSelectorRule
then gives us helper methods for handling multiple selections. </p>
<p>Because the term "testcase" or "testenvironment" are so often used, this
- special testenvironment got a new name: <i>bed</i>. Like you initialize the
- test environment by calling setUp() and cleaning by calling tearDown() (<i>or like
- to make your bed before go sleeping</i>) you have to do that work with your
- <i>bed</i> by calling <tt>makeBed()</tt> respective <tt>cleanupBed()</tt>.</p>
+ special testenvironment got a new name: <i>bed</i>. The setup and cleanup of
+ the bed is all handled by the BaseSelectorRule so any test only has to handle
+ the actual test scenarios</p>
- <p>A usual test scenario is<ol>
- <li>make the bed</li>
+ <p>A usual test scenario is:</p>
+ <ol>
<li>instantiate the selector</li>
<li>configure the selector</li>
<li>let the selector do some work</li>
<li>verify the work</li>
- <li>clean the bed</li>
- </ol>
- </p>
+ </ol>
+
- <p>For common way of instantiation you have to override the <tt>getInstance()</tt>
- simply by returning a new object of your selector. For easier "selection and verification work"
- BaseSelectorTest provides the method <tt>performTests()</tt> which
- iterates over all files (and directories) in the String array <tt>filenames</tt>
- and checks whether the given selector returns the expected result. If an error
- occurred (especially the selector does not return the expected result) the test
- fails and the failing filenames are logged.</p>
<p>An example test would be:<pre>
package org.apache.tools.ant.types.selectors;
-public class MySelectorTest extends BaseSelectorTest {
-
- public MySelectorTest(String name) {
- super(name);
- }
+public class MySelectorTest {
- public BaseSelector getInstance() {
- return new MySelector();
- }
+ @Rule
+ public final BaseSelectorRule selectorRule = new BaseSelectorRule();
+ @Test
public void testCase1() {
- try {
- // initialize test environment 'bed'
- makeBed();
-
- // Configure the selector
- MySelector s = (MySelector)getSelector();
- s.addParam("key1", "value1");
- s.addParam("key2", "value2");
- s.setXX(true);
- s.setYY("a value");
-
- // do the tests
- performTests(s, "FTTTTTTTTTTT"); // First is not selected - rest is
-
- } finally {
- // cleanup the environment
- cleanupBed();
- }
+
+
+ // Configure the selector
+ MySelector s = new MySelector();
+ s.addParam("key1", "value1");
+ s.addParam("key2", "value2");
+ s.setXX(true);
+ s.setYY("a value");
+
+ // do the tests
+ assertEquals("FTTTTTTTT", selectorRule.selectionString(s));
}
}
</pre>
Modified: ant/core/trunk/manual/tutorial-tasks-filesets-properties.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/tutorial-tasks-filesets-properties.html?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/manual/tutorial-tasks-filesets-properties.html (original)
+++ ant/core/trunk/manual/tutorial-tasks-filesets-properties.html Fri Apr 18 21:00:38 2014
@@ -135,20 +135,28 @@ to them, sorry :-)</p>
we can call that from our testcase:
<pre class="code">
-import org.apache.tools.ant.BuildFileTest;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.Assert;
+import org.apache.tools.ant.BuildFileRule;
-public class FindTest extends BuildFileTest {
- public FindTest(String name) {
- super(name);
- }
+public class FindTest {
+
+ @Rule
+ public final BuildFileRule buildRule = new BuildFileRule();
+
+ @Before
public void setUp() {
configureProject("build.xml");
}
+ @Test
public void testSimple() {
- <b>expectLog("use.simple", "test-value");</b>
+ buildRule.executeTarget("useSimgle");
+ <b>Assert.assertEquals("test-value", buildRule.getLog());</b>
}
}
</pre>
@@ -211,10 +219,14 @@ Maybe you find some more testcases. But
For each of these points we create a <tt>testXX</tt> method.</p>
<pre class="code">
-public class FindTest extends BuildFileTest {
+public class FindTest {
+
+ @Rule
+ public final BuildFileRule buildRule = new BuildFileRule();
... // constructor, setUp as above
+ @Test
public void testMissingFile() {
<b>Find find = new Find();</b>
try {
@@ -227,6 +239,7 @@ public class FindTest extends BuildFileT
}
}
+ @Test
public void testMissingLocation() {
Find find = new Find();
<b>find.setFile("ant.jar");</b>
@@ -238,6 +251,7 @@ public class FindTest extends BuildFileT
}
}
+ @Test
public void testMissingFileset() {
Find find = new Find();
find.setFile("ant.jar");
@@ -250,15 +264,17 @@ public class FindTest extends BuildFileT
}
}
+ @Test
public void testFileNotPresent() {
- executeTarget("testFileNotPresent");
- String result = getProject().getProperty("location.ant-jar");
+ buildRule.executeTarget("testFileNotPresent");
+ String result = buildRule.getProject().getProperty("location.ant-jar");
assertNull("Property set to wrong value.", result);
}
+ @Test
public void testFilePresent() {
- executeTarget("testFilePresent");
- String result = getProject().getProperty("location.ant-jar");
+ buildRule.executeTarget("testFilePresent");
+ String result = buildRule.getProject().getProperty("location.ant-jar");
assertNotNull("Property not set.", result);
assertTrue("Wrong file found.", result.endsWith("ant.jar"));
}
@@ -906,7 +922,7 @@ entry. For both we need some information
</tr>
<tr>
<th>attachments</th>
- <td><i>all files needed to apply the path</td>
+ <td><i>all files needed to apply the path</i></td>
<td>Archive containing a patch with the new and modified resources</td>
</tr>
</table>
Modified: ant/core/trunk/manual/tutorial-writing-tasks.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/manual/tutorial-writing-tasks.html?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/manual/tutorial-writing-tasks.html (original)
+++ ant/core/trunk/manual/tutorial-writing-tasks.html Fri Apr 18 21:00:38 2014
@@ -17,8 +17,7 @@
<html>
<head>
<title>Tutorial: Writing Tasks</title>
- <link rel="stylesheet" type="text/css" href="stylesheets/style.css">
- </link>
+ <link rel="stylesheet" type="text/css" href="stylesheets/style.css" />
</head>
<body>
<h1>Tutorial: Writing Tasks</h1>
@@ -596,12 +595,9 @@ Next step: test ...
<h2>Test the Task</h2>
<p>We have written a test already: the use.* tasks in the buildfile. But its
difficult to test that automatically. Common (and in Ant) used is JUnit for
-that. For testing tasks Ant provides a baseclass <tt>org.apache.tools.ant.BuildFileTest</tt>.
-This class extends <tt>junit.framework.TestCase</tt> and can therefore be integrated
-into the unit tests. But this class provides some for testing tasks useful methods:
-initialize Ant, load a buildfile, execute targets,
-expecting BuildExceptions with a specified text, expect a special text
-in the output log ... </p>
+that. For testing tasks Ant provides a JUnit Rule <tt>org.apache.tools.ant.BuildFileRule</tt>.
+This class provides some for testing tasks useful methods:
+initialize Ant, load a buildfile, execute targets, capturing debug and run logs ...</p>
<p>In Ant it is usual that the testcase has the same name as the task with a prepending
<i>Test</i>, therefore we will create a file <i>HelloWorldTest.java</i>. Because we
@@ -677,49 +673,68 @@ and <code><junitreport></code>. So
...
</pre>
-<p>Back to the <i>src/HelloWorldTest.java</i>. We create a class extending
-<i>BuildFileTest</i> with String-constructor (JUnit-standard), a <i>setUp()</i>
-method initializing Ant and for each testcase (targets use.*) a <i>testXX()</i>
-method invoking that target.</p>
-<pre class="code">
-import org.apache.tools.ant.BuildFileTest;
+<p>Back to the <i>src/HelloWorldTest.java</i>. We create a class with a public
+<i>BuildFileRule</i> field annotated with JUnit's <i>@Rule</i> annotation. As per
+conventional JUnit4 tests, this class should have no constructors, or a default no-args
+constructor, setup methods should be annotated with <i>@Before</i>, tear down methods
+annotated with <i>@After</i> and any test method annotated with <i>@Test</i>.
+<pre class="code">
+import org.apache.tools.ant.BuildFileRule;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.Before;
+import org.junit.Rule;
+import org.apache.tools.ant.AntAssert;
+import org.apache.tools.ant.BuildException;
-public class HelloWorldTest extends BuildFileTest {
+public class HelloWorldTest {
- public HelloWorldTest(String s) {
- super(s);
- }
+ @Rule
+ public final BuildFileRule buildRule = new BuildFileRule();
+ @Before
public void setUp() {
// initialize Ant
- configureProject("build.xml");
+ buildRule.configureProject("build.xml");
}
+ @Test
public void testWithout() {
- executeTarget("use.without");
- assertEquals("Message was logged but should not.", getLog(), "");
+ buildRule.executeTarget("use.without");
+ assertEquals("Message was logged but should not.", buildRule.getLog(), "");
}
public void testMessage() {
// execute target 'use.nestedText' and expect a message
// 'attribute-text' in the log
- expectLog("use.message", "attribute-text");
+ buildRule.executeTarget("use.message");
+ Assert.assertEquals("attribute-text", buildRule.getLog());
}
+ @Test
public void testFail() {
// execute target 'use.fail' and expect a BuildException
// with text 'Fail requested.'
- expectBuildException("use.fail", "Fail requested.");
+ try {
+ buildRule.executeTarget("use.fail");
+ fail("BuildException should have been thrown as task was set to fail");
+ } catch (BuildException ex) {
+ Assert.assertEquals("fail requested", ex.getMessage());
+ }
+
}
+ @Test
public void testNestedText() {
- expectLog("use.nestedText", "nested-text");
+ buildRule.executeTarget("use.nestedText");
+ Assert.assertEquals("nested-text", buildRule.getLog());
}
+ @Test
public void testNestedElement() {
- executeTarget("use.nestedElement");
- assertLogContaining("Nested Element 1");
- assertLogContaining("Nested Element 2");
+ buildRule.executeTarget("use.nestedElement");
+ AntAssert.assertContains("Nested Element 1", buildRule.getLog());
+ AntAssert.assertContains("Nested Element 2", buildRule.getLog());
}
}
</pre>
@@ -790,14 +805,14 @@ The ZIP provided there contains</p><ul>
<a href="tutorial-writing-tasks-src.zip">here [7]</a> inside the manual.
</p>
-<p>Used Links:<br></br>
- [1] <a href="http://ant.apache.org/manual/properties.html#built-in-props">http://ant.apache.org/manual/properties.html#built-in-props</a><br></br>
- [2] <a href="http://ant.apache.org/manual/Tasks/taskdef.html">http://ant.apache.org/manual/Tasks/taskdef.html</a><br></br>
- [3] <a href="http://ant.apache.org/manual/develop.html#set-magic">http://ant.apache.org/manual/develop.html#set-magic</a><br></br>
- [4] <a href="http://ant.apache.org/manual/develop.html#nested-elements">http://ant.apache.org/manual/develop.html#nested-elements</a><br></br>
- [5] <a href="http://gump.covalent.net/jars/latest/ant/ant-testutil.jar">http://gump.covalent.net/jars/latest/ant/ant-testutil.jar</a><br></br>
- [6] <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=22570">http://issues.apache.org/bugzilla/show_bug.cgi?id=22570</a><br></br>
- [7] <a href="tutorial-writing-tasks-src.zip">tutorial-writing-tasks-src.zip</a><br></br>
+<p>Used Links:<br />
+ [1] <a href="http://ant.apache.org/manual/properties.html#built-in-props">http://ant.apache.org/manual/properties.html#built-in-props</a><br />
+ [2] <a href="http://ant.apache.org/manual/Tasks/taskdef.html">http://ant.apache.org/manual/Tasks/taskdef.html</a><br />
+ [3] <a href="http://ant.apache.org/manual/develop.html#set-magic">http://ant.apache.org/manual/develop.html#set-magic</a><br />
+ [4] <a href="http://ant.apache.org/manual/develop.html#nested-elements">http://ant.apache.org/manual/develop.html#nested-elements</a><br />
+ [5] <a href="http://gump.covalent.net/jars/latest/ant/ant-testutil.jar">http://gump.covalent.net/jars/latest/ant/ant-testutil.jar</a><br />
+ [6] <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=22570">http://issues.apache.org/bugzilla/show_bug.cgi?id=22570</a><br />
+ [7] <a href="tutorial-writing-tasks-src.zip">tutorial-writing-tasks-src.zip</a><br />
</p>
</body>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/copy.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/copy.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/copy.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/copy.xml Fri Apr 18 21:00:38 2014
@@ -63,13 +63,10 @@ a=b=
<target name="test3">
<!-- create an empty file -->
<touch file="${output}/copytest3.tmp"/>
- <!--wait -->
- <sleep seconds="4"/>
<!-- copy a different file to two places -->
<copy file="copy.xml" tofile="${output}/copytest3a.tmp" overwrite="true"/>
<copy file="copy.xml" tofile="${output}/copytest3b.tmp" overwrite="true"/>
- <!--wait -->
- <sleep seconds="4"/>
+ </target><target name="test3Part2">
<!-- copy an old file onto a newer file (should not work) -->
<copy file="${output}/copytest3.tmp" tofile="${output}/copytest3b.tmp" />
<!-- copy an older file onto a new one, should succeed -->
Modified: ant/core/trunk/src/etc/testcases/taskdefs/jar.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/jar.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/jar.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/jar.xml Fri Apr 18 21:00:38 2014
@@ -66,7 +66,6 @@
</target>
<target name="testRecreateNewerFileSetup" depends="test4">
- <sleep seconds="3"/>
<touch file="jar.xml"/>
</target>
@@ -111,7 +110,6 @@
</manifest>
<jar destfile="${tmp.jar}" basedir="." includes="jar.xml"
manifest="${tmp.dir}/manifest"/>
- <sleep seconds="3"/>
<touch file="jar.xml"/>
<jar destfile="${tmp.jar}" basedir="." includes="jar.xml"
update="true"/>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/antlr/antlr.xml Fri Apr 18 21:00:38 2014
@@ -110,14 +110,12 @@
<!-- test9 will have been run before that -->
<target name="normalRecompile">
- <sleep seconds="2"/>
<touch file="${output}/extended.calc.g"/>
<antlr target="${output}/extended.calc.g" glib="${output}/antlr.g"/>
</target>
<!-- test9 will have been run before that -->
<target name="supergrammarChangeRecompile">
- <sleep seconds="2"/>
<touch file="${output}/antlr.g"/>
<antlr target="${output}/extended.calc.g" glib="${output}/antlr.g"/>
</target>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/depend/depend.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/depend/depend.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/depend/depend.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/depend/depend.xml Fri Apr 18 21:00:38 2014
@@ -19,11 +19,13 @@
<project name="depend" basedir="." default="help">
<import file="../../../buildfiletest-base.xml"/>
- <target name="setUp">
- <mkdir dir="${output}" />
<property name="tempsrc.dir" value="${output}/tempsrc.dir"/>
<property name="cache.dir" value="${output}/tempsrc.dir"/>
<property name="classes.dir" value="${output}/classes"/>
+
+ <target name="setUp">
+ <mkdir dir="${output}" />
+
</target>
<property name="src1.dir" value="src1"/>
@@ -71,16 +73,14 @@
<javac srcdir="${tempsrc.dir}" destdir="${classes.dir}"/>
</target>
- <target name="testdirect" depends="src1setup, compile">
- <sleep seconds="3"/>
+ <target name="testdirect">
<delete file="${tempsrc.dir}/C.java"/>
<copy file="${src1.dir}/C.java" tofile="${tempsrc.dir}/C.java"/>
<depend srcdir="${tempsrc.dir}" destdir="${classes.dir}"/>
<fileset id="result" dir="${classes.dir}"/>
</target>
- <target name="testclosure" depends="src1setup, compile">
- <sleep seconds="3"/>
+ <target name="testclosure">
<delete file="${tempsrc.dir}/C.java"/>
<copy file="${src1.dir}/C.java" tofile="${tempsrc.dir}/C.java"/>
<depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
@@ -138,16 +138,14 @@
<classfileset id="result" dir="${classes.dir}" rootclass="E"/>
</target>
- <target name="testinner" depends="src2setup, compile">
- <sleep seconds="3"/>
+ <target name="testinner">
<delete file="${tempsrc.dir}/B.java"/>
<copy file="${src2.dir}/B.java" tofile="${tempsrc.dir}/B.java"/>
<depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
<fileset id="result" dir="${classes.dir}"/>
</target>
- <target name="testinnerinner" depends="src3setup, compile">
- <sleep seconds="3"/>
+ <target name="testinnerinner">
<delete file="${tempsrc.dir}/B.java"/>
<copy file="${src3.dir}/B.java" tofile="${tempsrc.dir}/B.java"/>
<depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
@@ -173,10 +171,9 @@
</path>
<javac srcdir="${tempsrc.dir}" destdir="${classes.dir}"
- classpathref="path.compile"/>
+ classpathref="path.compile" fork="false" />
- <sleep seconds="3"/>
- <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}"
+ <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}"
closure="yes" dump="yes"
classpathref="path.compile"/>
@@ -190,8 +187,7 @@
destdir="${classes.dir}" closure="yes"/>
</target>
- <target name="testnonpublic" depends="src5setup, compile">
- <sleep seconds="3"/>
+ <target name="testnonpublic">
<delete file="${tempsrc.dir}/B.java"/>
<copy file="${src2.dir}/B.java" tofile="${tempsrc.dir}/B.java"/>
<depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/junit.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/junit.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/junit.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/junit.xml Fri Apr 18 21:00:38 2014
@@ -280,8 +280,7 @@
<!-- JUnit4 Ignore and Assume for skipping tests -->
<target name="testSkippableTests">
<mkdir dir="${output}"/>
- <junit fork="true">
- <classpath refid="test"/>
+ <junit>
<formatter type="xml"/>
<classpath refid="test"/>
<batchtest todir="${output}">
@@ -297,8 +296,7 @@
<!-- Skipping classes that are not tests -->
<target name="testNonTests">
<mkdir dir="${output}"/>
- <junit fork="true">
- <classpath refid="test"/>
+ <junit>
<formatter type="xml"/>
<classpath refid="test"/>
<batchtest todir="${output}" skipNonTests="true">
@@ -313,8 +311,7 @@
<!-- Not skipping classes that are not tests -->
<target name="testNonTestsRun">
<mkdir dir="${output}"/>
- <junit fork="true">
- <classpath refid="test"/>
+ <junit>
<formatter type="xml"/>
<classpath refid="test"/>
<batchtest todir="${output}" skipNonTests="false">
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/replaceregexp.xml Fri Apr 18 21:00:38 2014
@@ -43,7 +43,7 @@
<!-- use in conjunction with testDirectoryDateDoesNotChange to make sure something will happen -->
<target name="touchDirectory">
<copy file="replaceregexp.properties" tofile="${output}/test.properties" />
- <sleep seconds="2"/>
+
</target>
<target name="testDirectoryDateDoesNotChange">
<replaceregexp file="${output}/test.properties" byline="true">
Modified: ant/core/trunk/src/etc/testcases/taskdefs/optional/unix/symlink.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/optional/unix/symlink.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/optional/unix/symlink.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/optional/unix/symlink.xml Fri Apr 18 21:00:38 2014
@@ -44,7 +44,7 @@
before they have finnished (hopefully). Tweak if needed.
-->
- <property name="delay" value="3"/>
+ <property name="delay" value="0"/>
<import file="../../../buildfiletest-base.xml"/>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/uptodate.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/uptodate.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/uptodate.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/uptodate.xml Fri Apr 18 21:00:38 2014
@@ -19,7 +19,6 @@
<target name="setUp">
<touch file="source"/>
- <sleep seconds="3"/>
<touch file="target"/>
</target>
@@ -28,19 +27,19 @@
<delete file="target"/>
</target>
- <target name="testFilesetUpToDate" depends="setUp">
+ <target name="testFilesetUpToDate">
<uptodate property="foo" targetfile="target">
<srcfiles dir="." includes="source"/>
</uptodate>
</target>
- <target name="testFilesetOutOfDate" depends="setUp">
+ <target name="testFilesetOutOfDate">
<uptodate property="foo" targetfile="source">
<srcfiles dir="." includes="target"/>
</uptodate>
</target>
- <target name="testRCUpToDate" depends="setUp">
+ <target name="testRCUpToDate">
<uptodate property="foo" targetfile="target">
<srcresources>
<fileset dir="." includes="source"/>
@@ -48,7 +47,7 @@
</uptodate>
</target>
- <target name="testRCOutOfDate" depends="setUp">
+ <target name="testRCOutOfDate">
<uptodate property="foo" targetfile="source">
<srcresources>
<fileset dir="." includes="target"/>
Modified: ant/core/trunk/src/etc/testcases/taskdefs/zip.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/taskdefs/zip.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/taskdefs/zip.xml (original)
+++ ant/core/trunk/src/etc/testcases/taskdefs/zip.xml Fri Apr 18 21:00:38 2014
@@ -118,7 +118,6 @@
</target>
<target name="testUpdateIsNecessary" depends="feather">
- <sleep seconds="5" />
<touch file="${output}/dummyfile" />
<copy file="../asf-logo.gif" todir="${output}"/>
<zip destFile="${output}/asf-logo.gif.zip"
Modified: ant/core/trunk/src/etc/testcases/types/selectors.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/etc/testcases/types/selectors.xml?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/etc/testcases/types/selectors.xml (original)
+++ ant/core/trunk/src/etc/testcases/types/selectors.xml Fri Apr 18 21:00:38 2014
@@ -88,11 +88,8 @@
<mkdir dir="${mirror.dir}/tar/bz2" />
<touch file="${mirror.dir}/asf-logo.gif.md5"/>
<touch file="${mirror.dir}/asf-logo.gif.bz2"/>
- <sleep seconds="2"/>
<touch file="${mirror.dir}/zip/asf-logo.gif.zip"/>
- <sleep seconds="3"/>
<touch file="${mirror.dir}/tar/asf-logo.gif.tar"/>
- <sleep seconds="2"/>
<touch file="${mirror.dir}/tar/asf-logo-huge.tar.gz"/>
<touch file="${mirror.dir}/tar/gz/asf-logo.gif.tar.gz"/>
<touch file="${mirror.dir}/tar/bz2/asf-logo.gif.tar.bz2"/>
Added: ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntAssert.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntAssert.java?rev=1588563&view=auto
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntAssert.java (added)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntAssert.java Fri Apr 18 21:00:38 2014
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tools.ant;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Provides common assert functions for use across multiple tests, similar to the <tt>Assert</tt>s
+ * within JUnit.
+ */
+public class AntAssert {
+
+ /**
+ * Assert that a string contains the given substring.
+ * @param message the message to fail with if the substring is not present in the target string.
+ * @param needle the string to search for.
+ * @param haystack the string to search in.
+ */
+ public static void assertContains(String message, String needle, String haystack) {
+ String formattedMessage = (message == null ? "" : message + " ");
+ assertTrue(formattedMessage + String.format("expected message containing: <%s> but got: <%s>", needle, haystack), haystack.contains(needle));
+ }
+
+ /**
+ * Assert that a string contains the given substring. A default failure message will be used if the target string
+ * is not found.
+ * @param needle the target string to search for.
+ * @param haystack the string to search in.
+ */
+ public static void assertContains(String needle, String haystack) {
+ assertContains("", needle, haystack);
+ }
+
+ /**
+ * Assert that a string does not contain the given substring.
+ * @param message the message to fail with if the substring is present in the target string.
+ * @param needle the string to search for.
+ * @param haystack the string to search in.
+ */
+ public static void assertNotContains(String message, String needle, String haystack) {
+ String formattedMessage = (message == null ? "" : message + " ");
+ assertFalse(formattedMessage + String.format("expected message not to contain: <%s> but got: <%s>", needle, haystack), haystack.contains(needle));
+ }
+
+ /**
+ * Assert that a string does not contain the given substring. A default failure message will be used if the target
+ * string is found.
+ * @param needle the target string to search for.
+ * @param haystack the string to search in.
+ */
+ public static void assertNotContains(String needle, String haystack) {
+ assertNotContains("", needle, haystack);
+ }
+
+
+}
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderDelegationTest.java Fri Apr 18 21:00:38 2014
@@ -25,26 +25,27 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
-import junit.framework.TestCase;
-import org.apache.tools.ant.Project;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
/**
* Test case for ant class loader
*
*/
-public class AntClassLoaderDelegationTest extends TestCase {
+public class AntClassLoaderDelegationTest {
/** Instance of a utility class to use for file operations. */
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
private Project p;
- public AntClassLoaderDelegationTest(String name) {
- super(name);
- }
-
+ @Before
public void setUp() {
p = new Project();
p.init();
@@ -53,7 +54,8 @@ public class AntClassLoaderDelegationTes
/** Sample resource present in build/testcases/ */
private static final String TEST_RESOURCE
= "apache/tools/ant/IncludeTest.class";
-
+
+ @Test
public void testFindResources() throws Exception {
// This path should contain the class files for these testcases:
String buildTestcases = System.getProperty("build.tests");
@@ -79,6 +81,7 @@ public class AntClassLoaderDelegationTes
enum2List(acl.getResources(TEST_RESOURCE)));
}
+ @Test
public void testFindIsolateResources() throws Exception {
String buildTestcases = System.getProperty("build.tests");
assertNotNull("defined ${build.tests}", buildTestcases);
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderPerformance.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderPerformance.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderPerformance.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderPerformance.java Fri Apr 18 21:00:38 2014
@@ -19,15 +19,16 @@
package org.apache.tools.ant;
import java.io.File;
-import junit.framework.TestCase;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;
+import org.junit.Test;
/**
* Used to verify the performance effect of classloader changes.
*/
-public class AntClassLoaderPerformance extends TestCase {
+public class AntClassLoaderPerformance {
+ @Test
public void testFindClass() throws Exception {
String testCaseURL = getClass()
.getClassLoader().getResource("junit/framework/TestCase.class")
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/AntClassLoaderTest.java Fri Apr 18 21:00:38 2014
@@ -18,63 +18,75 @@
package org.apache.tools.ant;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.File;
import java.io.PrintStream;
import java.net.URL;
+
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
/**
* Test case for ant class loader
*
*/
-public class AntClassLoaderTest extends BuildFileTest {
+public class AntClassLoaderTest {
+
+ @Rule
+ public BuildFileRule buildRule = new BuildFileRule();
private AntClassLoader loader;
- public AntClassLoaderTest(String name) {
- super(name);
- }
-
+ @Before
public void setUp() {
- super.configureProject("src/etc/testcases/core/antclassloader.xml");
- getProject().executeTarget("setUp");
+ buildRule.configureProject("src/etc/testcases/core/antclassloader.xml");
+ buildRule.executeTarget("setUp");
}
+ @After
public void tearDown() {
if (loader != null) {
loader.cleanup();
}
- try {
- super.tearDown();
- } catch ( Exception e) {
- System.err.println(e.getMessage());
- }
}
+
//test inspired by bug report 37085
+ @Test
public void testJarWithManifestInDirWithSpace() {
- String mainjarstring = getProject().getProperty("main.jar");
- String extjarstring = getProject().getProperty("ext.jar");
- Path myPath = new Path(getProject());
+ String mainjarstring = buildRule.getProject().getProperty("main.jar");
+ String extjarstring = buildRule.getProject().getProperty("ext.jar");
+ Path myPath = new Path(buildRule.getProject());
myPath.setLocation(new File(mainjarstring));
- getProject().setUserProperty("build.sysclasspath","ignore");
- loader = getProject().createClassLoader(myPath);
+ buildRule.getProject().setUserProperty("build.sysclasspath","ignore");
+ loader = buildRule.getProject().createClassLoader(myPath);
String path = loader.getClasspath();
assertEquals(mainjarstring + File.pathSeparator + extjarstring, path);
}
+
+ @Test
public void testJarWithManifestInNonAsciiDir() {
- String mainjarstring = getProject().getProperty("main.jar.nonascii");
- String extjarstring = getProject().getProperty("ext.jar.nonascii");
- Path myPath = new Path(getProject());
+ String mainjarstring = buildRule.getProject().getProperty("main.jar.nonascii");
+ String extjarstring = buildRule.getProject().getProperty("ext.jar.nonascii");
+ Path myPath = new Path(buildRule.getProject());
myPath.setLocation(new File(mainjarstring));
- getProject().setUserProperty("build.sysclasspath","ignore");
- loader = getProject().createClassLoader(myPath);
+ buildRule.getProject().setUserProperty("build.sysclasspath","ignore");
+ loader = buildRule.getProject().createClassLoader(myPath);
String path = loader.getClasspath();
assertEquals(mainjarstring + File.pathSeparator + extjarstring, path);
}
+
+ @Test
public void testCleanup() throws BuildException {
- Path path = new Path(project, ".");
- loader = project.createClassLoader(path);
+ Path path = new Path(buildRule.getProject(), ".");
+ loader = buildRule.getProject().createClassLoader(path);
try {
// we don't expect to find this
loader.findClass("fubar");
@@ -95,7 +107,7 @@ public class AntClassLoaderTest extends
}
// tell the build it is finished
- project.fireBuildFinished(null);
+ buildRule.getProject().fireBuildFinished(null);
try {
// we don't expect to find this
loader.findClass("fubar");
@@ -107,40 +119,43 @@ public class AntClassLoaderTest extends
}
}
+ @Test
public void testGetPackage() throws Exception {
- executeTarget("prepareGetPackageTest");
- Path myPath = new Path(getProject());
- myPath.setLocation(new File(getProject().getProperty("test.jar")));
- getProject().setUserProperty("build.sysclasspath","ignore");
- loader = getProject().createClassLoader(myPath);
+ buildRule.executeTarget("prepareGetPackageTest");
+ Path myPath = new Path(buildRule.getProject());
+ myPath.setLocation(new File(buildRule.getProject().getProperty("test.jar")));
+ buildRule.getProject().setUserProperty("build.sysclasspath","ignore");
+ loader = buildRule.getProject().createClassLoader(myPath);
assertNotNull("should find class", loader.findClass("org.example.Foo"));
assertNotNull("should find package",
new GetPackageWrapper(loader).getPackage("org.example"));
}
+ @Test
public void testCodeSource() throws Exception {
- executeTarget("prepareGetPackageTest");
- Path myPath = new Path(getProject());
- File testJar = new File(getProject().getProperty("test.jar"));
+ buildRule.executeTarget("prepareGetPackageTest");
+ Path myPath = new Path(buildRule.getProject());
+ File testJar = new File(buildRule.getProject().getProperty("test.jar"));
myPath.setLocation(testJar);
- getProject().setUserProperty("build.sysclasspath","ignore");
- loader = getProject().createClassLoader(myPath);
- Class foo = loader.findClass("org.example.Foo");
+ buildRule.getProject().setUserProperty("build.sysclasspath","ignore");
+ loader = buildRule.getProject().createClassLoader(myPath);
+ Class<?> foo = loader.findClass("org.example.Foo");
URL codeSourceLocation =
foo.getProtectionDomain().getCodeSource().getLocation();
assertEquals(codeSourceLocation + " should point to test.jar",
FileUtils.getFileUtils().getFileURL(testJar), codeSourceLocation);
}
+ @Test
public void testSignedJar() throws Exception {
- executeTarget("signTestJar");
- File jar = new File(getProject().getProperty("test.jar"));
+ buildRule.executeTarget("signTestJar");
+ File jar = new File(buildRule.getProject().getProperty("test.jar"));
- Path myPath = new Path(getProject());
+ Path myPath = new Path(buildRule.getProject());
myPath.setLocation(jar);
- getProject().setUserProperty("build.sysclasspath","ignore");
- loader = getProject().createClassLoader(myPath);
- Class foo = loader.findClass("org.example.Foo");
+ buildRule.getProject().setUserProperty("build.sysclasspath","ignore");
+ loader = buildRule.getProject().createClassLoader(myPath);
+ Class<?> foo = loader.findClass("org.example.Foo");
assertNotNull("should find class", foo);
assertNotNull("should have certificates",
@@ -154,23 +169,24 @@ public class AntClassLoaderTest extends
* bug 47593, request to log the name of corrupt zip files from which
* classes cannot be loaded</a>
*/
+ @Test
public void testInvalidZipException() throws Exception {
- executeTarget("createNonJar");
- File jar = new File(getProject().getProperty("tmp.dir")
+ buildRule.executeTarget("createNonJar");
+ File jar = new File(buildRule.getProject().getProperty("tmp.dir")
+ "/foo.jar");
- Path myPath = new Path(getProject());
+ Path myPath = new Path(buildRule.getProject());
myPath.setLocation(jar);
- getProject().setUserProperty("build.sysclasspath","ignore");
- loader = getProject().createClassLoader(myPath);
+ buildRule.getProject().setUserProperty("build.sysclasspath","ignore");
+ loader = buildRule.getProject().createClassLoader(myPath);
PrintStream sysErr = System.err;
try {
StringBuffer errBuffer = new StringBuffer();
PrintStream err =
- new PrintStream(new BuildFileTest.AntOutputStream(errBuffer));
+ new PrintStream(new BuildFileRule.AntOutputStream(errBuffer));
System.setErr(err);
loader.getResource("foo.txt");
- String log = getLog();
+ String log = buildRule.getLog();
int startMessage = log.indexOf("CLASSPATH element ");
assertTrue(startMessage >= 0);
assertTrue(log.indexOf("foo.jar is not a JAR", startMessage) > 0);
Added: ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileRule.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileRule.java?rev=1588563&view=auto
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileRule.java (added)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileRule.java Fri Apr 18 21:00:38 2014
@@ -0,0 +1,318 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant;
+
+import java.io.File;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+import org.apache.tools.ant.util.ProcessUtil;
+import org.junit.rules.ExternalResource;
+
+/**
+ * Provides access for JUnit tests to execute Ant targets and access execution details (i.e logs).
+ *
+ * Example usage:
+ * <code>
+ * public class MyTest {
+ *
+ * \@Rule
+ * public BuildFileRule rule = new BuildFileRule();
+ *
+ * \@Before
+ * public void setUp() {
+ * rule.configureProject("my/and/file.xml");
+ * }
+ *
+ * \@Test
+ * public void testSuccess() {
+ * rule.executeTarget("passingTaget");
+ * assertEquals("Incorrect log message", "[taskName] Action Complete", rule.getLog());
+ * }
+ *
+ * \@Test
+ * public void testException() {
+ * try {
+ * rule.executeTarget("failingTarget");
+ * fail("Target should have thrown a BuildException");
+ * } catch (BuildException ex) {
+ * assertContains("Exception did not contain correct text", "Could not find compiler on classpath", ex.getMessage());
+ * }
+ * }
+ *
+ * }
+ * </code>
+ */
+public class BuildFileRule extends ExternalResource {
+
+ private Project project;
+
+ private StringBuffer logBuffer;
+ private StringBuffer fullLogBuffer;
+ private StringBuffer outputBuffer;
+ private StringBuffer errorBuffer;
+
+
+
+ /**
+ * Tidies up following a test execution. If the currently configured
+ * project has a <tt>tearDown</tt> target then this will automatically
+ * be called, otherwise this method will not perform any actions.
+ */
+ @Override
+ protected void after() {
+ if (project == null) {
+ // configureProject has not been called - nothing we can clean-up
+ return;
+ }
+ final String tearDown = "tearDown";
+ if (project.getTargets().containsKey(tearDown)) {
+ project.executeTarget(tearDown);
+ }
+ }
+
+ /**
+ * Gets the INFO, WARNING and ERROR message from the current execution,
+ * unless the logging level is set above any of these level in which case
+ * the message is excluded.
+ * This is only valid if configureProject() has been called.
+ *
+ * @return The INFO, WARN and ERROR messages in the log.
+ */
+ public String getLog() {
+ return logBuffer.toString();
+ }
+
+ /**
+ * Gets any messages that have been logged during the current execution, unless
+ * the logging level has been set above the log level defined in the message.
+ *
+ * Only valid if configureProject() has been called.
+ * @return the content of the log.
+ */
+ public String getFullLog() {
+ return fullLogBuffer.toString();
+ }
+
+ /**
+ * Provides all output sent to the System.out stream during the current execution.
+ * @return all output messages in a single string, normalised to have platform independent line breaks.
+ */
+ public String getOutput() {
+ return cleanBuffer(outputBuffer);
+ }
+
+ /**
+ * Provides all output sent to the System.err stream during the current execution.
+ * @return all error messages in a single string, normalised to have platform independent line breaks.
+ */
+ public String getError() {
+ return cleanBuffer(errorBuffer);
+ }
+
+ private String cleanBuffer(StringBuffer buffer) {
+ StringBuilder cleanedBuffer = new StringBuilder();
+ for (int i = 0; i < buffer.length(); i++) {
+ char ch = buffer.charAt(i);
+ if (ch != '\r') {
+ cleanedBuffer.append(ch);
+ }
+ }
+ return cleanedBuffer.toString();
+ }
+
+ /**
+ * Sets up to run the named project
+ *
+ * @param filename name of project file to run
+ */
+ public void configureProject(String filename) throws BuildException {
+ configureProject(filename, Project.MSG_DEBUG);
+ }
+
+ /**
+ * Sets up to run the named project
+ *
+ * @param filename name of project file to run
+ */
+ public void configureProject(String filename, int logLevel) throws BuildException {
+ logBuffer = new StringBuffer();
+ fullLogBuffer = new StringBuffer();
+ project = new Project();
+ project.init();
+ File antFile = new File(System.getProperty("root"), filename);
+ project.setProperty("ant.processid", ProcessUtil.getProcessId("<Process>"));
+ project.setProperty("ant.threadname", Thread.currentThread().getName());
+ project.setUserProperty("ant.file" , antFile.getAbsolutePath());
+ project.addBuildListener(new AntTestListener(logLevel));
+ ProjectHelper.configureProject(project, antFile);
+ }
+
+ /**
+ * Executes a target in the configured Ant build file. Requires #configureProject()
+ * to have been invoked before this call.
+ *
+ * @param targetName the target in the currently configured build file to run.
+ */
+ public void executeTarget(String targetName) {
+ outputBuffer = new StringBuffer();
+ PrintStream out = new PrintStream(new AntOutputStream(outputBuffer));
+ errorBuffer = new StringBuffer();
+ PrintStream err = new PrintStream(new AntOutputStream(errorBuffer));
+ logBuffer = new StringBuffer();
+ fullLogBuffer = new StringBuffer();
+
+ /* we synchronize to protect our custom output streams from being overridden
+ * by other tests executing targets concurrently. Ultimately this would only
+ * happen if we ran a multi-threaded test executing multiple targets at once, and
+ * this protection doesn't prevent a target from internally modifying the output
+ * stream during a test - but at least this scenario is fairly deterministic so
+ * easier to troubleshoot.
+ */
+ synchronized (System.out) {
+ PrintStream sysOut = System.out;
+ PrintStream sysErr = System.err;
+ sysOut.flush();
+ sysErr.flush();
+ try {
+ System.setOut(out);
+ System.setErr(err);
+ project.executeTarget(targetName);
+ } finally {
+ System.setOut(sysOut);
+ System.setErr(sysErr);
+ }
+ }
+ }
+
+ /**
+ * Get the project which has been configured for a test.
+ *
+ * @return the Project instance for this test.
+ */
+ public Project getProject() {
+ return project;
+ }
+
+
+ /**
+ * An output stream which saves contents to our buffer.
+ */
+ protected static class AntOutputStream extends OutputStream {
+ private StringBuffer buffer;
+
+ public AntOutputStream( StringBuffer buffer ) {
+ this.buffer = buffer;
+ }
+
+ public void write(int b) {
+ buffer.append((char)b);
+ }
+ }
+
+ /**
+ * Our own personal build listener.
+ */
+ private class AntTestListener implements BuildListener {
+ private int logLevel;
+
+ /**
+ * Constructs a test listener which will ignore log events
+ * above the given level.
+ */
+ public AntTestListener(int logLevel) {
+ this.logLevel = logLevel;
+ }
+
+ /**
+ * Fired before any targets are started.
+ */
+ public void buildStarted(BuildEvent event) {
+ }
+
+ /**
+ * Fired after the last target has finished. This event
+ * will still be thrown if an error occurred during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void buildFinished(BuildEvent event) {
+ }
+
+ /**
+ * Fired when a target is started.
+ *
+ * @see BuildEvent#getTarget()
+ */
+ public void targetStarted(BuildEvent event) {
+ }
+
+ /**
+ * Fired when a target has finished. This event will
+ * still be thrown if an error occurred during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void targetFinished(BuildEvent event) {
+ }
+
+ /**
+ * Fired when a task is started.
+ *
+ * @see BuildEvent#getTask()
+ */
+ public void taskStarted(BuildEvent event) {
+ }
+
+ /**
+ * Fired when a task has finished. This event will still
+ * be throw if an error occurred during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void taskFinished(BuildEvent event) {
+ }
+
+ /**
+ * Fired whenever a message is logged.
+ *
+ * @see BuildEvent#getMessage()
+ * @see BuildEvent#getPriority()
+ */
+ public void messageLogged(BuildEvent event) {
+ if (event.getPriority() > logLevel) {
+ // ignore event
+ return;
+ }
+
+ if (event.getPriority() == Project.MSG_INFO ||
+ event.getPriority() == Project.MSG_WARN ||
+ event.getPriority() == Project.MSG_ERR) {
+ logBuffer.append(event.getMessage());
+ }
+ fullLogBuffer.append(event.getMessage());
+ }
+ }
+
+ public File getOutputDir() {
+ return new File(getProject().getProperty("output"));
+ }
+
+}
+
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/BuildFileTest.java Fri Apr 18 21:00:38 2014
@@ -32,7 +32,10 @@ import org.apache.tools.ant.util.Process
* This class provides a number of utility methods for particular build file
* tests which extend this class.
*
+ * @deprecated as of 1.9.4. Use BuildFileRule, Assert, AntAssert and JUnit4 annotations to drive tests instead
+ * @see org.apache.tools.ant.BuildFileRule
*/
+@Deprecated
public abstract class BuildFileTest extends TestCase {
protected Project project;
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/CaseTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/CaseTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/CaseTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/CaseTest.java Fri Apr 18 21:00:38 2014
@@ -18,37 +18,47 @@
package org.apache.tools.ant;
-import org.apache.tools.ant.BuildFileTest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.apache.tools.ant.AntAssert.assertContains;
+import static org.junit.Assert.fail;
/**
* Simple tests of build file processing
*/
-public class CaseTest extends BuildFileTest {
-
- public CaseTest(String name) {
- super(name);
- }
+public class CaseTest {
+
+ @Rule
+ public BuildFileRule buildRule = new BuildFileRule();
+ @Before
public void setUp() {
- configureProject("src/etc/testcases/core/case.xml");
+ buildRule.configureProject("src/etc/testcases/core/case.xml");
}
/**
* Test whether the build file treats nested elements without
* regard to case. This should not cause an exception.
*/
+ @Test
public void testCaseSensitivity() {
- executeTarget("case-sensitivity");
+ buildRule.executeTarget("case-sensitivity");
}
/**
* Test whether the build file uses case when determining
* task names.
*/
+ @Test
public void testTaskCase() {
- expectBuildExceptionContaining("taskcase",
- "Task names are case sensitive",
- "Problem: failed to create task or type ecHO");
+ try {
+ buildRule.executeTarget("taskcase");
+ fail("Build exception should have been thrown due to case sensitivity of name");
+ } catch(BuildException ex) {
+ assertContains("Task names should be case sensitive", "Problem: failed to create task or type ecHO", ex.getMessage());
+ }
}
}
Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java?rev=1588563&r1=1588562&r2=1588563&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/DefaultLoggerTest.java Fri Apr 18 21:00:38 2014
@@ -18,15 +18,15 @@
package org.apache.tools.ant;
-import java.io.PrintWriter;
-import junit.framework.TestCase;
import org.apache.tools.ant.util.StringUtils;
+import org.junit.Test;
-public class DefaultLoggerTest extends TestCase {
+import java.io.PrintWriter;
+
+import static org.junit.Assert.assertEquals;
+
+public class DefaultLoggerTest {
- public DefaultLoggerTest(String n) {
- super(n);
- }
private static String msg(Throwable error, boolean verbose) {
StringBuffer m = new StringBuffer();
@@ -34,6 +34,7 @@ public class DefaultLoggerTest extends T
return m.toString();
}
+ @Test
public void testThrowableMessage() throws Exception { // #43398
BuildException be = new BuildException("oops", new Location("build.xml", 1, 0));
assertEquals(