From b5057787a256a6f12770296a0c86faff809b9ee5 Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Thu, 21 Sep 2006 19:12:05 +0000 Subject: [PATCH] committing the 'D' portion from svn move src/testcases src/tests/junit git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@448638 13f79535-47bb-0310-9956-ffa450edef68 --- .../ant/AntClassLoaderDelegationTest.java | 121 -- .../apache/tools/ant/AntClassLoaderTest.java | 101 -- .../org/apache/tools/ant/BuildFileTest.java | 524 --------- .../org/apache/tools/ant/CaseTest.java | 54 - .../tools/ant/DirectoryScannerTest.java | 534 --------- .../apache/tools/ant/DispatchTaskTest.java | 36 - .../apache/tools/ant/DummyTaskAbstract.java | 32 - .../apache/tools/ant/DummyTaskInterface.java | 25 - .../org/apache/tools/ant/DummyTaskOk.java | 31 - .../apache/tools/ant/DummyTaskOkNonTask.java | 29 - .../ant/DummyTaskWithNonPublicExecute.java | 29 - .../ant/DummyTaskWithNonVoidExecute.java | 30 - .../DummyTaskWithoutDefaultConstructor.java | 31 - .../tools/ant/DummyTaskWithoutExecute.java | 29 - .../DummyTaskWithoutPublicConstructor.java | 31 - .../org/apache/tools/ant/ExecutorTest.java | 129 --- .../apache/tools/ant/ExtendedTaskdefTest.java | 65 -- .../org/apache/tools/ant/ImmutableTest.java | 78 -- .../org/apache/tools/ant/IncludeTest.java | 133 --- .../tools/ant/IntrospectionHelperTest.java | 683 ----------- .../org/apache/tools/ant/LoaderRefTest.java | 45 - .../org/apache/tools/ant/LocationTest.java | 77 -- .../apache/tools/ant/MockBuildListener.java | 63 - .../org/apache/tools/ant/PickOneTask.java | 31 - .../org/apache/tools/ant/ProjectTest.java | 296 ----- .../tools/ant/PropertyExpansionTest.java | 90 -- .../apache/tools/ant/TaskContainerTest.java | 61 - .../apache/tools/ant/TopLevelTaskTest.java | 49 - .../tools/ant/filters/ConcatFilterTest.java | 154 --- .../tools/ant/filters/DynamicFilterTest.java | 112 -- .../tools/ant/filters/EscapeUnicodeTest.java | 52 - .../tools/ant/filters/HeadTailTest.java | 131 --- .../tools/ant/filters/LineContainsTest.java | 56 - .../tools/ant/filters/NoNewLineTest.java | 49 - .../tools/ant/filters/ReplaceTokensTest.java | 59 - .../ant/filters/StripJavaCommentsTest.java | 52 - .../tools/ant/filters/TokenFilterTest.java | 296 ----- .../ant/taskdefs/AbstractCvsTaskTest.java | 61 - .../taskdefs/AntLikeTasksAtTopLevelTest.java | 62 - .../tools/ant/taskdefs/AntStructureTest.java | 97 -- .../apache/tools/ant/taskdefs/AntTest.java | 512 --------- .../apache/tools/ant/taskdefs/AntlibTest.java | 94 -- .../apache/tools/ant/taskdefs/AptTest.java | 77 -- .../tools/ant/taskdefs/AvailableTest.java | 213 ---- .../tools/ant/taskdefs/BUnzip2Test.java | 63 - .../apache/tools/ant/taskdefs/BZip2Test.java | 111 -- .../tools/ant/taskdefs/BasenameTest.java | 83 -- .../tools/ant/taskdefs/CVSPassTest.java | 122 -- .../tools/ant/taskdefs/CallTargetTest.java | 72 -- .../tools/ant/taskdefs/ChecksumTest.java | 93 -- .../apache/tools/ant/taskdefs/ConcatTest.java | 284 ----- .../tools/ant/taskdefs/ConditionTest.java | 275 ----- .../apache/tools/ant/taskdefs/CopyTest.java | 231 ---- .../tools/ant/taskdefs/CopydirTest.java | 68 -- .../tools/ant/taskdefs/CopyfileTest.java | 68 -- .../ant/taskdefs/DefaultExcludesTest.java | 111 -- .../apache/tools/ant/taskdefs/DeleteTest.java | 83 -- .../tools/ant/taskdefs/DeltreeTest.java | 44 - .../tools/ant/taskdefs/DemuxOutputTask.java | 75 -- .../tools/ant/taskdefs/DependSetTest.java | 70 -- .../tools/ant/taskdefs/DirnameTest.java | 70 -- .../tools/ant/taskdefs/DynamicTask.java | 46 - .../tools/ant/taskdefs/DynamicTest.java | 40 - .../apache/tools/ant/taskdefs/EchoTest.java | 77 -- .../tools/ant/taskdefs/EchoXMLTest.java | 49 - .../tools/ant/taskdefs/ExecTaskTest.java | 491 -------- .../tools/ant/taskdefs/ExecuteJavaTest.java | 136 --- .../tools/ant/taskdefs/ExecuteOnTest.java | 599 ---------- .../ant/taskdefs/ExecuteWatchdogTest.java | 153 --- .../apache/tools/ant/taskdefs/FailTest.java | 164 --- .../apache/tools/ant/taskdefs/FilterTest.java | 114 -- .../tools/ant/taskdefs/FixCrLfTest.java | 219 ---- .../apache/tools/ant/taskdefs/GUnzipTest.java | 71 -- .../apache/tools/ant/taskdefs/GetTest.java | 71 -- .../apache/tools/ant/taskdefs/GzipTest.java | 76 -- .../apache/tools/ant/taskdefs/ImportTest.java | 172 --- .../ant/taskdefs/InitializeClassTest.java | 64 -- .../apache/tools/ant/taskdefs/InputTest.java | 106 -- .../apache/tools/ant/taskdefs/JarTest.java | 270 ----- .../apache/tools/ant/taskdefs/JavaTest.java | 328 ------ .../apache/tools/ant/taskdefs/JavacTest.java | 245 ---- .../tools/ant/taskdefs/JavadocTest.java | 134 --- .../apache/tools/ant/taskdefs/LengthTest.java | 123 -- .../tools/ant/taskdefs/LoadFileTest.java | 155 --- .../ant/taskdefs/LoadPropertiesTest.java | 60 - .../tools/ant/taskdefs/MacroDefTest.java | 158 --- .../tools/ant/taskdefs/MakeUrlTest.java | 137 --- .../ant/taskdefs/ManifestClassPathTest.java | 150 --- .../tools/ant/taskdefs/ManifestTest.java | 346 ------ .../apache/tools/ant/taskdefs/MkdirTest.java | 51 - .../apache/tools/ant/taskdefs/MoveTest.java | 146 --- .../tools/ant/taskdefs/MultiMapTest.java | 74 -- .../apache/tools/ant/taskdefs/NiceTest.java | 62 - .../tools/ant/taskdefs/ParallelTest.java | 154 --- .../tools/ant/taskdefs/PathConvertTest.java | 56 - .../tools/ant/taskdefs/PreSetDefTest.java | 117 -- .../ant/taskdefs/ProcessDestroyerTest.java | 84 -- .../tools/ant/taskdefs/PropertyTest.java | 111 -- .../ant/taskdefs/ProtectedJarMethodsTest.java | 95 -- .../tools/ant/taskdefs/RecorderTest.java | 85 -- .../apache/tools/ant/taskdefs/RenameTest.java | 55 - .../tools/ant/taskdefs/ReplaceTest.java | 107 -- .../tools/ant/taskdefs/RmicAdvancedTest.java | 269 ----- .../apache/tools/ant/taskdefs/RmicTest.java | 101 -- .../tools/ant/taskdefs/SQLExecTest.java | 237 ---- .../tools/ant/taskdefs/SignJarTest.java | 216 ---- .../apache/tools/ant/taskdefs/SleepTest.java | 111 -- .../apache/tools/ant/taskdefs/StyleTest.java | 214 ---- .../apache/tools/ant/taskdefs/SubAntTest.java | 144 --- .../apache/tools/ant/taskdefs/SyncTest.java | 136 --- .../apache/tools/ant/taskdefs/TStampTest.java | 112 -- .../apache/tools/ant/taskdefs/TarTest.java | 158 --- .../tools/ant/taskdefs/TaskdefTest.java | 82 -- .../tools/ant/taskdefs/TaskdefsTest.java | 31 - .../tools/ant/taskdefs/TestProcess.java | 86 -- .../tools/ant/taskdefs/TimeProcess.java | 34 - .../apache/tools/ant/taskdefs/TouchTest.java | 183 --- .../tools/ant/taskdefs/TypeAdapterTest.java | 155 --- .../tools/ant/taskdefs/TypedefTest.java | 87 -- .../apache/tools/ant/taskdefs/UntarTest.java | 92 -- .../apache/tools/ant/taskdefs/UnzipTest.java | 206 ---- .../tools/ant/taskdefs/UpToDateTest.java | 52 - .../apache/tools/ant/taskdefs/WarTest.java | 53 - .../tools/ant/taskdefs/WhichResourceTest.java | 49 - .../tools/ant/taskdefs/XmlPropertyTest.java | 359 ------ .../apache/tools/ant/taskdefs/XmlnsTest.java | 68 -- .../apache/tools/ant/taskdefs/ZipTest.java | 191 ---- .../taskdefs/condition/AntVersionTest.java | 43 - .../ant/taskdefs/condition/ContainsTest.java | 43 - .../ant/taskdefs/condition/EqualsTest.java | 56 - .../ant/taskdefs/condition/IsFailureTest.java | 43 - .../condition/IsFileSelectedTest.java | 53 - .../taskdefs/condition/IsReachableTest.java | 82 -- .../taskdefs/condition/IsReferenceTest.java | 59 - .../ant/taskdefs/condition/IsSignedTest.java | 48 - .../condition/ParserSupportsTest.java | 70 -- .../ant/taskdefs/condition/TypeFoundTest.java | 67 -- .../tools/ant/taskdefs/condition/XorTest.java | 68 -- .../taskdefs/cvslib/ChangeLogParserTest.java | 63 - .../taskdefs/cvslib/ChangeLogWriterTest.java | 96 -- .../org/apache/tools/ant/taskdefs/dir1/B.java | 30 - .../org/apache/tools/ant/taskdefs/dir2/A.java | 40 - .../ant/taskdefs/email/EmailAddressTest.java | 104 -- .../ant/taskdefs/email/EmailTaskTest.java | 45 - .../ant/taskdefs/optional/ANTLRTest.java | 165 --- .../optional/AbstractXSLTLiaisonTest.java | 100 -- .../optional/BeanShellScriptTest.java | 44 - .../ant/taskdefs/optional/DotnetTest.java | 136 --- .../taskdefs/optional/EchoPropertiesTest.java | 233 ---- .../ant/taskdefs/optional/JavahTest.java | 45 - .../tools/ant/taskdefs/optional/JspcTest.java | 229 ---- .../taskdefs/optional/Native2AsciiTest.java | 48 - .../taskdefs/optional/PropertyFileTest.java | 227 ---- .../tools/ant/taskdefs/optional/PvcsTest.java | 58 - .../taskdefs/optional/ReplaceRegExpTest.java | 105 -- .../taskdefs/optional/RhinoReferenceTest.java | 44 - .../taskdefs/optional/RhinoScriptTest.java | 69 -- .../tools/ant/taskdefs/optional/RpmTest.java | 66 -- .../taskdefs/optional/SchemaValidateTest.java | 99 -- .../taskdefs/optional/TraXLiaisonTest.java | 100 -- .../taskdefs/optional/WsdlToDotnetTest.java | 201 ---- .../optional/XmlValidateCatalogTest.java | 83 -- .../taskdefs/optional/XmlValidateTest.java | 189 --- .../tools/ant/taskdefs/optional/XsltTest.java | 104 -- .../taskdefs/optional/depend/DependTest.java | 158 --- .../taskdefs/optional/i18n/TranslateTest.java | 96 -- .../taskdefs/optional/image/ImageTest.java | 119 -- .../optional/jdepend/JDependTest.java | 97 -- .../optional/junit/JUnitClassLoaderTest.java | 38 - .../optional/junit/JUnitReportTest.java | 206 ---- .../optional/junit/JUnitTaskTest.java | 159 --- .../optional/junit/JUnitTestListenerTest.java | 80 -- .../optional/junit/JUnitTestRunnerTest.java | 153 --- .../junit/JUnitVersionHelperTest.java | 90 -- .../taskdefs/optional/junit/NoVmCrash.java | 33 - .../ant/taskdefs/optional/junit/Printer.java | 42 - .../ant/taskdefs/optional/junit/Sleeper.java | 37 - .../optional/junit/SuiteMethodTest.java | 42 - .../optional/junit/TestFormatter.java | 112 -- .../ant/taskdefs/optional/junit/VmCrash.java | 34 - .../XMLFormatterWithCDATAOnSystemOut.java | 77 -- .../ant/taskdefs/optional/net/FTPTest.java | 895 --------------- .../optional/perforce/P4ChangeTest.java | 52 - .../optional/perforce/p4integrate.xml | 15 - .../optional/script/ScriptDefTest.java | 117 -- .../ant/taskdefs/optional/sos/SOSTest.java | 336 ------ .../optional/splash/SplashScreenTest.java | 56 - .../ant/taskdefs/optional/ssh/ScpTest.java | 166 --- .../taskdefs/optional/unix/SymlinkTest.java | 190 --- .../ant/taskdefs/optional/vss/MSVSSTest.java | 453 -------- .../tools/ant/types/AbstractFileSetTest.java | 245 ---- .../apache/tools/ant/types/AddTypeTest.java | 186 --- .../tools/ant/types/AssertionsTest.java | 102 -- .../tools/ant/types/CommandlineJavaTest.java | 186 --- .../tools/ant/types/CommandlineTest.java | 143 --- .../tools/ant/types/DescriptionTest.java | 58 - .../apache/tools/ant/types/DirSetTest.java | 83 -- .../ant/types/EnumeratedAttributeTest.java | 86 -- .../apache/tools/ant/types/FileListTest.java | 149 --- .../apache/tools/ant/types/FileSetTest.java | 39 - .../apache/tools/ant/types/FilterSetTest.java | 221 ---- .../tools/ant/types/FlexIntegerTest.java | 73 -- .../apache/tools/ant/types/MapperTest.java | 246 ---- .../org/apache/tools/ant/types/PathTest.java | 552 --------- .../tools/ant/types/PatternSetTest.java | 203 ---- .../tools/ant/types/PermissionsTest.java | 156 --- .../org/apache/tools/ant/types/PolyTest.java | 67 -- .../tools/ant/types/PropertySetTest.java | 44 - .../ant/types/RedirectorElementTest.java | 64 -- .../ant/types/ResourceCollectionsTest.java | 141 --- .../ant/types/ResourceComparatorsTest.java | 101 -- .../tools/ant/types/ResourceOutputTest.java | 152 --- .../ant/types/ResourceSelectorsTest.java | 101 -- .../tools/ant/types/TarFileSetTest.java | 115 -- .../ant/types/XMLCatalogBuildFileTest.java | 96 -- .../tools/ant/types/XMLCatalogTest.java | 411 ------- .../tools/ant/types/ZipFileSetTest.java | 115 -- .../ant/types/mappers/GlobMapperTest.java | 43 - .../tools/ant/types/mappers/MapperResult.java | 103 -- .../mappers/RegexpPatternMapperTest.java | 43 - .../types/optional/ScriptConditionTest.java | 62 - .../ant/types/optional/ScriptMapperTest.java | 44 - .../types/optional/ScriptSelectorTest.java | 61 - .../optional/depend/ClassFileSetTest.java | 177 --- .../ant/types/resources/JavaResourceTest.java | 41 - .../ant/types/resources/TarResourceTest.java | 44 - .../ant/types/selectors/BaseSelectorTest.java | 289 ----- .../types/selectors/ContainsRegexpTest.java | 84 -- .../types/selectors/ContainsSelectorTest.java | 123 -- .../ant/types/selectors/DateSelectorTest.java | 239 ---- .../types/selectors/DependSelectorTest.java | 172 --- .../types/selectors/DepthSelectorTest.java | 158 --- .../types/selectors/FilenameSelectorTest.java | 125 -- .../ant/types/selectors/MockAlgorithm.java | 37 - .../tools/ant/types/selectors/MockCache.java | 68 -- .../ant/types/selectors/MockComparator.java | 32 - .../types/selectors/ModifiedSelectorTest.java | 1017 ----------------- .../types/selectors/PresentSelectorTest.java | 154 --- .../apache/tools/ant/types/selectors/README | 96 -- .../types/selectors/SignedSelectorTest.java | 45 - .../ant/types/selectors/SizeSelectorTest.java | 201 ---- .../ant/types/selectors/TypeSelectorTest.java | 90 -- .../tools/ant/util/ClasspathUtilsTest.java | 67 -- .../tools/ant/util/CollectionUtilsTest.java | 101 -- .../tools/ant/util/DOMElementWriterTest.java | 257 ----- .../apache/tools/ant/util/DateUtilsTest.java | 91 -- .../apache/tools/ant/util/FileUtilsTest.java | 574 ---------- .../tools/ant/util/GlobPatternMapperTest.java | 98 -- .../apache/tools/ant/util/JAXPUtilsTest.java | 43 - .../tools/ant/util/JavaEnvUtilsTest.java | 130 --- .../ant/util/LazyFileOutputStreamTest.java | 69 -- .../util/LineOrientedOutputStreamTest.java | 139 --- .../tools/ant/util/LoaderUtilsTest.java | 43 - .../tools/ant/util/PackageNameMapperTest.java | 40 - .../tools/ant/util/ReaderInputStreamTest.java | 96 -- .../tools/ant/util/ResourceUtilsTest.java | 61 - .../tools/ant/util/StringUtilsTest.java | 106 -- .../ant/util/UnPackageNameMapperTest.java | 40 - .../tools/ant/util/XMLFragmentTest.java | 82 -- .../ant/util/facade/FacadeTaskHelperTest.java | 63 - .../ImplementationSpecificArgumentTest.java | 59 - .../util/regexp/JakartaOroMatcherTest.java | 35 - .../ant/util/regexp/JakartaOroRegexpTest.java | 35 - .../util/regexp/JakartaRegexpMatcherTest.java | 63 - .../util/regexp/JakartaRegexpRegexpTest.java | 62 - .../util/regexp/Jdk14RegexpMatcherTest.java | 70 -- .../util/regexp/Jdk14RegexpRegexpTest.java | 71 -- .../ant/util/regexp/RegexpMatcherTest.java | 204 ---- .../tools/ant/util/regexp/RegexpTest.java | 63 - .../apache/tools/mail/MailMessageTest.java | 734 ------------ .../org/apache/tools/tar/TarEntryTest.java | 38 - .../apache/tools/tar/TarOutputStreamTest.java | 34 - .../apache/tools/tar/TarRoundTripTest.java | 60 - .../apache/tools/zip/AsiExtraFieldTest.java | 141 --- .../apache/tools/zip/ExtraFieldUtilsTest.java | 114 -- .../org/apache/tools/zip/ZipEntryTest.java | 118 -- .../org/apache/tools/zip/ZipLongTest.java | 82 -- .../apache/tools/zip/ZipOutputStreamTest.java | 77 -- .../org/apache/tools/zip/ZipShortTest.java | 80 -- src/testcases/org/example/junit/Output.java | 37 - .../org/example/junit/ThreadedOutput.java | 43 - .../org/example/junit/XmlParserTest.java | 56 - .../tasks/TaskdefTestContainerTask.java | 25 - .../example/tasks/TaskdefTestSimpleTask.java | 45 - src/testcases/org/example/tasks/antlib.xml | 10 - src/testcases/org/example/tasks/antlib2.xml | 10 - .../org/example/types/TypedefTestType.java | 25 - 287 files changed, 36196 deletions(-) delete mode 100644 src/testcases/org/apache/tools/ant/AntClassLoaderDelegationTest.java delete mode 100644 src/testcases/org/apache/tools/ant/AntClassLoaderTest.java delete mode 100644 src/testcases/org/apache/tools/ant/BuildFileTest.java delete mode 100644 src/testcases/org/apache/tools/ant/CaseTest.java delete mode 100644 src/testcases/org/apache/tools/ant/DirectoryScannerTest.java delete mode 100644 src/testcases/org/apache/tools/ant/DispatchTaskTest.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskAbstract.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskInterface.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskOk.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskOkNonTask.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskWithNonPublicExecute.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskWithNonVoidExecute.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskWithoutDefaultConstructor.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskWithoutExecute.java delete mode 100644 src/testcases/org/apache/tools/ant/DummyTaskWithoutPublicConstructor.java delete mode 100755 src/testcases/org/apache/tools/ant/ExecutorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/ExtendedTaskdefTest.java delete mode 100644 src/testcases/org/apache/tools/ant/ImmutableTest.java delete mode 100644 src/testcases/org/apache/tools/ant/IncludeTest.java delete mode 100644 src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/LoaderRefTest.java delete mode 100644 src/testcases/org/apache/tools/ant/LocationTest.java delete mode 100644 src/testcases/org/apache/tools/ant/MockBuildListener.java delete mode 100644 src/testcases/org/apache/tools/ant/PickOneTask.java delete mode 100644 src/testcases/org/apache/tools/ant/ProjectTest.java delete mode 100644 src/testcases/org/apache/tools/ant/PropertyExpansionTest.java delete mode 100644 src/testcases/org/apache/tools/ant/TaskContainerTest.java delete mode 100644 src/testcases/org/apache/tools/ant/TopLevelTaskTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/ConcatFilterTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/DynamicFilterTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/EscapeUnicodeTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/HeadTailTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/LineContainsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/NoNewLineTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/ReplaceTokensTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/StripJavaCommentsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/AntStructureTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/AntTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/AntlibTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/AptTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/BUnzip2Test.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/BZip2Test.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/BasenameTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/CallTargetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ChecksumTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ConcatTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/CopydirTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/CopyfileTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DefaultExcludesTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DeleteTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DeltreeTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DemuxOutputTask.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DependSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DirnameTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DynamicTask.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/DynamicTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/EchoTest.java delete mode 100755 src/testcases/org/apache/tools/ant/taskdefs/EchoXMLTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ExecTaskTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java delete mode 100755 src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/FailTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/GUnzipTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/GetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/InitializeClassTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/InputTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/JarTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java delete mode 100755 src/testcases/org/apache/tools/ant/taskdefs/JavadocTest.java delete mode 100755 src/testcases/org/apache/tools/ant/taskdefs/LengthTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/LoadFileTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/LoadPropertiesTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/MakeUrlTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/MkdirTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/MultiMapTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/NiceTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ParallelTest.java delete mode 100755 src/testcases/org/apache/tools/ant/taskdefs/PathConvertTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ProcessDestroyerTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ProtectedJarMethodsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/RecorderTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/RenameTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ReplaceTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/RmicTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/SQLExecTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/SubAntTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/SyncTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TStampTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TarTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TaskdefTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TestProcess.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TimeProcess.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TouchTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TypeAdapterTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/TypedefTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/UntarTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java delete mode 100755 src/testcases/org/apache/tools/ant/taskdefs/UpToDateTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/WarTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/WhichResourceTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/XmlnsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/AntVersionTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/ContainsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/EqualsTest.java delete mode 100755 src/testcases/org/apache/tools/ant/taskdefs/condition/IsFailureTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/IsFileSelectedTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/IsReachableTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/IsReferenceTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/IsSignedTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/ParserSupportsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/TypeFoundTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/condition/XorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/cvslib/ChangeLogParserTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/cvslib/ChangeLogWriterTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/dir1/B.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/dir2/A.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/email/EmailAddressTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/JavahTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/JspcTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/PvcsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/RpmTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/WsdlToDotnetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/XsltTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Printer.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/TestFormatter.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/P4ChangeTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/p4integrate.xml delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/splash/SplashScreenTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java delete mode 100644 src/testcases/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/AbstractFileSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/AddTypeTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/AssertionsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/CommandlineTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/DescriptionTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/DirSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/FileListTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/FileSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/FilterSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/FlexIntegerTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/MapperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/PathTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/PatternSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/PermissionsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/PolyTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/PropertySetTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/ResourceCollectionsTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/ResourceComparatorsTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/ResourceOutputTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/ResourceSelectorsTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/TarFileSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/XMLCatalogBuildFileTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/ZipFileSetTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/mappers/GlobMapperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/mappers/MapperResult.java delete mode 100644 src/testcases/org/apache/tools/ant/types/mappers/RegexpPatternMapperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/optional/ScriptConditionTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/optional/ScriptMapperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/optional/ScriptSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/resources/JavaResourceTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/resources/TarResourceTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/BaseSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/ContainsSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/DepthSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/MockAlgorithm.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/MockCache.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/MockComparator.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/PresentSelectorTest.java delete mode 100755 src/testcases/org/apache/tools/ant/types/selectors/README delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/SignedSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/SizeSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/types/selectors/TypeSelectorTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/ClasspathUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/CollectionUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/DOMElementWriterTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/DateUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/FileUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/GlobPatternMapperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/JAXPUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/JavaEnvUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/LazyFileOutputStreamTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/LoaderUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/PackageNameMapperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/ResourceUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/StringUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/UnPackageNameMapperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/XMLFragmentTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java delete mode 100644 src/testcases/org/apache/tools/ant/util/regexp/RegexpTest.java delete mode 100644 src/testcases/org/apache/tools/mail/MailMessageTest.java delete mode 100644 src/testcases/org/apache/tools/tar/TarEntryTest.java delete mode 100644 src/testcases/org/apache/tools/tar/TarOutputStreamTest.java delete mode 100644 src/testcases/org/apache/tools/tar/TarRoundTripTest.java delete mode 100644 src/testcases/org/apache/tools/zip/AsiExtraFieldTest.java delete mode 100644 src/testcases/org/apache/tools/zip/ExtraFieldUtilsTest.java delete mode 100644 src/testcases/org/apache/tools/zip/ZipEntryTest.java delete mode 100644 src/testcases/org/apache/tools/zip/ZipLongTest.java delete mode 100644 src/testcases/org/apache/tools/zip/ZipOutputStreamTest.java delete mode 100644 src/testcases/org/apache/tools/zip/ZipShortTest.java delete mode 100644 src/testcases/org/example/junit/Output.java delete mode 100644 src/testcases/org/example/junit/ThreadedOutput.java delete mode 100644 src/testcases/org/example/junit/XmlParserTest.java delete mode 100644 src/testcases/org/example/tasks/TaskdefTestContainerTask.java delete mode 100644 src/testcases/org/example/tasks/TaskdefTestSimpleTask.java delete mode 100644 src/testcases/org/example/tasks/antlib.xml delete mode 100644 src/testcases/org/example/tasks/antlib2.xml delete mode 100644 src/testcases/org/example/types/TypedefTestType.java diff --git a/src/testcases/org/apache/tools/ant/AntClassLoaderDelegationTest.java b/src/testcases/org/apache/tools/ant/AntClassLoaderDelegationTest.java deleted file mode 100644 index d66ed7d5e..000000000 --- a/src/testcases/org/apache/tools/ant/AntClassLoaderDelegationTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -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; - -/** - * Test case for ant class loader - * - */ -public class AntClassLoaderDelegationTest extends TestCase { - - /** 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); - } - - public void setUp() { - p = new Project(); - p.init(); - } - - /** Sample resource present in build/testcases/ */ - private static final String TEST_RESOURCE = "org/apache/tools/ant/IncludeTest.class"; - - public void testFindResources() throws Exception { - //System.err.println("loading from: " + AntClassLoader.class.getProtectionDomain().getCodeSource().getLocation()); - // See bug #30161. - // This path should contain the class files for these testcases: - String buildTestcases = System.getProperty("build.tests"); - assertNotNull("defined ${build.tests}", buildTestcases); - assertTrue("have a dir " + buildTestcases, new File(buildTestcases).isDirectory()); - Path path = new Path(p, buildTestcases); - // A special parent loader which is not the system class loader: - ClassLoader parent = new ParentLoader(); - // An AntClassLoader which is supposed to delegate to the parent and then to the disk path: - ClassLoader acl = new AntClassLoader(parent, p, path, true); - // The intended result URLs: - URL urlFromPath = new URL(FILE_UTILS.toURI(buildTestcases) + TEST_RESOURCE); - URL urlFromParent = new URL("http://ant.apache.org/" + TEST_RESOURCE); - assertEquals("correct resources (regular delegation order)", - Arrays.asList(new URL[] {urlFromParent, urlFromPath}), - enum2List(acl.getResources(TEST_RESOURCE))); - acl = new AntClassLoader(parent, p, path, false); - assertEquals("correct resources (reverse delegation order)", - Arrays.asList(new URL[] {urlFromPath, urlFromParent}), - enum2List(acl.getResources(TEST_RESOURCE))); - } - - public void testFindIsolateResources() throws Exception { - String buildTestcases = System.getProperty("build.tests"); - assertNotNull("defined ${build.tests}", buildTestcases); - assertTrue("have a dir " + buildTestcases, new File(buildTestcases).isDirectory()); - Path path = new Path(p, buildTestcases); - // A special parent loader which is not the system class loader: - ClassLoader parent = new ParentLoader(); - - URL urlFromPath = new URL(FILE_UTILS.toURI(buildTestcases) + TEST_RESOURCE); - AntClassLoader acl = new AntClassLoader(parent, p, path, false); - acl.setIsolated(true); - assertEquals("correct resources (reverse delegation order)", - Arrays.asList(new URL[] {urlFromPath}), - enum2List(acl.getResources(TEST_RESOURCE))); - } - - private static List enum2List(Enumeration e) { - // JDK 1.4: return Collections.list(e); - List l = new ArrayList(); - while (e.hasMoreElements()) { - l.add(e.nextElement()); - } - return l; - } - - /** Special loader that just knows how to find TEST_RESOURCE. */ - private static final class ParentLoader extends ClassLoader { - - public ParentLoader() {} - - protected Enumeration findResources(String name) throws IOException { - if (name.equals(TEST_RESOURCE)) { - return Collections.enumeration(Collections.singleton(new URL("http://ant.apache.org/" + name))); - } else { - return Collections.enumeration(Collections.EMPTY_SET); - } - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/AntClassLoaderTest.java b/src/testcases/org/apache/tools/ant/AntClassLoaderTest.java deleted file mode 100644 index 10649da41..000000000 --- a/src/testcases/org/apache/tools/ant/AntClassLoaderTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import java.io.File; -import org.apache.tools.ant.types.Path; - -/** - * Test case for ant class loader - * - */ -public class AntClassLoaderTest extends BuildFileTest { - - private Project p; - - public AntClassLoaderTest(String name) { - super(name); - } - - public void setUp() { - p = new Project(); - p.init(); - configureProject("src/etc/testcases/core/antclassloader.xml"); - getProject().executeTarget("setup"); - } - - public void tearDown() { - getProject().executeTarget("cleanup"); - } - //test inspired by bug report 37085 - public void testJarWithManifestInDirWithSpace() { - String mainjarstring = getProject().getProperty("main.jar"); - String extjarstring = getProject().getProperty("ext.jar"); - Path myPath = new Path(getProject()); - myPath.setLocation(new File(mainjarstring)); - getProject().setUserProperty("build.sysclasspath","ignore"); - AntClassLoader myLoader = getProject().createClassLoader(myPath); - String path = myLoader.getClasspath(); - assertEquals(mainjarstring + File.pathSeparator + extjarstring, path); - } - public void testJarWithManifestInNonAsciiDir() { - String mainjarstring = getProject().getProperty("main.jar.nonascii"); - String extjarstring = getProject().getProperty("ext.jar.nonascii"); - Path myPath = new Path(getProject()); - myPath.setLocation(new File(mainjarstring)); - getProject().setUserProperty("build.sysclasspath","ignore"); - AntClassLoader myLoader = getProject().createClassLoader(myPath); - String path = myLoader.getClasspath(); - assertEquals(mainjarstring + File.pathSeparator + extjarstring, path); - } - public void testCleanup() throws BuildException { - Path path = new Path(p, "."); - AntClassLoader loader = p.createClassLoader(path); - try { - // we don't expect to find this - loader.findClass("fubar"); - fail("Did not expect to find fubar class"); - } catch (ClassNotFoundException e) { - // ignore expected - } - - loader.cleanup(); - try { - // we don't expect to find this - loader.findClass("fubar"); - fail("Did not expect to find fubar class"); - } catch (ClassNotFoundException e) { - // ignore expected - } catch (NullPointerException e) { - fail("loader should not fail even if cleaned up"); - } - - // tell the build it is finished - p.fireBuildFinished(null); - try { - // we don't expect to find this - loader.findClass("fubar"); - fail("Did not expect to find fubar class"); - } catch (ClassNotFoundException e) { - // ignore expected - } catch (NullPointerException e) { - fail("loader should not fail even if project finished"); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/BuildFileTest.java b/src/testcases/org/apache/tools/ant/BuildFileTest.java deleted file mode 100644 index 0b55ce7c0..000000000 --- a/src/testcases/org/apache/tools/ant/BuildFileTest.java +++ /dev/null @@ -1,524 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import junit.framework.TestCase; -import java.io.File; -import java.io.PrintStream; -import java.net.URL; - -/** - * A BuildFileTest is a TestCase which executes targets from an Ant buildfile - * for testing. - * - * This class provides a number of utility methods for particular build file - * tests which extend this class. - * - */ -public abstract class BuildFileTest extends TestCase { - - protected Project project; - - private StringBuffer logBuffer; - private StringBuffer fullLogBuffer; - private StringBuffer outBuffer; - private StringBuffer errBuffer; - private BuildException buildException; - - /** - * Default constructor for the BuildFileTest object. - */ - public BuildFileTest() { - super(); - } - - /** - * Constructor for the BuildFileTest object. - * - * @param name string to pass up to TestCase constructor - */ - public BuildFileTest(String name) { - super(name); - } - - /** - * Automatically calls the target called "tearDown" - * from the build file tested if it exits. - * - * This allows to use Ant tasks directly in the build file - * to clean up after each test. Note that no "setUp" target - * is automatically called, since it's trivial to have a - * test target depend on it. - */ - protected void tearDown() throws Exception { - final String tearDown = "tearDown"; - if (project.getTargets().containsKey(tearDown)) { - project.executeTarget(tearDown); - } - } - - /** - * run a target, expect for any build exception - * - * @param target target to run - * @param cause information string to reader of report - */ - public void expectBuildException(String target, String cause) { - expectSpecificBuildException(target, cause, null); - } - - /** - * Assert that only the given message has been logged with a - * priority <= INFO when running the given target. - */ - public void expectLog(String target, String log) { - executeTarget(target); - String realLog = getLog(); - assertEquals(log, realLog); - } - - /** - * Assert that the given substring is in the log messages. - */ - public void assertLogContaining(String substring) { - String realLog = getLog(); - assertTrue("expecting log to contain \"" + substring + "\" log was \"" - + realLog + "\"", - realLog.indexOf(substring) >= 0); - } - - /** - * Assert that the given substring is in the output messages. - * @since Ant1.7 - */ - public void assertOutputContaining(String substring) { - String realOutput = getOutput(); - assertTrue("expecting output to contain \"" + substring - + "\" output was \"" + realOutput + "\"", - realOutput.indexOf(substring) >= 0); - } - - /** - * Assert that the given message has been logged with a priority - * <= INFO when running the given target. - */ - public void expectLogContaining(String target, String log) { - executeTarget(target); - assertLogContaining(log); - } - - /** - * Gets the log the BuildFileTest object. - * Only valid if configureProject() has been called. - * - * @pre logBuffer!=null - * @return The log value - */ - public String getLog() { - return logBuffer.toString(); - } - - /** - * Assert that the given message has been logged with a priority - * >= VERBOSE when running the given target. - */ - public void expectDebuglog(String target, String log) { - executeTarget(target); - String realLog = getFullLog(); - assertEquals(log, realLog); - } - - /** - * Assert that the given substring is in the log messages. - */ - public void assertDebuglogContaining(String substring) { - String realLog = getFullLog(); - assertTrue("expecting debug log to contain \"" + substring - + "\" log was \"" - + realLog + "\"", - realLog.indexOf(substring) >= 0); - } - - /** - * Gets the log the BuildFileTest object. - * - * Only valid if configureProject() has been called. - * - * @pre fullLogBuffer!=null - * @return The log value - */ - public String getFullLog() { - return fullLogBuffer.toString(); - } - - /** - * execute the target, verify output matches expectations - * - * @param target target to execute - * @param output output to look for - */ - public void expectOutput(String target, String output) { - executeTarget(target); - String realOutput = getOutput(); - assertEquals(output, realOutput.trim()); - } - - /** - * Executes the target, verify output matches expectations - * and that we got the named error at the end - * - * @param target target to execute - * @param output output to look for - * @param error Description of Parameter - */ - public void expectOutputAndError(String target, String output, String error) { - executeTarget(target); - String realOutput = getOutput(); - assertEquals(output, realOutput); - String realError = getError(); - assertEquals(error, realError); - } - - public String getOutput() { - return cleanBuffer(outBuffer); - } - - public String getError() { - return cleanBuffer(errBuffer); - } - - public BuildException getBuildException() { - return buildException; - } - - private String cleanBuffer(StringBuffer buffer) { - StringBuffer cleanedBuffer = new StringBuffer(); - boolean cr = false; - for (int i = 0; i < buffer.length(); i++) { - char ch = buffer.charAt(i); - if (ch == '\r') { - cr = true; - continue; - } - - if (!cr) { - cleanedBuffer.append(ch); - } else { - 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.setUserProperty("ant.file" , antFile.getAbsolutePath()); - project.addBuildListener(new AntTestListener(logLevel)); - ProjectHelper.configureProject(project, antFile); - } - - /** - * Executes a target we have set up - * - * @pre configureProject has been called - * @param targetName target to run - */ - public void executeTarget(String targetName) { - PrintStream sysOut = System.out; - PrintStream sysErr = System.err; - try { - sysOut.flush(); - sysErr.flush(); - outBuffer = new StringBuffer(); - PrintStream out = new PrintStream(new AntOutputStream(outBuffer)); - System.setOut(out); - errBuffer = new StringBuffer(); - PrintStream err = new PrintStream(new AntOutputStream(errBuffer)); - System.setErr(err); - logBuffer = new StringBuffer(); - fullLogBuffer = new StringBuffer(); - buildException = null; - 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; - } - - /** - * Gets the directory of the project. - * - * @return the base dir of the project - */ - public File getProjectDir() { - return project.getBaseDir(); - } - - /** - * Runs a target, wait for a build exception. - * - * @param target target to run - * @param cause information string to reader of report - * @param msg the message value of the build exception we are waiting - * for set to null for any build exception to be valid - */ - public void expectSpecificBuildException(String target, String cause, String msg) { - try { - executeTarget(target); - } catch (org.apache.tools.ant.BuildException ex) { - buildException = ex; - if ((null != msg) && (!ex.getMessage().equals(msg))) { - fail("Should throw BuildException because '" + cause - + "' with message '" + msg - + "' (actual message '" + ex.getMessage() + "' instead)"); - } - return; - } - fail("Should throw BuildException because: " + cause); - } - - /** - * run a target, expect an exception string - * containing the substring we look for (case sensitive match) - * - * @param target target to run - * @param cause information string to reader of report - * @param contains substring of the build exception to look for - */ - public void expectBuildExceptionContaining(String target, String cause, String contains) { - try { - executeTarget(target); - } catch (org.apache.tools.ant.BuildException ex) { - buildException = ex; - if ((null != contains) && (ex.getMessage().indexOf(contains) == -1)) { - fail("Should throw BuildException because '" + cause + "' with message containing '" + contains + "' (actual message '" + ex.getMessage() + "' instead)"); - } - return; - } - fail("Should throw BuildException because: " + cause); - } - - /** - * call a target, verify property is as expected - * - * @param target build file target - * @param property property name - * @param value expected value - */ - public void expectPropertySet(String target, String property, String value) { - executeTarget(target); - assertPropertyEquals(property, value); - } - - /** - * assert that a property equals a value; comparison is case sensitive. - * - * @param property property name - * @param value expected value - */ - public void assertPropertyEquals(String property, String value) { - String result = project.getProperty(property); - assertEquals("property " + property,value,result); - } - - /** - * assert that a property equals "true". - * - * @param property property name - */ - public void assertPropertySet(String property) { - assertPropertyEquals(property, "true"); - } - - /** - * assert that a property is null. - * - * @param property property name - */ - public void assertPropertyUnset(String property) { - assertPropertyEquals(property, null); - } - - /** - * call a target, verify named property is "true". - * - * @param target build file target - * @param property property name - */ - public void expectPropertySet(String target, String property) { - expectPropertySet(target, property, "true"); - } - - /** - * Call a target, verify property is null. - * - * @param target build file target - * @param property property name - */ - public void expectPropertyUnset(String target, String property) { - expectPropertySet(target, property, null); - } - - /** - * Retrieve a resource from the caller classloader to avoid - * assuming a vm working directory. The resource path must be - * relative to the package name or absolute from the root path. - * - * @param resource the resource to retrieve its url. - * @throws junit.framework.AssertionFailedError if the resource is not found. - */ - public URL getResource(String resource){ - URL url = getClass().getResource(resource); - assertNotNull("Could not find resource :" + resource, url); - return url; - } - - /** - * an output stream which saves stuff to our buffer. - */ - private static class AntOutputStream extends java.io.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) { - //System.out.println("targetStarted " + event.getTarget().getName()); - } - - /** - * 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) { - //System.out.println("targetFinished " + event.getTarget().getName()); - } - - /** - * Fired when a task is started. - * - * @see BuildEvent#getTask() - */ - public void taskStarted(BuildEvent event) { - //System.out.println("taskStarted " + event.getTask().getTaskName()); - } - - /** - * 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) { - //System.out.println("taskFinished " + event.getTask().getTaskName()); - } - - /** - * 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()); - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/CaseTest.java b/src/testcases/org/apache/tools/ant/CaseTest.java deleted file mode 100644 index fcb56d752..000000000 --- a/src/testcases/org/apache/tools/ant/CaseTest.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Simple tests of build file processing - */ -public class CaseTest extends BuildFileTest { - - public CaseTest(String name) { - super(name); - } - - public void setUp() { - 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. - */ - public void testCaseSensitivity() { - executeTarget("case-sensitivity"); - } - - /** - * Test whether the build file uses case when determining - * task names. - */ - public void testTaskCase() { - expectBuildExceptionContaining("taskcase", - "Task names are case sensitive", - "Problem: failed to create task or type ecHO"); - } -} - diff --git a/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java b/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java deleted file mode 100644 index 9c69618d2..000000000 --- a/src/testcases/org/apache/tools/ant/DirectoryScannerTest.java +++ /dev/null @@ -1,534 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.util.FileUtils; - - -import java.io.File; -import java.io.IOException; -import java.util.Set; -import java.util.TreeSet; -import java.util.Iterator; - -/** - * JUnit 3 testcases for org.apache.tools.ant.DirectoryScanner - * - */ -public class DirectoryScannerTest extends BuildFileTest { - - public DirectoryScannerTest(String name) {super(name);} - - // keep track of what operating systems are supported here. - private boolean supportsSymlinks = Os.isFamily("unix"); - - public void setUp() { - configureProject("src/etc/testcases/core/directoryscanner.xml"); - getProject().executeTarget("setup"); - } - - public void tearDown() { - getProject().executeTarget("cleanup"); - } - - public void test1() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha"}); - ds.scan(); - compareFiles(ds, new String[] {} ,new String[] {"alpha"}); - } - - public void test2() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void test3() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"", "alpha", "alpha/beta", - "alpha/beta/gamma"}); - } - - public void testFullPathMatchesCaseSensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); - ds.scan(); - compareFiles(ds, new String[] {}, new String[] {}); - } - - public void testFullPathMatchesCaseInsensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setCaseSensitive(false); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); - } - - public void test2ButCaseInsensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"ALPHA/"}); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testAllowSymlinks() { - if (!supportsSymlinks) { - return; - } - - getProject().executeTarget("symlink-setup"); - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha/beta/gamma"}); - } - - public void testProhibitSymlinks() { - if (!supportsSymlinks) { - return; - } - - getProject().executeTarget("symlink-setup"); - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/"}); - ds.setFollowSymlinks(false); - ds.scan(); - compareFiles(ds, new String[] {}, new String[] {}); - } - - // father and child pattern test - public void testOrderOfIncludePatternsIrrelevant() { - String [] expectedFiles = {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}; - String [] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" }; - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/be?a/**", "alpha/beta/gamma/"}); - ds.scan(); - compareFiles(ds, expectedFiles, expectedDirectories); - // redo the test, but the 2 include patterns are inverted - ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/", "alpha/be?a/**"}); - ds.scan(); - compareFiles(ds, expectedFiles, expectedDirectories); - } - - public void testPatternsDifferInCaseScanningSensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testPatternsDifferInCaseScanningInsensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/"}); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testFullpathDiffersInCaseScanningSensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] { - "alpha/beta/gamma/gamma.xml", - "alpha/beta/gamma/GAMMA.XML" - }); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); - } - - public void testFullpathDiffersInCaseScanningInsensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] { - "alpha/beta/gamma/gamma.xml", - "alpha/beta/gamma/GAMMA.XML" - }); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); - } - - public void testParentDiffersInCaseScanningSensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testParentDiffersInCaseScanningInsensitive() { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"}); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - /** - * Test case for setFollowLinks() and associated functionality. - * Only supports test on Linux at the moment because Java has - * no real notion of symlinks built in, so an os-specfic call - * to Runtime.exec() must be made to create a link to test against. - */ - public void testSetFollowLinks() throws IOException { - if (supportsSymlinks) { - File linkFile = new File(System.getProperty("root"), "src/main/org/apache/tools/ThisIsALink"); - System.err.println("link exists pre-test? " + linkFile.exists()); - - try { - // add conditions and more commands as soon as the need arises - String[] command = new String[] { - "ln", "-s", "ant", linkFile.getAbsolutePath() - }; - try { - Runtime.getRuntime().exec(command); - // give ourselves some time for the system call - // to execute... tweak if you have a really over - // loaded system. - Thread.sleep(1000); - } catch (IOException ioe) { - fail("IOException making link "+ioe); - } catch (InterruptedException ie) { - } - - File dir = new File(System.getProperty("root"), "src/main/org/apache/tools"); - System.err.println("link exists after exec? " + linkFile.exists()); - System.err.println("Ant knows it is a link? " + FileUtils.getFileUtils().isSymbolicLink(dir, "ThisIsALink")); - - DirectoryScanner ds = new DirectoryScanner(); - - // followLinks should be true by default, but if this ever - // changes we will need this line. - ds.setFollowSymlinks(true); - - ds.setBasedir(dir); - ds.setExcludes(new String[] {"ant/**"}); - ds.scan(); - - boolean haveZipPackage = false; - boolean haveTaskdefsPackage = false; - - String[] included = ds.getIncludedDirectories(); - for (int i=0; i 0); - } - - private void compareFiles(DirectoryScanner ds, String[] expectedFiles, - String[] expectedDirectories) { - String includedFiles[] = ds.getIncludedFiles(); - String includedDirectories[] = ds.getIncludedDirectories(); - assertEquals("file present: ", expectedFiles.length, - includedFiles.length); - assertEquals("directories present: ", expectedDirectories.length, - includedDirectories.length); - - TreeSet files = new TreeSet(); - for (int counter=0; counter < includedFiles.length; counter++) { - files.add(includedFiles[counter].replace(File.separatorChar, '/')); - } - TreeSet directories = new TreeSet(); - for (int counter=0; counter < includedDirectories.length; counter++) { - directories.add(includedDirectories[counter] - .replace(File.separatorChar, '/')); - } - - String currentfile; - Iterator i = files.iterator(); - int counter = 0; - while (i.hasNext()) { - currentfile = (String) i.next(); - assertEquals(expectedFiles[counter], currentfile); - counter++; - } - String currentdirectory; - Iterator dirit = directories.iterator(); - counter = 0; - while (dirit.hasNext()) { - currentdirectory = (String) dirit.next(); - assertEquals(expectedDirectories[counter], currentdirectory); - counter++; - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/DispatchTaskTest.java b/src/testcases/org/apache/tools/ant/DispatchTaskTest.java deleted file mode 100644 index 2184a97dc..000000000 --- a/src/testcases/org/apache/tools/ant/DispatchTaskTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.BuildFileTest; - -public class DispatchTaskTest extends BuildFileTest { - - public DispatchTaskTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/core/dispatch/dispatch.xml"); - } - - public void testDisp() { - expectBuildException("disp", "list"); - } -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskAbstract.java b/src/testcases/org/apache/tools/ant/DummyTaskAbstract.java deleted file mode 100644 index 18fe09d29..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskAbstract.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.Task; - -public abstract class DummyTaskAbstract extends Task { - - public DummyTaskAbstract() { - } - - public void execute() { - } - - public abstract void abstractDummy(); -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskInterface.java b/src/testcases/org/apache/tools/ant/DummyTaskInterface.java deleted file mode 100644 index 8ae5f5b33..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskInterface.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -public interface DummyTaskInterface { - - void execute(); - -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskOk.java b/src/testcases/org/apache/tools/ant/DummyTaskOk.java deleted file mode 100644 index ff8fdab3a..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskOk.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.Task; - -public class DummyTaskOk extends Task { - - public DummyTaskOk() { - } - - public void execute() { - } - -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskOkNonTask.java b/src/testcases/org/apache/tools/ant/DummyTaskOkNonTask.java deleted file mode 100644 index 234abd613..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskOkNonTask.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -public class DummyTaskOkNonTask { - - public DummyTaskOkNonTask() { - } - - public void execute() { - } - -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskWithNonPublicExecute.java b/src/testcases/org/apache/tools/ant/DummyTaskWithNonPublicExecute.java deleted file mode 100644 index 766283d68..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskWithNonPublicExecute.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -public class DummyTaskWithNonPublicExecute { - - public DummyTaskWithNonPublicExecute() { - } - - void execute() { - } - -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskWithNonVoidExecute.java b/src/testcases/org/apache/tools/ant/DummyTaskWithNonVoidExecute.java deleted file mode 100644 index 876b9b701..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskWithNonVoidExecute.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -public class DummyTaskWithNonVoidExecute { - - public DummyTaskWithNonVoidExecute() { - } - - public int execute() { - return 0; - } - -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskWithoutDefaultConstructor.java b/src/testcases/org/apache/tools/ant/DummyTaskWithoutDefaultConstructor.java deleted file mode 100644 index 40661f5e1..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskWithoutDefaultConstructor.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.Task; - -public class DummyTaskWithoutDefaultConstructor extends Task { - - public DummyTaskWithoutDefaultConstructor(int dummy) { - } - - public void execute() { - } - -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskWithoutExecute.java b/src/testcases/org/apache/tools/ant/DummyTaskWithoutExecute.java deleted file mode 100644 index 6d5ea006b..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskWithoutExecute.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -public class DummyTaskWithoutExecute { - - public DummyTaskWithoutExecute() { - } - - public void execute(String dummy) { - } - -} diff --git a/src/testcases/org/apache/tools/ant/DummyTaskWithoutPublicConstructor.java b/src/testcases/org/apache/tools/ant/DummyTaskWithoutPublicConstructor.java deleted file mode 100644 index 0ec4ff8e0..000000000 --- a/src/testcases/org/apache/tools/ant/DummyTaskWithoutPublicConstructor.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.Task; - -public class DummyTaskWithoutPublicConstructor extends Task { - - DummyTaskWithoutPublicConstructor() { - } - - public void execute() { - } - -} diff --git a/src/testcases/org/apache/tools/ant/ExecutorTest.java b/src/testcases/org/apache/tools/ant/ExecutorTest.java deleted file mode 100755 index 39313bbf4..000000000 --- a/src/testcases/org/apache/tools/ant/ExecutorTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import java.util.Vector; - - -/** - * Executor tests - */ -public class ExecutorTest extends BuildFileTest implements BuildListener { - private static final String SINGLE_CHECK - = "org.apache.tools.ant.helper.SingleCheckExecutor"; - private static final Vector targetNames; - static { - targetNames = new Vector(); - targetNames.add("a"); - targetNames.add("b"); - } - - private int targetCount; - - /* BuildListener stuff */ - public void targetStarted(BuildEvent event) { - targetCount++; - } - public void buildStarted(BuildEvent event) {} - public void buildFinished(BuildEvent event) {} - public void targetFinished(BuildEvent event) {} - public void taskStarted(BuildEvent event) {} - public void taskFinished(BuildEvent event) {} - public void messageLogged(BuildEvent event) {} - - public ExecutorTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/core/executor.xml"); - targetCount = 0; - getProject().addBuildListener(this); - } - - private Project getProject(String e) { - return getProject(e, false); - } - - private Project getProject(String e, boolean f) { - return getProject(e, f, false); - } - - private Project getProject(String e, boolean f, boolean k) { - Project p = getProject(); - p.setNewProperty("ant.executor.class", e); - p.setKeepGoingMode(k); - if (f) { - p.setNewProperty("failfoo", "foo"); - } - return p; - } - - public void testDefaultExecutor() { - getProject().executeTargets(targetNames); - assertEquals(targetCount, 4); - } - - public void testSingleCheckExecutor() { - getProject(SINGLE_CHECK).executeTargets(targetNames); - assertEquals(targetCount, 3); - } - - public void testDefaultFailure() { - try { - getProject(null, true).executeTargets(targetNames); - fail("should fail"); - } catch (BuildException e) { - assertTrue(e.getMessage().equals("failfoo")); - assertEquals(targetCount, 1); - } - } - - public void testSingleCheckFailure() { - try { - getProject(SINGLE_CHECK, true).executeTargets(targetNames); - fail("should fail"); - } catch (BuildException e) { - assertTrue(e.getMessage().equals("failfoo")); - assertEquals(targetCount, 1); - } - } - - public void testKeepGoingDefault() { - try { - getProject(null, true, true).executeTargets(targetNames); - fail("should fail"); - } catch (BuildException e) { - assertTrue(e.getMessage().equals("failfoo")); - assertEquals(targetCount, 2); - } - } - - public void testKeepGoingSingleCheck() { - try { - getProject(SINGLE_CHECK, true, true).executeTargets(targetNames); - fail("should fail"); - } catch (BuildException e) { - assertTrue(e.getMessage().equals("failfoo")); - assertEquals(targetCount, 1); - } - } - -} - diff --git a/src/testcases/org/apache/tools/ant/ExtendedTaskdefTest.java b/src/testcases/org/apache/tools/ant/ExtendedTaskdefTest.java deleted file mode 100644 index 08a8029d9..000000000 --- a/src/testcases/org/apache/tools/ant/ExtendedTaskdefTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant; - -/** - * created 16-Mar-2006 12:25:12 - */ - -public class ExtendedTaskdefTest extends BuildFileTest { - - /** - * Constructor for the BuildFileTest object. - * - * @param name string to pass up to TestCase constructor - */ - public ExtendedTaskdefTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/core/extended-taskdef.xml"); - } - - /** - * Automatically calls the target called "tearDown" - * from the build file tested if it exits. - *

- * This allows to use Ant tasks directly in the build file - * to clean up after each test. Note that no "setUp" target - * is automatically called, since it's trivial to have a - * test target depend on it. - */ - protected void tearDown() throws Exception { - super.tearDown(); - executeTarget("teardown"); - } - - public void testRun() throws Exception { - expectBuildExceptionContaining("testRun", - "exception thrown by the subclass", - "executing the Foo task"); - } - - public void testRun2() throws Exception { - expectBuildExceptionContaining("testRun2", - "exception thrown by the subclass", - "executing the Foo task"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/ImmutableTest.java b/src/testcases/org/apache/tools/ant/ImmutableTest.java deleted file mode 100644 index fef59cd7f..000000000 --- a/src/testcases/org/apache/tools/ant/ImmutableTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class ImmutableTest extends BuildFileTest { - - public ImmutableTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/core/immutable.xml"); - } - - // override allowed on - public void test1() { - executeTarget("test1"); - assertEquals("override", project.getProperty("test")); - } - - // ensure 's new prefix attribute is working - public void test2() { - executeTarget("test2"); - assertNotNull(project.getProperty("DSTAMP")); - assertNotNull(project.getProperty("start.DSTAMP")); - } - - // ensure follows the immutability rule - public void test3() { - executeTarget("test3"); - assertEquals("original", project.getProperty("DSTAMP")); - } - - // ensure follows the immutability rule - public void test4() { - executeTarget("test4"); - assertEquals("original", project.getProperty("test")); - } - // ensure follows the immutability rule - public void test5() { - executeTarget("test5"); - assertEquals("original", project.getProperty("test")); - } - - // ensure follows the immutability rule - public void test6() { - executeTarget("test6"); - assertEquals("original", project.getProperty("test1")); - assertEquals("original", project.getProperty("test2")); - } - - // ensure follows the immutability rule - public void test7() { - executeTarget("test7"); - assertEquals("original", project.getProperty("test")); - } -} - diff --git a/src/testcases/org/apache/tools/ant/IncludeTest.java b/src/testcases/org/apache/tools/ant/IncludeTest.java deleted file mode 100644 index 56cb5d56e..000000000 --- a/src/testcases/org/apache/tools/ant/IncludeTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import junit.framework.AssertionFailedError; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Test the build file inclusion using XML entities. - * - */ -public class IncludeTest extends BuildFileTest { - - public IncludeTest(String name) { - super(name); - } - - public void test1() { - configureProject("src/etc/testcases/core/include/basic/include.xml"); - expectLog("test1", "from included entity"); - } - - public void test2() { - configureProject("src/etc/testcases/core/include/frag#ment/include.xml"); - expectLog("test1", "from included entity"); - } - - public void test3() { - configureProject("src/etc/testcases/core/include/frag#ment/simple.xml"); - expectLog("test1", "from simple buildfile"); - } - - public void test4() { - configureProject("src/etc/testcases/core/include/basic/relative.xml"); - expectLog("test1", "from included entity"); - } - - public void test5() { - configureProject("src/etc/testcases/core/include/frag#ment/relative.xml"); - expectLog("test1", "from included entity"); - } - - public void testParseErrorInIncluding() { - try { - configureProject("src/etc/testcases/core/include/including_file_parse_error/build.xml"); - fail("should have caused a parser exception"); - } catch (BuildException e) { - assertTrue(e.getLocation().toString() - + " should refer to build.xml", - e.getLocation().toString().indexOf("build.xml:") > -1); - } - } - - public void testTaskErrorInIncluding() { - configureProject("src/etc/testcases/core/include/including_file_task_error/build.xml"); - try { - executeTarget("test"); - fail("should have cause a build failure"); - } catch (BuildException e) { - assertTrue(e.getMessage() - + " should start with \'Warning: Could not find", - e.getMessage().startsWith("Warning: Could not find file ")); - assertTrue(e.getLocation().toString() - + " should end with build.xml:14: ", - e.getLocation().toString().endsWith("build.xml:14: ")); - } - } - - public void testParseErrorInIncluded() { - try { - configureProject("src/etc/testcases/core/include/included_file_parse_error/build.xml"); - fail("should have caused a parser exception"); - } catch (BuildException e) { - assertTrue(e.getLocation().toString() - + " should refer to included_file.xml", - e.getLocation().toString() - .indexOf("included_file.xml:") > -1); - } - } - - public void testTaskErrorInIncluded() { - configureProject("src/etc/testcases/core/include/included_file_task_error/build.xml"); - try { - executeTarget("test"); - fail("should have cause a build failure"); - } catch (BuildException e) { - assertTrue(e.getMessage() - + " should start with \'Warning: Could not find", - e.getMessage().startsWith("Warning: Could not find file ")); - assertTrue(e.getLocation().toString() - + " should end with included_file.xml:2: ", - e.getLocation().toString().endsWith("included_file.xml:2: ")); - } - } - - public void testWithSpaceInclude() { - configureProject("src/etc/testcases/core/include/with space/include.xml"); - try { - expectLog("test1", "from included entity in 'with space'"); - } catch (Throwable t) { - throw new AssertionFailedError( - t.toString() + "; log=\n" + getFullLog()); - } - } - - public void testWithSpaceSimple() { - configureProject("src/etc/testcases/core/include/with space/simple.xml"); - expectLog("test1", "from simple buildfile in 'with space'"); - } - - public void testWithSpaceRelative() { - configureProject("src/etc/testcases/core/include/with space/relative.xml"); - expectLog("test1", "from included entity in 'with space'"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java b/src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java deleted file mode 100644 index 298477680..000000000 --- a/src/testcases/org/apache/tools/ant/IntrospectionHelperTest.java +++ /dev/null @@ -1,683 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import junit.framework.TestCase; -import junit.framework.AssertionFailedError; -import java.io.File; -import java.lang.reflect.Method; -import java.lang.reflect.InvocationTargetException; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import org.apache.tools.ant.taskdefs.condition.Os; - -/** - * JUnit 3 testcases for org.apache.tools.ant.IntrospectionHelper. - * - */ - -public class IntrospectionHelperTest extends TestCase { - - private Project p; - private IntrospectionHelper ih; - private static final String projectBasedir = File.separator; - - public IntrospectionHelperTest(String name) { - super(name); - } - - public void setUp() { - p = new Project(); - p.setBasedir(projectBasedir); - ih = IntrospectionHelper.getHelper(getClass()); - } - - public void testIsDynamic() { - assertTrue("Not dynamic", false == ih.isDynamic()); - } - - public void testIsContainer() { - assertTrue("Not a container", false == ih.isContainer()); - } - - public void testAddText() throws BuildException { - ih.addText(p, this, "test"); - try { - ih.addText(p, this, "test2"); - fail("test2 shouldn\'t be equal to test"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - - ih = IntrospectionHelper.getHelper(String.class); - try { - ih.addText(p, "", "test"); - fail("String doesn\'t support addText"); - } catch (BuildException be) { - } - } - - public void testGetAddTextMethod() { - Method m = ih.getAddTextMethod(); - assertMethod(m, "addText", String.class, "test", "bing!"); - - ih = IntrospectionHelper.getHelper(String.class); - try { - m = ih.getAddTextMethod(); - } catch (BuildException e) {} - } - - public void testSupportsCharacters() { - assertTrue("IntrospectionHelperTest supports addText", - ih.supportsCharacters()); - - ih = IntrospectionHelper.getHelper(String.class); - assertTrue("String doesn\'t support addText", !ih.supportsCharacters()); - } - - public void addText(String text) { - assertEquals("test", text); - } - - public void testElementCreators() throws BuildException { - try { - ih.getElementType("one"); - fail("don't have element type one"); - } catch (BuildException be) { - } - try { - ih.getElementType("two"); - fail("createTwo takes arguments"); - } catch (BuildException be) { - } - try { - ih.getElementType("three"); - fail("createThree returns void"); - } catch (BuildException be) { - } - try { - ih.getElementType("four"); - fail("createFour returns array"); - } catch (BuildException be) { - } - try { - ih.getElementType("five"); - fail("createFive returns primitive type"); - } catch (BuildException be) { - } - assertEquals(String.class, ih.getElementType("six")); - assertEquals("test", ih.createElement(p, this, "six")); - - try { - ih.getElementType("seven"); - fail("addSeven takes two arguments"); - } catch (BuildException be) { - } - try { - ih.getElementType("eight"); - fail("addEight takes no arguments"); - } catch (BuildException be) { - } - try { - ih.getElementType("nine"); - fail("nine return non void"); - } catch (BuildException be) { - } - try { - ih.getElementType("ten"); - fail("addTen takes array argument"); - } catch (BuildException be) { - } - try { - ih.getElementType("eleven"); - fail("addEleven takes primitive argument"); - } catch (BuildException be) { - } - try { - ih.getElementType("twelve"); - fail("no primitive constructor for java.lang.Class"); - } catch (BuildException be) { - } - assertEquals(StringBuffer.class, ih.getElementType("thirteen")); - assertEquals("test", ih.createElement(p, this, "thirteen").toString()); - - try { - ih.createElement(p, this, "fourteen"); - fail("fourteen throws NullPointerException"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof NullPointerException); - } - - try { - ih.createElement(p, this, "fourteen"); - fail("fifteen throws NullPointerException"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof NullPointerException); - } - } - - private Map getExpectedNestedElements() { - Map elemMap = new Hashtable(); - elemMap.put("six", String.class); - elemMap.put("thirteen", StringBuffer.class); - elemMap.put("fourteen", StringBuffer.class); - elemMap.put("fifteen", StringBuffer.class); - return elemMap; - } - - public void testGetNestedElements() { - Map elemMap = getExpectedNestedElements(); - Enumeration e = ih.getNestedElements(); - while (e.hasMoreElements()) { - String name = (String) e.nextElement(); - Class expect = (Class) elemMap.get(name); - assertNotNull("Support for "+name+" in IntrospectioNHelperTest?", - expect); - assertEquals("Return type of "+name, expect, ih.getElementType(name)); - elemMap.remove(name); - } - assertTrue("Found all", elemMap.isEmpty()); - } - - public void testGetNestedElementMap() { - Map elemMap = getExpectedNestedElements(); - Map actualMap = ih.getNestedElementMap(); - for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) { - Map.Entry entry = (Map.Entry) i.next(); - String elemName = (String) entry.getKey(); - Class elemClass = (Class) elemMap.get(elemName); - assertNotNull("Support for " + elemName + - " in IntrospectionHelperTest?", elemClass); - assertEquals("Type of " + elemName, elemClass, entry.getValue()); - elemMap.remove(elemName); - } - assertTrue("Found all", elemMap.isEmpty()); - - // Check it's a read-only map. - try { - actualMap.clear(); - } catch (UnsupportedOperationException e) {} - } - - public void testGetElementMethod() { - assertElemMethod("six", "createSix", String.class, null); - assertElemMethod("thirteen", "addThirteen", null, StringBuffer.class); - assertElemMethod("fourteen", "addFourteen", null, StringBuffer.class); - assertElemMethod("fifteen", "createFifteen", StringBuffer.class, null); - } - - private void assertElemMethod(String elemName, String methodName, - Class returnType, Class methodArg) { - Method m = ih.getElementMethod(elemName); - assertEquals("Method name", methodName, m.getName()); - Class expectedReturnType = (returnType == null)? Void.TYPE: returnType; - assertEquals("Return type", expectedReturnType, m.getReturnType()); - Class[] args = m.getParameterTypes(); - if (methodArg != null) { - assertEquals("Arg Count", 1, args.length); - assertEquals("Arg Type", methodArg, args[0]); - } else { - assertEquals("Arg Count", 0, args.length); - } - } - - public Object createTwo(String s) { - return null; - } - - public void createThree() {} - - public Object[] createFour() { - return null; - } - - public int createFive() { - return 0; - } - - public String createSix() { - return "test"; - } - - public StringBuffer createFifteen() { - throw new NullPointerException(); - } - - public void addSeven(String s, String s2) {} - - public void addEight() {} - - public String addNine(String s) { - return null; - } - - public void addTen(String[] s) {} - - public void addEleven(int i) {} - - public void addTwelve(Class c) {} - - public void addThirteen(StringBuffer sb) { - sb.append("test"); - } - - public void addFourteen(StringBuffer s) { - throw new NullPointerException(); - } - - public void testAttributeSetters() throws BuildException { - try { - ih.setAttribute(p, this, "one", "test"); - fail("setOne doesn't exist"); - } catch (BuildException be) { - } - try { - ih.setAttribute(p, this, "two", "test"); - fail("setTwo returns non void"); - } catch (BuildException be) { - } - try { - ih.setAttribute(p, this, "three", "test"); - fail("setThree takes no args"); - } catch (BuildException be) { - } - try { - ih.setAttribute(p, this, "four", "test"); - fail("setFour takes two args"); - } catch (BuildException be) { - } - try { - ih.setAttribute(p, this, "five", "test"); - fail("setFive takes array arg"); - } catch (BuildException be) { - } - try { - ih.setAttribute(p, this, "six", "test"); - fail("Project doesn't have a String constructor"); - } catch (BuildException be) { - } - ih.setAttribute(p, this, "seven", "2"); - try { - ih.setAttribute(p, this, "seven", "3"); - fail("2 shouldn't be equals to three"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "eight", "2"); - try { - ih.setAttribute(p, this, "eight", "3"); - fail("2 shouldn't be equals to three - as int"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "nine", "2"); - try { - ih.setAttribute(p, this, "nine", "3"); - fail("2 shouldn't be equals to three - as Integer"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "ten", "2"); - try { - ih.setAttribute(p, this, "ten", "3"); - fail(projectBasedir+"2 shouldn't be equals to "+projectBasedir+"3"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "eleven", "2"); - try { - ih.setAttribute(p, this, "eleven", "on"); - fail("on shouldn't be false"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "twelve", "2"); - try { - ih.setAttribute(p, this, "twelve", "on"); - fail("on shouldn't be false"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project"); - try { - ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.ProjectHelper"); - fail("org.apache.tools.ant.Project shouldn't be equal to org.apache.tools.ant.ProjectHelper"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - try { - ih.setAttribute(p, this, "thirteen", "org.apache.tools.ant.Project2"); - fail("org.apache.tools.ant.Project2 doesn't exist"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof ClassNotFoundException); - } - ih.setAttribute(p, this, "fourteen", "2"); - try { - ih.setAttribute(p, this, "fourteen", "on"); - fail("2 shouldn't be equals to three - as StringBuffer"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "fifteen", "abcd"); - try { - ih.setAttribute(p, this, "fifteen", "on"); - fail("o shouldn't be equal to a"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "sixteen", "abcd"); - try { - ih.setAttribute(p, this, "sixteen", "on"); - fail("o shouldn't be equal to a"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "seventeen", "17"); - try { - ih.setAttribute(p, this, "seventeen", "3"); - fail("17 shouldn't be equals to three"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "eightteen", "18"); - try { - ih.setAttribute(p, this, "eightteen", "3"); - fail("18 shouldn't be equals to three"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - ih.setAttribute(p, this, "nineteen", "19"); - try { - ih.setAttribute(p, this, "nineteen", "3"); - fail("19 shouldn't be equals to three"); - } catch (BuildException be) { - assertTrue(be.getException() instanceof AssertionFailedError); - } - } - - private Map getExpectedAttributes() { - Map attrMap = new Hashtable(); - attrMap.put("seven", String.class); - attrMap.put("eight", Integer.TYPE); - attrMap.put("nine", Integer.class); - attrMap.put("ten", File.class); - attrMap.put("eleven", Boolean.TYPE); - attrMap.put("twelve", Boolean.class); - attrMap.put("thirteen", Class.class); - attrMap.put("fourteen", StringBuffer.class); - attrMap.put("fifteen", Character.TYPE); - attrMap.put("sixteen", Character.class); - attrMap.put("seventeen", Byte.TYPE); - attrMap.put("eightteen", Short.TYPE); - attrMap.put("nineteen", Double.TYPE); - - /* - * JUnit 3.7 adds a getName method to TestCase - so we now - * have a name attribute in IntrospectionHelperTest if we run - * under JUnit 3.7 but not in earlier versions. - * - * Simply add it here and remove it after the tests. - */ - attrMap.put("name", String.class); - - return attrMap; - } - - public void testGetAttributes() { - Map attrMap = getExpectedAttributes(); - Enumeration e = ih.getAttributes(); - while (e.hasMoreElements()) { - String name = (String) e.nextElement(); - Class expect = (Class) attrMap.get(name); - assertNotNull("Support for "+name+" in IntrospectionHelperTest?", - expect); - assertEquals("Type of "+name, expect, ih.getAttributeType(name)); - attrMap.remove(name); - } - attrMap.remove("name"); - assertTrue("Found all", attrMap.isEmpty()); - } - - public void testGetAttributeMap() { - Map attrMap = getExpectedAttributes(); - Map actualMap = ih.getAttributeMap(); - for (Iterator i = actualMap.entrySet().iterator(); i.hasNext();) { - Map.Entry entry = (Map.Entry) i.next(); - String attrName = (String) entry.getKey(); - Class attrClass = (Class) attrMap.get(attrName); - assertNotNull("Support for " + attrName + - " in IntrospectionHelperTest?", attrClass); - assertEquals("Type of " + attrName, attrClass, entry.getValue()); - attrMap.remove(attrName); - } - attrMap.remove("name"); - assertTrue("Found all", attrMap.isEmpty()); - - // Check it's a read-only map. - try { - actualMap.clear(); - } catch (UnsupportedOperationException e) {} - } - - public void testGetAttributeMethod() { - assertAttrMethod("seven", "setSeven", String.class, - "2", "3"); - assertAttrMethod("eight", "setEight", Integer.TYPE, - new Integer(2), new Integer(3)); - assertAttrMethod("nine", "setNine", Integer.class, - new Integer(2), new Integer(3)); - assertAttrMethod("ten", "setTen", File.class, - new File(projectBasedir + 2), new File("toto")); - assertAttrMethod("eleven", "setEleven", Boolean.TYPE, - Boolean.FALSE, Boolean.TRUE); - assertAttrMethod("twelve", "setTwelve", Boolean.class, - Boolean.FALSE, Boolean.TRUE); - assertAttrMethod("thirteen", "setThirteen", Class.class, - Project.class, Map.class); - assertAttrMethod("fourteen", "setFourteen", StringBuffer.class, - new StringBuffer("2"), new StringBuffer("3")); - assertAttrMethod("fifteen", "setFifteen", Character.TYPE, - new Character('a'), new Character('b')); - assertAttrMethod("sixteen", "setSixteen", Character.class, - new Character('a'), new Character('b')); - assertAttrMethod("seventeen", "setSeventeen", Byte.TYPE, - new Byte((byte)17), new Byte((byte)10)); - assertAttrMethod("eightteen", "setEightteen", Short.TYPE, - new Short((short)18), new Short((short)10)); - assertAttrMethod("nineteen", "setNineteen", Double.TYPE, - new Double(19), new Double((short)10)); - - try { - assertAttrMethod("onehundred", null, null, null, null); - fail("Should have raised a BuildException!"); - } catch (BuildException e) {} - } - - private void assertAttrMethod(String attrName, String methodName, - Class methodArg, Object arg, Object badArg) { - Method m = ih.getAttributeMethod(attrName); - assertMethod(m, methodName, methodArg, arg, badArg); - } - - public int setTwo(String s) { - return 0; - } - - public void setThree() {} - - public void setFour(String s1, String s2) {} - - public void setFive(String[] s) {} - - public void setSix(Project p) {} - - public void setSeven(String s) { - assertEquals("2", s); - } - - public void setEight(int i) { - assertEquals(2, i); - } - - public void setNine(Integer i) { - assertEquals(2, i.intValue()); - } - - public void setTen(File f) { - String path = f.getAbsolutePath(); - if (Os.isFamily("unix") || Os.isFamily("openvms")) { - assertEquals(projectBasedir+"2", path); - } else if (Os.isFamily("netware")) { - assertEquals(projectBasedir+"2", path.toLowerCase(Locale.US)); - } else { - assertEquals(":"+projectBasedir+"2", - path.toLowerCase(Locale.US).substring(1)); - } - } - - public void setEleven(boolean b) { - assertTrue(!b); - } - - public void setTwelve(Boolean b) { - assertTrue(!b.booleanValue()); - } - - public void setThirteen(Class c) { - assertEquals(Project.class, c); - } - - public void setFourteen(StringBuffer sb) { - assertEquals("2", sb.toString()); - } - - public void setFifteen(char c) { - assertEquals(c, 'a'); - } - - public void setSixteen(Character c) { - assertEquals(c.charValue(), 'a'); - } - - public void setSeventeen(byte b) { - assertEquals(17, b); - } - - public void setEightteen(short s) { - assertEquals(18, s); - } - - public void setNineteen(double d) { - assertEquals(19, d, 1e-6); - } - - public void testGetExtensionPoints() { - List extensions = ih.getExtensionPoints(); - final int adders = 2; - assertEquals("extension count", adders, extensions.size()); - - // this original test assumed something about the order of - // add(Number) and addConfigured(Map) returned by reflection. - // Unfortunately the assumption doesn't hold for all VMs - // (failed on MacOS X using JDK 1.4.2_05) and the possible - // combinatorics are too hard to check. We really only want - // to ensure that the more derived Hashtable can be found - // before Map. -// assertExtMethod(extensions.get(0), "add", Number.class, -// new Integer(2), new Integer(3)); - - // addConfigured(Hashtable) should come before addConfigured(Map) - assertExtMethod(extensions.get(adders - 2), - "addConfigured", Hashtable.class, - makeTable("key", "value"), makeTable("1", "2")); - - assertExtMethod(extensions.get(adders - 1), "addConfigured", Map.class, - new HashMap(), makeTable("1", "2")); - } - - private void assertExtMethod(Object mo, String methodName, Class methodArg, - Object arg, Object badArg) { - assertMethod((Method) mo, methodName, methodArg, arg, badArg); - } - - private void assertMethod(Method m, String methodName, Class methodArg, - Object arg, Object badArg) { - assertEquals("Method name", methodName, m.getName()); - assertEquals("Return type", Void.TYPE, m.getReturnType()); - Class[] args = m.getParameterTypes(); - assertEquals("Arg Count", 1, args.length); - assertEquals("Arg Type", methodArg, args[0]); - - try { - m.invoke(this, new Object[] { arg }); - } catch (IllegalAccessException e) { - throw new BuildException(e); - } catch (InvocationTargetException e) { - throw new BuildException(e); - } - - try { - m.invoke(this, new Object[] { badArg }); - fail("Should have raised an assertion exception"); - } catch (IllegalAccessException e) { - throw new BuildException(e); - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - assertTrue(t instanceof junit.framework.AssertionFailedError); - } - } - - public List add(List l) { - // INVALID extension point - return null; - } - - // see comments in testGetExtensionPoints -// public void add(Number n) { -// // Valid extension point -// assertEquals(2, n.intValue()); -// } - - public void add(List l, int i) { - // INVALID extension point - } - - public void addConfigured(Map m) { - // Valid extension point - assertTrue(m.size() == 0); - } - - public void addConfigured(Hashtable h) { - // Valid extension point, more derived than Map above, but *after* it! - assertEquals(makeTable("key", "value"), h); - } - - private Hashtable makeTable(Object key, Object value) { - Hashtable table = new Hashtable(); - table.put(key, value); - return table; - } - -} // IntrospectionHelperTest - diff --git a/src/testcases/org/apache/tools/ant/LoaderRefTest.java b/src/testcases/org/apache/tools/ant/LoaderRefTest.java deleted file mode 100644 index 946c59cdf..000000000 --- a/src/testcases/org/apache/tools/ant/LoaderRefTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class LoaderRefTest extends BuildFileTest { - - public LoaderRefTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/core/loaderref/loaderref.xml"); - } - - public void tearDown() { - executeTarget("clean"); - } - - // override allowed on - public void testBadRef() { - expectBuildExceptionContaining("testbadref", "Should fail due to ref " - + "not being a class loader", "does not reference a class loader"); - } -} - diff --git a/src/testcases/org/apache/tools/ant/LocationTest.java b/src/testcases/org/apache/tools/ant/LocationTest.java deleted file mode 100644 index b8c9af03c..000000000 --- a/src/testcases/org/apache/tools/ant/LocationTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.taskdefs.ConditionTask; -import org.apache.tools.ant.taskdefs.Echo; -import org.apache.tools.ant.types.FileSet; - -public class LocationTest extends BuildFileTest { - - public void setUp() { - configureProject("src/etc/testcases/core/location.xml"); - } - - public void testPlainTask() { - executeTarget("testPlainTask"); - Echo e = (Echo) getProject().getReference("echo"); - assertFalse(e.getLocation() == Location.UNKNOWN_LOCATION); - assertFalse(e.getLocation().getLineNumber() == 0); - } - - public void testStandaloneType() { - executeTarget("testStandaloneType"); - Echo e = (Echo) getProject().getReference("echo2"); - FileSet f = (FileSet) getProject().getReference("fs"); - assertFalse(f.getLocation() == Location.UNKNOWN_LOCATION); - assertEquals(e.getLocation().getLineNumber() + 1, - f.getLocation().getLineNumber()); - } - - public void testConditionTask() { - executeTarget("testConditionTask"); - TaskAdapter ta = (TaskAdapter) getProject().getReference("cond"); - ConditionTask c = (ConditionTask) ta.getProxy(); - assertFalse(c.getLocation() == Location.UNKNOWN_LOCATION); - assertFalse(c.getLocation().getLineNumber() == 0); - } - - public void testMacrodefWrappedTask() { - executeTarget("testMacrodefWrappedTask"); - Echo e = (Echo) getProject().getReference("echo3"); - assertTrue(getLog().indexOf("Line: " - + (e.getLocation().getLineNumber() + 1)) - > -1); - } - - public void testPresetdefWrappedTask() { - executeTarget("testPresetdefWrappedTask"); - Echo e = (Echo) getProject().getReference("echo4"); - assertTrue(getLog().indexOf("Line: " - + (e.getLocation().getLineNumber() + 1)) - > -1); - } - - public static class EchoLocation extends Task { - public void execute() { - log("Line: " + getLocation().getLineNumber(), Project.MSG_INFO); - } - } -} - diff --git a/src/testcases/org/apache/tools/ant/MockBuildListener.java b/src/testcases/org/apache/tools/ant/MockBuildListener.java deleted file mode 100644 index f68a828c6..000000000 --- a/src/testcases/org/apache/tools/ant/MockBuildListener.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import java.util.Vector; - -import junit.framework.Assert; - -public class MockBuildListener extends Assert implements BuildListener { - - private final Vector buffer = new Vector(); - private final Project project; - - public MockBuildListener(final Project project) { - this.project = project; - } - - public void buildStarted(BuildEvent event) {} - public void buildFinished(BuildEvent event) {} - public void targetStarted(BuildEvent event) {} - public void targetFinished(BuildEvent event) {} - public void taskStarted(BuildEvent event) {} - public void taskFinished(BuildEvent event) {} - - public void messageLogged(final BuildEvent actual) { - if(actual.getPriority()==Project.MSG_DEBUG) - return; - assertTrue("unexpected messageLogged: "+actual.getMessage(), !buffer.isEmpty()); - assertEquals("unexpected project ", project, actual.getProject()); - - BuildEvent expected = (BuildEvent) buffer.elementAt(0); - buffer.removeElementAt(0); - assertEquals("unexpected messageLogged ", expected.getMessage(), actual.getMessage()); - assertEquals("unexpected priority ", expected.getPriority(), actual.getPriority()); - } - - public void assertEmpty() { - assertTrue("MockBuildListener is not empty", buffer.isEmpty()); - } - - public void addBuildEvent(final String message, final int priority) { - final BuildEvent be = new BuildEvent(project); - be.setMessage(message, priority); - buffer.addElement(be); - } - -} diff --git a/src/testcases/org/apache/tools/ant/PickOneTask.java b/src/testcases/org/apache/tools/ant/PickOneTask.java deleted file mode 100644 index 560194b0e..000000000 --- a/src/testcases/org/apache/tools/ant/PickOneTask.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.dispatch.DispatchTask; - -public class PickOneTask extends DispatchTask { - public void list() { - throw new BuildException("list"); - } - - public void show() { - throw new BuildException("show"); - } -} diff --git a/src/testcases/org/apache/tools/ant/ProjectTest.java b/src/testcases/org/apache/tools/ant/ProjectTest.java deleted file mode 100644 index 6774c4ca6..000000000 --- a/src/testcases/org/apache/tools/ant/ProjectTest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -import org.apache.tools.ant.input.DefaultInputHandler; -import org.apache.tools.ant.input.InputHandler; -import org.apache.tools.ant.input.PropertyFileInputHandler; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.types.*; - -import java.io.File; -import junit.framework.TestCase; - - -/** - * Very limited test class for Project. Waiting to be extended. - * - */ -public class ProjectTest extends TestCase { - - private Project p; - private String root; - private MockBuildListener mbl; - - public ProjectTest(String name) { - super(name); - } - - public void setUp() { - p = new Project(); - p.init(); - root = new File(File.separator).getAbsolutePath().toUpperCase(); - mbl = new MockBuildListener(p); - } - - public void testDataTypes() throws BuildException { - assertNull("dummy is not a known data type", - p.createDataType("dummy")); - Object o = p.createDataType("fileset"); - assertNotNull("fileset is a known type", o); - assertTrue("fileset creates FileSet", o instanceof FileSet); - assertTrue("PatternSet", - p.createDataType("patternset") instanceof PatternSet); - assertTrue("Path", p.createDataType("path") instanceof Path); - } - - /** - * This test has been a starting point for moving the code to FileUtils. - */ - public void testResolveFile() { - if (Os.isFamily("netware") || Os.isFamily("dos")) { - assertEqualsIgnoreDriveCase(localize(File.separator), - p.resolveFile("/", null).getPath()); - assertEqualsIgnoreDriveCase(localize(File.separator), - p.resolveFile("\\", null).getPath()); - /* - * throw in drive letters - */ - String driveSpec = "C:"; - assertEquals(driveSpec + "\\", - p.resolveFile(driveSpec + "/", null).getPath()); - assertEquals(driveSpec + "\\", - p.resolveFile(driveSpec + "\\", null).getPath()); - String driveSpecLower = "c:"; - assertEquals(driveSpec + "\\", - p.resolveFile(driveSpecLower + "/", null).getPath()); - assertEquals(driveSpec + "\\", - p.resolveFile(driveSpecLower + "\\", null).getPath()); - /* - * promised to eliminate consecutive slashes after drive letter. - */ - assertEquals(driveSpec + "\\", - p.resolveFile(driveSpec + "/////", null).getPath()); - assertEquals(driveSpec + "\\", - p.resolveFile(driveSpec + "\\\\\\\\\\\\", null).getPath()); - } else { - /* - * Start with simple absolute file names. - */ - assertEquals(File.separator, - p.resolveFile("/", null).getPath()); - assertEquals(File.separator, - p.resolveFile("\\", null).getPath()); - /* - * drive letters are not used, just to be considered as normal - * part of a name - */ - String driveSpec = "C:"; - String udir = System.getProperty("user.dir") + File.separatorChar; - assertEquals(udir + driveSpec, - p.resolveFile(driveSpec + "/", null).getPath()); - assertEquals(udir + driveSpec, - p.resolveFile(driveSpec + "\\", null).getPath()); - String driveSpecLower = "c:"; - assertEquals(udir + driveSpecLower, - p.resolveFile(driveSpecLower + "/", null).getPath()); - assertEquals(udir + driveSpecLower, - p.resolveFile(driveSpecLower + "\\", null).getPath()); - } - /* - * Now test some relative file name magic. - */ - assertEquals(localize("/1/2/3/4"), - p.resolveFile("4", new File(localize("/1/2/3"))).getPath()); - assertEquals(localize("/1/2/3/4"), - p.resolveFile("./4", new File(localize("/1/2/3"))).getPath()); - assertEquals(localize("/1/2/3/4"), - p.resolveFile(".\\4", new File(localize("/1/2/3"))).getPath()); - assertEquals(localize("/1/2/3/4"), - p.resolveFile("./.\\4", new File(localize("/1/2/3"))).getPath()); - assertEquals(localize("/1/2/3/4"), - p.resolveFile("../3/4", new File(localize("/1/2/3"))).getPath()); - assertEquals(localize("/1/2/3/4"), - p.resolveFile("..\\3\\4", new File(localize("/1/2/3"))).getPath()); - assertEquals(localize("/1/2/3/4"), - p.resolveFile("../../5/.././2/./3/6/../4", new File(localize("/1/2/3"))).getPath()); - assertEquals(localize("/1/2/3/4"), - p.resolveFile("..\\../5/..\\./2/./3/6\\../4", new File(localize("/1/2/3"))).getPath()); - - } - - /** - * adapt file separators to local conventions - */ - private String localize(String path) { - path = root + path.substring(1); - return path.replace('\\', File.separatorChar).replace('/', File.separatorChar); - } - - /** - * convenience method - * the drive letter is in lower case under cygwin - * calling this method allows tests where FileUtils.normalize - * is called via resolveFile to pass under cygwin - */ - private void assertEqualsIgnoreDriveCase(String s1, String s2) { - if ((Os.isFamily("dos") || Os.isFamily("netware")) - && s1.length() >= 1 && s2.length() >= 1) { - StringBuffer sb1 = new StringBuffer(s1); - StringBuffer sb2 = new StringBuffer(s2); - sb1.setCharAt(0, Character.toUpperCase(s1.charAt(0))); - sb2.setCharAt(0, Character.toUpperCase(s2.charAt(0))); - assertEquals(sb1.toString(), sb2.toString()); - } else { - assertEquals(s1, s2); - } - } - - private void assertTaskDefFails(final Class taskClass, - final String message) { - final String dummyName = "testTaskDefinitionDummy"; - try { - mbl.addBuildEvent(message, Project.MSG_ERR); - p.addTaskDefinition(dummyName, taskClass); - fail("expected BuildException(\""+message+"\", Project.MSG_ERR) when adding task " + taskClass); - } - catch(BuildException e) { - assertEquals(message, e.getMessage()); - mbl.assertEmpty(); - assertTrue(!p.getTaskDefinitions().containsKey(dummyName)); - } - } - - public void testAddTaskDefinition() { - p.addBuildListener(mbl); - - p.addTaskDefinition("Ok", DummyTaskOk.class); - assertEquals(DummyTaskOk.class, p.getTaskDefinitions().get("Ok")); - p.addTaskDefinition("OkNonTask", DummyTaskOkNonTask.class); - assertEquals(DummyTaskOkNonTask.class, p.getTaskDefinitions().get("OkNonTask")); - mbl.assertEmpty(); - - assertTaskDefFails(DummyTaskPrivate.class, DummyTaskPrivate.class + " is not public"); - - assertTaskDefFails(DummyTaskProtected.class, - DummyTaskProtected.class + " is not public"); - - assertTaskDefFails(DummyTaskPackage.class, DummyTaskPackage.class + " is not public"); - - assertTaskDefFails(DummyTaskAbstract.class, DummyTaskAbstract.class + " is abstract"); - assertTaskDefFails(DummyTaskInterface.class, DummyTaskInterface.class + " is abstract"); - - assertTaskDefFails(DummyTaskWithoutDefaultConstructor.class, "No public no-arg constructor in " + DummyTaskWithoutDefaultConstructor.class); - assertTaskDefFails(DummyTaskWithoutPublicConstructor.class, "No public no-arg constructor in " + DummyTaskWithoutPublicConstructor.class); - - assertTaskDefFails(DummyTaskWithoutExecute.class, "No public execute() in " + DummyTaskWithoutExecute.class); - assertTaskDefFails(DummyTaskWithNonPublicExecute.class, "No public execute() in " + DummyTaskWithNonPublicExecute.class); - - mbl.addBuildEvent("return type of execute() should be void but was \"int\" in " + DummyTaskWithNonVoidExecute.class, Project.MSG_WARN); - p.addTaskDefinition("NonVoidExecute", DummyTaskWithNonVoidExecute.class); - mbl.assertEmpty(); - assertEquals(DummyTaskWithNonVoidExecute.class, p.getTaskDefinitions().get("NonVoidExecute")); - } - - public void testInputHandler() { - InputHandler ih = p.getInputHandler(); - assertNotNull(ih); - assertTrue(ih instanceof DefaultInputHandler); - InputHandler pfih = new PropertyFileInputHandler(); - p.setInputHandler(pfih); - assertSame(pfih, p.getInputHandler()); - } - - public void testTaskDefinitionContainsKey() { - assertTrue(p.getTaskDefinitions().containsKey("echo")); - } - - public void testTaskDefinitionContains() { - assertTrue(p.getTaskDefinitions().contains(org.apache.tools.ant.taskdefs.Echo.class)); - } - - public void testDuplicateTargets() { - // fail, because buildfile contains two targets with the same name - try { - BFT bft = new BFT("", "core/duplicate-target.xml"); - } catch (BuildException ex) { - assertEquals("specific message", - "Duplicate target 'twice'", - ex.getMessage()); - return; - } - fail("Should throw BuildException about duplicate target"); - } - - public void testDuplicateTargetsImport() { - // overriding target from imported buildfile is allowed - BFT bft = new BFT("", "core/duplicate-target2.xml"); - bft.expectLog("once", "once from buildfile"); - } - - - private class DummyTaskPrivate extends Task { - public DummyTaskPrivate() {} - public void execute() {} - } - - protected class DummyTaskProtected extends Task { - public DummyTaskProtected() {} - public void execute() {} - } - - private class BFT extends org.apache.tools.ant.BuildFileTest { - BFT(String name, String buildfile) { - super(name); - this.buildfile = buildfile; - setUp(); - } - - // avoid multiple configurations - boolean isConfigured = false; - - // the buildfile to use - String buildfile = ""; - - public void setUp() { - if (!isConfigured) { - configureProject("src/etc/testcases/"+buildfile); - isConfigured = true; - } - } - - public void tearDown() { } - - // call a target - public void doTarget(String target) { - if (!isConfigured) setUp(); - executeTarget(target); - } - - public org.apache.tools.ant.Project getProject() { - return super.getProject(); - } - }//class-BFT - -} - -class DummyTaskPackage extends Task { - public DummyTaskPackage() {} - public void execute() {} -} diff --git a/src/testcases/org/apache/tools/ant/PropertyExpansionTest.java b/src/testcases/org/apache/tools/ant/PropertyExpansionTest.java deleted file mode 100644 index 718d84340..000000000 --- a/src/testcases/org/apache/tools/ant/PropertyExpansionTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -package org.apache.tools.ant; - -/** - * class to look at how we expand properties - */ -public class PropertyExpansionTest extends BuildFileTest { - - - public PropertyExpansionTest(String name) { - super(name); - } - - /** - * we bind to an existing test file because we are too lazy to write our - * own, and we don't really care what it is - */ - public void setUp() { - configureProject("src/etc/testcases/core/immutable.xml"); - } - - /** - * run through the test cases of expansion - */ - public void testPropertyExpansion() { - assertExpandsTo("",""); - assertExpandsTo("$","$"); - assertExpandsTo("$$-","$-"); - assertExpandsTo("$$","$"); - project.setProperty("expanded","EXPANDED"); - assertExpandsTo("a${expanded}b","aEXPANDEDb"); - assertExpandsTo("${expanded}${expanded}","EXPANDEDEXPANDED"); - assertExpandsTo("$$$","$$"); - assertExpandsTo("$$$$-","$$-"); - assertExpandsTo("",""); - assertExpandsTo("Class$$subclass","Class$subclass"); - } - - /** - * new things we want - */ - public void testDollarPassthru() { - assertExpandsTo("$-","$-"); - assertExpandsTo("Class$subclass","Class$subclass"); - assertExpandsTo("$$$-","$$-"); - assertExpandsTo("$$$$$","$$$"); - assertExpandsTo("${unassigned.property}","${unassigned.property}"); - assertExpandsTo("a$b","a$b"); - assertExpandsTo("$}}","$}}"); - } - - - /** - * old things we dont want; not a test no more - */ - public void oldtestQuirkyLegacyBehavior() { - assertExpandsTo("Class$subclass","Classsubclass"); - assertExpandsTo("$$$-","$-"); - assertExpandsTo("a$b","ab"); - assertExpandsTo("$}}","}}"); - } - - /** - * little helper method to validate stuff - */ - private void assertExpandsTo(String source,String expected) { - String actual=project.replaceProperties(source); - assertEquals(source,expected,actual); - } - -//end class -} diff --git a/src/testcases/org/apache/tools/ant/TaskContainerTest.java b/src/testcases/org/apache/tools/ant/TaskContainerTest.java deleted file mode 100644 index e582f1388..000000000 --- a/src/testcases/org/apache/tools/ant/TaskContainerTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -public class TaskContainerTest extends BuildFileTest { - - public TaskContainerTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/core/taskcontainer.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testPropertyExpansion() { - executeTarget("testPropertyExpansion"); - assertTrue("attribute worked", - getLog().indexOf("As attribute: it worked") > -1); - assertTrue("nested text worked", - getLog().indexOf("As nested text: it worked") > -1); - } - - public void testTaskdef() { - executeTarget("testTaskdef"); - assertTrue("attribute worked", - getLog().indexOf("As attribute: it worked") > -1); - assertTrue("nested text worked", - getLog().indexOf("As nested text: it worked") > -1); - assertTrue("nested text worked", - getLog().indexOf("As nested task: it worked") > -1); - } - - public void testCaseInsensitive() { - executeTarget("testCaseInsensitive"); - assertTrue("works outside of container", - getLog().indexOf("hello ") > -1); - assertTrue("works inside of container", - getLog().indexOf("world") > -1); - } - -} diff --git a/src/testcases/org/apache/tools/ant/TopLevelTaskTest.java b/src/testcases/org/apache/tools/ant/TopLevelTaskTest.java deleted file mode 100644 index 1aceaa2e9..000000000 --- a/src/testcases/org/apache/tools/ant/TopLevelTaskTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant; - -// This test will fail with embed, or if top-level is moved out of -// dependency - as 'echo' happens as part of configureProject stage. - -/** - * Tests for builds with tasks at the top level - * - * @since Ant 1.6 - */ -public class TopLevelTaskTest extends BuildFileTest { - - public TopLevelTaskTest(String name) { - super(name); - } - - public void testNoTarget() { - configureProject("src/etc/testcases/core/topleveltasks/notarget.xml"); - expectLog("", "Called"); - } - - public void testCalledFromTopLevelAnt() { - configureProject("src/etc/testcases/core/topleveltasks/toplevelant.xml"); - expectLog("", "Called"); - } - - public void testCalledFromTargetLevelAnt() { - configureProject("src/etc/testcases/core/topleveltasks/targetlevelant.xml"); - expectLog("foo", "Called"); - } -} diff --git a/src/testcases/org/apache/tools/ant/filters/ConcatFilterTest.java b/src/testcases/org/apache/tools/ant/filters/ConcatFilterTest.java deleted file mode 100644 index 46060bb73..000000000 --- a/src/testcases/org/apache/tools/ant/filters/ConcatFilterTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.StringUtils; - -/** - * JUnit Testcases for ConcatReader - */ -public class ConcatFilterTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - private static final String lSep = StringUtils.LINE_SEP; - - private static final String FILE_PREPEND_WITH = - "this-should-be-the-first-line" + lSep - + "Line 1" + lSep - + "Line 2" + lSep - + "Line 3" + lSep - + "Line 4" + lSep - ; - - private static final String FILE_PREPEND = - "Line 1" + lSep - + "Line 2" + lSep - + "Line 3" + lSep - + "Line 4" + lSep - + "Line 5" + lSep - ; - - private static final String FILE_APPEND_WITH = - "Line 57" + lSep - + "Line 58" + lSep - + "Line 59" + lSep - + "Line 60" + lSep - + "this-should-be-the-last-line" + lSep - ; - - private static final String FILE_APPEND = - "Line 56" + lSep - + "Line 57" + lSep - + "Line 58" + lSep - + "Line 59" + lSep - + "Line 60" + lSep - ; - - - public ConcatFilterTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/concat.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testFilterReaderNoArgs() throws IOException { - executeTarget("testFilterReaderNoArgs"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"input/concatfilter.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(), "result/concat.FilterReaderNoArgs.test"); - assertTrue("testFilterReaderNoArgs: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testFilterReaderBefore() { - doTest("testFilterReaderPrepend", FILE_PREPEND_WITH, FILE_APPEND); - } - - public void testFilterReaderAfter() { - doTest("testFilterReaderAppend", FILE_PREPEND, FILE_APPEND_WITH); - } - - public void testFilterReaderBeforeAfter() { - doTest("testFilterReaderPrependAppend", FILE_PREPEND_WITH, FILE_APPEND_WITH); - } - - public void testConcatFilter() { - doTest("testConcatFilter", FILE_PREPEND, FILE_APPEND); - } - - public void testConcatFilterBefore() { - doTest("testConcatFilterPrepend", FILE_PREPEND_WITH, FILE_APPEND); - } - - public void testConcatFilterAfter() { - doTest("testConcatFilterAppend", FILE_PREPEND, FILE_APPEND_WITH); - } - - public void testConcatFilterBeforeAfter() { - doTest("testConcatFilterPrependAppend", FILE_PREPEND_WITH, FILE_APPEND_WITH); - } - - - /** - * Executes a target and checks the beginning and the ending of a file. - * The filename depends on the target name: target name testHelloWorld - * will search for a file result/concat.HelloWorld.test. - * @param target The target to invoke - * @param expectedStart The string which should be at the beginning of the file - * @param expectedEnd The string which should be at the end of the file - */ - protected void doTest(String target, String expectedStart, String expectedEnd) { - executeTarget(target); - String resultContent = read("result/concat." + target.substring(4) + ".test"); - assertTrue("First 5 lines differs.", resultContent.startsWith(expectedStart)); - assertTrue("Last 5 lines differs.", resultContent.endsWith(expectedEnd)); - } - - - /** - * Wrapper for FileUtils.readFully(). - * Additionally it resolves the filename according the the projects basedir - * and closes the used reader. - * @param filename The name of the file to read - * @return the content of the file or null if something goes wrong - */ - protected String read(String filename) { - String content = null; - try { - File file = FILE_UTILS.resolveFile(getProject().getBaseDir(), filename); - java.io.FileReader rdr = new java.io.FileReader(file); - content = FileUtils.readFully(rdr); - rdr.close(); - rdr = null; - } catch (Exception e) { - e.printStackTrace(); - } - return content; - } - -} diff --git a/src/testcases/org/apache/tools/ant/filters/DynamicFilterTest.java b/src/testcases/org/apache/tools/ant/filters/DynamicFilterTest.java deleted file mode 100644 index 6de81c648..000000000 --- a/src/testcases/org/apache/tools/ant/filters/DynamicFilterTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.Reader; -import java.io.FileReader; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class DynamicFilterTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public DynamicFilterTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/dynamicfilter.xml"); - executeTarget("init"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - public void testCustomFilter() throws IOException { - expectFileContains("dynamicfilter", "result/dynamicfilter", - "hellO wOrld"); - } - - // ------------------------------------------------------ - // Helper methods - // ----------------------------------------------------- - - private String getFileString(String filename) - throws IOException - { - Reader r = null; - try { - r = new FileReader(FILE_UTILS.resolveFile(getProject().getBaseDir(), filename)); - return FileUtils.readFully(r); - } - finally { - FileUtils.close(r); - } - - } - - private void expectFileContains(String name, String contains) - throws IOException - { - String content = getFileString(name); - assertTrue( - "expecting file " + name + " to contain " + contains + - " but got " + content, content.indexOf(contains) > -1); - } - - private void expectFileContains( - String target, String name, String contains) - throws IOException - { - executeTarget(target); - expectFileContains(name, contains); - } - - public static class CustomFilter implements ChainableReader { - char replace = 'x'; - char with = 'y'; - - public void setReplace(char replace) { - this.replace = replace; - } - - public void setWith(char with) { - this.with = with; - } - - public Reader chain(final Reader rdr) { - return new BaseFilterReader(rdr) { - public int read() - throws IOException - { - int c = in.read(); - if (c == replace) - return with; - else - return c; - } - }; - } - } -} diff --git a/src/testcases/org/apache/tools/ant/filters/EscapeUnicodeTest.java b/src/testcases/org/apache/tools/ant/filters/EscapeUnicodeTest.java deleted file mode 100644 index b054699ad..000000000 --- a/src/testcases/org/apache/tools/ant/filters/EscapeUnicodeTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class EscapeUnicodeTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public EscapeUnicodeTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/build.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testEscapeUnicode() throws IOException { - executeTarget("testEscapeUnicode"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), "expected/escapeunicode.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(), "result/escapeunicode.test"); - assertTrue(FILE_UTILS.contentEquals(expected, result)); - } - -} diff --git a/src/testcases/org/apache/tools/ant/filters/HeadTailTest.java b/src/testcases/org/apache/tools/ant/filters/HeadTailTest.java deleted file mode 100644 index 4bff51720..000000000 --- a/src/testcases/org/apache/tools/ant/filters/HeadTailTest.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** JUnit Testcases for TailFilter and HeadFilter - */ -/* I wrote the testcases in one java file because I want also to test the - * combined behaviour (see end of the class). -*/ -public class HeadTailTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public HeadTailTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/head-tail.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testHead() throws IOException { - executeTarget("testHead"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), "expected/head-tail.head.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(), "result/head-tail.head.test"); - assertTrue("testHead: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testHeadLines() throws IOException { - executeTarget("testHeadLines"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), "expected/head-tail.headLines.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(), "result/head-tail.headLines.test"); - assertTrue("testHeadLines: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testHeadSkip() throws IOException { - executeTarget("testHeadSkip"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.headSkip.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/head-tail.headSkip.test"); - assertTrue("testHeadSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testHeadLinesSkip() throws IOException { - executeTarget("testHeadLinesSkip"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.headLinesSkip.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/head-tail.headLinesSkip.test"); - assertTrue("testHeadLinesSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testFilterReaderHeadLinesSkip() throws IOException { - executeTarget("testFilterReaderHeadLinesSkip"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), - "expected/head-tail.headLinesSkip.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(), - "result/head-tail.filterReaderHeadLinesSkip.test"); - assertTrue("testFilterReaderHeadLinesSkip: Result not like expected", - FILE_UTILS.contentEquals(expected, result)); - } - - public void testTail() throws IOException { - executeTarget("testTail"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tail.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/head-tail.tail.test"); - assertTrue("testTail: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testTailLines() throws IOException { - executeTarget("testTailLines"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tailLines.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/head-tail.tailLines.test"); - assertTrue("testTailLines: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testTailSkip() throws IOException { - executeTarget("testTailSkip"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tailSkip.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/head-tail.tailSkip.test"); - assertTrue("testTailSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testTailLinesSkip() throws IOException { - executeTarget("testTailLinesSkip"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.tailLinesSkip.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/head-tail.tailLinesSkip.test"); - assertTrue("testTailLinesSkip: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - - public void testFilterReaderTailLinesSkip() throws IOException { - executeTarget("testFilterReaderTailLinesSkip"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(), - "expected/head-tail.tailLinesSkip.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(), - "result/head-tail.filterReaderTailLinesSkip.test"); - assertTrue("testFilterReaderTailLinesSkip: Result not like expected", - FILE_UTILS.contentEquals(expected, result)); - } - - public void testHeadTail() throws IOException { - executeTarget("testHeadTail"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/head-tail.headtail.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/head-tail.headtail.test"); - assertTrue("testHeadTail: Result not like expected", FILE_UTILS.contentEquals(expected, result)); - } - -} diff --git a/src/testcases/org/apache/tools/ant/filters/LineContainsTest.java b/src/testcases/org/apache/tools/ant/filters/LineContainsTest.java deleted file mode 100644 index fb3336453..000000000 --- a/src/testcases/org/apache/tools/ant/filters/LineContainsTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class LineContainsTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public LineContainsTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/build.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testLineContains() throws IOException { - executeTarget("testLineContains"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/linecontains.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/linecontains.test"); - assertTrue(FILE_UTILS.contentEquals(expected, result)); - } - - public void testNegateLineContains() throws IOException { - executeTarget("testNegateLineContains"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/filters/NoNewLineTest.java b/src/testcases/org/apache/tools/ant/filters/NoNewLineTest.java deleted file mode 100644 index 00df34e51..000000000 --- a/src/testcases/org/apache/tools/ant/filters/NoNewLineTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; - -/** JUnit Testcases for No new line when filterchain used - */ - - -public class NoNewLineTest extends BuildFileTest { - - public NoNewLineTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/build.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testNoAddNewLine() throws IOException { - executeTarget("testNoAddNewLine"); - } - - -} - diff --git a/src/testcases/org/apache/tools/ant/filters/ReplaceTokensTest.java b/src/testcases/org/apache/tools/ant/filters/ReplaceTokensTest.java deleted file mode 100644 index 7a4294833..000000000 --- a/src/testcases/org/apache/tools/ant/filters/ReplaceTokensTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class ReplaceTokensTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public ReplaceTokensTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/build.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testReplaceTokens() throws IOException { - executeTarget("testReplaceTokens"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/replacetokens.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/replacetokens.test"); - assertTrue(FILE_UTILS.contentEquals(expected, result)); - } - - public void testReplaceTokensPropertyFile() throws IOException { - executeTarget("testReplaceTokensPropertyFile"); - File expected = FILE_UTILS.resolveFile(getProjectDir(), "expected/replacetokens.test"); - File result = FILE_UTILS.resolveFile(getProjectDir(), "result/replacetokensPropertyFile.test"); - assertTrue(FILE_UTILS.contentEquals(expected, result)); - } - -} diff --git a/src/testcases/org/apache/tools/ant/filters/StripJavaCommentsTest.java b/src/testcases/org/apache/tools/ant/filters/StripJavaCommentsTest.java deleted file mode 100644 index c3311c067..000000000 --- a/src/testcases/org/apache/tools/ant/filters/StripJavaCommentsTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class StripJavaCommentsTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public StripJavaCommentsTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/build.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testStripJavaComments() throws IOException { - executeTarget("testStripJavaComments"); - File expected = FILE_UTILS.resolveFile(getProject().getBaseDir(),"expected/stripjavacomments.test"); - File result = FILE_UTILS.resolveFile(getProject().getBaseDir(),"result/stripjavacomments.test"); - assertTrue(FILE_UTILS.contentEquals(expected, result)); - } - -} diff --git a/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java b/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java deleted file mode 100644 index acd944a9e..000000000 --- a/src/testcases/org/apache/tools/ant/filters/TokenFilterTest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.filters; - -import java.io.Reader; -import java.io.FileReader; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class TokenFilterTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public TokenFilterTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/filters/tokenfilter.xml"); - executeTarget("init"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - /** make sure tokenfilter exists */ - public void testTokenfilter() throws IOException { - executeTarget("tokenfilter"); - } - - public void testTrimignore() throws IOException { - expectLogContaining("trimignore", "Hello-World"); - } - - public void testStringTokenizer() throws IOException { - expectLogContaining( - "stringtokenizer", "#This#is#a#number#of#words#"); - } - - public void testUnixLineOutput() throws IOException { - expectFileContains( - "unixlineoutput", "result/unixlineoutput", - "\nThis\nis\na\nnumber\nof\nwords\n"); - } - - public void testDosLineOutput() throws IOException { - expectFileContains( - "doslineoutput", "result/doslineoutput", - "\r\nThis\r\nis\r\na\r\nnumber\r\nof\r\nwords\r\n"); - } - - public void testFileTokenizer() throws IOException { - String contents = getFileString( - "filetokenizer", "result/filetokenizer"); - assertStringContains(contents, " of words"); - assertStringNotContains(contents, " This is"); - } - - public void testReplaceString() throws IOException { - expectFileContains( - "replacestring", "result/replacestring", - "this is the moon"); - } - - public void testReplaceStrings() throws IOException { - expectLogContaining("replacestrings", "bar bar bar"); - } - - public void testContainsString() throws IOException { - String contents = getFileString( - "containsstring", "result/containsstring"); - assertStringContains(contents, "this is a line contains foo"); - assertStringNotContains(contents, "this line does not"); - } - - public void testReplaceRegex() throws IOException { - if (! hasRegex("testReplaceRegex")) - return; - String contents = getFileString( - "replaceregex", "result/replaceregex"); - assertStringContains(contents, "world world world world"); - assertStringContains(contents, "dog Cat dog"); - assertStringContains(contents, "moon Sun Sun"); - assertStringContains(contents, "found WhiteSpace"); - assertStringContains(contents, "Found digits [1234]"); - assertStringNotContains(contents, "This is a line with digits"); - } - - public void testFilterReplaceRegex() throws IOException { - if (! hasRegex("testFilterReplaceRegex")) - return; - String contents = getFileString( - "filterreplaceregex", "result/filterreplaceregex"); - assertStringContains(contents, "world world world world"); - } - - public void testHandleDollerMatch() throws IOException { - if (! hasRegex("testFilterReplaceRegex")) - return; - executeTarget("dollermatch"); - } - - public void testTrimFile() throws IOException { - String contents = getFileString( - "trimfile", "result/trimfile"); - assertTrue("no ws at start", contents.startsWith("This is th")); - assertTrue("no ws at end", contents.endsWith("second line.")); - assertStringContains(contents, " This is the second"); - } - - public void testTrimFileByLine() throws IOException { - String contents = getFileString( - "trimfilebyline", "result/trimfilebyline"); - assertFalse("no ws at start", contents.startsWith("This is th")); - assertFalse("no ws at end", contents.endsWith("second line.")); - assertStringNotContains(contents, " This is the second"); - assertStringContains(contents, "file.\nThis is the second"); - } - - public void testFilterReplaceString() throws IOException { - String contents = getFileString( - "filterreplacestring", "result/filterreplacestring"); - assertStringContains(contents, "This is the moon"); - } - - public void testFilterReplaceStrings() throws IOException { - expectLogContaining("filterreplacestrings", "bar bar bar"); - } - - public void testContainsRegex() throws IOException { - if (! hasRegex("testContainsRegex")) - return; - String contents = getFileString( - "containsregex", "result/containsregex"); - assertStringContains(contents, "hello world"); - assertStringNotContains(contents, "this is the moon"); - assertStringContains(contents, "World here"); - } - - public void testFilterContainsRegex() throws IOException { - if (! hasRegex("testFilterContainsRegex")) - return; - String contents = getFileString( - "filtercontainsregex", "result/filtercontainsregex"); - assertStringContains(contents, "hello world"); - assertStringNotContains(contents, "this is the moon"); - assertStringContains(contents, "World here"); - } - - public void testContainsRegex2() throws IOException { - if (! hasRegex("testContainsRegex2")) - return; - String contents = getFileString( - "containsregex2", "result/containsregex2"); - assertStringContains(contents, "void register_bits();"); - } - - public void testDeleteCharacters() throws IOException { - String contents = getFileString( - "deletecharacters", "result/deletechars"); - assertStringNotContains(contents, "#"); - assertStringNotContains(contents, "*"); - assertStringContains(contents, "This is some "); - } - - public void testScriptFilter() throws IOException { - if (! hasScript("testScriptFilter")) - return; - - expectFileContains("scriptfilter", "result/scriptfilter", - "HELLO WORLD"); - } - - - public void testScriptFilter2() throws IOException { - if (! hasScript("testScriptFilter")) - return; - - expectFileContains("scriptfilter2", "result/scriptfilter2", - "HELLO MOON"); - } - - public void testCustomTokenFilter() throws IOException { - expectFileContains("customtokenfilter", "result/custom", - "Hello World"); - } - - // ------------------------------------------------------ - // Helper methods - // ----------------------------------------------------- - private boolean hasScript(String test) { - try { - executeTarget("hasscript"); - } - catch (Throwable ex) { - System.out.println( - test + ": skipped - script not present "); - return false; - } - return true; - } - - private boolean hasRegex(String test) { - try { - executeTarget("hasregex"); - expectFileContains("result/replaceregexp", "bye world"); - } - catch (Throwable ex) { - System.out.println(test + ": skipped - regex not present " - + ex); - return false; - } - return true; - } - - private void assertStringContains(String string, String contains) { - assertTrue("[" + string + "] does not contain [" + contains +"]", - string.indexOf(contains) > -1); - } - - private void assertStringNotContains(String string, String contains) { - assertTrue("[" + string + "] does contain [" + contains +"]", - string.indexOf(contains) == -1); - } - - private String getFileString(String filename) - throws IOException - { - Reader r = null; - try { - r = new FileReader(FILE_UTILS.resolveFile(getProject().getBaseDir(),filename)); - return FileUtils.readFully(r); - } - finally { - FileUtils.close(r); - } - - } - - private String getFileString(String target, String filename) - throws IOException - { - executeTarget(target); - return getFileString(filename); - } - - private void expectFileContains(String name, String contains) - throws IOException - { - String content = getFileString(name); - assertTrue( - "expecting file " + name + " to contain " + contains + - " but got " + content, content.indexOf(contains) > -1); - } - - private void expectFileContains( - String target, String name, String contains) - throws IOException - { - executeTarget(target); - expectFileContains(name, contains); - } - - public static class Capitalize - implements TokenFilter.Filter - { - public String filter(String token) { - if (token.length() == 0) - return token; - return token.substring(0, 1).toUpperCase() + - token.substring(1); - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java deleted file mode 100644 index 50e3f61fc..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/AbstractCvsTaskTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import java.io.File; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class AbstractCvsTaskTest extends BuildFileTest { - - public AbstractCvsTaskTest() { - this( "AbstractCvsTaskTest" ); - } - - public AbstractCvsTaskTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/abstractcvstask.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testAbstractCvsTask() { - executeTarget( "all" ); - } - - public void testPackageAttribute() { - File f = getProject().resolveFile("tmpdir/ant/build.xml"); - assertTrue("starting empty", !f.exists()); - expectLogContaining("package-attribute", "U ant/build.xml"); - assertTrue("now it is there", f.exists()); - } - - public void testTagAttribute() { - File f = getProject().resolveFile("tmpdir/ant/build.xml"); - assertTrue("starting empty", !f.exists()); - expectLogContaining("tag-attribute", "ANT_141 (revision: 1.175.2.13)"); - assertTrue("now it is there", f.exists()); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java deleted file mode 100644 index e8c1349a9..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/AntLikeTasksAtTopLevelTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; - -/** - * @since Ant 1.6 - */ -public class AntLikeTasksAtTopLevelTest extends BuildFileTest { - public AntLikeTasksAtTopLevelTest(String name) { - super(name); - } - - public void testAnt() { - try { - configureProject("src/etc/testcases/taskdefs/toplevelant.xml"); - fail("no exception thrown"); - } catch (BuildException e) { - assertEquals("ant task at the top level must not invoke its own" - + " build file.", e.getMessage()); - } - } - - public void testSubant() { - try { - configureProject("src/etc/testcases/taskdefs/toplevelsubant.xml"); - fail("no exception thrown"); - } catch (BuildException e) { - assertEquals("subant task at the top level must not invoke its own" - + " build file.", e.getMessage()); - } - } - - public void testAntcall() { - try { - configureProject("src/etc/testcases/taskdefs/toplevelantcall.xml"); - fail("no exception thrown"); - } catch (BuildException e) { - assertEquals("antcall must not be used at the top level.", - e.getMessage()); - } - } - -}// AntLikeTasksAtTopLevelTest diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AntStructureTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AntStructureTest.java deleted file mode 100644 index af09c97f2..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/AntStructureTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.PrintWriter; -import java.util.Hashtable; -import junit.framework.Assert; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; - -/** - */ -public class AntStructureTest extends BuildFileTest { - - public AntStructureTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/antstructure.xml"); - } - - public void tearDown() { - executeTarget("tearDown"); - } - - public void test1() { - expectBuildException("test1", "required argument not specified"); - } - - public void testCustomPrinter() { - executeTarget("testCustomPrinter"); - // can't access the booleans in MyPrinter here (even if they - // were static) since the MyPrinter instance that was used in - // the test has likely been loaded via a different classloader - // than this class. Therefore we make the printer assert its - // state and only check for the tail invocation. - assertLogContaining(MyPrinter.TAIL_CALLED); - } - - public static class MyPrinter implements AntStructure.StructurePrinter { - private static final String TAIL_CALLED = "tail has been called"; - private boolean headCalled = false; - private boolean targetCalled = false; - private boolean tailCalled = false; - private int elementCalled = 0; - private Project p; - - public void printHead(PrintWriter out, Project p, Hashtable tasks, - Hashtable types) { - Assert.assertTrue(!headCalled); - Assert.assertTrue(!targetCalled); - Assert.assertTrue(!tailCalled); - Assert.assertEquals(0, elementCalled); - headCalled = true; - } - public void printTargetDecl(PrintWriter out) { - Assert.assertTrue(headCalled); - Assert.assertTrue(!targetCalled); - Assert.assertTrue(!tailCalled); - Assert.assertEquals(0, elementCalled); - targetCalled = true; - } - public void printElementDecl(PrintWriter out, Project p, String name, - Class element) { - Assert.assertTrue(headCalled); - Assert.assertTrue(targetCalled); - Assert.assertTrue(!tailCalled); - elementCalled++; - this.p = p; - } - public void printTail(PrintWriter out) { - Assert.assertTrue(headCalled); - Assert.assertTrue(targetCalled); - Assert.assertTrue(!tailCalled); - Assert.assertTrue(elementCalled > 0); - tailCalled = true; - p.log(TAIL_CALLED); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java deleted file mode 100644 index 32a55b57d..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/AntTest.java +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; - -import junit.framework.AssertionFailedError; - -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.BuildListener; -import org.apache.tools.ant.input.InputHandler; -import org.apache.tools.ant.input.PropertyFileInputHandler; -import org.apache.tools.ant.types.Path; - -/** - */ -public class AntTest extends BuildFileTest { - - public AntTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/ant.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - expectBuildException("test1", "recursive call"); - } - - // target must be specified - public void test2() { - expectBuildException("test2", "required argument not specified"); - } - - // Should fail since a recursion will occur... - public void test3() { - expectBuildException("test1", "recursive call"); - } - - public void test4() { - expectBuildException("test4", "target attribute must not be empty"); - } - - public void test4b() { - expectBuildException("test4b", "target doesn't exist"); - } - - public void test5() { - executeTarget("test5"); - } - - public void test6() { - executeTarget("test6"); - } - - public void testExplicitBasedir1() { - File dir1 = getProjectDir(); - File dir2 = project.resolveFile(".."); - testBaseDirs("explicitBasedir1", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath() - }); - } - - public void testExplicitBasedir2() { - File dir1 = getProjectDir(); - File dir2 = project.resolveFile(".."); - testBaseDirs("explicitBasedir2", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath() - }); - } - - public void testInheritBasedir() { - String basedir = getProjectDir().getAbsolutePath(); - testBaseDirs("inheritBasedir", new String[] {basedir, basedir}); - } - - public void testDoNotInheritBasedir() { - File dir1 = getProjectDir(); - File dir2 = project.resolveFile("ant"); - String basedir = getProjectDir().getAbsolutePath(); - testBaseDirs("doNotInheritBasedir", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath() - }); - } - - public void testBasedirTripleCall() { - File dir1 = getProjectDir(); - File dir2 = project.resolveFile("ant"); - testBaseDirs("tripleCall", - new String[] {dir1.getAbsolutePath(), - dir2.getAbsolutePath(), - dir1.getAbsolutePath() - }); - } - - protected void testBaseDirs(String target, String[] dirs) { - BasedirChecker bc = new BasedirChecker(dirs); - project.addBuildListener(bc); - executeTarget(target); - AssertionFailedError ae = bc.getError(); - if (ae != null) { - throw ae; - } - project.removeBuildListener(bc); - } - - public void testReferenceInheritance() { - Path p = Path.systemClasspath; - p.setProject(project); - project.addReference("path", p); - project.addReference("no-override", p); - testReference("testInherit", new String[] {"path", "path"}, - new boolean[] {true, true}, p); - testReference("testInherit", - new String[] {"no-override", "no-override"}, - new boolean[] {true, false}, p); - testReference("testInherit", - new String[] {"no-override", "no-override"}, - new boolean[] {false, false}, null); - } - - public void testReferenceNoInheritance() { - Path p = Path.systemClasspath; - p.setProject(project); - project.addReference("path", p); - project.addReference("no-override", p); - testReference("testNoInherit", new String[] {"path", "path"}, - new boolean[] {true, false}, p); - testReference("testNoInherit", new String[] {"path", "path"}, - new boolean[] {false, true}, null); - testReference("testInherit", - new String[] {"no-override", "no-override"}, - new boolean[] {true, false}, p); - testReference("testInherit", - new String[] {"no-override", "no-override"}, - new boolean[] {false, false}, null); - } - - public void testReferenceRename() { - Path p = Path.systemClasspath; - p.setProject(project); - project.addReference("path", p); - testReference("testRename", new String[] {"path", "path"}, - new boolean[] {true, false}, p); - testReference("testRename", new String[] {"path", "path"}, - new boolean[] {false, true}, null); - testReference("testRename", new String[] {"newpath", "newpath"}, - new boolean[] {false, true}, p); - } - - public void testInheritPath() { - executeTarget("testInheritPath"); - } - - protected void testReference(String target, String[] keys, - boolean[] expect, Object value) { - ReferenceChecker rc = new ReferenceChecker(keys, expect, value); - project.addBuildListener(rc); - executeTarget(target); - AssertionFailedError ae = rc.getError(); - if (ae != null) { - throw ae; - } - project.removeBuildListener(rc); - } - - public void testLogfilePlacement() { - File[] logFiles = new File[] { - getProject().resolveFile("test1.log"), - getProject().resolveFile("test2.log"), - getProject().resolveFile("ant/test3.log"), - getProject().resolveFile("ant/test4.log") - }; - for (int i=0; i -1); - assertTrue(getLog().indexOf("test2 is ${test2}") > -1); - assertTrue(getLog().indexOf("test1.x is 1") > -1); - } - - public void testInfiniteLoopViaDepends() { - expectBuildException("infinite-loop-via-depends", "recursive call"); - } - - public void testMultiSameProperty() { - expectLog("multi-same-property", "prop is two"); - } - - public void testTopLevelTarget() { - expectLog("topleveltarget", "Hello world"); - } - - public void testMultiplePropertyFileChildren() { - PropertyChecker pcBar = new PropertyChecker("bar", - new String[] {null, "Bar"}); - PropertyChecker pcFoo = new PropertyChecker("foo", - new String[] {null, "Foo"}); - project.addBuildListener(pcBar); - project.addBuildListener(pcFoo); - executeTarget("multiple-property-file-children"); - AssertionFailedError aeBar = pcBar.getError(); - if (aeBar != null) { - throw aeBar; - } - AssertionFailedError aeFoo = pcFoo.getError(); - if (aeFoo != null) { - throw aeFoo; - } - project.removeBuildListener(pcBar); - project.removeBuildListener(pcFoo); - } - - public void testBlankTarget() { - expectBuildException("blank-target", "target name must not be empty"); - } - - public void testMultipleTargets() { - expectLog("multiple-targets", "tadadctbdbtc"); - } - - public void testMultipleTargets2() { - expectLog("multiple-targets-2", "dadctb"); - } - - private class BasedirChecker implements BuildListener { - private String[] expectedBasedirs; - private int calls = 0; - private AssertionFailedError error; - - BasedirChecker(String[] dirs) { - expectedBasedirs = dirs; - } - - public void buildStarted(BuildEvent event) {} - public void buildFinished(BuildEvent event) {} - public void targetFinished(BuildEvent event){} - public void taskStarted(BuildEvent event) {} - public void taskFinished(BuildEvent event) {} - public void messageLogged(BuildEvent event) {} - - public void targetStarted(BuildEvent event) { - if (event.getTarget().getName().equals("")) { - return; - } - if (error == null) { - try { - assertEquals(expectedBasedirs[calls++], - event.getProject().getBaseDir().getAbsolutePath()); - } catch (AssertionFailedError e) { - error = e; - } - } - } - - AssertionFailedError getError() { - return error; - } - - } - - private class ReferenceChecker implements BuildListener { - private String[] keys; - private boolean[] expectSame; - private Object value; - private int calls = 0; - private AssertionFailedError error; - - ReferenceChecker(String[] keys, boolean[] expectSame, Object value) { - this.keys = keys; - this.expectSame = expectSame; - this.value = value; - } - - public void buildStarted(BuildEvent event) {} - public void buildFinished(BuildEvent event) {} - public void targetFinished(BuildEvent event){} - public void taskStarted(BuildEvent event) {} - public void taskFinished(BuildEvent event) {} - public void messageLogged(BuildEvent event) {} - - public void targetStarted(BuildEvent event) { - if (event.getTarget().getName().equals("")) { - return; - } - if (error == null) { - try { - String msg = - "Call " + calls + " refid=\'" + keys[calls] + "\'"; - if (value == null) { - Object o = event.getProject().getReference(keys[calls]); - if (expectSame[calls++]) { - assertNull(msg, o); - } else { - assertNotNull(msg, o); - } - } else { - // a rather convoluted equals() test - Path expect = (Path) value; - Path received = (Path) event.getProject().getReference(keys[calls]); - boolean shouldBeEqual = expectSame[calls++]; - if (received == null) { - assertTrue(msg, !shouldBeEqual); - } else { - String[] l1 = expect.list(); - String[] l2 = received.list(); - if (l1.length == l2.length) { - for (int i=0; i= expectedValues.length) { - error = new AssertionFailedError("Unexpected invocation of" - + " target " - + event.getTarget().getName()); - } - - if (error == null) { - try { - assertEquals(expectedValues[calls++], - event.getProject().getProperty(key)); - } catch (AssertionFailedError e) { - error = e; - } - } - } - - AssertionFailedError getError() { - return error; - } - - } - - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AntlibTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AntlibTest.java deleted file mode 100644 index ea9db5cb4..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/AntlibTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.Project; - -/** - */ -public class AntlibTest extends BuildFileTest { - public AntlibTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/antlib.xml"); - } - - /** - * only do the antlib tests if we are in the same JVM as ant. - * @return - */ - private boolean isSharedJVM() { - String property = System.getProperty("tests.and.ant.share.classloader"); - return property!=null && Project.toBoolean(property); - } - - public void testAntlibFile() { - expectLog("antlib.file", "MyTask called"); - } - - /** - * Confirms that all matching resources will be used, so that you - * can collect several antlibs in one Definer call. - * @see "http://issues.apache.org/bugzilla/show_bug.cgi?id=24024" - */ - public void testAntlibResource() { - expectLog("antlib.resource", "MyTask called-and-then-MyTask2 called"); - } - - public void testNsCurrent() { - expectLog("ns.current", "Echo2 inside a macroHello from x:p"); - } - - - public void testAntlib_uri() { - if (isSharedJVM()) { - executeTarget("antlib_uri"); - } - } - - public void testAntlib_uri_auto() { - if (isSharedJVM()) { - executeTarget("antlib_uri_auto"); - } - } - - public void testAntlib_uri_auto2() { - if (isSharedJVM()) { - executeTarget("antlib_uri_auto2"); - } - } - - public static class MyTask extends Task { - public void execute() { - log("MyTask called"); - } - } - - public static class MyTask2 extends Task { - public void execute() { - log("MyTask2 called"); - } - } - -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AptTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AptTest.java deleted file mode 100644 index e7a65db88..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/AptTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class AptTest extends BuildFileTest { - public AptTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/apt.xml"); - } - - /** - * Tears down the fixture, for example, close a network connection. This - * method is called after a test is executed. - */ - protected void tearDown() throws Exception { - executeTarget("clean"); - } - - public void testApt() { - executeTarget("testApt"); - } - - public void testAptFork() { - executeTarget("testAptFork"); - } - - public void testAptForkFalse() { - executeTarget("testAptForkFalse"); - assertLogContaining(Apt.WARNING_IGNORING_FORK); - } - - public void testListAnnotationTypes() { - executeTarget("testListAnnotationTypes"); - assertLogContaining("Set of annotations found:"); - assertLogContaining("Distributed"); - } - - public void testAptNewFactory() { - executeTarget("testAptNewFactory"); - assertProcessed(); - } - - public void testAptNewFactoryFork() { - executeTarget("testAptNewFactoryFork"); - assertProcessed(); - } - - private void assertProcessed() { - assertLogContaining("DistributedAnnotationProcessor-is-go"); - assertLogContaining("[-Abuild.dir="); - assertLogContaining("visiting DistributedAnnotationFactory"); - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java b/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java deleted file mode 100644 index 57b9ff024..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/AvailableTest.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - * JUnit test for the Available task/condition. - */ -public class AvailableTest extends BuildFileTest { - - public AvailableTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/available.xml"); - } - - // Nothing specified -> Fail - public void test1() { - expectBuildException("test1", "required argument not specified"); - } - - // Only property specified -> Fail - public void test2() { - expectBuildException("test2", "required argument not specified"); - } - - // Only file specified -> Fail - public void test3() { - expectBuildException("test3", "required argument not specified"); - } - - // file doesn't exist -> property 'test' == null - public void test4() { - executeTarget("test4"); - assertTrue(project.getProperty("test") == null); - } - - // file does exist -> property 'test' == 'true' - public void test5() { - executeTarget("test5"); - assertEquals("true", project.getProperty("test")); - } - - // resource doesn't exist -> property 'test' == null - public void test6() { - executeTarget("test6"); - assertTrue(project.getProperty("test") == null); - } - - // resource does exist -> property 'test' == 'true' - public void test7() { - executeTarget("test7"); - assertEquals("true", project.getProperty("test")); - } - - // class doesn't exist -> property 'test' == null - public void test8() { - executeTarget("test8"); - assertTrue(project.getProperty("test") == null); - } - - // class does exist -> property 'test' == 'true' - public void test9() { - executeTarget("test9"); - assertEquals("true", project.getProperty("test")); - } - - // All three specified and all three exist -> true - public void test10() { - executeTarget("test10"); - assertEquals("true", project.getProperty("test")); - } - - // All three specified but class missing -> null - public void test11() { - executeTarget("test11"); - assertNull(project.getProperty("test")); - } - - // Specified property-name is "" -> true - public void test12() { - executeTarget("test12"); - assertNull(project.getProperty("test")); - assertEquals("true", project.getProperty("")); - } - - // Specified file is "" -> invalid files do not exist - public void test13() { - executeTarget("test13"); - assertNull(project.getProperty("test")); - } - - // Specified file is "" actually a directory, so it should pass - public void test13b() { - executeTarget("test13b"); - assertEquals("true", project.getProperty("test")); - } - - // Specified resource is "" -> can such a thing exist? - /* - * returns non null IBM JDK 1.3 Linux - */ -// public void test14() { -// executeTarget("test14"); -// assertEquals(project.getProperty("test"), null); -// } - - // Specified class is "" -> can not exist - public void test15() { - executeTarget("test15"); - assertNull(project.getProperty("test")); - } - - // Specified dir is "" -> this is the current directory and should - // always exist - public void test16() { - executeTarget("test16"); - assertEquals("true", project.getProperty("test")); - } - - // Specified dir is "../taskdefs" -> should exist since it's the - // location of the buildfile used... - public void test17() { - executeTarget("test17"); - assertEquals("true", project.getProperty("test")); - } - - // Specified dir is "../this_dir_should_never_exist" -> null - public void test18() { - executeTarget("test18"); - assertNull(project.getProperty("test")); - } - - // Invalid type specified - public void test19() { - expectBuildException("test19", "Invalid value for type attribute."); - } - - // Core class that exists in system classpath is ignored - public void test20() { - executeTarget("test20"); - assertNull(project.getProperty("test")); - } - - // Core class that exists in system classpath is ignored, but found in specified classpath - public void test21() { - executeTarget("test21"); - assertEquals("true", project.getProperty("test")); - } - - // Core class that exists in system classpath is not ignored with ignoresystemclass="false" - public void test22() { - executeTarget("test22"); - assertEquals("true", project.getProperty("test")); - } - - // Core class that exists in system classpath is not ignored with default ignoresystemclasses value - public void test23() { - executeTarget("test23"); - assertEquals("true", project.getProperty("test")); - } - - // Class is found in specified classpath - public void test24() { - executeTarget("test24"); - assertEquals("true", project.getProperty("test")); - } - - // File is not found in specified filepath - public void testSearchInPathNotThere() { - executeTarget("searchInPathNotThere"); - assertNull(project.getProperty("test")); - } - - // File is not found in specified filepath - public void testSearchInPathIsThere() { - executeTarget("searchInPathIsThere"); - assertEquals("true", project.getProperty("test")); - } - - // test when file begins with basedir twice - public void testDoubleBasedir() { - executeTarget("testDoubleBasedir"); - } - - // test for searching parents - public void testSearchParents() { - executeTarget("search-parents"); - } - // test for not searching parents - public void testSearchParentsNot() { - executeTarget("search-parents-not"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/BUnzip2Test.java b/src/testcases/org/apache/tools/ant/taskdefs/BUnzip2Test.java deleted file mode 100644 index b2bf71ca3..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/BUnzip2Test.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - - -/** - */ -public class BUnzip2Test extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public BUnzip2Test(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/bunzip2.xml"); - executeTarget("prepare"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testRealTest() throws java.io.IOException { - testRealTest("realTest"); - } - - public void testRealTestWithResource() throws java.io.IOException { - testRealTest("realTestWithResource"); - } - - private void testRealTest(String target) throws java.io.IOException { - executeTarget(target); - assertTrue("File content mismatch after bunzip2", - FILE_UTILS.contentEquals(project.resolveFile("expected/asf-logo-huge.tar"), - project.resolveFile("asf-logo-huge.tar"))); - } - - public void testDocumentationClaimsOnCopy() throws java.io.IOException { - testRealTest("testDocumentationClaimsOnCopy"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/BZip2Test.java b/src/testcases/org/apache/tools/ant/taskdefs/BZip2Test.java deleted file mode 100644 index d5f7de450..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/BZip2Test.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.bzip2.CBZip2InputStream; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.InputStream; -import java.io.IOException; - -/** - */ -public class BZip2Test extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public BZip2Test(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/bzip2.xml"); - executeTarget("prepare"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testRealTest() throws IOException { - executeTarget("realTest"); - - // doesn't work: Depending on the compression engine used, - // compressed bytes may differ. False errors would be - // reported. - // assertTrue("File content mismatch", - // FILE_UTILS.contentEquals(project.resolveFile("expected/asf-logo-huge.tar.bz2"), - // project.resolveFile("asf-logo-huge.tar.bz2"))); - - // We have to compare the decompressed content instead: - - File originalFile = - project.resolveFile("expected/asf-logo-huge.tar.bz2"); - File actualFile = project.resolveFile("asf-logo-huge.tar.bz2"); - - InputStream originalIn = - new BufferedInputStream(new FileInputStream(originalFile)); - assertEquals((byte) 'B', originalIn.read()); - assertEquals((byte) 'Z', originalIn.read()); - - InputStream actualIn = - new BufferedInputStream(new FileInputStream(actualFile)); - assertEquals((byte) 'B', actualIn.read()); - assertEquals((byte) 'Z', actualIn.read()); - - originalIn = new CBZip2InputStream(originalIn); - actualIn = new CBZip2InputStream(actualIn); - - while (true) { - int expected = originalIn.read(); - int actual = actualIn.read(); - if (expected >= 0) { - if (expected != actual) { - fail("File content mismatch"); - } - } else { - if (actual >= 0) { - fail("File content mismatch"); - } - break; - } - } - - originalIn.close(); - actualIn.close(); - } - - public void testResource(){ - executeTarget("realTestWithResource"); - } - - public void testDateCheck(){ - executeTarget("testDateCheck"); - String log = getLog(); - assertTrue( - "Expecting message ending with 'asf-logo.gif.bz2 is up to date.' but got '" + log + "'", - log.endsWith("asf-logo.gif.bz2 is up to date.")); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/BasenameTest.java b/src/testcases/org/apache/tools/ant/taskdefs/BasenameTest.java deleted file mode 100644 index 07d128150..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/BasenameTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class BasenameTest extends BuildFileTest { - - public BasenameTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/basename.xml"); - } - - public void test1() { - expectBuildException("test1", "required attribute missing"); - } - - public void test2() { - expectBuildException("test2", "required attribute missing"); - } - - public void test3() { - expectBuildException("test3", "required attribute missing"); - } - - public void test4() { - executeTarget("test4"); - String checkprop = project.getProperty("file.w.suf"); - assertEquals("foo.txt", checkprop); - } - - public void test5() { - executeTarget("test5"); - String checkprop = project.getProperty("file.wo.suf"); - assertEquals("foo", checkprop); - } - - public void testMultipleDots() { - executeTarget("testMultipleDots"); - String checkprop = project.getProperty("file.wo.suf"); - assertEquals("foo.bar", checkprop); - } - - public void testNoDots() { - executeTarget("testNoDots"); - String checkprop = project.getProperty("file.wo.suf"); - assertEquals("foo.bar", checkprop); - } - - public void testValueEqualsSuffixWithDot() { - executeTarget("testValueEqualsSuffixWithDot"); - String checkprop = project.getProperty("file.wo.suf"); - assertEquals("", checkprop); - } - - public void testValueEqualsSuffixWithoutDot() { - executeTarget("testValueEqualsSuffixWithoutDot"); - String checkprop = project.getProperty("file.wo.suf"); - assertEquals("", checkprop); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java b/src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java deleted file mode 100644 index 57884f640..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/CVSPassTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.*; -import org.apache.tools.ant.*; -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests CVSLogin task. - * - */ -public class CVSPassTest extends BuildFileTest { - private final String EOL = System.getProperty("line.separator"); - private static final String JAKARTA_URL = - ":pserver:anoncvs@jakarta.apache.org:/home/cvspublic Ay=0=h -1); - } - - public void testNoOverwrite() { - executeTarget("testnooverwrite"); - File file2 = new File(getProjectDir(), tempFile2); - long size = file2.length(); - assertEquals(size, 0); - } - - public void testheaderfooter() { - test3(); - expectLog("testheaderfooter", "headerHello, World!footer"); - } - - public void testfileheader() { - test3(); - expectLog("testfileheader", "Hello, World!Hello, World!"); - } - - /** - * Expect an exception when attempting to cat an file to itself - */ - public void testsame() { - expectBuildException("samefile", "output file same as input"); - } - - /** - * Check if filter inline works - */ - public void testfilterinline() { - executeTarget("testfilterinline"); - assertTrue(getLog().indexOf("REPLACED") > -1); - } - - /** - * Check if multireader works - */ - public void testmultireader() { - executeTarget("testmultireader"); - assertTrue(getLog().indexOf("Bye") > -1); - assertTrue(getLog().indexOf("Hello") == -1); - } - /** - * Check if fixlastline works - */ - public void testfixlastline() - throws IOException - { - expectFileContains( - "testfixlastline", "concat.line4", - "end of line" + System.getProperty("line.separator") - + "This has"); - } - - /** - * Check if fixlastline works with eol - */ - public void testfixlastlineeol() - throws IOException - { - expectFileContains( - "testfixlastlineeol", "concat.linecr", - "end of line\rThis has"); - } - - // ------------------------------------------------------ - // Helper methods - should be in BuildFileTest - // ----------------------------------------------------- - - private String getFileString(String filename) - throws IOException - { - Reader r = null; - try { - r = new FileReader(getProject().resolveFile(filename)); - return FileUtils.readFully(r); - } - finally { - FileUtils.close(r); - } - - } - - private String getFileString(String target, String filename) - throws IOException - { - executeTarget(target); - return getFileString(filename); - } - - private void expectFileContains( - String target, String filename, String contains) - throws IOException - { - String content = getFileString(target, filename); - assertTrue( - "expecting file " + filename + " to contain " + - contains + - " but got " + content, content.indexOf(contains) > -1); - } - - public void testTranscoding() throws IOException { - executeTarget("testTranscoding"); - File f1 = getProject().resolveFile("copy/expected/utf-8"); - File f2 = getProject().resolveFile("concat.utf8"); - assertTrue(FILE_UTILS.contentEquals(f1, f2)); - } - - public void testResources() { - executeTarget("testResources"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java deleted file mode 100644 index 7cf71cc7b..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ConditionTest.java +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - * @created 13 January 2002 - */ -public class ConditionTest extends BuildFileTest { - - /** - * Constructor for the ConditionTest object - * - * @param name we dont know - */ - public ConditionTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/condition.xml"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("cleanup"); - } - - public void testBasic() { - expectPropertySet("basic","basic"); - } - - public void testConditionIncomplete() { - expectSpecificBuildException("condition-incomplete", - "property attribute has been omitted", - "The property attribute is required."); - } - - public void testConditionEmpty() { - expectSpecificBuildException("condition-empty", - "no conditions", - "You must nest a condition into "); - } - - public void testShortcut() { - expectPropertySet("shortcut","shortcut","set"); - } - - public void testUnset() { - expectPropertyUnset("dontset","dontset"); - } - - public void testSetValue() { - expectPropertySet("setvalue","setvalue","woowoo"); - } - - public void testNegation() { - expectPropertySet("negation","negation"); - } - - public void testNegationFalse() { - expectPropertyUnset("negationfalse","negationfalse"); - } - - public void testNegationIncomplete() { - expectSpecificBuildException("negationincomplete", - "no conditions in ", - "You must nest a condition into "); - } - - public void testAnd() { - expectPropertySet("and","and"); - } - - public void testAndFails() { - expectPropertyUnset("andfails","andfails"); - } - - public void testAndIncomplete() { - expectPropertyUnset("andincomplete","andincomplete"); - } - - public void testAndempty() { - expectPropertySet("andempty","andempty"); - } - - public void testOr() { - expectPropertySet("or","or"); - } - - public void testOrincomplete() { - expectPropertySet("or","or"); - } - - public void testOrFails() { - expectPropertyUnset("orfails","orfails"); - } - - public void testOrboth() { - expectPropertySet("orboth","orboth"); - } - - public void testFilesmatchIdentical() { - expectPropertySet("filesmatch-identical","filesmatch-identical"); - } - - - public void testFilesmatchIncomplete() { - expectSpecificBuildException("filesmatch-incomplete", - "Missing file2 attribute", - "both file1 and file2 are required in filesmatch"); - } - - public void testFilesmatchOddsizes() { - expectPropertyUnset("filesmatch-oddsizes","filesmatch-oddsizes"); - } - - public void testFilesmatchExistence() { - expectPropertyUnset("filesmatch-existence", "filesmatch-existence"); - } - - public void testFilesmatchDifferent() { - expectPropertyUnset("filesmatch-different","filesmatch-different"); - } - - public void testFilesmatchMatch() { - expectPropertySet("filesmatch-match","filesmatch-match"); - } - - public void testFilesmatchDifferentSizes() { - expectPropertyUnset("filesmatch-different-sizes", - "filesmatch-different-sizes"); - } - - public void testFilesmatchDifferentOnemissing() { - expectPropertyUnset("filesmatch-different-onemissing", - "filesmatch-different-onemissing"); - } - - public void testFilesmatchDifferentEol() { - executeTarget("filesmatch-different-eol"); - } - - public void testFilesmatchSameEol() { - executeTarget("filesmatch-same-eol"); - } - - public void testFilesmatchNeitherExist() { - executeTarget("filesmatch-neitherexist"); - } - - public void testContains() { - expectPropertySet("contains","contains"); - } - - - public void testContainsDoesnt() { - expectPropertyUnset("contains-doesnt","contains-doesnt"); - } - - public void testContainsAnycase() { - expectPropertySet("contains-anycase","contains-anycase"); - } - - - public void testContainsIncomplete1() { - expectSpecificBuildException("contains-incomplete1", - "Missing contains attribute", - "both string and substring are required in contains"); - } - - public void testContainsIncomplete2() { - expectSpecificBuildException("contains-incomplete2", - "Missing contains attribute", - "both string and substring are required in contains"); - } - - public void testIstrue() { - expectPropertySet("istrue","istrue"); - } - - public void testIstrueNot() { - expectPropertyUnset("istrue-not","istrue-not"); - } - - public void testIstrueFalse() { - expectPropertyUnset("istrue-false","istrue-false"); - } - - - public void testIstrueIncomplete1() { - expectSpecificBuildException("istrue-incomplete", - "Missing attribute", - "Nothing to test for truth"); - } - - public void testIsfalseTrue() { - expectPropertyUnset("isfalse-true","isfalse-true"); - } - - public void testIsfalseNot() { - expectPropertySet("isfalse-not","isfalse-not"); - } - - public void testIsfalseFalse() { - expectPropertySet("isfalse-false","isfalse-false"); - } - - - public void testIsfalseIncomplete1() { - expectSpecificBuildException("isfalse-incomplete", - "Missing attribute", - "Nothing to test for falsehood"); - } - - public void testElse() { - executeTarget("testElse"); - } - - public void testResourcesmatchError() { - expectBuildException("resourcesmatch-error", - "should fail because no resources specified"); - } - - public void testResourcesmatchEmpty() { - executeTarget("resourcesmatch-match-empty"); - } - - public void testResourcesmatchOne() { - executeTarget("resourcesmatch-match-one"); - } - - public void testResourcesmatchBinary() { - executeTarget("resourcesmatch-match-binary"); - } - - public void testResourcesmatchMultipleBinary() { - executeTarget("resourcesmatch-match-multiple-binary"); - } - - public void testResourcesmatchDiffer() { - executeTarget("resourcesmatch-differ"); - } - - public void testResourcesmatchText() { - executeTarget("resourcesmatch-match-text"); - } - - public void testResourcesmatchNoneExist() { - executeTarget("resourcesmatch-noneexist"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java b/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java deleted file mode 100644 index 28526387b..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/CopyTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; - -/** - * Tests FileSet using the Copy task. - * - */ -public class CopyTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public CopyTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/copy.xml"); - } - - public void test1() { - executeTarget("test1"); - File f = new File(getProjectDir(), "copytest1.tmp"); - if ( !f.exists()) { - fail("Copy failed"); - } - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test2() { - executeTarget("test2"); - File f = new File(getProjectDir(), "copytest1dir/copy.xml"); - if ( !f.exists()) { - fail("Copy failed"); - } - } - - public void test3() { - executeTarget("test3"); - File file3 = new File(getProjectDir(), "copytest3.tmp"); - assertTrue(file3.exists()); - File file3a = new File(getProjectDir(), "copytest3a.tmp"); - assertTrue(file3a.exists()); - File file3b = new File(getProjectDir(), "copytest3b.tmp"); - assertTrue(file3b.exists()); - File file3c = new File(getProjectDir(), "copytest3c.tmp"); - assertTrue(file3c.exists()); - - //file length checks rely on touch generating a zero byte file - if(file3.length()==0) { - fail("could not overwrite an existing, older file"); - } - if(file3c.length()!=0) { - fail("could not force overwrite an existing, newer file"); - } - if(file3b.length()==0) { - fail("unexpectedly overwrote an existing, newer file"); - } - - //file time checks for java1.2+ - assertTrue(file3a.lastModified()==file3.lastModified()); - assertTrue(file3c.lastModified() or element must be set"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test2() { - expectBuildException("test2","At least one or element must be set"); - } - - public void test3() { - expectBuildException("test1","At least one or element must be set"); - } - - public void test4() { - executeTarget("test4"); - } - - public void test5() { - executeTarget("test5"); - } - - public void test6() { - executeTarget("test6"); - } - public void test7() { - executeTarget("test7"); - } - public void test8() { - executeTarget("test8"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/DirnameTest.java b/src/testcases/org/apache/tools/ant/taskdefs/DirnameTest.java deleted file mode 100644 index 842d69e22..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/DirnameTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.taskdefs.condition.Os; - -/** - */ -public class DirnameTest extends BuildFileTest { - - public DirnameTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/dirname.xml"); - } - - public void test1() { - expectBuildException("test1", "required attribute missing"); - } - - public void test2() { - expectBuildException("test2", "required attribute missing"); - } - - public void test3() { - expectBuildException("test3", "required attribute missing"); - } - - public void test4() { - if (Os.isFamily("netware") || Os.isFamily("dos")) { - return; - } - executeTarget("test4"); - String filesep = System.getProperty("file.separator"); - String expected = filesep + "usr" + filesep + "local"; - String checkprop = project.getProperty("local.dir"); - if (!checkprop.equals(expected)) { - fail("dirname failed"); - } - } - - public void test5() { - executeTarget("test5"); - String expected = project.getProperty("basedir"); - String checkprop = project.getProperty("base.dir"); - if (!checkprop.equals(expected)) { - fail("dirname failed"); - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/DynamicTask.java b/src/testcases/org/apache/tools/ant/taskdefs/DynamicTask.java deleted file mode 100644 index 0d4b6cda7..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/DynamicTask.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.DynamicConfigurator; -import org.apache.tools.ant.Task; - -public class DynamicTask extends Task implements DynamicConfigurator { - - public void execute() { - } - - public void setDynamicAttribute(String name, String value) { - getProject().setNewProperty(name, value); - } - - public Object createDynamicElement(String name) { - return new Sub(); - } - - public class Sub implements DynamicConfigurator { - public void setDynamicAttribute(String name, String value) { - getProject().setNewProperty(name, value); - } - - public Object createDynamicElement(String name) { - return null; - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/DynamicTest.java b/src/testcases/org/apache/tools/ant/taskdefs/DynamicTest.java deleted file mode 100644 index de4426155..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/DynamicTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -public class DynamicTest extends BuildFileTest { - - public DynamicTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/dynamictask.xml"); - } - - public void testSimple() { - executeTarget("simple"); - assertEquals("1", project.getProperty("prop1")); - assertEquals("2", project.getProperty("prop2")); - assertEquals("3", project.getProperty("prop3")); - assertEquals("4", project.getProperty("prop4")); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/EchoTest.java b/src/testcases/org/apache/tools/ant/taskdefs/EchoTest.java deleted file mode 100644 index 31df91dd3..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/EchoTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class EchoTest extends BuildFileTest { - - public EchoTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/echo.xml"); - } - - public void tearDown() { - executeTarget("clean"); - } - - // Output an empty String - public void test1() { - expectLog("test1", ""); - } - - // Output 'OUTPUT OF ECHO' - public void test2() { - expectLog("test2", "OUTPUT OF ECHO"); - } - - public void test3() { - expectLog("test3", "\n"+ - " This \n"+ - " is\n"+ - " a \n"+ - " multiline\n"+ - " message\n"+ - " "); - } - - public void testFile() throws Exception { - executeTarget("testFile"); - } - - public void testAppend() throws Exception { - executeTarget("testAppend"); - } - - public void testEmptyEncoding() throws Exception { - executeTarget("testEmptyEncoding"); - } - - public void testUTF16Encoding() throws Exception { - executeTarget("testUTF16Encoding"); - } - public void testUTF8Encoding() throws Exception { - executeTarget("testUTF8Encoding"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/EchoXMLTest.java b/src/testcases/org/apache/tools/ant/taskdefs/EchoXMLTest.java deleted file mode 100755 index 2cf2817d0..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/EchoXMLTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -public class EchoXMLTest extends BuildFileTest { - - public EchoXMLTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/echoxml.xml"); - } - - public void tearDown() { - executeTarget("tearDown"); - } - - public void testPass() { - executeTarget("testPass"); - } - - public void testFail() { - expectBuildExceptionContaining("testFail", "must fail", "${foo}=bar"); - } - - public void testEmpty() { - expectBuildExceptionContaining("testEmpty", "must fail", "No nested XML specified"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ExecTaskTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ExecTaskTest.java deleted file mode 100644 index 34ff1102e..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ExecTaskTest.java +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.*; -import org.apache.tools.ant.util.FileUtils; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.GregorianCalendar; - -import junit.framework.ComparisonFailure; - -/** - * Unit test for the <exec> task. - */ -public class ExecTaskTest extends BuildFileTest { - private static final String BUILD_PATH = "src/etc/testcases/taskdefs/exec/"; - private static final String BUILD_FILE = BUILD_PATH + "exec.xml"; - private static final int TIME_TO_WAIT = 1; - /** maximum time allowed for the build in milliseconds */ - private static final int MAX_BUILD_TIME = 4000; - private static final int SECURITY_MARGIN = 2000; // wait 2 second extras - // the test failed with 100 ms of margin on cvs.apache.org on August 1st, 2003 - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - private File logFile; - private MonitoredBuild myBuild = null; - volatile private boolean buildFinished = false; - public ExecTaskTest(String name) { - super(name); - } - - public void setUp() { - configureProject(BUILD_FILE); - } - - public void tearDown() { - if (logFile != null && logFile.exists()) { - getProject().setProperty("logFile", logFile.getAbsolutePath()); - } - executeTarget("cleanup"); - } - - public void testNoRedirect() { - executeTarget("no-redirect"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - assertEquals("unexpected log content", - getProject().getProperty("ant.file") + " out" - + getProject().getProperty("ant.file") + " err", getLog()); - } - - public void testRedirect1() throws IOException { - executeTarget("redirect1"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String expectedOut = getProject().getProperty("ant.file") + " out\n" - + getProject().getProperty("ant.file") + " err\n"; - - assertEquals("unexpected output", - expectedOut, getFileString("redirect.out")); - } - - public void testRedirect2() throws IOException { - executeTarget("redirect2"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - - assertEquals("unexpected output", - getProject().getProperty("ant.file") + " out\n", - getFileString("redirect.out")); - assertEquals("unexpected error output", - getProject().getProperty("ant.file") + " err\n", - getFileString("redirect.err")); - } - - public void testRedirect3() throws IOException { - executeTarget("redirect3"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - assertEquals("unexpected log content", - getProject().getProperty("ant.file") + " err", getLog()); - String expectedOut = getProject().getProperty("ant.file") + " out\n"; - - assertEquals("unexpected output", - expectedOut, getFileString("redirect.out")); - assertPropertyEquals("redirect.out", expectedOut.trim()); - } - - public void testRedirect4() throws IOException { - executeTarget("redirect4"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String expectedOut = getProject().getProperty("ant.file") + " out\n"; - String expectedErr = getProject().getProperty("ant.file") + " err\n"; - - assertEquals("unexpected output", - expectedOut, getFileString("redirect.out")); - assertPropertyEquals("redirect.out", expectedOut.trim()); - assertEquals("unexpected error output", - expectedErr, getFileString("redirect.err")); - assertPropertyEquals("redirect.err", expectedErr.trim()); - } - - public void testRedirect5() throws IOException { - testRedirect5or6("redirect5"); - } - - public void testRedirect6() throws IOException { - testRedirect5or6("redirect6"); - } - - public void testRedirect5or6(String target) throws IOException { - executeTarget(target); - if (getProject().getProperty("wc.can.run") == null) { - return; - } - - assertEquals("unexpected output", "3", getFileString("redirect.out").trim()); - assertEquals("property redirect.out", "3", - getProject().getProperty("redirect.out").trim()); - assertNull("unexpected error output", getFileString("redirect.err")); - assertPropertyEquals("redirect.err", ""); - } - - public void testRedirect7() throws IOException { - executeTarget("redirect7"); - if (getProject().getProperty("wc.can.run") == null) { - return; - } - - assertEquals("unexpected output", "3", getFileString("redirect.out").trim()); - assertEquals("property redirect.out", "3", - getProject().getProperty("redirect.out").trim()); - assertNull("unexpected error output", getFileString("redirect.err")); - } - - public void testRedirector1() { - executeTarget("init"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - expectBuildException("redirector1", "cannot have > 1 nested s"); - } - - public void testRedirector2() throws IOException { - executeTarget("redirector2"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - - assertEquals("unexpected output", - getProject().getProperty("ant.file") + " out\n" - + getProject().getProperty("ant.file") + " err\n", - getFileString("redirector.out")); - } - - public void testRedirector3() throws IOException { - executeTarget("redirector3"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - - assertEquals("unexpected output", - getProject().getProperty("ant.file") + " out\n", - getFileString("redirector.out")); - assertEquals("unexpected error output", - getProject().getProperty("ant.file") + " err\n", - getFileString("redirector.err")); - } - - public void testRedirector4() throws IOException { - executeTarget("redirector4"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String expectedOut = getProject().getProperty("ant.file") + " out\n"; - - assertEquals("unexpected log content", - getProject().getProperty("ant.file") + " err", getLog()); - assertEquals("unexpected output", expectedOut, - getFileString("redirector.out")); - assertPropertyEquals("redirector.out", expectedOut.trim()); - } - - public void testRedirector5() throws IOException { - testRedirector5or6("redirector5"); - } - - public void testRedirector6() throws IOException { - testRedirector5or6("redirector6"); - } - - private void testRedirector5or6(String target) throws IOException { - executeTarget(target); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String expectedOut = getProject().getProperty("ant.file") + " out\n"; - String expectedErr = getProject().getProperty("ant.file") + " err\n"; - - assertEquals("unexpected output", expectedOut, - getFileString("redirector.out")); - assertPropertyEquals("redirector.out", expectedOut.trim()); - assertEquals("unexpected error output", expectedErr, - getFileString("redirector.err")); - assertPropertyEquals("redirector.err", expectedErr.trim()); - } - - public void testRedirector7() throws IOException { - executeTarget("redirector7"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String expectedOut = getProject().getProperty("ant.file") + " out\n"; - String expectedErr = getProject().getProperty("ant.file") + " ERROR!!!\n"; - - assertEquals("unexpected output", expectedOut, - getFileString("redirector.out")); - assertPropertyEquals("redirector.out", expectedOut.trim()); - assertEquals("unexpected error output", expectedErr, - getFileString("redirector.err")); - assertPropertyEquals("redirector.err", expectedErr.trim()); - } - - public void testRedirector8() throws IOException { - executeTarget("redirector8"); - if (getProject().getProperty("wc.can.run") == null) { - return; - } - - assertEquals("unexpected output", "3", getFileString("redirector.out").trim()); - assertEquals("property redirector.out", "3", - getProject().getProperty("redirector.out").trim()); - assertNull("unexpected error output", getFileString("redirector.err")); - assertPropertyEquals("redirector.err", ""); - } - - public void testRedirector9() throws IOException { - testRedirector9Thru12("redirector9"); - } - - public void testRedirector10() throws IOException { - testRedirector9Thru12("redirector10"); - } - - public void testRedirector11() throws IOException { - testRedirector9Thru12("redirector11"); - } - - public void testRedirector12() throws IOException { - testRedirector9Thru12("redirector12"); - } - - private void testRedirector9Thru12(String target) throws IOException { - executeTarget(target); - if (getProject().getProperty("cat.can.run") == null) { - return; - } - String expectedOut = "blah after blah"; - - assertEquals("unexpected output", - expectedOut, getFileString("redirector.out").trim()); - assertPropertyEquals("redirector.out", expectedOut.trim()); - assertNull("unexpected error output", getFileString("redirector.err")); - assertPropertyEquals("redirector.err", ""); - } - - public void testRedirector13() { - executeTarget("redirector13"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String antfile = getProject().getProperty("ant.file"); - try { - //no point in setting a message - assertEquals(antfile + " OUTPUT???" + antfile + " ERROR!!!", getLog()); - } catch (ComparisonFailure cf) { - assertEquals("unexpected log content", - antfile + " ERROR!!!" + antfile + " OUTPUT???", getLog()); - } - } - - public void testRedirector14() { - executeTarget("redirector14"); - if (getProject().getProperty("cat.can.run") == null) { - return; - } - assertEquals("unexpected log output", "blah after blah", getLog()); - } - - public void testRedirector15() throws IOException { - executeTarget("redirector15"); - if (getProject().getProperty("cat.can.run") == null) { - return; - } - assertTrue("error with transcoding", - FILE_UTILS.contentEquals( - getProject().resolveFile("expected/utf-8"), - getProject().resolveFile("redirector.out"))); - } - - public void testRedirector16() { - executeTarget("redirector16"); - } - - public void testRedirector17() { - executeTarget("redirector17"); - } - - public void testRedirector18() { - if (getProject().getProperty("test.can.run") == null) { - return; - } - expectLog("redirector18", getProject().getProperty("ant.file") - + " out" + getProject().getProperty("ant.file") + " err"); - } - - public void testspawn() { - project.executeTarget("init"); - if (project.getProperty("test.can.run") == null) { - return; - } - myBuild = new MonitoredBuild(new File(System.getProperty("root"), BUILD_FILE), "spawn"); - logFile = FILE_UTILS.createTempFile("spawn","log", project.getBaseDir()); - // this is guaranteed by FileUtils#createTempFile - assertTrue("log file not existing", !logFile.exists()); - // make the spawned process run 4 seconds - myBuild.setTimeToWait(TIME_TO_WAIT); - myBuild.setLogFile(logFile.getAbsolutePath()); - myBuild.addBuildListener(new MonitoredBuildListener()); - myBuild.start(); - GregorianCalendar startwait = new GregorianCalendar(); - // this loop runs parallel to the build - while (!buildFinished) { - try { - Thread.sleep(10); - } catch (InterruptedException e) { - System.out.println("my sleep was interrupted"); - } - GregorianCalendar now = new GregorianCalendar(); - // security - if (now.getTime().getTime() - startwait.getTime().getTime() > MAX_BUILD_TIME) { - System.out.println("aborting wait, too long " + (now.getTime().getTime() - startwait.getTime().getTime()) + "milliseconds"); - break; - } - } - // now wait until the spawned process is finished - try { - Thread.sleep((TIME_TO_WAIT) * 1000 + SECURITY_MARGIN); - } catch (InterruptedException e) { - System.out.println("my sleep was interrupted"); - } - // time of the build in milli seconds - long elapsed = myBuild.getTimeElapsed(); - assertTrue("we waited more than the process lasted", TIME_TO_WAIT * 1000 - + SECURITY_MARGIN > elapsed); - logFile = new File(logFile.getAbsolutePath()); - assertTrue("log file found after spawn", logFile.exists()); - } - - public void testExecUnknownOS() { - executeTarget("testExecUnknownOS"); - } - - public void testExecOSFamily() { - executeTarget("testExecOSFamily"); - } - - public void testExecInconsistentSettings() { - executeTarget("testExecInconsistentSettings"); - } - - private static class MonitoredBuild implements Runnable { - private Thread worker; - private File myBuildFile = null; - private String target = null; - private Project project = null; - private int timeToWait = 0; - private String logFile = null; - private GregorianCalendar timeStarted = null; - private GregorianCalendar timeFinished = null; - - public void setLogFile(String logFile) { - this.logFile = logFile; - project.setProperty("logFile", logFile); - } - - public void setTimeToWait(int timeToWait) { - this.timeToWait = timeToWait; - project.setProperty("timeToWait", Long.toString(timeToWait)); - } - - public void addBuildListener(BuildListener bl) { - project.addBuildListener(bl); - } - public MonitoredBuild(File buildFile, String target) { - myBuildFile = buildFile; - this.target = target; - project=new Project(); - project = new Project(); - project.init(); - project.setUserProperty( "ant.file" , myBuildFile.getAbsolutePath() ); - ProjectHelper.configureProject(project, myBuildFile); - } - /** - * - * @return time in millis of the build - */ - public long getTimeElapsed() { - return timeFinished.getTime().getTime() - timeStarted.getTime().getTime(); - } - public void start() { - worker = new Thread(this, myBuildFile.toString() + "/" + target); - worker.start(); - } - public void run() { - startProject(); - } - private void startProject() { - timeStarted = new GregorianCalendar(); - project.executeTarget(target); - timeFinished = new GregorianCalendar(); - } - } - private class MonitoredBuildListener implements BuildListener { - public void buildStarted(BuildEvent event) { - } - - public void buildFinished(BuildEvent event) { - } - - public void targetStarted(BuildEvent event) { - } - - public void targetFinished(BuildEvent event) { - if (event.getTarget().getName().equals("spawn")) { - buildFinished = true; - } - } - - public void taskStarted(BuildEvent event) { - } - - public void taskFinished(BuildEvent event) { - } - - public void messageLogged(BuildEvent event) { - } - } - - //borrowed from TokenFilterTest - private String getFileString(String filename) throws IOException { - String result = null; - FileReader reader = null; - try { - reader = new FileReader(getProject().resolveFile(filename)); - result = FileUtils.readFully(reader); - } catch (IOException eyeOhEx) { - } finally { - FileUtils.close(reader); - } - return result; - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java deleted file mode 100644 index 09e23bb3a..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteJavaTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.MagicNames; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.util.JavaEnvUtils; - -import junit.framework.TestCase; - -/** - * Simple testcase for the ExecuteJava class - mostly stolen from - * ExecuteWatchdogTest. - * - */ -public class ExecuteJavaTest extends TestCase { - - private final static int TIME_OUT = 5000; - - private final static int CLOCK_ERROR=200; - private final static int TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; - - private ExecuteJava ej; - private Project project; - private Path cp; - - public ExecuteJavaTest(String name) { - super(name); - } - - protected void setUp(){ - ej = new ExecuteJava(); - ej.setTimeout(new Long(TIME_OUT)); - project = new Project(); - project.setBasedir("."); - project.setProperty(MagicNames.ANT_HOME, System.getProperty(MagicNames.ANT_HOME)); - cp = new Path(project, getTestClassPath()); - ej.setClasspath(cp); - } - - private Commandline getCommandline(int timetorun) throws Exception { - Commandline cmd = new Commandline(); - cmd.setExecutable(TimeProcess.class.getName()); - cmd.createArgument().setValue(String.valueOf(timetorun)); - return cmd; - } - - public void testNoTimeOut() throws Exception { - Commandline cmd = getCommandline(TIME_OUT/2); - ej.setJavaCommand(cmd); - ej.execute(project); - assertTrue("process should not have been killed", !ej.killedProcess()); - } - - // test that the watchdog ends the process - public void testTimeOut() throws Exception { - Commandline cmd = getCommandline(TIME_OUT*2); - ej.setJavaCommand(cmd); - long now = System.currentTimeMillis(); - ej.execute(project); - long elapsed = System.currentTimeMillis() - now; - assertTrue("process should have been killed", ej.killedProcess()); - - assertTrue("elapse time of "+elapsed - +" ms is less than timeout value of "+TIME_OUT_TEST+" ms", - elapsed >= TIME_OUT_TEST); - assertTrue("elapse time of "+elapsed - +" ms is greater than run value of "+(TIME_OUT*2)+" ms", - elapsed < TIME_OUT*2); - } - - - public void testNoTimeOutForked() throws Exception { - Commandline cmd = getCommandline(TIME_OUT/2); - ej.setJavaCommand(cmd); - ej.fork(cp); - assertTrue("process should not have been killed", !ej.killedProcess()); - } - - // test that the watchdog ends the process - public void testTimeOutForked() throws Exception { - //process doesn't die properly under this combination, - //thus test fails. No workaround? - if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) - && Os.isFamily("dos")) { - return; - } - Commandline cmd = getCommandline(TIME_OUT*2); - ej.setJavaCommand(cmd); - long now = System.currentTimeMillis(); - ej.fork(cp); - long elapsed = System.currentTimeMillis() - now; - assertTrue("process should have been killed", ej.killedProcess()); - - assertTrue("elapse time of "+elapsed - +" ms is less than timeout value of "+TIME_OUT_TEST+" ms", - elapsed >= TIME_OUT_TEST); - assertTrue("elapse time of "+elapsed - +" ms is greater than run value of "+(TIME_OUT*2)+" ms", - elapsed < TIME_OUT*2); - } - - /** - * Dangerous method to obtain the classpath for the test. This is - * severely tighted to the build.xml properties. - */ - private static String getTestClassPath(){ - String classpath = System.getProperty("build.tests"); - if (classpath == null) { - System.err.println("WARNING: 'build.tests' property is not available !"); - classpath = System.getProperty("java.class.path"); - } - - return classpath; - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java deleted file mode 100755 index a748cd373..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteOnTest.java +++ /dev/null @@ -1,599 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - * Unit test for the <apply> task. - */ -public class ExecuteOnTest extends BuildFileTest { - private static final String BUILD_PATH = "src/etc/testcases/taskdefs/exec/"; - private static final String BUILD_FILE = BUILD_PATH + "apply.xml"; - private static final String LINE_SEP = System.getProperty("line.separator"); - - public ExecuteOnTest(String name) { - super(name); - } - - public void setUp() { - configureProject(BUILD_FILE); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testNoRedirect() { - executeTarget("no-redirect"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - - String log = getLog(); - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = log.indexOf(x + " out"); - int yout = log.indexOf(y + " out"); - int zout = log.indexOf(z + " out"); - int xerr = log.indexOf(x + " err"); - int yerr = log.indexOf(y + " err"); - int zerr = log.indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - } - - public void testRedirect1() throws IOException { - executeTarget("redirect1"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String actualOut = getFileString("redirect.out"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = actualOut.indexOf(x + " err"); - int yerr = actualOut.indexOf(y + " err"); - int zerr = actualOut.indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - } - - public void testRedirect2() throws IOException { - executeTarget("redirect2"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String actualOut = getFileString("redirect.out"); - String actualErr = getFileString("redirect.err"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = actualErr.indexOf(x + " err"); - int yerr = actualErr.indexOf(y + " err"); - int zerr = actualErr.indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - } - - public void testRedirect3() throws IOException { - executeTarget("redirect3"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String actualOut = getFileString("redirect.out"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = getLog().indexOf(x + " err"); - int yerr = getLog().indexOf(y + " err"); - int zerr = getLog().indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - - String outProperty = getProject().getProperty("redirect.out"); - int pxout = outProperty.indexOf(x + " out"); - int pyout = outProperty.indexOf(y + " out"); - int pzout = outProperty.indexOf(z + " out"); - assertFalse("pxout=" + pxout, pxout < 0); - assertFalse("pyout=" + pyout, pyout < 0); - assertFalse("pzout=" + pzout, pzout < 0); - assertFalse("pyout < pxout", pyout < pxout); - assertFalse("pzout < pyout", pzout < pyout); - } - - public void testRedirect4() throws IOException { - executeTarget("redirect4"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String actualOut = getFileString("redirect.out"); - String actualErr = getFileString("redirect.err"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = actualErr.indexOf(x + " err"); - int yerr = actualErr.indexOf(y + " err"); - int zerr = actualErr.indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - - String outProperty = getProject().getProperty("redirect.out"); - int pxout = outProperty.indexOf(x + " out"); - int pyout = outProperty.indexOf(y + " out"); - int pzout = outProperty.indexOf(z + " out"); - assertFalse("pxout=" + pxout, pxout < 0); - assertFalse("pyout=" + pyout, pyout < 0); - assertFalse("pzout=" + pzout, pzout < 0); - assertFalse("pyout < pxout", pyout < pxout); - assertFalse("pzout < pyout", pzout < pyout); - - String errorProperty = getProject().getProperty("redirect.err"); - int pxerr = errorProperty.indexOf(x + " err"); - int pyerr = errorProperty.indexOf(y + " err"); - int pzerr = errorProperty.indexOf(z + " err"); - assertFalse("pxerr=" + pxerr, pxerr < 0); - assertFalse("pyerr=" + pyerr, pyerr < 0); - assertFalse("pzerr=" + pzerr, pzerr < 0); - assertFalse("pyerr < pxerr", pyerr < pxerr); - assertFalse("pzerr < pyerr", pzerr < pyerr); - } - - public void testRedirect5() throws IOException { - testRedirect5or6("redirect5"); - } - - public void testRedirect6() throws IOException { - testRedirect5or6("redirect6"); - } - - private void testRedirect5or6(String target) throws IOException { - executeTarget(target); - if (getProject().getProperty("sed.can.run") == null) { - return; - } - - assertPropertyEquals("redirect.out", getProject().replaceProperties( - "blah y z${line.separator}x blah z${line.separator}x y blah")); - assertPropertyEquals("redirect.err", ""); - assertEquals("unexpected output", - "blah y z\nx blah z\nx y blah\n", getFileString("redirect.out")); - assertNull("unexpected error output", getFileString("redirect.err")); - } - - public void testRedirect7() throws IOException { - executeTarget("redirect7"); - if (getProject().getProperty("sed.can.run") == null) { - return; - } - - assertPropertyEquals("redirect.out", "blah y z"); - assertPropertyUnset("redirect.err"); - assertEquals("unexpected output", - "x y blah\n", getFileString("redirect.out")); - assertNull("unexpected error output", getFileString("redirect.err")); - } - - public void testRedirector1() { - executeTarget("init"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - expectBuildException("redirector1", "cannot have > 1 nested s"); - } - - public void testRedirector2() throws IOException { - executeTarget("redirector2"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - - String actualOut = getFileString("redirector.out"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = actualOut.indexOf(x + " err"); - int yerr = actualOut.indexOf(y + " err"); - int zerr = actualOut.indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - } - - public void testRedirector3() throws IOException { - executeTarget("redirector3"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - - String actualOut = getFileString("redirector.out"); - String actualErr = getFileString("redirector.err"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = actualErr.indexOf(x + " err"); - int yerr = actualErr.indexOf(y + " err"); - int zerr = actualErr.indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - } - - public void testRedirector4() throws IOException { - executeTarget("redirector4"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String actualOut = getFileString("redirector.out"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = getLog().indexOf(x + " err"); - int yerr = getLog().indexOf(y + " err"); - int zerr = getLog().indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - - String outProperty = getProject().getProperty("redirector.out"); - int pxout = outProperty.indexOf(x + " out"); - int pyout = outProperty.indexOf(y + " out"); - int pzout = outProperty.indexOf(z + " out"); - assertFalse("pxout=" + pxout, pxout < 0); - assertFalse("pyout=" + pyout, pyout < 0); - assertFalse("pzout=" + pzout, pzout < 0); - assertFalse("pyout < pxout", pyout < pxout); - assertFalse("pzout < pyout", pzout < pyout); - } - - public void testRedirector5() throws IOException { - testRedirector5or6("redirector5"); - } - - public void testRedirector6() throws IOException { - testRedirector5or6("redirector6"); - } - - private void testRedirector5or6(String target) throws IOException { - executeTarget(target); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String actualOut = getFileString("redirector.out"); - String actualErr = getFileString("redirector.err"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = actualErr.indexOf(x + " err"); - int yerr = actualErr.indexOf(y + " err"); - int zerr = actualErr.indexOf(z + " err"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - - String outProperty = getProject().getProperty("redirector.out"); - int pxout = outProperty.indexOf(x + " out"); - int pyout = outProperty.indexOf(y + " out"); - int pzout = outProperty.indexOf(z + " out"); - assertFalse("pxout=" + pxout, pxout < 0); - assertFalse("pyout=" + pyout, pyout < 0); - assertFalse("pzout=" + pzout, pzout < 0); - assertFalse("pyout < pxout", pyout < pxout); - assertFalse("pzout < pyout", pzout < pyout); - - String errorProperty = getProject().getProperty("redirector.err"); - int pxerr = errorProperty.indexOf(x + " err"); - int pyerr = errorProperty.indexOf(y + " err"); - int pzerr = errorProperty.indexOf(z + " err"); - assertFalse("pxerr=" + pxerr, pxerr < 0); - assertFalse("pyerr=" + pyerr, pyerr < 0); - assertFalse("pzerr=" + pzerr, pzerr < 0); - assertFalse("pyerr < pxerr", pyerr < pxerr); - assertFalse("pzerr < pyerr", pzerr < pyerr); - } - - public void testRedirector7() throws IOException { - executeTarget("redirector7"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String actualOut = getFileString("redirector.out"); - String actualErr = getFileString("redirector.err"); - - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = actualOut.indexOf(x + " out"); - int yout = actualOut.indexOf(y + " out"); - int zout = actualOut.indexOf(z + " out"); - int xerr = actualErr.indexOf(x + " ERROR!!!"); - int yerr = actualErr.indexOf(y + " ERROR!!!"); - int zerr = actualErr.indexOf(z + " ERROR!!!"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - - String outProperty = getProject().getProperty("redirector.out"); - int pxout = outProperty.indexOf(x + " out"); - int pyout = outProperty.indexOf(y + " out"); - int pzout = outProperty.indexOf(z + " out"); - assertFalse("pxout=" + pxout, pxout < 0); - assertFalse("pyout=" + pyout, pyout < 0); - assertFalse("pzout=" + pzout, pzout < 0); - assertFalse("pyout < pxout", pyout < pxout); - assertFalse("pzout < pyout", pzout < pyout); - - String errorProperty = getProject().getProperty("redirector.err"); - int pxerr = errorProperty.indexOf(x + " ERROR!!!"); - int pyerr = errorProperty.indexOf(y + " ERROR!!!"); - int pzerr = errorProperty.indexOf(z + " ERROR!!!"); - assertFalse("pxerr=" + pxerr, pxerr < 0); - assertFalse("pyerr=" + pyerr, pyerr < 0); - assertFalse("pzerr=" + pzerr, pzerr < 0); - assertFalse("pyerr < pxerr", pyerr < pxerr); - assertFalse("pzerr < pyerr", pzerr < pyerr); - } - - public void testRedirector8() throws IOException { - executeTarget("redirector8"); - if (getProject().getProperty("sed.can.run") == null) { - return; - } - - assertPropertyEquals("redirector.out", getProject().replaceProperties( - "blah y z${line.separator}x blah z${line.separator}x y blah")); - assertPropertyEquals("redirector.err", ""); - assertEquals("unexpected output", - "blah y z\nx blah z\nx y blah\n", getFileString("redirector.out")); - assertNull("unexpected error output", getFileString("redirector.err")); - } - - public void testRedirector9() throws IOException { - testRedirector9Thru12("redirector9"); - } - - public void testRedirector10() throws IOException { - testRedirector9Thru12("redirector10"); - } - - public void testRedirector11() throws IOException { - testRedirector9Thru12("redirector11"); - } - - public void testRedirector12() throws IOException { - testRedirector9Thru12("redirector12"); - } - - private void testRedirector9Thru12(String target) throws IOException { - executeTarget(target); - if (getProject().getProperty("sed.can.run") == null) { - return; - } - - assertNull("unexpected error output", getFileString("redirector.err")); - assertPropertyEquals("redirector.out", getProject().replaceProperties( - "blah after y after z${line.separator}x after blah after z" - + "${line.separator}x after y after blah")); - assertPropertyEquals("redirector.err", ""); - assertEquals("unexpected output", - "blah after y after z\nx after blah after z" - + "\nx after y after blah\n", getFileString("redirector.out")); - } - - public void testRedirector13() { - executeTarget("redirector13"); - if (getProject().getProperty("test.can.run") == null) { - return; - } - String log = getLog(); - File x = getProject().resolveFile("x"); - File y = getProject().resolveFile("y"); - File z = getProject().resolveFile("z"); - int xout = log.indexOf(x + " OUTPUT???"); - int yout = log.indexOf(y + " OUTPUT???"); - int zout = log.indexOf(z + " OUTPUT???"); - int xerr = log.indexOf(x + " ERROR!!!"); - int yerr = log.indexOf(y + " ERROR!!!"); - int zerr = log.indexOf(z + " ERROR!!!"); - assertFalse("xout=" + xout, xout < 0); - assertFalse("yout=" + yout, yout < 0); - assertFalse("zout=" + zout, zout < 0); - assertFalse("xerr=" + xerr, xerr < 0); - assertFalse("yerr=" + yerr, yerr < 0); - assertFalse("zerr=" + zerr, zerr < 0); - assertFalse("yout < xout", yout < xout); - assertFalse("zout < yout", zout < yout); - assertFalse("yerr < xerr", yerr < xerr); - assertFalse("zerr < yerr", zerr < yerr); - } - - public void testRedirector14() throws IOException { - executeTarget("redirector14"); - if (getProject().getProperty("sed.can.run") == null) { - return; - } - - assertEquals("unexpected log content", - "z after y after blahx after y after blah", getLog()); - - assertEquals("unexpected redirector.out content", - "x after blah after z\n", getFileString("redirector.out")); - - assertNull("unexpected redirector.err content", getFileString("redirector.err")); - } - - public void testIgnoreMissing() { - executeTarget("ignoremissing"); - } - - public void testForce() { - executeTarget("force"); - } - - public void testNoDest() { - executeTarget("testNoDest"); - } - - public void testLsPath() { - testLsPath("lsPath"); - } - - public void testLsPathParallel() { - testLsPath("lsPathParallel"); - } - - private void testLsPath(String target) { - executeTarget(target); - if (getProject().getProperty("ls.can.run") == null) { - return; - } - String foo = getProject().getProperty("foo"); - assertNotNull(foo); - int indNoExt = foo.indexOf("ls" + LINE_SEP); - int indExe = foo.indexOf("ls.exe" + LINE_SEP); - assertTrue(indNoExt >= 0 || indExe >= 0); - } - - //borrowed from TokenFilterTest - private String getFileString(String filename) throws IOException { - String result = null; - FileReader reader = null; - try { - reader = new FileReader(getProject().resolveFile(filename)); - result = FileUtils.readFully(reader); - } finally { - FileUtils.close(reader); - } - return result; - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java deleted file mode 100644 index 92c4a104c..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ExecuteWatchdogTest.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.util.JavaEnvUtils; -import junit.framework.*; -import java.io.*; - -/** - * Simple testcase for the ExecuteWatchdog class. - * - */ -public class ExecuteWatchdogTest extends TestCase { - - private final static long TIME_OUT = 5000; - - private final static String TEST_CLASSPATH = getTestClassPath(); - - private final static int CLOCK_ERROR=200; - private final static long TIME_OUT_TEST=TIME_OUT-CLOCK_ERROR; - - private ExecuteWatchdog watchdog; - - public ExecuteWatchdogTest(String name) { - super(name); - } - - protected void setUp(){ - watchdog = new ExecuteWatchdog(TIME_OUT); - } - - /** - * Dangerous method to obtain the classpath for the test. This is - * severely tighted to the build.xml properties. - */ - private static String getTestClassPath(){ - String classpath = System.getProperty("build.tests"); - if (classpath == null) { - System.err.println("WARNING: 'build.tests' property is not available !"); - classpath = System.getProperty("java.class.path"); - } - - return classpath; - } - - private Process getProcess(long timetorun) throws Exception { - String[] cmdArray = { - JavaEnvUtils.getJreExecutable("java"), "-classpath", TEST_CLASSPATH, - TimeProcess.class.getName(), String.valueOf(timetorun) - }; - //System.out.println("Testing with classpath: " + System.getProperty("java.class.path")); - return Runtime.getRuntime().exec(cmdArray); - } - - private String getErrorOutput(Process p) throws Exception { - BufferedReader err = new BufferedReader( new InputStreamReader(p.getErrorStream()) ); - StringBuffer buf = new StringBuffer(); - String line; - while ( (line = err.readLine()) != null){ - buf.append(line); - } - return buf.toString(); - } - - private int waitForEnd(Process p) throws Exception { - int retcode = p.waitFor(); - if (retcode != 0){ - String err = getErrorOutput(p); - if (err.length() > 0){ - System.err.println("ERROR:"); - System.err.println(err); - } - } - return retcode; - } - - public void testNoTimeOut() throws Exception { - Process process = getProcess(TIME_OUT/2); - watchdog.start(process); - int retCode = waitForEnd(process); - assertTrue("process should not have been killed", !watchdog.killedProcess()); - assertFalse(Execute.isFailure(retCode)); - } - - // test that the watchdog ends the process - public void testTimeOut() throws Exception { - Process process = getProcess(TIME_OUT*2); - long now = System.currentTimeMillis(); - watchdog.start(process); - int retCode = process.waitFor(); - long elapsed = System.currentTimeMillis() - now; - assertTrue("process should have been killed", watchdog.killedProcess()); - // assertTrue("return code is invalid: " + retCode, retCode!=0); - assertTrue("elapse time of "+elapsed+" ms is less than timeout value of "+TIME_OUT_TEST+" ms", elapsed >= TIME_OUT_TEST); - assertTrue("elapse time of "+elapsed+" ms is greater than run value of "+(TIME_OUT*2)+" ms", elapsed < TIME_OUT*2); - } - - // test a process that runs and failed - public void testFailed() throws Exception { - Process process = getProcess(-1); // process should abort - watchdog.start(process); - int retCode = process.waitFor(); - assertTrue("process should not have been killed", !watchdog.killedProcess()); - assertTrue("return code is invalid: " + retCode, retCode!=0); - } - - public void testManualStop() throws Exception { - final Process process = getProcess(TIME_OUT*2); - watchdog.start(process); - - // I assume that starting this takes less than TIME_OUT/2 ms... - Thread thread = new Thread(){ - public void run(){ - try { - process.waitFor(); - } catch(InterruptedException e){ - // not very nice but will do the job - fail("process interrupted in thread"); - } - } - }; - thread.start(); - - // wait for TIME_OUT/2, there should be about TIME_OUT/2 ms remaining before timeout - thread.join(TIME_OUT/2); - - // now stop the watchdog. - watchdog.stop(); - - // wait for the thread to die, should be the end of the process - thread.join(); - - // process should be dead and well finished - assertEquals(0, process.exitValue()); - assertTrue("process should not have been killed", !watchdog.killedProcess()); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/FailTest.java b/src/testcases/org/apache/tools/ant/taskdefs/FailTest.java deleted file mode 100644 index 5628fbb37..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/FailTest.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class FailTest extends BuildFileTest { - - public FailTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/fail.xml"); - } - - public void test1() { - expectBuildExceptionContaining("test1", - "it is required to fail :-)", - "No message"); - } - - public void test2() { - expectSpecificBuildException("test2", - "it is required to fail :-)", - "test2"); - } - - public void testText() { - expectSpecificBuildException("testText", - "it is required to fail :-)", - "testText"); - } - - public void testIf() { - try { - executeTarget("testIf"); - } catch (BuildException be) { - fail("foo has not been defined, testIf must not fail"); - } - project.setProperty("foo", ""); - expectBuildException("testIf", "testIf must fail if foo has been set"); - } - - public void testUnless() { - expectBuildException("testUnless", - "testUnless must fail unless foo has been set"); - project.setProperty("foo", ""); - try { - executeTarget("testUnless"); - } catch (BuildException be) { - fail("foo has been defined, testUnless must not fail"); - } - } - - /** - * see that the different combinations work, and - * that the autogenerated text contains information - * about which condition was not met - */ - public void testIfAndUnless() { - //neither - executeTarget("testIfAndUnless"); - project.setProperty("if", ""); - expectBuildExceptionContaining("testIfAndUnless", - "expect fail on defined(if)", - "if=if and unless=unless"); - project.setProperty("unless", ""); - //this call should succeed as unless overrides if - executeTarget("testIfAndUnless"); - } - /** - * see that the different combinations work, and - * that the autogenerated text contains information - * about which condition was not met - */ - public void testIfAndUnless2() { - project.setProperty("unless", ""); - try { - executeTarget("testIfAndUnless"); - } catch (BuildException be) { - fail("defined(if) && !defined(unless); testIfAndUnless must not fail"); - } - } - - public void testNested1() { - expectSpecificBuildException("testNested1", - "it is required to fail :-)", - "condition satisfied"); - } - - public void testNested2() { - try { - executeTarget("testNested2"); - } catch (BuildException be) { - fail("condition not satisfied; testNested2 must not fail"); - } - } - - public void testNested3() { - expectSpecificBuildException("testNested3", - "it is required to fail :-)", - "testNested3"); - } - - public void testNested4() { - String specificMessage = "Nested conditions " - + "not permitted in conjunction with if/unless attributes"; - - char[] c = {'a', 'b', 'c'}; - StringBuffer target = new StringBuffer("testNested4x"); - - for (int i = 0; i < c.length; i++) { - target.setCharAt(target.length() - 1, c[i]); - expectSpecificBuildException(target.toString(), - "it is required to fail :-)", specificMessage); - } - } - - public void testNested5() { - expectSpecificBuildException("testNested5", - "it is required to fail :-)", - "Only one nested condition is allowed."); - } - - public void testNested6() { - expectSpecificBuildException("testNested6", - "it is required to fail :-)", - "testNested6\ntestNested6\ntestNested6"); - } - - public void testNested7() { - String specificMessage = "A single nested condition is required."; - - char[] c = {'a', 'b'}; - StringBuffer target = new StringBuffer("testNested7x"); - - for (int i = 0; i < c.length; i++) { - target.setCharAt(target.length() - 1, c[i]); - expectSpecificBuildException(target.toString(), - "it is required to fail :-)", specificMessage); - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java b/src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java deleted file mode 100644 index c4e9efbf4..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/FilterTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class FilterTest extends BuildFileTest { - - public FilterTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/filter.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - expectBuildException("test1", "required argument missing"); - } - - public void test2() { - expectBuildException("test2", "required argument missing"); - } - - public void test3() { - expectBuildException("test3", "required argument missing"); - } - - public void test4() { - executeTarget("test4"); - } - - public void test5() { - executeTarget("test5"); - assertEquals("2000", - getFilteredFile("5", "filtered.tmp")); - } - - - public void test6() { - executeTarget("test6"); - assertEquals("2000", - getFilteredFile("6", "taskdefs.tmp/filter1.txt")); - } - - public void test7() { - executeTarget("test7"); - assertEquals("<%@ include file=\"root/some/include.jsp\"%>", - getFilteredFile("7", "filtered.tmp")); - } - - public void test8() { - executeTarget("test8"); - assertEquals("<%@ include file=\"root/some/include.jsp\"%>", - getFilteredFile("8", "taskdefs.tmp/filter2.txt")); - } - - public void test9() { - executeTarget("test9"); - assertEquals("included", - getFilteredFile("9", "taskdefs.tmp/filter3.txt")); - } - - private String getFilteredFile(String testNumber, String filteredFile) { - - String line = null; - File f = new File(getProjectDir(), filteredFile); - if (!f.exists()) { - fail("filter test"+testNumber+" failed"); - } else { - BufferedReader in = null; - try { - in = new BufferedReader(new FileReader(f)); - } catch (FileNotFoundException fnfe) { - fail("filter test"+testNumber+" failed, filtered file: " + f.toString() + " not found"); - } - try { - line = in.readLine(); - in.close(); - } catch (IOException ioe) { - fail("filter test"+testNumber+" failed. IOException while reading filtered file: " + ioe); - } - } - f.delete(); - return line; - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java b/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java deleted file mode 100644 index 98b2cb294..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/FixCrLfTest.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import junit.framework.AssertionFailedError; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class FixCrLfTest extends BuildFileTest { - - public FixCrLfTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/fixcrlf/build.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() throws IOException { - executeTarget("test1"); - } - - public void test2() throws IOException { - executeTarget("test2"); - } - - public void test3() throws IOException { - executeTarget("test3"); - } - - public void test4() throws IOException { - executeTarget("test4"); - } - - public void test5() throws IOException { - executeTarget("test5"); - } - - public void test6() throws IOException { - executeTarget("test6"); - } - - public void test7() throws IOException { - executeTarget("test7"); - } - - public void test8() throws IOException { - executeTarget("test8"); - } - - public void test9() throws IOException { - executeTarget("test9"); - } - - public void testMacLines() throws IOException { - executeTarget("testMacLines"); - } - - public void testNoOverwrite() throws IOException { - executeTarget("testNoOverwrite"); - } - - public void testEncoding() throws IOException { - executeTarget("testEncoding"); - } - - public void testOutputEncoding() throws IOException { - executeTarget("testOutputEncoding"); - } - - public void testLongLines() throws IOException { - executeTarget("testLongLines"); - } - - public void testCrCrLfSequenceUnix() throws IOException { - executeTarget("testCrCrLfSequence-unix"); - } - - public void testCrCrLfSequenceDos() throws IOException { - executeTarget("testCrCrLfSequence-dos"); - } - - public void testCrCrLfSequenceMac() throws IOException { - executeTarget("testCrCrLfSequence-mac"); - } - - public void testFixlastDos() throws IOException { - executeTarget("testFixlastDos"); - } - - public void testFixlastFalseMac() throws IOException { - executeTarget("testFixlastFalseMac"); - } - - public void testFixFile() throws Exception { - executeTarget("testFixFile"); - } - - public void testFixFileExclusive() throws Exception { - expectBuildExceptionContaining("testFixFileExclusive", - FixCRLF.ERROR_FILE_AND_SRCDIR, FixCRLF.ERROR_FILE_AND_SRCDIR); - } - - /** - * Bugzilla Report 20840 - * - * Will fail with an exception if the parent directories do not - * get created. - */ - public void testCreateParentDirs() { - executeTarget("createParentDirs"); - } - - public void testPreserveLastModified() { - executeTarget("testPreserveLastModified"); - } - - public void testFilter1() { - executeTarget("testFilter1"); - } - - public void testFilter2() { - executeTarget("testFilter2"); - } - - public void testFilter3() { - executeTarget("testFilter3"); - } - - public void testFilter4() { - executeTarget("testFilter4"); - } - - public void testFilter5() { - executeTarget("testFilter5"); - } - - public void testFilter6() { - executeTarget("testFilter6"); - } - - public void testFilter7() { - executeTarget("testFilter7"); - } - - public void testFilter8() { - executeTarget("testFilter8"); - } - - public void testFilter9() { - executeTarget("testFilter9"); - } - - public void testCannotDoubleEof() { - executeTarget("testCannotDoubleEof"); - } - - public void testTabInLiteralInComment() { - executeTarget("testTabInLiteralInComment"); - } - - // not used, but public so theoretically must remain for BC? - public void assertEqualContent(File expect, File result) - throws AssertionFailedError, IOException { - if (!result.exists()) { - fail("Expected file "+result+" doesn\'t exist"); - } - - InputStream inExpect = null; - InputStream inResult = null; - try { - inExpect = new BufferedInputStream(new FileInputStream(expect)); - inResult = new BufferedInputStream(new FileInputStream(result)); - - int expectedByte = inExpect.read(); - while (expectedByte != -1) { - assertEquals(expectedByte, inResult.read()); - expectedByte = inExpect.read(); - } - assertEquals("End of file", -1, inResult.read()); - } finally { - if (inResult != null) { - inResult.close(); - } - if (inExpect != null) { - inExpect.close(); - } - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/GUnzipTest.java b/src/testcases/org/apache/tools/ant/taskdefs/GUnzipTest.java deleted file mode 100644 index 57a819666..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/GUnzipTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class GUnzipTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public GUnzipTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/gunzip.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - expectBuildException("test1", "required argument missing"); - } - - public void test2() { - expectBuildException("test2", "attribute src invalid"); - } - - public void testRealTest() throws java.io.IOException { - testRealTest("realTest"); - } - - public void testRealTestWithResource() throws java.io.IOException { - testRealTest("realTestWithResource"); - } - - private void testRealTest(String target) throws java.io.IOException { - executeTarget(target); - assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), - project.resolveFile("asf-logo.gif"))); - } - - public void testTestGzipTask() throws java.io.IOException { - testRealTest("testGzipTask"); - } - - public void testDocumentationClaimsOnCopy() throws java.io.IOException { - testRealTest("testDocumentationClaimsOnCopy"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java b/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java deleted file mode 100644 index dd01d0eab..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/GetTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class GetTest extends BuildFileTest { - - public GetTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/get.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - expectBuildException("test1", "required argument missing"); - } - - public void test2() { - expectBuildException("test2", "required argument missing"); - } - - public void test3() { - expectBuildException("test3", "required argument missing"); - } - - public void test4() { - expectBuildException("test4", "src invalid"); - } - - public void test5() { - expectBuildException("test5", "dest invalid (or no http-server on local machine)"); - } - - public void test6() { - executeTarget("test6"); - } - - public void testUseTimestamp() { - executeTarget("testUseTimestamp"); - } - - public void testUseTomorrow() { - executeTarget("testUseTomorrow"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java b/src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java deleted file mode 100644 index c2426fa3f..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/GzipTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class GzipTest extends BuildFileTest { - - public GzipTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/gzip.xml"); - } - - public void test1() { - expectBuildException("test1", "required argument missing"); - } - - public void test2() { - expectBuildException("test2", "required argument missing"); - } - - public void test3() { - expectBuildException("test3", "required argument missing"); - } - - public void test4() { - expectBuildException("test4", "zipfile must not point to a directory"); - } - - public void testGZip(){ - executeTarget("realTest"); - String log = getLog(); - assertTrue("Expecting message starting with 'Building:' but got '" - + log + "'", log.startsWith("Building:")); - assertTrue("Expecting message ending with 'asf-logo.gif.gz' but got '" - + log + "'", log.endsWith("asf-logo.gif.gz")); - } - - public void testResource(){ - executeTarget("realTestWithResource"); - } - - public void testDateCheck(){ - executeTarget("testDateCheck"); - String log = getLog(); - assertTrue( - "Expecting message ending with 'asf-logo.gif.gz is up to date.' but got '" + log + "'", - log.endsWith("asf-logo.gif.gz is up to date.")); - } - - public void tearDown(){ - executeTarget("cleanup"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java deleted file mode 100644 index ad4d05bcf..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ImportTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; -import java.io.IOException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Location; -import org.apache.tools.ant.Project; - -/** - */ -public class ImportTest extends BuildFileTest { - - public ImportTest(String name) { - super(name); - } - - public void setUp() { - } - - public void tearDown() { - } - - public void testSimpleImport() { - configureProject("src/etc/testcases/taskdefs/import/import.xml"); - assertLogContaining("Before importIn imported topAfter import"); - } - - public void testUnnamedNesting() { - configureProject("src/etc/testcases/taskdefs/import/unnamedImport.xml", - Project.MSG_WARN); - String log = getLog(); - assertTrue("Warnings logged when not expected: " + log, - log.length() == 0); - } - - public void testSerial() { - configureProject("src/etc/testcases/taskdefs/import/subdir/serial.xml"); - assertLogContaining("Unnamed2.xmlUnnamed1.xml"); - String fullLog = getFullLog(); - String substring = "Skipped already imported file"; - assertTrue("expecting full log to contain \"" + substring - + "\" full log was \"" + fullLog + "\"", - fullLog.indexOf(substring) >= 0); - } - - // allow this as imported in targets are only tested when a target is run - public void testImportInTargetNoEffect() { - configureProject("src/etc/testcases/taskdefs/import/subdir/importintarget.xml"); - expectPropertyUnset("no-import", "foo"); - assertTrue(null == getProject().getReference("baz")); - } - - // deactivate this test as imports within targets are not allowed - public void notTestImportInTargetWithEffect() { - configureProject("src/etc/testcases/taskdefs/import/subdir/importintarget.xml"); - expectPropertySet("do-import", "foo", "bar"); - assertNotNull(getProject().getReference("baz")); - } - - public void testImportInTargetNotAllowed() { - configureProject( - "src/etc/testcases/taskdefs/import/subdir/importintarget.xml"); - expectBuildExceptionContaining( - "do-import", "not a top level task", - "import only allowed as a top-level task"); - } - - public void testImportInSequential() { - configureProject( - "src/etc/testcases/taskdefs/import/subdir/importinsequential.xml"); - expectPropertySet("within-imported", "foo", "bar"); - assertNotNull(getProject().getReference("baz")); - } - - public void testImportSameTargets() { - try { - configureProject( - "src/etc/testcases/taskdefs/import/same_target.xml"); - } catch (BuildException ex) { - String message = ex.getMessage(); - if (message.indexOf("Duplicate target") == -1) { - assertTrue("Did not see 'Duplicate target' in '" + message +"'", false); - } - return; - } - assertTrue( - "Did not see build exception", - false); - } - - public void testImportError() { - try { - configureProject( - "src/etc/testcases/taskdefs/import/import_bad_import.xml"); - } catch (BuildException ex) { - Location lo = ex.getLocation(); - assertTrue( - "expected location of build exception to be set", - (lo != null)); - assertTrue( - "expected location to contain calling file", - lo.getFileName().indexOf("import_bad_import.xml") != -1); - assertTrue( - "expected message of ex to contain called file", - ex.getMessage().indexOf("bad.xml") != -1); - return; - } - assertTrue( - "Did not see build exception", - false); - } - - public void testSymlinkedImports() throws Exception { - String ln = "/usr/bin/ln"; - if (!new File(ln).exists()) { - ln = "/bin/ln"; - } - if (!new File(ln).exists()) { - // Running on Windows or something, so skip it. - return; - } - String symlink = "src/etc/testcases/taskdefs/import/symlinks/d3b"; - File symlinkFile = new File(System.getProperty("root"), symlink); - if (Runtime.getRuntime().exec(new String[] {ln, "-s", "d3a", symlinkFile.getAbsolutePath()}).waitFor() != 0) { - throw new IOException("'" + ln + " -s d3a " + symlink + "' failed"); - } - try { - configureProject( - "src/etc/testcases/taskdefs/import/symlinks/d1/p1.xml"); - assertPropertyEquals( - "ant.file.p2", - new File(System.getProperty("root"), "src/etc/testcases/taskdefs/import/symlinks/d2/p2.xml") - .getAbsolutePath()); - assertPropertyEquals( - "ant.file.p3", - new File(System.getProperty("root"), "src/etc/testcases/taskdefs/import/symlinks/d3b/p3.xml") - .getAbsolutePath()); - } finally { - symlinkFile.delete(); - } - } - - public void testTargetFirst() { - configureProject("src/etc/testcases/taskdefs/import/importtargetfirst.xml"); - assertLogContaining("Importing targetfirstAfter target firstAfter importing"); - } - - public void testTargetName() { - configureProject("src/etc/testcases/taskdefs/import/c.xml"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/InitializeClassTest.java b/src/testcases/org/apache/tools/ant/taskdefs/InitializeClassTest.java deleted file mode 100644 index 0994e1723..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/InitializeClassTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - * Test to see if static initializers are invoked the same way - * when is invoked in forked and unforked modes. - * - */ -public class InitializeClassTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - private File f1 = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/forkedout"); - private File f2 = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/unforkedout"); - - public InitializeClassTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/initializeclass.xml"); - } - - public void testAll() throws IOException { - executeTarget("forked"); - PrintStream ps = System.out; - PrintStream newps = new PrintStream(new FileOutputStream(f2)); - System.setOut(newps); - project.executeTarget("unforked"); - System.setOut(ps); - newps.close(); - assertTrue("Forked - non-forked mismatch", FILE_UTILS.contentEquals(f1, f2)); - } - - public void tearDown() { - f1.delete(); - f2.delete(); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/InputTest.java b/src/testcases/org/apache/tools/ant/taskdefs/InputTest.java deleted file mode 100644 index debdc0c57..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/InputTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.FileInputStream; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.input.PropertyFileInputHandler; - - -public class InputTest extends BuildFileTest { - - public InputTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/input.xml"); - System.getProperties() - .put(PropertyFileInputHandler.FILE_NAME_KEY, - getProject().resolveFile("input.properties") - .getAbsolutePath()); - getProject().setInputHandler(new PropertyFileInputHandler()); - } - - public void test1() { - executeTarget("test1"); - } - - public void test2() { - executeTarget("test2"); - } - - public void test3() { - expectSpecificBuildException("test3", "invalid input", - "Found invalid input test for \'" - + getKey("All data is" - + " going to be deleted from DB" - + " continue?") - + "\'"); - } - - public void test5() { - executeTarget("test5"); - } - - public void test6() { - executeTarget("test6"); - assertEquals("scott", project.getProperty("db.user")); - } - - public void testPropertyFileInlineHandler() { - executeTarget("testPropertyFileInlineHandler"); - } - - public void testDefaultInlineHandler() { - stdin(); - executeTarget("testDefaultInlineHandler"); - } - - public void testGreedyInlineHandler() { - stdin(); - executeTarget("testGreedyInlineHandler"); - } - - public void testGreedyInlineHandlerClassname() { - stdin(); - executeTarget("testGreedyInlineHandlerClassname"); - } - - public void testGreedyInlineHandlerRefid() { - stdin(); - executeTarget("testGreedyInlineHandlerRefid"); - } - - private void stdin() { - try { - System.setIn(new FileInputStream( - getProject().resolveFile("input.stdin"))); - } catch (Exception e) { - throw e instanceof RuntimeException - ? (RuntimeException) e : new RuntimeException(e.getMessage()); - } - } - - private String getKey(String key) { - return key; // XXX what is this for? - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java deleted file mode 100644 index 726956ee8..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.IOException; -import java.io.Reader; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class JarTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - private static String tempJar = "tmp.jar"; - private static String tempDir = "jartmp/"; - private Reader r1, r2; - - public JarTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/jar.xml"); - } - - public void tearDown() { - if (r1 != null) { - try { - r1.close(); - } catch (IOException e) { - } - } - if (r2 != null) { - try { - r2.close(); - } catch (IOException e) { - } - } - - executeTarget("cleanup"); - } - - public void test1() { - expectBuildException("test1", "required argument not specified"); - } - - public void test2() { - expectBuildException("test2", "manifest file does not exist"); - } - - public void test3() { - expectBuildException("test3", "Unrecognized whenempty attribute: format C: /y"); - } - - public void test4() { - executeTarget("test4"); - File jarFile = new File(getProjectDir(), tempJar); - assertTrue(jarFile.exists()); - } - - public void testNoRecreateWithoutUpdate() { - testNoRecreate("test4"); - } - - public void testNoRecreateWithUpdate() { - testNoRecreate("testNoRecreateWithUpdate"); - } - - private void testNoRecreate(String secondTarget) { - executeTarget("test4"); - File jarFile = new File(getProjectDir(), tempJar); - long jarModifiedDate = jarFile.lastModified(); - try { - Thread.sleep(2500); - } catch (InterruptedException e) { - } // end of try-catch - executeTarget(secondTarget); - assertEquals("jar has not been recreated in " + secondTarget, - jarModifiedDate, jarFile.lastModified()); - } - - public void testRecreateWithoutUpdateAdditionalFiles() { - testRecreate("test4", "testRecreateWithoutUpdateAdditionalFiles"); - } - - public void testRecreateWithUpdateAdditionalFiles() { - testRecreate("test4", "testRecreateWithUpdateAdditionalFiles"); - } - - public void testRecreateWithoutUpdateNewerFile() { - testRecreate("testRecreateNewerFileSetup", - "testRecreateWithoutUpdateNewerFile"); - } - - public void testRecreateWithUpdateNewerFile() { - testRecreate("testRecreateNewerFileSetup", - "testRecreateWithUpdateNewerFile"); - } - - private void testRecreate(String firstTarget, String secondTarget) { - executeTarget(firstTarget); - long sleeptime = 3000 - + FILE_UTILS.getFileTimestampGranularity(); - try { - Thread.sleep(sleeptime); - } catch (InterruptedException e) { - } // end of try-catch - File jarFile = new File(getProjectDir(), tempJar); - long jarModifiedDate = jarFile.lastModified(); - executeTarget(secondTarget); - jarFile = new File(getProjectDir(), tempJar); - assertTrue("jar has been recreated in " + secondTarget, - jarModifiedDate < jarFile.lastModified()); - } - - public void testManifestStaysIntact() - throws IOException, ManifestException { - executeTarget("testManifestStaysIntact"); - - r1 = new FileReader(getProject() - .resolveFile(tempDir + "manifest")); - r2 = new FileReader(getProject() - .resolveFile(tempDir + "META-INF/MANIFEST.MF")); - Manifest mf1 = new Manifest(r1); - Manifest mf2 = new Manifest(r2); - assertEquals(mf1, mf2); - } - - public void testNoRecreateBasedirExcludesWithUpdate() { - testNoRecreate("testNoRecreateBasedirExcludesWithUpdate"); - } - - public void testNoRecreateBasedirExcludesWithoutUpdate() { - testNoRecreate("testNoRecreateBasedirExcludesWithoutUpdate"); - } - - public void testNoRecreateZipfilesetExcludesWithUpdate() { - testNoRecreate("testNoRecreateZipfilesetExcludesWithUpdate"); - } - - public void testNoRecreateZipfilesetExcludesWithoutUpdate() { - testNoRecreate("testNoRecreateZipfilesetExcludesWithoutUpdate"); - } - - public void testRecreateZipfilesetWithoutUpdateAdditionalFiles() { - testRecreate("test4", - "testRecreateZipfilesetWithoutUpdateAdditionalFiles"); - } - - public void testRecreateZipfilesetWithUpdateAdditionalFiles() { - testRecreate("test4", - "testRecreateZipfilesetWithUpdateAdditionalFiles"); - } - - public void testRecreateZipfilesetWithoutUpdateNewerFile() { - testRecreate("testRecreateNewerFileSetup", - "testRecreateZipfilesetWithoutUpdateNewerFile"); - } - - public void testRecreateZipfilesetWithUpdateNewerFile() { - testRecreate("testRecreateNewerFileSetup", - "testRecreateZipfilesetWithUpdateNewerFile"); - } - - public void testCreateWithEmptyFileset() { - executeTarget("testCreateWithEmptyFilesetSetUp"); - executeTarget("testCreateWithEmptyFileset"); - executeTarget("testCreateWithEmptyFileset"); - } - - public void testUpdateIfOnlyManifestHasChanged() { - executeTarget("testUpdateIfOnlyManifestHasChanged"); - File jarXml = getProject().resolveFile(tempDir + "jar.xml"); - assertTrue(jarXml.exists()); - } - - // bugzilla report 10262 - public void testNoDuplicateIndex() throws IOException { - ZipFile archive = null; - try { - executeTarget("testIndexTests"); - archive = new ZipFile(getProject().resolveFile(tempJar)); - Enumeration e = archive.entries(); - int numberOfIndexLists = 0; - while (e.hasMoreElements()) { - ZipEntry ze = (ZipEntry) e.nextElement(); - if (ze.getName().equals("META-INF/INDEX.LIST")) { - numberOfIndexLists++; - } - } - assertEquals(1, numberOfIndexLists); - } finally { - if (archive != null) { - archive.close(); - } - } - } - - // bugzilla report 16972 - public void testRootFilesInIndex() throws IOException { - ZipFile archive = null; - try { - executeTarget("testIndexTests"); - archive = new ZipFile(getProject().resolveFile(tempJar)); - ZipEntry ze = archive.getEntry("META-INF/INDEX.LIST"); - InputStream is = archive.getInputStream(ze); - BufferedReader r = new BufferedReader(new InputStreamReader(is, - "UTF8")); - boolean foundSub = false; - boolean foundSubFoo = false; - boolean foundFoo = false; - - String line = r.readLine(); - while (line != null) { - if (line.equals("foo")) { - foundFoo = true; - } else if (line.equals("sub")) { - foundSub = true; - } else if (line.equals("sub/foo")) { - foundSubFoo = true; - } - line = r.readLine(); - } - - assertTrue(foundSub); - assertTrue(!foundSubFoo); - assertTrue(foundFoo); - } finally { - if (archive != null) { - archive.close(); - } - } - } - public void testManifestOnlyJar() { - expectLogContaining("testManifestOnlyJar", "Building MANIFEST-only jar: "); - File manifestFile = getProject().resolveFile(tempDir + "META-INF" + File.separator + "MANIFEST.MF"); - assertTrue(manifestFile.exists()); - } - - public void testIndexJarsPlusJarMarker() { - executeTarget("testIndexJarsPlusJarMarker"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java b/src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java deleted file mode 100644 index 3ae80c1e5..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/JavaTest.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.TeeOutputStream; - -/** - * stress out java task - * */ -public class JavaTest extends BuildFileTest { - - private static final int TIME_TO_WAIT = 1; - // wait 1 second extra to allow for java to start ... - // this time was OK on a Win NT machine and on nagoya - private static final int SECURITY_MARGIN = 2000; - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - private boolean runFatalTests=false; - - public JavaTest(String name) { - super(name); - } - - /** - * configure the project. - * if the property junit.run.fatal.tests is set we run - * the fatal tests - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/java.xml"); - - //final String propname="tests-classpath.value"; - //String testClasspath=System.getProperty(propname); - //System.out.println("Test cp="+testClasspath); - String propname="tests-classpath.value"; - String runFatal=System.getProperty("junit.run.fatal.tests"); - if(runFatal!=null) - runFatalTests=true; - } - - public void tearDown() { - // remove log file from testSpawn - project.executeTarget("cleanup"); - } - - public void testNoJarNoClassname(){ - expectBuildExceptionContaining("testNoJarNoClassname", - "parameter validation", - "Classname must not be null."); - } - - public void testJarNoFork() { - expectBuildExceptionContaining("testJarNoFork", - "parameter validation", - "Cannot execute a jar in non-forked mode. " - + "Please set fork='true'. "); - } - - public void testJarAndClassName() { - expectBuildException("testJarAndClassName", - "Should not be able to set both classname AND jar"); - } - - - public void testClassnameAndJar() { - expectBuildException("testClassnameAndJar", - "Should not be able to set both classname AND jar"); - } - - public void testRun() { - executeTarget("testRun"); - } - - - - /** this test fails but we ignore the return value; - * we verify that failure only matters when failonerror is set - */ - public void testRunFail() { - if(runFatalTests) { - executeTarget("testRunFail"); - } - } - - public void testRunFailFoe() { - if(runFatalTests) { - expectBuildExceptionContaining("testRunFailFoe", - "java failures being propagated", - "Java returned:"); - } -} - - public void testRunFailFoeFork() { - expectBuildExceptionContaining("testRunFailFoeFork", - "java failures being propagated", - "Java returned:"); - } - - public void testExcepting() { - expectLogContaining("testExcepting", - "Exception raised inside called program"); - } - - public void testExceptingFork() { - expectLogContaining("testExceptingFork", - "Java Result:"); - } - - public void testExceptingFoe() { - expectBuildExceptionContaining("testExceptingFoe", - "passes exception through", - "Exception raised inside called program"); - } - - public void testExceptingFoeFork() { - expectBuildExceptionContaining("testExceptingFoeFork", - "exceptions turned into error codes", - "Java returned:"); - } - - public void testResultPropertyZero() { - executeTarget("testResultPropertyZero"); - assertEquals("0",project.getProperty("exitcode")); - } - - public void testResultPropertyNonZero() { - executeTarget("testResultPropertyNonZero"); - assertEquals("2",project.getProperty("exitcode")); - } - - public void testResultPropertyZeroNoFork() { - executeTarget("testResultPropertyZeroNoFork"); - assertEquals("0",project.getProperty("exitcode")); - } - - public void testResultPropertyNonZeroNoFork() { - executeTarget("testResultPropertyNonZeroNoFork"); - assertEquals("-1",project.getProperty("exitcode")); - } - - public void testRunFailWithFailOnError() { - expectBuildExceptionContaining("testRunFailWithFailOnError", - "non zero return code", - "Java returned:"); - } - - public void testRunSuccessWithFailOnError() { - executeTarget("testRunSuccessWithFailOnError"); - } - - public void testSpawn() { - File logFile = FILE_UTILS.createTempFile("spawn","log", project.getBaseDir()); - // this is guaranteed by FileUtils#createTempFile - assertTrue("log file not existing", !logFile.exists()); - project.setProperty("logFile", logFile.getAbsolutePath()); - project.setProperty("timeToWait", Long.toString(TIME_TO_WAIT)); - project.executeTarget("testSpawn"); - try { - Thread.sleep(TIME_TO_WAIT * 1000 + SECURITY_MARGIN); - } catch (Exception ex) { - System.out.println("my sleep was interrupted"); - } - // let's be nice with the next generation of developers - if (!logFile.exists()) { - System.out.println("suggestion: increase the constant" - + " SECURITY_MARGIN to give more time for java to start."); - } - assertTrue("log file exists", logFile.exists()); - } - - public void testRedirect1() { - executeTarget("redirect1"); - } - - public void testRedirect2() { - executeTarget("redirect2"); - } - - public void testRedirect3() { - executeTarget("redirect3"); - } - - public void testRedirector1() { - executeTarget("redirector1"); - } - - public void testRedirector2() { - executeTarget("redirector2"); - } - - /** - * entry point class with no dependencies other - * than normal JRE runtime - */ - public static class EntryPoint { - - /** - * this entry point is used by the java.xml tests to - * generate failure strings to handle - * argv[0] = exit code (optional) - * argv[1] = string to print to System.out (optional) - * argv[1] = string to print to System.err (optional) - */ - public static void main(String[] argv) { - int exitCode=0; - if(argv.length>0) { - try { - exitCode=Integer.parseInt(argv[0]); - } catch(NumberFormatException nfe) { - exitCode=-1; - } - } - if(argv.length>1) { - System.out.println(argv[1]); - } - if(argv.length>2) { - System.err.println(argv[2]); - } - if(exitCode!=0) { - System.exit(exitCode); - } - } - } - - /** - * entry point class with no dependencies other - * than normal JRE runtime - */ - public static class ExceptingEntryPoint { - - /** - * throw a run time exception which does not need - * to be in the signature of the entry point - */ - public static void main(String[] argv) { - throw new NullPointerException("Exception raised inside called program"); - } - } - /** - * test class for spawn - */ - public static class SpawnEntryPoint { - public static void main(String [] argv) { - int sleepTime = 10; - String logFile = "spawn.log"; - if (argv.length >= 1) { - sleepTime = Integer.parseInt(argv[0]); - } - if (argv.length >= 2) - { - logFile = argv[1]; - } - OutputStreamWriter out = null; - try { - Thread.sleep(sleepTime * 1000); - } catch (InterruptedException ex) { - System.out.println("my sleep was interrupted"); - } - - try { - File dest = new File(logFile); - FileOutputStream fos = new FileOutputStream(dest); - out = new OutputStreamWriter(fos); - out.write("bye bye\n"); - } catch (Exception ex) {} - finally { - try {out.close();} catch (IOException ioe) {}} - - } - } - - /** - * entry point class to pipe System.in to the specified stream: - * "out", "err", or "both". If none specified, swallow the input. - */ - public static class PipeEntryPoint { - - /** - * pipe input to specified output - */ - public static void main(String[] args) { - OutputStream os = null; - if (args.length > 0) { - if ("out".equalsIgnoreCase(args[0])) { - os = System.out; - } else if ("err".equalsIgnoreCase(args[0])) { - os = System.err; - } else if ("both".equalsIgnoreCase(args[0])) { - os = new TeeOutputStream(System.out, System.err); - } - } - if (os != null) { - Thread t = new Thread(new StreamPumper(System.in, os, true)); - t.start(); - try { - t.join(); - } catch (InterruptedException eyeEx) { - } - } - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java b/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java deleted file mode 100644 index 9b234cf63..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/JavacTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.compilers.CompilerAdapter; -import org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory; -import org.apache.tools.ant.taskdefs.compilers.Javac12; -import org.apache.tools.ant.taskdefs.compilers.Javac13; -import org.apache.tools.ant.taskdefs.compilers.JavacExternal; -import org.apache.tools.ant.util.JavaEnvUtils; - -import junit.framework.TestCase; - -/** - * Testcase for . - * - */ -public class JavacTest extends TestCase { - - private Project project; - private Javac javac; - - public JavacTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.init(); - javac = new Javac(); - javac.setProject(project); - } - - /** - * Test setting the name of the javac executable. - */ - public void testForkedExecutableName() { - assertNull("no fork means no executable", javac.getJavacExecutable()); - - project.setProperty("build.compiler", "modern"); - assertNull("no fork means no executable", javac.getJavacExecutable()); - - javac.setFork(true); - assertNotNull("normal fork", javac.getJavacExecutable()); - assertTrue("name should contain \"javac\"", - javac.getJavacExecutable().indexOf("javac") > -1); - - project.setProperty("build.compiler", "extJavac"); - javac.setFork(false); - assertNotNull("fork via property", javac.getJavacExecutable()); - assertTrue("name should contain \"javac\"", - javac.getJavacExecutable().indexOf("javac") > -1); - - project.setProperty("build.compiler", "whatever"); - assertNull("no fork and not extJavac means no executable", - javac.getJavacExecutable()); - - String myJavac = "Slartibartfast"; - javac.setFork(true); - javac.setExecutable(myJavac); - assertEquals(myJavac, javac.getJavacExecutable()); - } - - /** - * Test nested compiler args. - */ - public void testCompilerArg() { - String[] args = javac.getCurrentCompilerArgs(); - assertNotNull(args); - assertEquals("no args", 0, args.length); - - Javac.ImplementationSpecificArgument arg = javac.createCompilerArg(); - String ford = "Ford"; - String prefect = "Prefect"; - String testArg = ford + " " + prefect; - arg.setValue(testArg); - args = javac.getCurrentCompilerArgs(); - assertEquals("unconditional single arg", 1, args.length); - assertEquals(testArg, args[0]); - - arg.setCompiler("jikes"); - args = javac.getCurrentCompilerArgs(); - assertNotNull(args); - assertEquals("implementation is jikes but build.compiler is null", - 0, args.length); - - project.setProperty("build.compiler", "jvc"); - args = javac.getCurrentCompilerArgs(); - assertNotNull(args); - assertEquals("implementation is jikes but build.compiler is jvc", - 0, args.length); - - project.setProperty("build.compiler", "jikes"); - args = javac.getCurrentCompilerArgs(); - assertEquals("both are jikes", 1, args.length); - assertEquals(testArg, args[0]); - - arg.setLine(testArg); - args = javac.getCurrentCompilerArgs(); - assertEquals("split at space", 2, args.length); - assertEquals(ford, args[0]); - assertEquals(prefect, args[1]); - } - - /** - * Test nested compiler args in the fork="true" and - * implementation="extJavac" case. - */ - public void testCompilerArgForForkAndExtJavac() { - Javac.ImplementationSpecificArgument arg = javac.createCompilerArg(); - String ford = "Ford"; - String prefect = "Prefect"; - String testArg = ford + " " + prefect; - arg.setValue(testArg); - arg.setCompiler("extJavac"); - javac.setFork(true); - String[] args = javac.getCurrentCompilerArgs(); - assertEquals("both are forked javac", 1, args.length); - assertEquals(testArg, args[0]); - } - - /** - * Test compiler attribute. - */ - public void testCompilerAttribute() { - // check defaults - String compiler = javac.getCompiler(); - assertNotNull(compiler); - if (System.getProperty("build.compiler") != null) { - assertEquals(System.getProperty("build.compiler"), - compiler); - } else { - assertTrue("default value", - "javac1.1".equals(compiler) - || "javac1.2".equals(compiler) - || "javac1.3".equals(compiler) - || "javac1.4".equals(compiler) - || "javac1.5".equals(compiler) - || "classic".equals(compiler)); - } - - javac.setFork(true); - assertNotNull(javac.getCompiler()); - assertEquals("extJavac", javac.getCompiler()); - assertEquals(compiler, javac.getCompilerVersion()); - - // check build.compiler provides defaults - javac = new Javac(); - javac.setProject(project); - // setUserProperty to override system properties - project.setUserProperty("build.compiler", "jikes"); - compiler = javac.getCompiler(); - assertNotNull(compiler); - assertEquals("jikes", compiler); - - javac.setFork(true); - compiler = javac.getCompiler(); - assertNotNull(compiler); - assertEquals("jikes", compiler); - - // check attribute overrides build.compiler - javac.setFork(false); - javac.setCompiler("jvc"); - compiler = javac.getCompiler(); - assertNotNull(compiler); - assertEquals("jvc", compiler); - - javac.setFork(true); - compiler = javac.getCompiler(); - assertNotNull(compiler); - assertEquals("jvc", compiler); - } - - public void testCompilerAdapter() { - if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) - || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) { - javac.setCompiler("javac1.1"); - } else { - javac.setCompiler("javac1.4"); - } - - javac.setDepend(true); - CompilerAdapter adapter = - CompilerAdapterFactory.getCompiler(javac.getCompiler(), javac); - - if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) - || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) { - assertTrue(adapter instanceof Javac12); - } else { - assertTrue(adapter instanceof Javac13); - } - - javac.setFork(true); - adapter = - CompilerAdapterFactory.getCompiler(javac.getCompiler(), javac); - assertTrue(adapter instanceof JavacExternal); - } - - public void testSourceNoDefault() { - assertNull(javac.getSource()); - } - - public void testSourceWithDefault() { - project.setNewProperty("ant.build.javac.source", "1.4"); - assertEquals("1.4", javac.getSource()); - } - - public void testSourceOverridesDefault() { - project.setNewProperty("ant.build.javac.source", "1.4"); - javac.setSource("1.5"); - assertEquals("1.5", javac.getSource()); - } - - public void testTargetNoDefault() { - assertNull(javac.getTarget()); - } - - public void testTargetWithDefault() { - project.setNewProperty("ant.build.javac.target", "1.4"); - assertEquals("1.4", javac.getTarget()); - } - - public void testTargetOverridesDefault() { - project.setNewProperty("ant.build.javac.target", "1.4"); - javac.setTarget("1.5"); - assertEquals("1.5", javac.getTarget()); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/JavadocTest.java b/src/testcases/org/apache/tools/ant/taskdefs/JavadocTest.java deleted file mode 100755 index f27f80b5e..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/JavadocTest.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; - -public class JavadocTest extends BuildFileTest { - - public JavadocTest(String name) { - super(name); - } - - private static final String BUILD_PATH = "src/etc/testcases/taskdefs/javadoc/"; - private static final String BUILD_FILENAME = "javadoc.xml"; - private static final String BUILD_FILE = BUILD_PATH + BUILD_FILENAME; - - protected void setUp() throws Exception { - super.setUp(); - configureProject(BUILD_FILE); - } - - // PR 38370 - public void testDirsetPath() throws Exception { - executeTarget("dirsetPath"); - } - - // PR 38370 - public void testDirsetPathWithoutPackagenames() throws Exception { - try { - executeTarget("dirsetPathWithoutPackagenames"); - } catch (BuildException e) { - fail("Contents of path should be picked up without specifying package names: " + e); - } - } - - // PR 38370 - public void testNestedDirsetPath() throws Exception { - executeTarget("nestedDirsetPath"); - } - - // PR 38370 - public void testFilesetPath() throws Exception { - try { - executeTarget("filesetPath"); - } catch (BuildException e) { - fail("A path can contain filesets: " + e); - } - } - - // PR 38370 - public void testNestedFilesetPath() throws Exception { - try { - executeTarget("nestedFilesetPath"); - } catch (BuildException e) { - fail("A path can contain nested filesets: " + e); - } - } - - // PR 38370 - public void testFilelistPath() throws Exception { - try { - executeTarget("filelistPath"); - } catch (BuildException e) { - fail("A path can contain filelists: " + e); - } - } - - // PR 38370 - public void testNestedFilelistPath() throws Exception { - try { - executeTarget("nestedFilelistPath"); - } catch (BuildException e) { - fail("A path can contain nested filelists: " + e); - } - } - - // PR 38370 - public void testPathelementPath() throws Exception { - executeTarget("pathelementPath"); - } - - // PR 38370 - public void testPathelementLocationPath() throws Exception { - try { - executeTarget("pathelementLocationPath"); - } catch (BuildException e) { - fail("A path can contain pathelements pointing to a file: " + e); - } - } - - // PR 38370 - public void testNestedSource() throws Exception { - executeTarget("nestedSource"); - } - - // PR 38370 - public void testNestedFilesetRef() throws Exception { - executeTarget("nestedFilesetRef"); - } - - // PR 38370 - public void testNestedFilesetRefInPath() throws Exception { - executeTarget("nestedFilesetRefInPath"); - } - - public void testNestedFilesetNoPatterns() throws Exception { - executeTarget("nestedFilesetNoPatterns"); - } - - public void testDoublyNestedFileset() throws Exception { - executeTarget("doublyNestedFileset"); - } - - public void testDoublyNestedFilesetNoPatterns() throws Exception { - executeTarget("doublyNestedFilesetNoPatterns"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/LengthTest.java b/src/testcases/org/apache/tools/ant/taskdefs/LengthTest.java deleted file mode 100755 index a88d7b687..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/LengthTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -public class LengthTest extends BuildFileTest { - - public LengthTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/length.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testEach() { - executeTarget("testEach"); - } - - public void testEachCondition() { - executeTarget("testEachCondition"); - } - - public void testAll() { - executeTarget("testAll"); - } - - public void testAllCondition() { - executeTarget("testAllCondition"); - } - - public void testFile() { - executeTarget("testFile"); - } - - public void testFileCondition() { - executeTarget("testFileCondition"); - } - - public void testBoth() { - executeTarget("testBoth"); - } - - public void testBothCondition() { - executeTarget("testBothCondition"); - } - - public void testDupes() { - executeTarget("testDupes"); - } - - public void testDupesCondition() { - executeTarget("testDupesCondition"); - } - - public void testString() { - executeTarget("testString"); - } - - public void testStringCondition() { - executeTarget("testStringCondition"); - } - - public void testTrimString() { - executeTarget("testTrimString"); - } - - public void testTrimStringCondition() { - executeTarget("testTrimStringCondition"); - } - - public void testNoTrimString() { - executeTarget("testNoTrimString"); - } - - public void testNoTrimStringCondition() { - executeTarget("testNoTrimStringCondition"); - } - - public void testStringFile() { - expectBuildExceptionContaining("testStringFile", - "should fail", "incompatible"); - } - - public void testTrimFile() { - expectBuildExceptionContaining("testTrimFile", - "should fail", "string length function only"); - } - - public void testImmutable() { - executeTarget("testImmutable"); - } - - public void testZipFileSet() { - executeTarget("testZipFileSet"); - } - - public void testZipFileSetCondition() { - executeTarget("testZipFileSetCondition"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/LoadFileTest.java b/src/testcases/org/apache/tools/ant/taskdefs/LoadFileTest.java deleted file mode 100644 index 479a6c364..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/LoadFileTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; - -/** - * Test the load file task - * - * @created 10 December 2001 - */ -public class LoadFileTest extends BuildFileTest { - - /** - * Constructor for the LoadFileTest object - * - * @param name Description of Parameter - */ - public LoadFileTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/loadfile.xml"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("cleanup"); - } - - - /** - * A unit test for JUnit - */ - public void testNoSourcefileDefined() { - expectBuildException("testNoSourcefileDefined", - "source file not defined"); - } - - - /** - * A unit test for JUnit - */ - public void testNoPropertyDefined() { - expectBuildException("testNoPropertyDefined", - "output property not defined"); - } - - - /** - * A unit test for JUnit - */ - public void testNoSourcefilefound() { - expectBuildExceptionContaining("testNoSourcefilefound", - "File not found", " doesn't exist"); - } - - /** - * A unit test for JUnit - */ - public void testFailOnError() - throws BuildException { - expectPropertyUnset("testFailOnError","testFailOnError"); - } - - - /** - * A unit test for JUnit - */ - public void testLoadAFile() - throws BuildException { - executeTarget("testLoadAFile"); - if(project.getProperty("testLoadAFile").indexOf("eh?")<0) { - fail("property is not all in the file"); - } - } - - - /** - * A unit test for JUnit - */ - public void testLoadAFileEnc() - throws BuildException { - executeTarget("testLoadAFileEnc"); - if(project.getProperty("testLoadAFileEnc")==null) { - fail("file load failed"); - } - } - - /** - * A unit test for JUnit - */ - public void testEvalProps() - throws BuildException { - executeTarget("testEvalProps"); - if(project.getProperty("testEvalProps").indexOf("rain")<0) { - fail("property eval broken"); - } - } - - /** - * Test FilterChain and FilterReaders - */ - public void testFilterChain() - throws BuildException { - executeTarget("testFilterChain"); - if(project.getProperty("testFilterChain").indexOf("World!")<0) { - fail("Filter Chain broken"); - } - } - - /** - * Test StripJavaComments filterreader functionality. - */ - public final void testStripJavaComments() - throws BuildException { - executeTarget("testStripJavaComments"); - final String expected = project.getProperty("expected"); - final String generated = project.getProperty("testStripJavaComments"); - assertEquals(expected, generated); - } - - /** - * A unit test for JUnit - */ - public void testOneLine() - throws BuildException { - expectPropertySet("testOneLine","testOneLine","1,2,3,4"); - - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/LoadPropertiesTest.java b/src/testcases/org/apache/tools/ant/taskdefs/LoadPropertiesTest.java deleted file mode 100644 index 24b7413e0..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/LoadPropertiesTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class LoadPropertiesTest extends BuildFileTest { - - public LoadPropertiesTest(String name) { - super(name); - } - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/loadproperties.xml"); - } - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("cleanup"); - } - - public void testPrefixedProperties() { - executeTarget("testPrefixedProperties"); - String url = project.getProperty("server1.http.url"); - assertEquals("http://localhost:80", url); - } - - public void testPropertiesFromResource() { - executeTarget("testPropertiesFromResource"); - executeTarget("loadPropertiesCheck"); - } - - public void testPropertiesFromFileSet() { - executeTarget("testPropertiesFromFileSet"); - executeTarget("loadPropertiesCheck"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java b/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java deleted file mode 100644 index d24096c40..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class MacroDefTest extends BuildFileTest { - public MacroDefTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/macrodef.xml"); - } - - public void testSimple() { - expectLog("simple", "Hello World"); - } - - public void testText() { - expectLog("text", "Inner Text"); - } - - public void testDuplicateAttribute() { - expectBuildException( - "duplicate.attribute", - "the attribute text has already been specified"); - } - - public void testDuplicateElement() { - expectBuildException( - "duplicate.element", - "the element text has already been specified"); - } - - public void testUri() { - expectLog("uri", "Hello World"); - } - - public void testNested() { - expectLog("nested", "A nested element"); - } - - public void testDouble() { - expectLog( - "double", - "@{prop} is 'property', value of ${property} is 'A property value'"); - } - - public void testIgnoreCase() { - expectLog( - "ignorecase", - "a is ab is b"); - } - - public void testIgnoreElementCase() { - expectLog( - "ignore-element-case", - "nested elementnested element"); - } - - public void testTextElement() { - expectLogContaining( - "textelement", "Hello world"); - } - - public void testTextTrim() { - expectLogContaining( - "text.trim", "[Hello world]"); - } - - public void testDuplicateTextName() { - expectBuildException( - "duplicatetextname", - "the name \"text\" is already used as an attribute"); - } - public void testDuplicateTextName2() { - expectBuildException( - "duplicatetextname2", - "the attribute name \"text\" has already been used by the text element"); - } - public void testEscape() { - expectLog( - "escape", - "a@b or a@b is avalue@bvalue"); - } - public void testAttributeDescription() { - expectLog( - "attribute.description", - "description is hello world"); - } - public void testOverrideDefault() { - expectLog( - "override.default", - "value is new"); - } - public void testImplicit() { - expectLog( - "implicit", "Before implicitIn implicitAfter implicit"); - } - public void testImplicitNotOptional() { - expectSpecificBuildException( - "implicit.notoptional", - "Missing nested elements for implicit element implicit", - "Missing nested elements for implicit element implicit"); - } - public void testImplicitOptional() { - expectLog( - "implicit.optional", "Before implicitAfter implicit"); - } - public void testImplicitExplicit() { - expectSpecificBuildException( - "implicit.explicit", - "Only one element allowed when using implicit elements", - "Only one element allowed when using implicit elements"); - } - - public void testBackTraceOff() { - try { - executeTarget("backtraceoff"); - } catch (BuildException ex) { - if (ex.getMessage().indexOf("following error occurred") != -1) { - fail("error message contained backtrace - " + ex.getMessage()); - } - } - } - - public void testBackTrace() { - expectBuildExceptionContaining( - "backtraceon", - "Checking if a back trace is created", - "following error occurred"); - } - - public void testTopLevelText() { - expectLogContaining("top-level-text", "Hello World"); - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/MakeUrlTest.java b/src/testcases/org/apache/tools/ant/taskdefs/MakeUrlTest.java deleted file mode 100644 index 7f9885fe3..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/MakeUrlTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -import java.io.InputStream; -import java.io.IOException; -import java.net.URL; - - -public class MakeUrlTest extends BuildFileTest { - - public MakeUrlTest(String s) { - super(s); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/makeurl.xml"); - } - - public void testEmpty() { - expectBuildExceptionContaining("testEmpty", "missing property", "property"); - } - - public void testNoProperty() { - expectBuildExceptionContaining("testNoProperty", "missing property", "property"); - } - - public void testNoFile() { - expectBuildExceptionContaining("testNoFile", "missing file", "file"); - } - - public void testValidation() { - expectBuildExceptionContaining("testValidation", MakeUrl.ERROR_MISSING_FILE, "file"); - } - - public void testWorks() { - executeTarget("testWorks"); - assertPropertyContains("testWorks", "file:"); - assertPropertyContains("testWorks", "/foo"); - } - - public void testIllegalChars() { - executeTarget("testIllegalChars"); - assertPropertyContains("testIllegalChars", "file:"); - assertPropertyContains("testIllegalChars", "fo%20o%25"); - } - - /** - * test that we can round trip by opening a url that exists - * - * @throws IOException - */ - public void testRoundTrip() throws IOException { - executeTarget("testRoundTrip"); - assertPropertyContains("testRoundTrip", "file:"); - String property = getProperty("testRoundTrip"); - URL url = new URL(property); - InputStream instream = url.openStream(); - instream.close(); - } - - public void testIllegalCombinations() { - executeTarget("testIllegalCombinations"); - assertPropertyContains("testIllegalCombinations", "/foo"); - assertPropertyContains("testIllegalCombinations", ".xml"); - } - - public void testFileset() { - executeTarget("testFileset"); - assertPropertyContains("testFileset", ".xml "); - String result = getProperty("testFileset"); - assertPropertyEndsWith("testFileset", ".xml"); - } - - public void testFilesetSeparator() { - executeTarget("testFilesetSeparator"); - assertPropertyContains("testFilesetSeparator", ".xml\",\""); - assertPropertyEndsWith("testFilesetSeparator", ".xml"); - } - - public void testPath() { - executeTarget("testPath"); - assertPropertyContains("testPath", "makeurl.xml"); - } - - /** - * assert that a property ends with - * - * @param property - * @param ending - */ - private void assertPropertyEndsWith(String property, String ending) { - String result = getProperty(property); - String substring = result.substring(result.length() - ending.length()); - assertEquals(ending, substring); - } - - /** - * assert that a property contains a string - * - * @param property name of property to look for - * @param contains what to search for in the string - */ - protected void assertPropertyContains(String property, String contains) { - String result = getProperty(property); - - assertTrue("expected " + contains + " in " + result, - result != null && result.indexOf(contains) >= 0); - } - - /** - * get a property from the project - * - * @param property - * @return - */ - protected String getProperty(String property) { - return project.getProperty(property); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java deleted file mode 100644 index 452be6627..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ManifestClassPathTest.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - - -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests <bm:manifestclasspath>. - */ -public class ManifestClassPathTest - extends BuildFileTest { - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/manifestclasspath.xml"); - } - - public void testBadDirectory() { - expectBuildExceptionContaining("test-bad-directory", "bad-jar-dir", - "Jar's directory not found:"); - assertPropertyUnset("jar.classpath"); - } - - public void testBadNoProperty() { - expectBuildExceptionContaining("test-bad-no-property", "no-property", - "Missing 'property' attribute!"); - assertPropertyUnset("jar.classpath"); - } - - public void testBadPropertyExists() { - expectBuildExceptionContaining("test-bad-property-exists", - "property-exits", "Property 'jar.classpath' already set!"); - assertPropertyEquals("jar.classpath", "exists"); - } - - public void testBadNoJarfile() { - expectBuildExceptionContaining("test-bad-no-jarfile", "no-jarfile", - "Missing 'jarfile' attribute!"); - assertPropertyUnset("jar.classpath"); - } - - public void testBadNoClassPath() { - expectBuildExceptionContaining("test-bad-no-classpath", "no-classpath", - "Missing nested !"); - assertPropertyUnset("jar.classpath"); - } - - public void testParentLevel1() { - executeTarget("test-parent-level1"); - - assertPropertyEquals("jar.classpath", "dsp-core/ " + - "dsp-pres/ " + - "dsp-void/ " + - "../generated/dsp-core/ " + - "../generated/dsp-pres/ " + - "../generated/dsp-void/ " + - "../resources/dsp-core/ " + - "../resources/dsp-pres/ " + - "../resources/dsp-void/"); - } - - public void testParentLevel2() { - executeTarget("test-parent-level2"); - - assertPropertyEquals("jar.classpath", "../dsp-core/ " + - "../dsp-pres/ " + - "../dsp-void/ " + - "../../generated/dsp-core/ " + - "../../generated/dsp-pres/ " + - "../../generated/dsp-void/ " + - "../../resources/dsp-core/ " + - "../../resources/dsp-pres/ " + - "../../resources/dsp-void/"); - } - - public void testParentLevel2TooDeep() { - expectBuildExceptionContaining("test-parent-level2-too-deep", "nopath", - "No suitable relative path from "); - assertPropertyUnset("jar.classpath"); - } - - public void testPseudoTahoeRefid() { - executeTarget("test-pseudo-tahoe-refid"); - - assertPropertyEquals("jar.classpath", "classes/dsp-core/ " + - "classes/dsp-pres/ " + - "classes/dsp-void/ " + - "generated/dsp-core/ " + - "resources/dsp-core/ " + - "resources/dsp-pres/"); - } - - public void testPseudoTahoeNested() { - executeTarget("test-pseudo-tahoe-nested"); - - assertPropertyEquals("jar.classpath", "classes/dsp-core/ " + - "classes/dsp-pres/ " + - "classes/dsp-void/ " + - "generated/dsp-core/ " + - "resources/dsp-core/ " + - "resources/dsp-pres/"); - } - - public void testParentLevel2WithJars() { - executeTarget("test-parent-level2-with-jars"); - - assertPropertyEquals("jar.classpath", "../../lib/acme-core.jar " + - "../../lib/acme-pres.jar " + - "../dsp-core/ " + - "../dsp-pres/ " + - "../dsp-void/ " + - "../../generated/dsp-core/ " + - "../../generated/dsp-pres/ " + - "../../generated/dsp-void/ " + - "../../resources/dsp-core/ " + - "../../resources/dsp-pres/ " + - "../../resources/dsp-void/"); - } - public void testInternationalGerman() { - executeTarget("international-german"); - expectLogContaining("run-two-jars", "beta alpha"); - } - public void testInternationalHebrew() { - if (!Os.isFamily("windows")) { - executeTarget("international-hebrew"); - expectLogContaining("run-two-jars", "beta alpha"); - } else { - System.out.println("Test with hebrew path not attempted under Windows"); - } - - } - -} // END class ManifestClassPathTest - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java deleted file mode 100644 index 5757f7cfc..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ManifestTest.java +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Set; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; - -/** - * Testcase for the Manifest class used in the jar task. - * - */ -public class ManifestTest extends BuildFileTest { - - public static final String EXPANDED_MANIFEST - = "src/etc/testcases/taskdefs/manifests/META-INF/MANIFEST.MF"; - - public static final String LONG_LINE - = "AReallyLongLineToTestLineBreakingInManifests-ACapabilityWhich" + - "IsSureToLeadToHundredsOfQuestionsAboutWhyAntMungesManifests" + - "OfCourseTheAnswerIsThatIsWhatTheSpecRequiresAndIfAnythingHas" + - "AProblemWithThatItIsNotABugInAnt"; - - public static final String LONG_70_NAME - = "ThisNameIsJustSeventyCharactersWhichIsAllowedAccordingToTheSpecsFiller"; - public static final String LONG_68_NAME - = "ThisNameIsJustSixtyEightCharactersWhichIsAllowedAccordingToTheSpecsX"; - public static final String NOT_LONG_NAME - = "NameIsJustUnderSeventyCharactersWhichIsAllowedAccordingTheSpec"; - - public static final String VALUE = "NOT_LONG"; - - public ManifestTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/manifest.xml"); - } - - public void tearDown() { - executeTarget("clean"); - } - - /** - * Empty manifest - is OK - */ - public void test1() throws ManifestException, IOException { - executeTarget("test1"); - Manifest manifest = getManifest(EXPANDED_MANIFEST); - String version = manifest.getManifestVersion(); - assertEquals("Manifest was not created with correct version - ", "1.0", version); - } - - /** - * Simple Manifest with version 2.0 - */ - public void test2() throws ManifestException, IOException { - executeTarget("test2"); - Manifest manifest = getManifest(EXPANDED_MANIFEST); - String version = manifest.getManifestVersion(); - assertEquals("Manifest was not created with correct version - ", "2.0", version); - } - - /** - * Malformed manifest - no : on the line - */ - public void test3() { - expectBuildExceptionContaining("test3", "Manifest is invalid - no colon on header line", - "Invalid Manifest"); - } - - /** - * Malformed manifest - starts with continuation line - */ - public void test4() { - expectBuildExceptionContaining("test4", "Manifest is invalid - section starts with continuation line", - "Invalid Manifest"); - } - - /** - * Malformed manifest - Name attribute in main section - */ - public void test5() { - executeTarget("test5"); - String output = getLog(); - boolean hasWarning = output.indexOf("Manifest warning: \"Name\" attributes should not occur in the main section") != -1; - assertEquals("Expected warning about Name in main section", true, hasWarning); - } - - /** - * New Section not starting with Name attribute. - */ - public void test6() { - expectBuildExceptionContaining("test6", "Manifest is invalid - section starts with incorrect attribute", - "Invalid Manifest"); - String output = getLog(); - boolean hasWarning = output.indexOf("Manifest sections should start with a \"Name\" attribute") != -1; - assertEquals("Expected warning about section not starting with Name: attribute", true, hasWarning); - } - - /** - * From attribute is illegal - */ - public void test7() { - executeTarget("test7"); - - boolean hasWarning = getLog().indexOf(Manifest.ERROR_FROM_FORBIDDEN) != -1; - assertEquals("Expected warning about From: attribute", true, hasWarning); - } - - /** - * Inline manifest - OK - */ - public void test8() throws IOException, ManifestException { - executeTarget("test8"); - Manifest manifest = getManifest(EXPANDED_MANIFEST); - Manifest.Section mainSection = manifest.getMainSection(); - String classpath = mainSection.getAttributeValue("class-path"); - assertEquals("Class-Path attribute was not set correctly - ", "fubar", classpath); - - Manifest.Section testSection = manifest.getSection("Test"); - String testAttr = testSection.getAttributeValue("TestAttr"); - assertEquals("TestAttr attribute was not set correctly - ", "Test", testAttr); - } - - /** - * Inline manifest - Invalid since has a Name attribute in the section element - */ - public void test9() { - expectBuildExceptionContaining("test9", "Construction is invalid - Name attribute should not be used", - "Specify the section name using the \"name\" attribute of the

element"); - } - - /** - * Inline manifest - Invalid attribute without name - */ - public void test10() { - expectBuildExceptionContaining("test10", "Attribute has no name", - "Attributes must have name and value"); - } - - /** - * Inline manifest - Invalid attribute without value - */ - public void test11() { - expectBuildExceptionContaining("test11", "Attribute has no value", - "Attributes must have name and value"); - } - - /** - * Inline manifest - Invalid attribute without value - */ - public void test12() { - expectBuildExceptionContaining("test12", "Section with no name", - "Sections must have a name"); - } - - /** - * Inline manifest - Duplicate attribute - */ - public void test13() { - expectBuildExceptionContaining("test13", "Duplicate Attribute", - "The attribute \"Test\" may not occur more than once in the same section"); - } - - /** - * Inline manifest - OK since classpath entries can be duplicated. - */ - public void test14() throws IOException, ManifestException { - executeTarget("test14"); - Manifest manifest = getManifest(EXPANDED_MANIFEST); - Manifest.Section mainSection = manifest.getMainSection(); - String classpath = mainSection.getAttributeValue("class-path"); - assertEquals("Class-Path attribute was not set correctly - ", - "Test1 Test2 Test3 Test4", classpath); - } - - /** - * Tets long line wrapping - */ - public void testLongLine() throws IOException, ManifestException { - Project p = getProject(); - p.setUserProperty("test.longline", LONG_LINE); - p.setUserProperty("test.long68name" , LONG_68_NAME); - p.setUserProperty("test.long70name" , LONG_70_NAME); - p.setUserProperty("test.notlongname" , NOT_LONG_NAME); - p.setUserProperty("test.value", VALUE); - executeTarget("testLongLine"); - - Manifest manifest = getManifest(EXPANDED_MANIFEST); - Manifest.Section mainSection = manifest.getMainSection(); - String classpath = mainSection.getAttributeValue("class-path"); - assertEquals("Class-Path attribute was not set correctly - ", - LONG_LINE, classpath); - - String value = mainSection.getAttributeValue(LONG_68_NAME); - assertEquals("LONG_68_NAME_VALUE_MISMATCH", VALUE, value); - value = mainSection.getAttributeValue(LONG_70_NAME); - assertEquals("LONG_70_NAME_VALUE_MISMATCH", VALUE, value); - value = mainSection.getAttributeValue(NOT_LONG_NAME); - assertEquals("NOT_LONG_NAME_VALUE_MISMATCH", VALUE, value); - - BufferedReader in = new BufferedReader(new FileReader(EXPANDED_MANIFEST)); - - Set set = new HashSet(); - String read = in.readLine(); - while (read != null) - { - set.add(read); - read = in.readLine(); - } - - assertTrue("Manifest file should have contained string ", set - .remove(" NOT_LONG")); - assertTrue("Manifest file should have contained string ", set - .remove(" NG")); - assertTrue("Manifest file should have contained string ", set - .remove(LONG_70_NAME + ": ")); - assertTrue("Manifest file should have contained string ", set - .remove(NOT_LONG_NAME + ": NOT_LO")); - } - - /** - * Tests ordering of sections - */ - public void testOrder1() throws IOException, ManifestException { - executeTarget("testOrder1"); - - Manifest manifest = getManifest(EXPANDED_MANIFEST); - Enumeration e = manifest.getSectionNames(); - String section1 = (String)e.nextElement(); - String section2 = (String)e.nextElement(); - assertEquals("First section name unexpected", "Test1", section1); - assertEquals("Second section name unexpected", "Test2", section2); - - Manifest.Section section = manifest.getSection("Test1"); - e = section.getAttributeKeys(); - String attr1Key = (String)e.nextElement(); - String attr2Key = (String)e.nextElement(); - String attr1 = section.getAttribute(attr1Key).getName(); - String attr2 = section.getAttribute(attr2Key).getName(); - assertEquals("First attribute name unexpected", "TestAttr1", attr1); - assertEquals("Second attribute name unexpected", "TestAttr2", attr2); - } - - /** - * Tests ordering of sections - */ - public void testOrder2() throws IOException, ManifestException { - executeTarget("testOrder2"); - - Manifest manifest = getManifest(EXPANDED_MANIFEST); - Enumeration e = manifest.getSectionNames(); - String section1 = (String)e.nextElement(); - String section2 = (String)e.nextElement(); - assertEquals("First section name unexpected", "Test2", section1); - assertEquals("Second section name unexpected", "Test1", section2); - - Manifest.Section section = manifest.getSection("Test1"); - e = section.getAttributeKeys(); - String attr1Key = (String)e.nextElement(); - String attr2Key = (String)e.nextElement(); - String attr1 = section.getAttribute(attr1Key).getName(); - String attr2 = section.getAttribute(attr2Key).getName(); - assertEquals("First attribute name unexpected", "TestAttr2", attr1); - assertEquals("Second attribute name unexpected", "TestAttr1", attr2); - } - - /** - * file attribute for manifest task is required. - */ - public void testNoFile() { - expectBuildException("testNoFile", "file is required"); - } - - /** - * replace changes Manifest-Version from 2.0 to 1.0 - */ - public void testReplace() throws IOException, ManifestException { - executeTarget("testReplace"); - Manifest mf = getManifest("src/etc/testcases/taskdefs/mftest.mf"); - assertNotNull(mf); - assertEquals(Manifest.getDefaultManifest(), mf); - } - - /** - * update keeps the Manifest-Version and adds a new attribute Foo - */ - public void testUpdate() throws IOException, ManifestException { - executeTarget("testUpdate"); - Manifest mf = getManifest("src/etc/testcases/taskdefs/mftest.mf"); - assertNotNull(mf); - assertTrue(!Manifest.getDefaultManifest().equals(mf)); - String mfAsString = mf.toString(); - assertNotNull(mfAsString); - assertTrue(mfAsString.startsWith("Manifest-Version: 2.0")); - assertTrue(mfAsString.indexOf("Foo: Bar") > -1); - - mf = getManifest("src/etc/testcases/taskdefs/mftest2.mf"); - assertNotNull(mf); - mfAsString = mf.toString(); - assertNotNull(mfAsString); - assertEquals(-1, mfAsString.indexOf("Foo: Bar")); - assertTrue(mfAsString.indexOf("Foo: Baz") > -1); - } - - public void testFrom() { - expectLogContaining("testFrom", Manifest.ERROR_FROM_FORBIDDEN); - } - - /** - * Reads mftest.mf. - */ - private Manifest getManifest(String filename) throws IOException, ManifestException { - FileReader r = new FileReader(new File(System.getProperty("root"), filename)); - try { - return new Manifest(r); - } finally { - r.close(); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/MkdirTest.java b/src/testcases/org/apache/tools/ant/taskdefs/MkdirTest.java deleted file mode 100644 index d9a10784e..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/MkdirTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class MkdirTest extends BuildFileTest { - - public MkdirTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/mkdir.xml"); - } - - public void test1() { - expectBuildException("test1", "required argument missing"); - } - - public void test2() { - expectBuildException("test2", "directory already exists as a file"); - } - - public void test3() { - executeTarget("test3"); - java.io.File f = new java.io.File(getProjectDir(), "testdir.tmp"); - if (!f.exists() || !f.isDirectory()) { - fail("mkdir failed"); - } else { - f.delete(); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java b/src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java deleted file mode 100644 index ce5dc71cd..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/MoveTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; -import java.io.File; -import java.io.IOException; - -/** - * Tests the Move task. - * - */ -public class MoveTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public MoveTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/move.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testFilterSet() throws IOException { - executeTarget("testFilterSet"); - File tmp = new File(getProjectDir(), "move.filterset.tmp"); - File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); - assertTrue(tmp.exists()); - assertTrue(FILE_UTILS.contentEquals(tmp, check)); - } - - public void testFilterChain() throws IOException { - executeTarget("testFilterChain"); - File tmp = new File(getProjectDir(), "move.filterchain.tmp"); - File check = new File(getProjectDir(), "expected/copy.filterset.filtered"); - assertTrue(tmp.exists()); - assertTrue(FILE_UTILS.contentEquals(tmp, check)); - } - - /** Bugzilla Report 11732 */ - public void testDirectoryRemoval() throws IOException { - executeTarget("testDirectoryRemoval"); - assertTrue(!getProject().resolveFile("E/B/1").exists()); - assertTrue(getProject().resolveFile("E/C/2").exists()); - assertTrue(getProject().resolveFile("E/D/3").exists()); - assertTrue(getProject().resolveFile("A/B/1").exists()); - assertTrue(!getProject().resolveFile("A/C/2").exists()); - assertTrue(!getProject().resolveFile("A/D/3").exists()); - assertTrue(!getProject().resolveFile("A/C").exists()); - assertTrue(!getProject().resolveFile("A/D").exists()); - } - - /** Bugzilla Report 18886 */ - public void testDirectoryRetaining() throws IOException { - executeTarget("testDirectoryRetaining"); - assertTrue(getProject().resolveFile("E").exists()); - assertTrue(getProject().resolveFile("E/1").exists()); - assertTrue(!getProject().resolveFile("A/1").exists()); - assertTrue(getProject().resolveFile("A").exists()); - } - - public void testCompleteDirectoryMove() throws IOException { - testCompleteDirectoryMove("testCompleteDirectoryMove"); - } - - public void testCompleteDirectoryMove2() throws IOException { - testCompleteDirectoryMove("testCompleteDirectoryMove2"); - } - - private void testCompleteDirectoryMove(String target) throws IOException { - executeTarget(target); - assertTrue(getProject().resolveFile("E").exists()); - assertTrue(getProject().resolveFile("E/1").exists()); - assertTrue(!getProject().resolveFile("A/1").exists()); - // swallows the basedir, it seems - //assertTrue(!getProject().resolveFile("A").exists()); - } - - public void testPathElementMove() throws IOException { - executeTarget("testPathElementMove"); - assertTrue(getProject().resolveFile("E").exists()); - assertTrue(getProject().resolveFile("E/1").exists()); - assertTrue(!getProject().resolveFile("A/1").exists()); - assertTrue(getProject().resolveFile("A").exists()); - } - - public void testMoveFileAndFileset() { - executeTarget("testMoveFileAndFileset"); - } - - public void testCompleteDirectoryMoveToExistingDir() { - executeTarget("testCompleteDirectoryMoveToExistingDir"); - } - - public void testCompleteDirectoryMoveFileToFile() { - executeTarget("testCompleteDirectoryMoveFileToFile"); - } - - public void testCompleteDirectoryMoveFileToDir() { - executeTarget("testCompleteDirectoryMoveFileToDir"); - } - - public void testCompleteDirectoryMoveFileAndFileset() { - executeTarget("testCompleteDirectoryMoveFileAndFileset"); - } - - public void testCompleteDirectoryMoveFileToExistingFile() { - executeTarget("testCompleteDirectoryMoveFileToExistingFile"); - } - - public void testCompleteDirectoryMoveFileToExistingDir() { - executeTarget("testCompleteDirectoryMoveFileToExistingDir"); - } - - public void testCompleteDirectoryMoveFileToDirWithExistingFile() { - executeTarget("testCompleteDirectoryMoveFileToDirWithExistingFile"); - } - - public void testCompleteDirectoryMoveFileToDirWithExistingDir() { - executeTarget("testCompleteDirectoryMoveFileToDirWithExistingDir"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/MultiMapTest.java b/src/testcases/org/apache/tools/ant/taskdefs/MultiMapTest.java deleted file mode 100644 index 680a8eb41..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/MultiMapTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileNameMapper; - - -/** - */ -public class MultiMapTest extends BuildFileTest { - - public MultiMapTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/multimap.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testMultiCopy() { - executeTarget("multicopy"); - } - - public void testMultiMove() { - executeTarget("multimove"); - } - - public void testSingleCopy() { - executeTarget("singlecopy"); - } - - public void testSingleMove() { - executeTarget("singlemove"); - } - - public void testCopyWithEmpty() { - executeTarget("copywithempty"); - } - - public void testMoveWithEmpty() { - executeTarget("movewithempty"); - } - - public static class TestMapper implements FileNameMapper { - public TestMapper() {} - public void setFrom(String from) {} - public void setTo(String to) {} - public String[] mapFileName(final String source_file_name) { - return new String[] { - source_file_name, source_file_name+".copy2" }; - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/NiceTest.java b/src/testcases/org/apache/tools/ant/taskdefs/NiceTest.java deleted file mode 100644 index 26d483afa..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/NiceTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - * test nice - */ -public class NiceTest extends BuildFileTest { - - public NiceTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/nice.xml"); - } - - public void testNoop() { - executeTarget("noop"); - } - - public void testCurrent() { - executeTarget("current"); - } - - public void testFaster() { - executeTarget("faster"); - } - - public void testSlower() { - executeTarget("slower"); - } - - public void testTooSlow() { - expectBuildExceptionContaining( - "too_slow","out of range","out of the range 1-10"); - } - - public void testTooFast() { - expectBuildExceptionContaining( - "too_fast", "out of range", "out of the range 1-10"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ParallelTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ParallelTest.java deleted file mode 100644 index b3b3cb77c..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ParallelTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; -import java.io.PrintStream; - -import junit.framework.AssertionFailedError; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.DemuxOutputStream; -import org.apache.tools.ant.Project; - -/** - * Test of the parallel TaskContainer - * - * @created 21 February 2002 - */ -public class ParallelTest extends BuildFileTest { - /** Standard property value for the basic test */ - public final static String DIRECT_MESSAGE = "direct"; - /** Standard property value for the basic and fail test */ - public final static String DELAYED_MESSAGE = "delayed"; - /** Standard property value for the fail test */ - public final static String FAILURE_MESSAGE = "failure"; - - /** the build fiel associated with this test */ - public final static String TEST_BUILD_FILE - = "src/etc/testcases/taskdefs/parallel.xml"; - - /** - * Constructor for the ParallelTest object - * - * @param name name of the test - */ - public ParallelTest(String name) { - super(name); - } - - /** The JUnit setup method */ - public void setUp() { - configureProject(TEST_BUILD_FILE); - } - - /** tests basic operation of the parallel task */ - public void testBasic() { - // should get no output at all - Project p = getProject(); - p.setUserProperty("test.direct", DIRECT_MESSAGE); - p.setUserProperty("test.delayed", DELAYED_MESSAGE); - expectOutputAndError("testBasic", "", ""); - String log = getLog(); - assertEquals("parallel tasks didn't output correct data", log, - DIRECT_MESSAGE + DELAYED_MESSAGE); - - } - - /** tests basic operation of the parallel task */ - public void testThreadCount() { - // should get no output at all - Project p = getProject(); - p.setUserProperty("test.direct", DIRECT_MESSAGE); - p.setUserProperty("test.delayed", DELAYED_MESSAGE); - expectOutputAndError("testThreadCount", "", ""); - String log = getLog(); - int pos = 0; - while (pos > -1) { - pos = countThreads(log, pos); - } - } - - /** - * the test result string should match the regex - * ^(\|\d+\/(+-)*)+\|$ for someting like - * |3/++--+-|5/+++++-----| - * - *@returns -1 no more tests - * # start pos of next test - *@throws AssertionFailedException when a constraint is invalid - */ - static int countThreads(String s, int start) { - int firstPipe = s.indexOf('|', start); - int beginSlash = s.indexOf('/', firstPipe); - int lastPipe = s.indexOf('|', beginSlash); - if ((firstPipe == -1) || (beginSlash == -1) || (lastPipe == -1)) { - return -1; - } - - int max = Integer.parseInt(s.substring(firstPipe + 1, beginSlash)); - int current = 0; - int pos = beginSlash + 1; - while (pos < lastPipe) { - switch (s.charAt(pos++)) { - case '+': - current++; - break; - case '-': - current--; - break; - default: - throw new AssertionFailedError("Only expect '+-' in result count, found " - + s.charAt(--pos) + " at position " + pos); - } - if (current > max) { - throw new AssertionFailedError("Number of executing threads exceeded number allowed: " - + current + " > " + max); - } - } - return lastPipe; - } - - - /** tests the failure of a task within a parallel construction */ - public void testFail() { - // should get no output at all - Project p = getProject(); - p.setUserProperty("test.failure", FAILURE_MESSAGE); - p.setUserProperty("test.delayed", DELAYED_MESSAGE); - expectBuildExceptionContaining("testFail", - "fail task in one parallel branch", FAILURE_MESSAGE); - } - - /** tests the demuxing of output streams in a multithreaded situation */ - public void testDemux() { - Project p = getProject(); - p.addTaskDefinition("demuxtest", DemuxOutputTask.class); - PrintStream out = System.out; - PrintStream err = System.err; - System.setOut(new PrintStream(new DemuxOutputStream(p, false))); - System.setErr(new PrintStream(new DemuxOutputStream(p, true))); - - try { - p.executeTarget("testDemux"); - } finally { - System.setOut(out); - System.setErr(err); - } - } - -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/PathConvertTest.java b/src/testcases/org/apache/tools/ant/taskdefs/PathConvertTest.java deleted file mode 100755 index 2f8428ccb..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/PathConvertTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Unit test for the <pathconvert> task. - */ -public class PathConvertTest extends BuildFileTest { - private static final String BUILD_PATH = "src/etc/testcases/taskdefs/"; - private static final String BUILD_FILENAME = "pathconvert.xml"; - private static final String BUILD_FILE = BUILD_PATH + BUILD_FILENAME; - - public PathConvertTest(String name) { - super(name); - } - - public void setUp() { - configureProject(BUILD_FILE); - } - - public void testMap() { - test("testmap"); - } - - public void testMapper() { - test("testmapper"); - } - - public void testNoTargetOs() { - executeTarget("testnotargetos"); - } - - private void test(String target) { - executeTarget(target); - assertPropertyEquals("result", "test#" + BUILD_FILENAME); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java b/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java deleted file mode 100644 index f0a25ba52..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/PreSetDefTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.FileSet; - -/** - */ -public class PreSetDefTest extends BuildFileTest { - public PreSetDefTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/presetdef.xml"); - } - - public void testSimple() { - expectLog("simple", "Hello world"); - } - - public void testText() { - expectLog("text", "Inner Text"); - } - - public void testUri() { - expectLog("uri", "Hello world"); - } - - public void testDefaultTest() { - expectLog("defaulttest", "attribute is false"); - } - - public void testDoubleDefault() { - expectLog("doubledefault", "attribute is falseattribute is true"); - } - - public void testTextOptional() { - expectLog("text.optional", "MyTextoverride text"); - } - - public void testElementOrder() { - expectLog("element.order", "Line 1Line 2"); - } - - public void testElementOrder2() { - expectLog("element.order2", "Line 1Line 2Line 3"); - } - - public void testAntTypeTest() { - expectLog("antTypeTest", ""); - } - - public void testCorrectTaskNameBadAttr() { - expectBuildExceptionContaining( - "correct_taskname_badattr", "attribute message", "javac doesn't support the"); - } - - public void testCorrectTaskNameBadEl() { - expectBuildExceptionContaining( - "correct_taskname_badel", "element message", "javac doesn't support the"); - } - - public void testPresetdefWithNestedElementTwice() { // #38056 - executeTarget("presetdef-with-nested-element-twice"); - executeTarget("presetdef-with-nested-element-twice"); - } - - /** - * A test class to check default properties - */ - public static class DefaultTest extends Task { - boolean isSet = false; - boolean attribute = false; - public void setAttribute(boolean b) { - if (isSet) { - throw new BuildException("Attribute Already set"); - } - attribute = b; - isSet = true; - } - - public void execute() { - getProject().log("attribute is " + attribute); - } - } - - /** - * A test class to check presetdef with add and addConfigured and ant-type - */ - public static class AntTypeTest extends Task { - public void addFileSet(FileSet fileset) { - } - public void addConfiguredConfigured(FileSet fileset) { - } - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ProcessDestroyerTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ProcessDestroyerTest.java deleted file mode 100644 index 110e04adc..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ProcessDestroyerTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* - * Created on Feb 19, 2003 - */ -package org.apache.tools.ant.taskdefs; - -import java.io.IOException; - -import org.apache.tools.ant.util.JavaEnvUtils; - -import junit.framework.TestCase; - -/** - */ -public class ProcessDestroyerTest extends TestCase { - - /** - * Constructor for ProcessDestroyerTest. - * @param arg0 - */ - public ProcessDestroyerTest(String arg0) { - super(arg0); - } - - public void testProcessDestroyer(){ - if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2)) { - return; - } - - try { - ProcessDestroyer processDestroyer = new ProcessDestroyer(); - Process process = - Runtime.getRuntime().exec( - "java -cp " - + System.getProperty("java.class.path") - + " " - + getClass().getName()); - - assertFalse("Not registered as shutdown hook", - processDestroyer.isAddedAsShutdownHook()); - - processDestroyer.add(process); - - assertTrue("Registered as shutdown hook", - processDestroyer.isAddedAsShutdownHook()); - try { - process.destroy(); - } finally { - processDestroyer.remove(process); - } - - assertFalse("Not registered as shutdown hook", - processDestroyer.isAddedAsShutdownHook()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static void main(String[] args){ - new ProcessDestroyerTest("testProcessDestroyer").testProcessDestroyer(); - try{ - Thread.sleep(60000); - }catch(InterruptedException ie){ - ie.printStackTrace(); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java deleted file mode 100644 index b636da656..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class PropertyTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public PropertyTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/property.xml"); - } - - public void test1() { - // should get no output at all - expectOutputAndError("test1", "", ""); - } - - public void test2() { - expectLog("test2", "testprop1=aa, testprop3=xxyy, testprop4=aazz"); - } - - public void test3() { - try { - executeTarget("test3"); - } - catch (BuildException e) { - assertEquals("Circular definition not detected - ", true, - e.getMessage().indexOf("was circularly defined") != -1); - return; - } - fail("Did not throw exception on circular exception"); - } - - public void test4() { - expectLog("test4", "http.url is http://localhost:999"); - } - - public void test5() { - String baseDir = getProject().getProperty("basedir"); - try { - String uri = FILE_UTILS.toURI( - baseDir + "/property3.properties"); - getProject().setNewProperty( - "test5.url", uri); - } catch (Exception ex) { - throw new BuildException(ex); - } - expectLog("test5", "http.url is http://localhost:999"); - } - - public void testPrefixSuccess() { - executeTarget("prefix.success"); - assertEquals("80", project.getProperty("server1.http.port")); - } - - public void testPrefixFailure() { - try { - executeTarget("prefix.fail"); - } - catch (BuildException e) { - assertEquals("Prefix allowed on non-resource/file load - ", true, - e.getMessage().indexOf("Prefix is only valid") != -1); - return; - } - fail("Did not throw exception on invalid use of prefix"); - } - - public void testCircularReference() { - try { - executeTarget("testCircularReference"); - } catch (BuildException e) { - assertEquals("Circular definition not detected - ", true, - e.getMessage().indexOf("was circularly defined") - != -1); - return; - } - fail("Did not throw exception on circular exception"); - } - - public void testThisIsNotACircularReference() { - expectLog("thisIsNotACircularReference", "b is A/A/A"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ProtectedJarMethodsTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ProtectedJarMethodsTest.java deleted file mode 100644 index 379df9cfa..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ProtectedJarMethodsTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class ProtectedJarMethodsTest extends BuildFileTest { - - private static String tempJar = "tmp.jar"; - - public ProtectedJarMethodsTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/jar.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testGrabFilesAndDirs() throws IOException { - executeTarget("testIndexTests"); - String archive = getProject().resolveFile(tempJar).getAbsolutePath(); - ArrayList dirs = new ArrayList(); - ArrayList files = new ArrayList(); - String[] expectedDirs = new String[] { - "sub/", - }; - String[] expectedFiles = new String[] { - "foo", - }; - Jar.grabFilesAndDirs(archive, dirs, files); - assertEquals(expectedDirs.length, dirs.size()); - for (int i = 0; i < expectedDirs.length; i++) { - assertTrue("Found " + expectedDirs[i], - dirs.contains(expectedDirs[i])); - } - assertEquals(expectedFiles.length, files.size()); - for (int i = 0; i < expectedFiles.length; i++) { - assertTrue("Found " + expectedFiles[i], - files.contains(expectedFiles[i])); - } - } - - public void testFindJarNameNoClasspath() { - assertEquals("foo", Jar.findJarName("foo", null)); - assertEquals("foo", Jar.findJarName("lib" + File.separatorChar + "foo", - null)); - } - - public void testFindJarNameNoMatch() { - assertNull(Jar.findJarName("foo", new String[] {"bar"})); - } - - public void testFindJarNameSimpleMatches() { - assertEquals("foo", Jar.findJarName("foo", new String[] {"foo"})); - assertEquals("lib/foo", Jar.findJarName("foo", - new String[] {"lib/foo"})); - assertEquals("foo", Jar.findJarName("bar" + File.separatorChar + "foo", - new String[] {"foo"})); - assertEquals("lib/foo", - Jar.findJarName("bar" + File.separatorChar + "foo", - new String[] {"lib/foo"})); - } - - public void testFindJarNameLongestMatchWins() { - assertEquals("lib/foo", - Jar.findJarName("lib/foo", - new String[] {"foo", "lib/foo", - "lib/bar/foo"})); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/RecorderTest.java b/src/testcases/org/apache/tools/ant/taskdefs/RecorderTest.java deleted file mode 100644 index 3750007b1..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/RecorderTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -import java.io.IOException; - -/** - */ -public class RecorderTest extends BuildFileTest { - - private static final String REC_IN = "recorder/"; - private static final String REC_DIR = "recorder-out/"; - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public RecorderTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/recorder.xml"); - executeTarget("prepare"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testNoAppend() throws IOException { - executeTarget("noappend"); - assertTrue(FILE_UTILS - .contentEquals(project.resolveFile(REC_IN - + "rectest1.result"), - project.resolveFile(REC_DIR - + "rectest1.log"), true)); - } - - public void testAppend() throws IOException { - executeTarget("append"); - assertTrue(FILE_UTILS - .contentEquals(project.resolveFile(REC_IN - + "rectest2.result"), - project.resolveFile(REC_DIR - + "rectest2.log"), true)); - } - - public void testRestart() throws IOException { - executeTarget("restart"); - assertTrue(FILE_UTILS - .contentEquals(project.resolveFile(REC_IN - + "rectest3.result"), - project.resolveFile(REC_DIR - + "rectest3.log"), true)); - } - - public void testDeleteRestart() throws IOException { - executeTarget("deleterestart"); - assertTrue(FILE_UTILS - .contentEquals(project.resolveFile(REC_IN - + "rectest4.result"), - project.resolveFile(REC_DIR - + "rectest4.log"), true)); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/RenameTest.java b/src/testcases/org/apache/tools/ant/taskdefs/RenameTest.java deleted file mode 100644 index 8460fc1cf..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/RenameTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class RenameTest extends BuildFileTest { - - public RenameTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/rename.xml"); - } - - public void test1() { - expectBuildException("test1", "required argument missing"); - } - public void test2() { - expectBuildException("test2", "required argument missing"); - } - public void test3() { - expectBuildException("test3", "required argument missing"); - } -/* - public void test4() { - expectBuildException("test4", "source and destination the same"); - } - public void test5() { - executeTarget("test5"); - } - */ - public void test6() { - executeTarget("test6"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/ReplaceTest.java b/src/testcases/org/apache/tools/ant/taskdefs/ReplaceTest.java deleted file mode 100644 index 22ee92a84..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/ReplaceTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -import java.io.*; - -import junit.framework.AssertionFailedError; - -/** - */ -public class ReplaceTest extends BuildFileTest { - - public ReplaceTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/replace.xml"); - } - - public void test1() { - expectBuildException("test1", "required argument not specified"); - } - - public void test2() { - expectBuildException("test2", "required argument not specified"); - } - - public void test3() { - expectBuildException("test3", "required argument not specified"); - } - - public void test4() { - expectBuildException("test4", "empty token not allowed"); - } - - public void test5() { - executeTarget("test5"); - } - - public void test6() { - expectBuildException("test6", "required argument not specified"); - } - - public void test7() { - expectBuildException("test7", "empty token not allowed"); - } - - public void test8() { - executeTarget("test8"); - } - - public void test9() throws IOException{ - executeTarget("test9"); - String tmpdir = project.getProperty("tmp.dir"); - assertEqualContent(new File(tmpdir, "result.txt"), - new File(tmpdir, "output.txt")); - } - public void tearDown() { - executeTarget("cleanup"); - } - public void assertEqualContent(File expect, File result) - throws AssertionFailedError, IOException { - if (!result.exists()) { - fail("Expected file "+result+" doesn\'t exist"); - } - - InputStream inExpect = null; - InputStream inResult = null; - try { - inExpect = new BufferedInputStream(new FileInputStream(expect)); - inResult = new BufferedInputStream(new FileInputStream(result)); - - int expectedByte = inExpect.read(); - while (expectedByte != -1) { - assertEquals(expectedByte, inResult.read()); - expectedByte = inExpect.read(); - } - assertEquals("End of file", -1, inResult.read()); - } finally { - if (inResult != null) { - inResult.close(); - } - if (inExpect != null) { - inExpect.close(); - } - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java b/src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java deleted file mode 100644 index 2925b790d..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/RmicAdvancedTest.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; -import org.apache.tools.ant.taskdefs.rmic.DefaultRmicAdapter; - -/** - * Date: 04-Aug-2004 - * Time: 22:15:46 - */ -public class RmicAdvancedTest extends BuildFileTest { - - public RmicAdvancedTest(String name) { - super(name); - } - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/rmic/"; - - /** - * The JUnit setup method - */ - public void setUp() throws Exception { - super.setUp(); - configureProject(TASKDEFS_DIR + "rmic.xml"); - } - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("teardown"); - } - - /** - * verify that "default" binds us to the default compiler - */ - public void testDefault() throws Exception { - executeTarget("testDefault"); - } - - /** - * verify that "" binds us to the default compiler - */ - public void testEmpty() throws Exception { - executeTarget("testEmpty"); - } - /** - * A unit test for JUnit - */ - public void testRmic() throws Exception { - executeTarget("testRmic"); - } - /** - * A unit test for JUnit - */ - public void testKaffe() throws Exception { - executeTarget("testKaffe"); - } - - /** - * A unit test for JUnit - */ - public void testWlrmic() throws Exception { - executeTarget("testWlrmic"); - } - - /** - * test the forking compiler - */ - public void NotestForking() throws Exception { - executeTarget("testForking"); - } - - /** - * test the forking compiler - */ - public void testForkingAntClasspath() throws Exception { - executeTarget("testForkingAntClasspath"); - } - - /** - * test the forking compiler - */ - public void testAntClasspath() throws Exception { - executeTarget("testAntClasspath"); - } - - /** - * A unit test for JUnit - */ - public void testBadName() throws Exception { - expectBuildExceptionContaining("testBadName", - "compiler not known", - RmicAdapterFactory.ERROR_UNKNOWN_COMPILER); - } - - /** - * load an adapter by name - */ - public void testExplicitClass() throws Exception { - executeTarget("testExplicitClass"); - } - - /** - * A unit test for JUnit - */ - public void testWrongClass() throws Exception { - expectBuildExceptionContaining("testWrongClass", - "class not an RMIC adapter", - RmicAdapterFactory.ERROR_NOT_RMIC_ADAPTER); - } - - - /** - * A unit test for JUnit - */ - public void testDefaultBadClass() throws Exception { - expectBuildExceptionContaining("testDefaultBadClass", - "expected the class to fail", - Rmic.ERROR_RMIC_FAILED); - //dont look for much text here as it is vendor and version dependent - assertLogContaining("unimplemented.class"); - } - - - /** - * A unit test for JUnit - */ - public void testMagicProperty() throws Exception { - expectBuildExceptionContaining("testMagicProperty", - "magic property not working", - RmicAdapterFactory.ERROR_UNKNOWN_COMPILER); - } - - /** - * A unit test for JUnit - */ - public void testMagicPropertyOverridesEmptyString() throws Exception { - expectBuildExceptionContaining("testMagicPropertyOverridesEmptyString", - "magic property not working", - RmicAdapterFactory.ERROR_UNKNOWN_COMPILER); - } - - - /** - * - */ - public void testMagicPropertyIsEmptyString() throws Exception { - executeTarget("testMagicPropertyIsEmptyString"); - } - - - public void NotestFailingAdapter() throws Exception { - expectBuildExceptionContaining("testFailingAdapter", - "expected failures to propagate", - Rmic.ERROR_RMIC_FAILED); - } - - - /** - * test that version 1.1 stubs are good - * @throws Exception - */ - public void testVersion11() throws Exception { - executeTarget("testVersion11"); - } - - /** - * test that version 1.2 stubs are good - * - * @throws Exception - */ - public void testVersion12() throws Exception { - executeTarget("testVersion12"); - } - - /** - * test that version compat stubs are good - * - * @throws Exception - */ - public void testVersionCompat() throws Exception { - executeTarget("testVersionCompat"); - } - - /** - * test that passes -Xnew to sun's rmic. - * - * @throws Exception - */ - public void testXnew() throws Exception { - executeTarget("testXnew"); - } - - /** - * test that passes -Xnew to sun's rmic running in a different VM. - * - * @throws Exception - */ - public void testXnewForked() throws Exception { - executeTarget("testXnewForked"); - } - - /** - * test that runs the new xnew compiler adapter. - * - * @throws Exception - */ - public void testXnewCompiler() throws Exception { - executeTarget("testXnewCompiler"); - } - - /** - * test that verifies that IDL compiles. - * - * @throws Exception - */ - public void testIDL() throws Exception { - executeTarget("testIDL"); - } - - /** - * test that verifies that IIOP compiles. - * - * @throws Exception - */ - public void testIIOP() throws Exception { - executeTarget("testIIOP"); - } - - /** - * this little bunny verifies that we can load stuff, and that - * a failure to execute is turned into a fault - */ - public static class FailingRmicAdapter extends DefaultRmicAdapter { - public static final String LOG_MESSAGE = "hello from FailingRmicAdapter"; - - /** - * Executes the task. - * - * @return false -always - */ - public boolean execute() throws BuildException { - getRmic().log(LOG_MESSAGE); - return false; - } - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/RmicTest.java b/src/testcases/org/apache/tools/ant/taskdefs/RmicTest.java deleted file mode 100644 index 78f07d189..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/RmicTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.Project; -import junit.framework.TestCase; - - -/** - * Testcase for . - * - * @since Ant 1.5 - */ -public class RmicTest extends TestCase { - - private Project project; - private Rmic rmic; - - public RmicTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.init(); - rmic = new Rmic(); - rmic.setProject(project); - } - - /** - * Test nested compiler args. - */ - public void testCompilerArg() { - String[] args = rmic.getCurrentCompilerArgs(); - assertNotNull(args); - assertEquals("no args", 0, args.length); - - Rmic.ImplementationSpecificArgument arg = rmic.createCompilerArg(); - String ford = "Ford"; - String prefect = "Prefect"; - String testArg = ford + " " + prefect; - arg.setValue(testArg); - args = rmic.getCurrentCompilerArgs(); - assertEquals("unconditional single arg", 1, args.length); - assertEquals(testArg, args[0]); - - arg.setCompiler("weblogic"); - args = rmic.getCurrentCompilerArgs(); - assertNotNull(args); - assertEquals("implementation is weblogic but build.rmic is null", - 0, args.length); - - project.setProperty("build.rmic", "sun"); - args = rmic.getCurrentCompilerArgs(); - assertNotNull(args); - assertEquals("implementation is weblogic but build.rmic is sun", - 0, args.length); - - project.setProperty("build.rmic", "weblogic"); - args = rmic.getCurrentCompilerArgs(); - assertEquals("both are weblogic", 1, args.length); - assertEquals(testArg, args[0]); - } - - /** - * Test compiler attribute. - */ - public void testCompilerAttribute() { - // check defaults - String compiler = rmic.getCompiler(); - assertNotNull(compiler); - assertEquals("expected sun or kaffe, but found "+compiler,compiler,"default"); - - project.setNewProperty("build.rmic", "weblogic"); - compiler = rmic.getCompiler(); - assertNotNull(compiler); - assertEquals("weblogic", compiler); - - // check attribute overrides build.compiler - rmic.setCompiler("kaffe"); - compiler = rmic.getCompiler(); - assertNotNull(compiler); - assertEquals("kaffe", compiler); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/SQLExecTest.java b/src/testcases/org/apache/tools/ant/taskdefs/SQLExecTest.java deleted file mode 100644 index 6854b8b31..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/SQLExecTest.java +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import java.sql.Driver; -import java.sql.Connection; -import java.sql.SQLException; -import java.sql.DriverPropertyInfo; -import java.util.Properties; -import java.io.File; -import java.net.URL; - -import junit.framework.TestCase; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.BuildException; - -/** - * Simple testcase to test for driver caching. - * To test for your own database, you may need to tweak getProperties(int) - * and add a couple of keys. see testOracle and testMySQL for an example. - * - * It would be much better to extend this testcase by using HSQL - * as the test db, so that a db is really used. - * - */ -public class SQLExecTest extends TestCase { - - // some database keys, see #getProperties(int) - public final static int NULL = 0; - public final static int ORACLE = 1; - public final static int MYSQL = 2; - - // keys used in properties. - public final static String DRIVER = "driver"; - public final static String USER = "user"; - public final static String PASSWORD = "password"; - public final static String URL = "url"; - public final static String PATH = "path"; - public final static String SQL = "sql"; - - public SQLExecTest(String s) { - super(s); - } - - protected void setUp() throws Exception { - // make sure the cache is cleared. - JDBCTask.getLoaderMap().clear(); - } - - // simple test to ensure that the caching does work... - public void testDriverCaching(){ - SQLExec sql = createTask(getProperties(NULL)); - assertTrue(!SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); - try { - sql.execute(); - } catch (BuildException e){ - assertTrue(e.getException().getMessage().indexOf("No suitable Driver") != -1); - } - assertTrue(SQLExec.getLoaderMap().containsKey(NULL_DRIVER)); - assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER)); - ClassLoader loader1 = sql.getLoader(); - - // 2nd run.. - sql = createTask(getProperties(NULL)); - // the driver must still be cached. - assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); - try { - sql.execute(); - } catch (BuildException e){ - assertTrue(e.getException().getMessage().indexOf("No suitable Driver") != -1); - } - assertTrue(JDBCTask.getLoaderMap().containsKey(NULL_DRIVER)); - assertSame(sql.getLoader(), JDBCTask.getLoaderMap().get(NULL_DRIVER)); - assertSame(loader1, sql.getLoader()); - } - - public void testNull() throws Exception { - doMultipleCalls(1000, NULL, true, true); - } - - /* - public void testOracle(){ - doMultipleCalls(1000, ORACLE, true, false); - }*/ - - /* - public void testMySQL(){ - doMultipleCalls(1000, MYSQL, true, false); - }*/ - - - /** - * run a sql tasks multiple times. - * @param calls number of times to execute the task - * @param database the database to execute on. - * @param caching should caching be enabled ? - * @param catchexception true to catch exception for each call, false if not. - */ - protected void doMultipleCalls(int calls, int database, boolean caching, boolean catchexception){ - Properties props = getProperties(database); - for (int i = 0; i < calls; i++){ - SQLExec sql = createTask(props); - sql.setCaching(caching); - try { - sql.execute(); - } catch (BuildException e){ - if (!catchexception){ - throw e; - } - } - } - } - - /** - * Create a task from a set of properties - * @see #getProperties(int) - */ - protected SQLExec createTask(Properties props){ - SQLExec sql = new SQLExec(); - sql.setProject( new Project() ); - sql.setDriver( props.getProperty(DRIVER) ); - sql.setUserid( props.getProperty(USER) ); - sql.setPassword( props.getProperty(PASSWORD) ); - sql.setUrl( props.getProperty(URL) ); - sql.createClasspath().setLocation( new File(props.getProperty(PATH)) ); - sql.addText( props.getProperty(SQL) ); - return sql; - } - - /** - * try to find the path from a resource (jar file or directory name) - * so that it can be used as a classpath to load the resource. - */ - protected String findResourcePath(String resource){ - resource = resource.replace('.', '/') + ".class"; - URL url = getClass().getClassLoader().getResource(resource); - if (url == null) { - return null; - } - String u = url.toString(); - if (u.startsWith("jar:file:")) { - int pling = u.indexOf("!"); - return u.substring("jar:file:".length(), pling); - } else if (u.startsWith("file:")) { - int tail = u.indexOf(resource); - return u.substring("file:".length(), tail); - } - return null; - } - - /** - * returns a configuration associated to a specific database. - * If you want to test on your specific base, you'd better - * tweak this to make it run or add your own database. - * The driver lib should be dropped into the system classloader. - */ - protected Properties getProperties(int database){ - Properties props = null; - switch (database){ - case ORACLE: - props = getProperties("oracle.jdbc.driver.OracleDriver", "test", "test", "jdbc:oracle:thin:@127.0.0.1:1521:orcl"); - break; - case MYSQL: - props = getProperties("org.gjt.mm.mysql.Driver", "test", "test", "jdbc:mysql://127.0.0.1:3306/test"); - break; - case NULL: - default: - props = getProperties(NULL_DRIVER, "test", "test", "jdbc:database://hostname:port/name"); - } - // look for the driver path... - String path = findResourcePath(props.getProperty(DRIVER)); - props.put(PATH, path); - props.put(SQL, "create table OOME_TEST(X INTEGER NOT NULL);\ndrop table if exists OOME_TEST;"); - return props; - } - - /** helper method to build properties */ - protected Properties getProperties(String driver, String user, String pwd, String url){ - Properties props = new Properties(); - props.put(DRIVER, driver); - props.put(USER, user); - props.put(PASSWORD, pwd); - props.put(URL, url); - return props; - } - - -//--- NULL JDBC driver just for simple test since there are no db driver -// available as a default in Ant :) - - public final static String NULL_DRIVER = NullDriver.class.getName(); - - public static class NullDriver implements Driver { - public Connection connect(String url, Properties info) - throws SQLException { - return null; - } - - public boolean acceptsURL(String url) throws SQLException { - return false; - } - - public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) - throws SQLException { - return new DriverPropertyInfo[0]; - } - - public int getMajorVersion() { - return 0; - } - - public int getMinorVersion() { - return 0; - } - - public boolean jdbcCompliant() { - return false; - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java deleted file mode 100644 index a232d6aa1..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/SignJarTest.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * Testcase for the Signjar task - * - */ -public class SignJarTest extends BuildFileTest { - - public static final String EXPANDED_MANIFEST - = "src/etc/testcases/taskdefs/manifests/META-INF/MANIFEST.MF"; - - - public SignJarTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/signjar.xml"); - } - - public void tearDown() { - executeTarget("clean"); - } - - /** - * check for being offline - * @return true iff the system property "offline" is "true" - */ - private boolean isOffline() { - return Boolean.getBoolean("offline"); - } - public void testBasicSigning() { - executeTarget("basic"); - } - - public void testSigFile() { - executeTarget("sigfile"); - } - - public void testMaxMemory() { - executeTarget("maxmemory"); - } - - public void testURLKeystoreFile() { - executeTarget("urlKeystoreFile"); - } - - public void testURLKeystoreHTTP() { - if(!isOffline()) { - executeTarget("urlKeystoreHTTP"); - } - } - - public void testPreserveLastModified() { - executeTarget("preserveLastModified"); - } - - public void testFileset() { - executeTarget("testFileset"); - } - - public void testFilesetAndJar() { - executeTarget("testFilesetAndJar"); - } - - public void testFilesetAndSignedJar() { - expectBuildExceptionContaining("testFilesetAndSignedJar", - "incompatible attributes", - SignJar.ERROR_SIGNEDJAR_AND_PATHS); - } - - public void testPath() { - executeTarget("testPath"); - } - - public void testPathAndJar() { - executeTarget("testPathAndJar"); - } - - public void testPathAndSignedJar() { - expectBuildExceptionContaining("testPathAndSignedJar", - "incompatible attributes", - SignJar.ERROR_SIGNEDJAR_AND_PATHS); - } - - public void testSignedJar() { - executeTarget("testSignedJar"); - } - - public void testDestDir() { - executeTarget("testDestDir"); - } - - public void testDestDirAndSignedJar() { - expectBuildExceptionContaining("testFilesetAndSignedJar", - "incompatible attributes", - SignJar.ERROR_SIGNEDJAR_AND_PATHS); - } - - public void testDestDirAndSignedJar2() { - expectBuildExceptionContaining("testPathAndSignedJar", - "incompatible attributes", - SignJar.ERROR_SIGNEDJAR_AND_PATHS); - } - - public void testDestDirFileset() { - executeTarget("testDestDirFileset"); - } - - public void testMapperFileset() { - executeTarget("testMapperFileset"); - } - - public void testDestDirPath() { - executeTarget("testDestDirPath"); - } - - public void testMapperPath() { - executeTarget("testMapperPath"); - } - - public void testMapperNoDest() { - expectBuildExceptionContaining("testMapperNoDest", - "two mappers", - SignJar.ERROR_MAPPER_WITHOUT_DEST); - } - - public void testTwoMappers() { - expectBuildExceptionContaining("testTwoMappers", - "two mappers", - SignJar.ERROR_TOO_MANY_MAPPERS); - } - - public void testNoAlias() { - expectBuildExceptionContaining("testNoAlias", - "no alias", - SignJar.ERROR_NO_ALIAS); - } - - public void testNoFiles() { - expectBuildExceptionContaining("testNoFiles", - "no files", - SignJar.ERROR_NO_SOURCE); - } - - public void testNoStorePass() { - expectBuildExceptionContaining("testNoStorePass", - "no password", - SignJar.ERROR_NO_STOREPASS); - } - - public void testTsaLocalhost() { - //only test on java1.5+ - if(JavaEnvUtils.getJavaVersionNumber()>=15) { - expectBuildException("testTsaLocalhost", - "no TSA at localhost:0"); - assertLogContaining("java.net.ConnectException"); - } - } - - public void testSysProperty() { - executeTarget("testSysProperty"); - } - - public void testVerifyJar() { - executeTarget("testVerifyJar"); - } - - public void testVerifyNoArgs() { - expectBuildExceptionContaining("testVerifyNoArgs", - "no args", - AbstractJarSignerTask.ERROR_NO_SOURCE); - } - - public void testVerifyJarUnsigned() { - expectBuildExceptionContaining("testVerifyJarUnsigned", - "unsigned JAR file", - VerifyJar.ERROR_NO_VERIFY); - } - - public void NotestVerifyJarNotInKeystore() { - expectBuildExceptionContaining("testVerifyJarNotInKeystore", - "signature not in keystore", - VerifyJar.ERROR_NO_VERIFY); - } - - public void testVerifyFileset() { - executeTarget("testVerifyFileset"); - } - - public void testVerifyPath() { - executeTarget("testVerifyPath"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java b/src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java deleted file mode 100644 index 63b61afcf..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/SleepTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -/** - * @created 01 May 2001 - */ -public class SleepTest extends BuildFileTest { - - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/"; - private final static boolean TRACE=false; - private final static int ERROR_RANGE=1000; - - public SleepTest(String name) { - super(name); - } - - public void setUp() { - configureProject(TASKDEFS_DIR + "sleep.xml"); - } - - public void test1() { - Timer timer=new Timer(); - executeTarget("test1"); - timer.stop(); - if(TRACE) System.out.println(" test1 elapsed time="+timer.time()); - assertTrue(timer.time()>=0); - } - - public void test2() { - Timer timer=new Timer(); - executeTarget("test2"); - timer.stop(); - if(TRACE) System.out.println(" test2 elapsed time="+timer.time()); - assertTrue(timer.time()>=0); - } - - public void test3() { - Timer timer=new Timer(); - executeTarget("test3"); - timer.stop(); - if(TRACE) System.out.println(" test3 elapsed time="+timer.time()); - assertTrue(timer.time()>=(2000-ERROR_RANGE)); - } - - public void test4() { - Timer timer=new Timer(); - executeTarget("test3"); - timer.stop(); - if(TRACE) System.out.println(" test4 elapsed time="+timer.time()); - assertTrue(timer.time()>=(2000-ERROR_RANGE) && timer.time()<60000); - } - - public void test5() { - expectBuildException("test5", - "Negative sleep periods are not supported"); - } - - public void test6() { - Timer timer=new Timer(); - executeTarget("test6"); - timer.stop(); - if(TRACE) System.out.println(" test6 elapsed time="+timer.time()); - assertTrue(timer.time()<2000); - } - - - /** - * inner timer class - */ - private static class Timer { - long start=0; - long stop=0; - - public Timer() { - start(); - } - - public void start() { - start=System.currentTimeMillis(); - } - - public void stop() { - stop=System.currentTimeMillis(); - } - - public long time() { - return stop-start; - } - } - -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java b/src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java deleted file mode 100644 index 092acab82..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/StyleTest.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - - -import java.io.FileReader; -import java.io.IOException; -import java.io.Reader; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.taskdefs.optional.XsltTest; -import org.apache.tools.ant.util.FileUtils; - - -/** - * TestCases for {@link XSLTProcess} task. - * XXX merge with {@link XsltTest}? - * @version 2003-08-05 - */ -public class StyleTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public StyleTest(String s) { - super(s); - } - - protected void setUp() throws Exception { - configureProject("src/etc/testcases/taskdefs/style/build.xml"); - //executeTarget("setup"); - //commented out for performance while target is empty - } - - protected void tearDown() throws Exception { - executeTarget("teardown"); - } - - public void testStyleIsSet() throws Exception { - expectSpecificBuildException("testStyleIsSet", - "no stylesheet specified", "specify the " + - "stylesheet either as a filename in style " + - "attribute or as a nested resource"); - } - - public void testTransferParameterSet() throws Exception { - expectFileContains("testTransferParameterSet", // target - "out/out.xml", // file - "set='myvalue'"); // exptected string - } - - public void testTransferParameterEmpty() throws Exception { - expectFileContains("testTransferParameterEmpty", - "out/out.xml", - "empty=''"); - } - - public void testTransferParameterUnset() throws Exception { - expectFileContains("testTransferParameterUnset", - "out/out.xml", - "undefined='${value}'"); - } - - public void testTransferParameterUnsetWithIf() throws Exception { - expectFileContains("testTransferParameterUnsetWithIf", - "out/out.xml", - "undefined='undefined default value'"); - } - - public void testNewerStylesheet() throws Exception { - expectFileContains("testNewerStylesheet", - "out/out.xml", - "new-value"); - } - - public void testDefaultMapper() throws Exception { - testDefaultMapper("testDefaultMapper"); - } - - public void testExplicitFileset() throws Exception { - testDefaultMapper("testExplicitFileset"); - } - - public void testDefaultMapper(String target) throws Exception { - assertTrue(!(FileUtils.getFileUtils().resolveFile( - getProject().getBaseDir(),"out/data.html")).exists()); - expectFileContains(target, - "out/data.html", - "set='myvalue'"); - } - - public void testCustomMapper() throws Exception { - assertTrue(!FILE_UTILS.resolveFile( - getProject().getBaseDir(), "out/out.xml").exists()); - expectFileContains("testCustomMapper", - "out/out.xml", - "set='myvalue'"); - } - - public void testTypedMapper() throws Exception { - assertTrue(!FILE_UTILS.resolveFile( - getProject().getBaseDir(), "out/out.xml").exists()); - expectFileContains("testTypedMapper", - "out/out.xml", - "set='myvalue'"); - } - - public void testDirectoryHierarchyWithDirMatching() throws Exception { - executeTarget("testDirectoryHierarchyWithDirMatching"); - assertTrue(FILE_UTILS.resolveFile( - getProject().getBaseDir(), "out/dest/level1/data.html") - .exists()); - } - - public void testDirsWithSpaces() throws Exception { - executeTarget("testDirsWithSpaces"); - assertTrue(FILE_UTILS.resolveFile( - getProject().getBaseDir(), "out/d est/data.html") - .exists()); - } - - public void testWithStyleAttrAndResource() throws Exception { - expectSpecificBuildException("testWithStyleAttrAndResource", - "Must throws a BuildException", "specify the " + - "stylesheet either as a filename in style " + - "attribute or as a nested resource but not " + - "as both"); - } - - public void testWithFileResource() throws Exception { - expectFileContains("testWithFileResource", "out/out.xml", "set='value'"); - } - - public void testWithUrlResource() throws Exception { - expectFileContains("testWithUrlResource", "out/out.xml", "set='value'"); - } - - public void testFilenameAsParam() throws Exception { - executeTarget("testFilenameAsParam"); - assertFileContains("out/out/one.txt", "filename='one.xml'"); - assertFileContains("out/out/two.txt", "filename='two.xml'"); - assertFileContains("out/out/three.txt", "filename='three.xml'"); - assertFileContains("out/out/dir/four.txt", "filename='four.xml'"); - assertFileContains("out/out/dir/four.txt", "filedir ='-not-set-'"); - } - - public void testFilenameAsParamNoSetting() throws Exception { - executeTarget("testFilenameAsParamNoSetting"); - assertFileContains("out/out/one.txt", "filename='-not-set-'"); - assertFileContains("out/out/two.txt", "filename='-not-set-'"); - assertFileContains("out/out/three.txt", "filename='-not-set-'"); - assertFileContains("out/out/dir/four.txt", "filename='-not-set-'"); - } - - public void testFilenameAndFiledirAsParam() throws Exception { - executeTarget("testFilenameAndFiledirAsParam"); - assertFileContains("out/out/one.txt", "filename='one.xml'"); - assertFileContains("out/out/one.txt", "filedir ='.'"); - assertFileContains("out/out/dir/four.txt", "filename='four.xml'"); - assertFileContains("out/out/dir/four.txt", "filedir ='dir'"); - } - - - // ************* copied from ConcatTest ************* - - // ------------------------------------------------------ - // Helper methods - should be in BuildFileTest - // ----------------------------------------------------- - - private String getFileString(String filename) - throws IOException - { - Reader r = null; - try { - r = new FileReader(getProject().resolveFile(filename)); - return FileUtils.readFully(r); - } - finally { - FileUtils.close(r); - } - } - - private void expectFileContains( - String target, String filename, String contains) - throws IOException - { - executeTarget(target); - assertFileContains(filename, contains); - } - - private void assertFileContains(String filename, String contains) throws IOException { - String content = getFileString(filename); - assertTrue( - "expecting file " + filename - + " to contain " + contains - + " but got " + content, - content.indexOf(contains) > -1); - } - -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/SubAntTest.java b/src/testcases/org/apache/tools/ant/taskdefs/SubAntTest.java deleted file mode 100644 index b66f9a00a..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/SubAntTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; - -import junit.framework.AssertionFailedError; - -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.BuildListener; - - -public class SubAntTest extends BuildFileTest { - - public SubAntTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/subant.xml"); - } - - public void testnodirs() { - project.executeTarget("testnodirs"); - expectLog("testnodirs", "No sub-builds to iterate on"); - } - - // target must be specified - public void testgenericantfile() { - File dir1 = project.resolveFile("."); - File dir2 = project.resolveFile("subant/subant-test1"); - File dir3 = project.resolveFile("subant/subant-test2"); - - testBaseDirs("testgenericantfile", - new String[] { dir1.getAbsolutePath(), - dir2.getAbsolutePath(), - dir3.getAbsolutePath() - - }); - } - - public void testantfile() { - File dir1 = project.resolveFile("."); - // basedir of subant/subant-test1/subant.xml is .. - // therefore we expect here the subant/subant-test1 subdirectory - File dir2 = project.resolveFile("subant/subant-test1"); - // basedir of subant/subant-test2/subant.xml is .. - // therefore we expect here the subant subdirectory - File dir3 = project.resolveFile("subant"); - - testBaseDirs("testantfile", - new String[] { dir1.getAbsolutePath(), - dir2.getAbsolutePath(), - dir3.getAbsolutePath() - - }); - - } - - public void testMultipleTargets() { - executeTarget("multipleTargets"); - assertLogContaining("test1-one"); - assertLogContaining("test1-two"); - assertLogContaining("test2-one"); - assertLogContaining("test2-two"); - } - - public void testMultipleTargetsOneDoesntExist_FOEfalse() { - executeTarget("multipleTargetsOneDoesntExist_FOEfalse"); - assertLogContaining("Target \"three\" does not exist in the project \"subant\""); - } - - public void testMultipleTargetsOneDoesntExist_FOEtrue() { - expectBuildExceptionContaining("multipleTargetsOneDoesntExist_FOEtrue", - "Calling not existent target", - "Target \"three\" does not exist in the project \"subant\""); - } - - protected void testBaseDirs(String target, String[] dirs) { - SubAntTest.BasedirChecker bc = new SubAntTest.BasedirChecker(dirs); - project.addBuildListener(bc); - executeTarget(target); - AssertionFailedError ae = bc.getError(); - if (ae != null) { - throw ae; - } - project.removeBuildListener(bc); - } - - private class BasedirChecker implements BuildListener { - private String[] expectedBasedirs; - private int calls = 0; - private AssertionFailedError error; - - BasedirChecker(String[] dirs) { - expectedBasedirs = dirs; - } - - public void buildStarted(BuildEvent event) {} - public void buildFinished(BuildEvent event) {} - public void targetFinished(BuildEvent event){} - public void taskStarted(BuildEvent event) {} - public void taskFinished(BuildEvent event) {} - public void messageLogged(BuildEvent event) {} - - public void targetStarted(BuildEvent event) { - if (event.getTarget().getName().equals("")) { - return; - } - if (error == null) { - try { - assertEquals(expectedBasedirs[calls++], - event.getProject().getBaseDir().getAbsolutePath()); - } catch (AssertionFailedError e) { - error = e; - } - } - } - - AssertionFailedError getError() { - return error; - } - - } - - -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/SyncTest.java b/src/testcases/org/apache/tools/ant/taskdefs/SyncTest.java deleted file mode 100644 index c0bb04f55..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/SyncTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -public class SyncTest extends BuildFileTest { - - public SyncTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/sync.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testSimpleCopy() { - executeTarget("simplecopy"); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsPresent(d); - assertTrue(getFullLog().indexOf("dangling") == -1); - } - - public void testEmptyCopy() { - executeTarget("emptycopy"); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsNotPresent(d); - String c = getProject().getProperty("dest") + "/a/b/c"; - assertFileIsNotPresent(c); - assertTrue(getFullLog().indexOf("dangling") == -1); - } - - public void testEmptyDirCopy() { - executeTarget("emptydircopy"); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsNotPresent(d); - String c = getProject().getProperty("dest") + "/a/b/c"; - assertFileIsPresent(c); - assertTrue(getFullLog().indexOf("dangling") == -1); - } - - public void testCopyAndRemove() { - testCopyAndRemove("copyandremove"); - } - - public void testCopyAndRemoveWithFileList() { - testCopyAndRemove("copyandremove-with-filelist"); - } - - public void testCopyAndRemoveWithZipfileset() { - testCopyAndRemove("copyandremove-with-zipfileset"); - } - - private void testCopyAndRemove(String target) { - executeTarget(target); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsPresent(d); - String f = getProject().getProperty("dest") + "/e/f"; - assertFileIsNotPresent(f); - assertTrue(getFullLog().indexOf("Removing orphan file:") > -1); - assertDebuglogContaining("Removed 1 dangling file from"); - assertDebuglogContaining("Removed 1 dangling directory from"); - } - - public void testCopyAndRemoveEmptyPreserve() { - executeTarget("copyandremove-emptypreserve"); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsPresent(d); - String f = getProject().getProperty("dest") + "/e/f"; - assertFileIsNotPresent(f); - assertTrue(getFullLog().indexOf("Removing orphan file:") > -1); - assertDebuglogContaining("Removed 1 dangling file from"); - assertDebuglogContaining("Removed 1 dangling directory from"); - } - - public void testEmptyDirCopyAndRemove() { - executeTarget("emptydircopyandremove"); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsNotPresent(d); - String c = getProject().getProperty("dest") + "/a/b/c"; - assertFileIsPresent(c); - String f = getProject().getProperty("dest") + "/e/f"; - assertFileIsNotPresent(f); - assertTrue(getFullLog().indexOf("Removing orphan directory:") > -1); - assertDebuglogContaining("NO dangling file to remove from"); - assertDebuglogContaining("Removed 2 dangling directories from"); - } - - public void testCopyNoRemove() { - executeTarget("copynoremove"); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsPresent(d); - String f = getProject().getProperty("dest") + "/e/f"; - assertFileIsPresent(f); - assertTrue(getFullLog().indexOf("Removing orphan file:") == -1); - } - - public void testCopyNoRemoveSelectors() { - executeTarget("copynoremove-selectors"); - String d = getProject().getProperty("dest") + "/a/b/c/d"; - assertFileIsPresent(d); - String f = getProject().getProperty("dest") + "/e/f"; - assertFileIsPresent(f); - assertTrue(getFullLog().indexOf("Removing orphan file:") == -1); - } - - public void assertFileIsPresent(String f) { - assertTrue("Expected file " + f, - getProject().resolveFile(f).exists()); - } - - public void assertFileIsNotPresent(String f) { - assertTrue("Didn't expect file " + f, - !getProject().resolveFile(f).exists()); - } -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TStampTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TStampTest.java deleted file mode 100644 index 8f915468b..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TStampTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import java.util.Calendar; -import java.util.TimeZone; -import java.util.Date; -import java.text.SimpleDateFormat; - -import junit.framework.TestCase; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Location; - -/** - * - */ -public class TStampTest extends TestCase { - - protected Tstamp tstamp; - protected Project project; - protected Location location; - - public TStampTest(String s) { - super(s); - } - - protected void setUp() throws Exception { - location = new Location("test.xml"); - project = new Project(); - tstamp = new Tstamp(); - tstamp.setLocation(location); - tstamp.setProject(project); - } - - public void testTimeZone() throws Exception { - Tstamp.CustomFormat format = tstamp.createFormat(); - format.setProperty("today"); - format.setPattern("HH:mm:ss z"); - format.setTimezone("GMT"); - Date date = Calendar.getInstance().getTime(); - format.execute(project, date, location); - String today = project.getProperty("today"); - - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); - sdf.setTimeZone( TimeZone.getTimeZone("GMT") ); - String expected = sdf.format(date); - - assertEquals(expected, today); - } - - /** - * verifies that custom props have priority over the - * originals - * @throws Exception - */ - public void testWriteOrder() throws Exception { - Tstamp.CustomFormat format = tstamp.createFormat(); - format.setProperty("TODAY"); - format.setPattern("HH:mm:ss z"); - format.setTimezone("GMT"); - Date date = Calendar.getInstance().getTime(); - format.execute(project, date, location); - String today = project.getProperty("TODAY"); - - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); - sdf.setTimeZone( TimeZone.getTimeZone("GMT") ); - String expected = sdf.format(date); - - assertEquals(expected, today); - - } - - /** - * verifies that custom props have priority over the - * originals - * @throws Exception - */ - public void testPrefix() throws Exception { - tstamp.setPrefix("prefix"); - tstamp.execute(); - String prop= project.getProperty("prefix.DSTAMP"); - assertNotNull(prop); - } - - public void testFormatPrefix() throws Exception { - Tstamp.CustomFormat format = tstamp.createFormat(); - format.setProperty("format"); - format.setPattern("HH:mm:ss z"); - format.setTimezone("GMT"); - - tstamp.setPrefix("prefix"); - tstamp.execute(); - String prop= project.getProperty("prefix.format"); - assertNotNull(prop); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TarTest.java deleted file mode 100644 index 55bed190f..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TarTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.IOException; -import java.io.File; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class TarTest extends BuildFileTest { - - public TarTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/tar.xml"); - } - - public void test1() { - expectBuildException("test1", "required argument not specified"); - } - - public void test2() { - expectBuildException("test2", "required argument not specified"); - } - - public void test3() { - expectBuildException("test3", "required argument not specified"); - } - - public void test4() { - expectBuildException("test4", "tar cannot include itself"); - } - - public void test5() { - executeTarget("test5"); - File f - = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test5.tar"); - - if (!f.exists()) { - fail("Tarring a directory failed"); - } - } - - public void test6() { - expectBuildException("test6", "Invalid value specified for longfile attribute."); - } - - public void test7() { - test7("test7"); - } - - public void test7UsingPlainFileSet() { - test7("test7UsingPlainFileSet"); - } - - public void test7UsingFileList() { - test7("test7UsingFileList"); - } - - private void test7(String target) { - executeTarget(target); - File f1 - = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test7-prefix"); - - if (!(f1.exists() && f1.isDirectory())) { - fail("The prefix attribute is not working properly."); - } - - File f2 - = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test7dir"); - - if (!(f2.exists() && f2.isDirectory())) { - fail("The prefix attribute is not working properly."); - } - } - - public void test8() { - test8("test8"); - } - - public void test8UsingZipFileset() { - test8("test8UsingZipFileset"); - } - - public void test8UsingZipFilesetSrc() { - test8("test8UsingZipFilesetSrc"); - } - - public void test8UsingTarFilesetSrc() { - test8("test8UsingTarFilesetSrc"); - } - - public void test8UsingZipEntry() { - test8("test8UsingZipEntry"); - } - - private void test8(String target) { - executeTarget(target); - File f1 - = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test8.xml"); - if (! f1.exists()) { - fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); - } - } - - public void test9() { - expectBuildException("test9", "Invalid value specified for compression attribute."); - } - - public void test10() { - executeTarget("test10"); - File f1 - = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test10.xml"); - if (! f1.exists()) { - fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); - } - } - - public void test11() { - executeTarget("test11"); - File f1 - = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test11.xml"); - if (! f1.exists()) { - fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly"); - } - } - - public void testGZipResource() throws IOException { - executeTarget("testGZipResource"); - assertTrue(FileUtils.getFileUtils() - .contentEquals(getProject().resolveFile("../asf-logo.gif"), - getProject().resolveFile("testout/asf-logo.gif.gz"))); - } - - public void tearDown() { - executeTarget("cleanup"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TaskdefTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TaskdefTest.java deleted file mode 100644 index 091a39312..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TaskdefTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class TaskdefTest extends BuildFileTest { - - public TaskdefTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/taskdef.xml"); - } - - public void test1() { - expectBuildException("test1", "required argument not specified"); - } - - public void test2() { - expectBuildException("test2", "required argument not specified"); - } - - public void test3() { - expectBuildException("test3", "required argument not specified"); - } - - public void test4() { - expectBuildException("test4", "classname specified doesn't exist"); - } - - public void test5() { - expectBuildException("test5", "No public execute() in " + Project.class); - } - - public void test5a() { - executeTarget("test5a"); - } - - public void test6() { - expectLog("test6", "simpletask: worked"); - } - - public void test7() { - expectLog("test7", "worked"); - } - - public void testGlobal() { - expectLog("testGlobal", "worked"); - } - - public void testOverride() { - executeTarget("testOverride"); - String log = getLog(); - assertTrue("override warning sent", - log.indexOf("Trying to override old definition of task copy") > -1); - assertTrue("task inside target worked", - log.indexOf("In target") > -1); - assertTrue("task inside target worked", - log.indexOf("In TaskContainer") > -1); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java deleted file mode 100644 index 5de5ef4e5..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - * @deprecated use BuildFileTest instead. - */ -public abstract class TaskdefsTest extends BuildFileTest { - - public TaskdefsTest(String name) { - super(name); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TestProcess.java b/src/testcases/org/apache/tools/ant/taskdefs/TestProcess.java deleted file mode 100644 index 00ebe4b8c..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TestProcess.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -/** - * Interactive Testcase for Processdestroyer. - * - */ -public class TestProcess - implements Runnable -{ - private boolean run = true; - private boolean done = false; - - public void shutdown() - { - if (!done) - { - System.out.println("shutting down TestProcess"); - run = false; - - synchronized(this) - { - while (!done) - { - try { wait(); } catch (InterruptedException ie) {} - } - } - - System.out.println("TestProcess shut down"); - } - } - - public void run() - { - for (int i = 0; i < 5 && run; i++) - { - System.out.println(Thread.currentThread().getName()); - - try { Thread.sleep(2000); } catch (InterruptedException ie) {} - } - - synchronized(this) - { - done = true; - notifyAll(); - } - } - - public Thread getShutdownHook() - { - return new TestProcessShutdownHook(); - } - - private class TestProcessShutdownHook - extends Thread - { - public void run() - { - shutdown(); - } - } - - public static void main(String[] args) - { - TestProcess tp = new TestProcess(); - new Thread(tp, "TestProcess thread").start(); - Runtime.getRuntime().addShutdownHook(tp.getShutdownHook()); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TimeProcess.java b/src/testcases/org/apache/tools/ant/taskdefs/TimeProcess.java deleted file mode 100644 index eee15d129..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TimeProcess.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -/** - * Helper class for ExecuteWatchdogTest and ExecuteJavaTest. - * - *

Used to be an inner class of ExecuteWatchdogTest. - * - */ -public class TimeProcess { - public static void main(String[] args) throws Exception { - int time = Integer.parseInt(args[0]); - if (time < 1) { - throw new IllegalArgumentException("Invalid time: " + time); - } - Thread.sleep(time); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TouchTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TouchTest.java deleted file mode 100644 index ea7d499fb..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TouchTest.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.util.FileUtils; - -import java.io.File; - -public class TouchTest extends BuildFileTest { - - private static String TOUCH_FILE = "src/etc/testcases/taskdefs/touchtest"; - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public TouchTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/touch.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public long getTargetTime() { - - File file = new File(System.getProperty("root"), TOUCH_FILE); - if(!file.exists()) { - throw new BuildException("failed to touch file " + file); - } - return file.lastModified(); - } - - /** - * No real test, simply checks whether the dateformat without - * seconds is accepted - by erroring out otherwise. - */ - public void testNoSeconds() { - executeTarget("noSeconds"); - long time = getTargetTime(); - } - - /** - * No real test, simply checks whether the dateformat with - * seconds is accepted - by erroring out otherwise. - */ - public void testSeconds() { - executeTarget("seconds"); - long time=getTargetTime(); - } - /** - * verify that the millis test sets things up - */ - public void testMillis() { - touchFile("testMillis", 662256000000L); - } - - /** - * verify that the default value defaults to now - */ - public void testNow() { - long now=System.currentTimeMillis(); - executeTarget("testNow"); - long time = getTargetTime(); - assertTimesNearlyMatch(time,now,5000); - } - /** - * verify that the millis test sets things up - */ - public void test2000() { - touchFile("test2000", 946080000000L); - } - - /** - * test the file list - */ - public void testFilelist() { - touchFile("testFilelist", 662256000000L); - } - - /** - * test the file set - */ - public void testFileset() { - touchFile("testFileset", 946080000000L); - } - - /** - * test the resource collection - */ - public void testResourceCollection() { - touchFile("testResourceCollection", 1662256000000L); - } - - /** - * test the mapped file set - */ - public void testMappedFileset() { - executeTarget("testMappedFileset"); - } - - /** - * test the explicit mapped file set - */ - public void testExplicitMappedFileset() { - executeTarget("testExplicitMappedFileset"); - } - - /** - * test the mapped file list - */ - public void testMappedFilelist() { - executeTarget("testMappedFilelist"); - } - - /** - * test the pattern attribute - */ - public void testGoodPattern() { - executeTarget("testGoodPattern"); - } - - /** - * test the pattern attribute again - */ - public void testBadPattern() { - expectBuildExceptionContaining("testBadPattern", - "No parsing exception thrown", "Unparseable"); - } - - /** - * run a target to touch the test file; verify the timestamp is as expected - * @param targetName - * @param timestamp - */ - private void touchFile(String targetName, long timestamp) { - executeTarget(targetName); - long time = getTargetTime(); - assertTimesNearlyMatch(timestamp, time); - } - - /** - * assert that two times are within the current FS granularity; - * @param timestamp - * @param time - */ - public void assertTimesNearlyMatch(long timestamp,long time) { - long granularity= FILE_UTILS.getFileTimestampGranularity(); - assertTimesNearlyMatch(timestamp, time, granularity); - } - - /** - * assert that two times are within a specified range - * @param timestamp - * @param time - * @param range - */ - private void assertTimesNearlyMatch(long timestamp, long time, long range) { - assertTrue("Time " + timestamp + " is not within " + range + " ms of " - + time, (Math.abs(time - timestamp) <= range)); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TypeAdapterTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TypeAdapterTest.java deleted file mode 100644 index d85e15616..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TypeAdapterTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.lang.reflect.Method; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.TypeAdapter; - - -/** - */ -public class TypeAdapterTest extends BuildFileTest { - - public TypeAdapterTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/typeadapter.xml"); - } - - public void testTaskAdapter() { - expectLogContaining("taskadapter", "MyExec called"); - } - - public void testRunAdapter() { - expectLogContaining("runadapter", "MyRunnable called"); - } - - public void testRunAdapterError() { - expectBuildExceptionContaining( - "runadaptererror", "xx", "No public run() method in"); - } - - public void testDelay() { - expectLogContaining("delay", "MyTask called"); - } - - public void testOnErrorReport() { - expectLogContaining("onerror.report", - "MyTaskNotPresent cannot be found"); - } - - public void testOnErrorIgnore() { - expectLog("onerror.ignore",""); - } - - public static class MyTask extends Task { - public void execute() { - log("MyTask called"); - } - } - - public static class MyExec { - private Project project; - public void setProject(Project project) { - this.project = project; - } - - public void execute() { - project.log("MyExec called"); - } - } - - public static class MyRunnable { - private Project project; - public void setProject(Project project) { - this.project = project; - } - - public void run() { - project.log("MyRunnable called"); - } - } - - public static class RunnableAdapter - extends Task implements TypeAdapter - { - private String execMethodName = "run"; - private Object proxy; - - public Method getExecuteMethod(Class proxyClass) { - try { - Method execMethod = proxyClass.getMethod( - execMethodName, null); - if (!Void.TYPE.equals(execMethod.getReturnType())) { - String message = - "return type of " + execMethodName + "() should be " - + "void but was \"" + execMethod.getReturnType() + - "\" in " - + proxyClass; - log(message, Project.MSG_WARN); - } - return execMethod; - } catch (NoSuchMethodException e) { - String message = "No public "+ execMethodName + - "() method in " - + proxyClass; - log(message, Project.MSG_ERR); - throw new BuildException(message); - } - } - public void checkProxyClass(Class proxyClass) { - getExecuteMethod(proxyClass); - } - - public void setProxy(Object o) { - getExecuteMethod(o.getClass()); - this.proxy = o; - } - - public Object getProxy() { - return proxy; - } - - public void execute() { - getProject().setProjectReference(proxy); - Method executeMethod = getExecuteMethod(proxy.getClass()); - try { - executeMethod.invoke(proxy, null); - } catch (java.lang.reflect.InvocationTargetException ie) { - log("Error in " + proxy.getClass(), Project.MSG_ERR); - Throwable t = ie.getTargetException(); - if (t instanceof BuildException) { - throw ((BuildException) t); - } else { - throw new BuildException(t); - } - } catch (Exception ex) { - log("Error in " + proxy.getClass(), Project.MSG_ERR); - throw new BuildException(ex); - } - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TypedefTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TypedefTest.java deleted file mode 100644 index 5c2c041b1..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/TypedefTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class TypedefTest extends BuildFileTest { - - public TypedefTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/typedef.xml"); - } - - public void testEmpty() { - expectBuildException("empty", "required argument not specified"); - } - - public void testNoName() { - expectBuildException("noName", "required argument not specified"); - } - - public void testNoClassname() { - expectBuildException("noClassname", "required argument not specified"); - } - - public void testClassNotFound() { - expectBuildException("classNotFound", - "classname specified doesn't exist"); - } - - public void testGlobal() { - expectLog("testGlobal", ""); - Object ref = project.getReferences().get("global"); - assertNotNull("ref is not null", ref); - assertEquals("org.example.types.TypedefTestType", - ref.getClass().getName()); - } - - public void testLocal() { - expectLog("testLocal", ""); - Object ref = project.getReferences().get("local"); - assertNotNull("ref is not null", ref); - assertEquals("org.example.types.TypedefTestType", - ref.getClass().getName()); - } - - /** - * test to make sure that one can define a not present - * optional type twice and then have a valid definition. - */ - public void testDoubleNotPresent() { - expectLogContaining("double-notpresent", "hi"); - } - - public void testNoResourceOnErrorFailAll(){ - this.expectBuildExceptionContaining("noresourcefailall","the requested resource does not exist","Could not load definitions from resource "); - } - - public void testNoResourceOnErrorFail(){ - expectLogContaining("noresourcefail","Could not load definitions from resource "); - } - - public void testNoResourceOnErrorNotFail(){ - expectLogContaining("noresourcenotfail","Could not load definitions from resource "); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/UntarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/UntarTest.java deleted file mode 100644 index 5ec3b9f7a..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/UntarTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class UntarTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public UntarTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/untar.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testRealTest() throws java.io.IOException { - testLogoExtraction("realTest"); - } - - public void testRealGzipTest() throws java.io.IOException { - testLogoExtraction("realGzipTest"); - } - - public void testRealBzip2Test() throws java.io.IOException { - testLogoExtraction("realBzip2Test"); - } - - public void testTestTarTask() throws java.io.IOException { - testLogoExtraction("testTarTask"); - } - - public void testTestGzipTarTask() throws java.io.IOException { - testLogoExtraction("testGzipTarTask"); - } - - public void testTestBzip2TarTask() throws java.io.IOException { - testLogoExtraction("testBzip2TarTask"); - } - - public void testSrcDirTest() { - expectBuildException("srcDirTest", "Src cannot be a directory."); - } - - public void testEncoding() { - expectSpecificBuildException("encoding", - " overrides setEncoding.", - "The untar task doesn't support the " - + "encoding attribute"); - } - - public void testResourceCollection() throws java.io.IOException { - testLogoExtraction("resourceCollection"); - } - - private void testLogoExtraction(String target) throws java.io.IOException { - executeTarget(target); - assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), - project.resolveFile("asf-logo.gif"))); - } - - public void testDocumentationClaimsOnCopy() { - executeTarget("testDocumentationClaimsOnCopy"); - assertFalse(getProject().resolveFile("untartestout/1/foo").exists()); - assertTrue(getProject().resolveFile("untartestout/2/bar").exists()); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java b/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java deleted file mode 100644 index 14a769b99..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/UnzipTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -import java.io.IOException; - -/** - */ -public class UnzipTest extends BuildFileTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public UnzipTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/unzip.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - expectBuildException("test1", "required argument not specified"); - } - - public void test2() { - expectBuildException("test2", "required argument not specified"); - } - - public void test3() { - expectBuildException("test3", "required argument not specified"); - } - - - public void testRealTest() throws java.io.IOException { - executeTarget("realTest"); - assertLogoUncorrupted(); - } - - /** - * test that the logo gif file has not been corrupted - * @throws IOException - */ - private void assertLogoUncorrupted() throws IOException { - assertTrue(FILE_UTILS.contentEquals(project.resolveFile("../asf-logo.gif"), - project.resolveFile("asf-logo.gif"))); - } - - public void testTestZipTask() throws java.io.IOException { - executeTarget("testZipTask"); - assertLogoUncorrupted(); - } - - public void testTestUncompressedZipTask() throws java.io.IOException { - executeTarget("testUncompressedZipTask"); - assertLogoUncorrupted(); - } - - /* - * PR 11100 - */ - public void testPatternSetExcludeOnly() { - executeTarget("testPatternSetExcludeOnly"); - assertFileMissing("1/foo is excluded", "unziptestout/1/foo"); - assertFileExists("2/bar is not excluded", "unziptestout/2/bar"); - } - - /* - * PR 11100 - */ - public void testPatternSetIncludeOnly() { - executeTarget("testPatternSetIncludeOnly"); - assertFileMissing("1/foo is not included", "unziptestout/1/foo"); - assertFileExists("2/bar is included", "unziptestout/2/bar"); - } - - /* - * PR 11100 - */ - public void testPatternSetIncludeAndExclude() { - executeTarget("testPatternSetIncludeAndExclude"); - assertFileMissing("1/foo is not included", "unziptestout/1/foo"); - assertFileMissing("2/bar is excluded", "unziptestout/2/bar"); - } - - /* - * PR 38973 - */ - public void testTwoPatternSets() { - executeTarget("testTwoPatternSets"); - assertFileMissing("1/foo is not included", "unziptestout/1/foo"); - assertFileExists("2/bar is included", "unziptestout/2/bar"); - } - - /* - * PR 38973 - */ - public void testTwoPatternSetsWithExcludes() { - executeTarget("testTwoPatternSetsWithExcludes"); - assertFileMissing("1/foo is not included", "unziptestout/1/foo"); - assertFileMissing("2/bar is excluded", "unziptestout/2/bar"); - } - - /* - * PR 16213 - */ - public void testSelfExtractingArchive() { - executeTarget("selfExtractingArchive"); - } - - - /* - * PR 20969 - */ - public void testPatternSetSlashOnly() { - executeTarget("testPatternSetSlashOnly"); - assertFileMissing("1/foo is not included", "unziptestout/1/foo"); - assertFileExists("\"2/bar is included", "unziptestout/2/bar"); - } - - - /* - * PR 10504 - */ - public void testEncoding() { - executeTarget("encodingTest"); - assertFileExists("foo has been properly named", "unziptestout/foo"); - } - - /* - * PR 21996 - */ - public void testFlattenMapper() { - executeTarget("testFlattenMapper"); - assertFileMissing("1/foo is not flattened", "unziptestout/1/foo"); - assertFileExists("foo is flattened", "unziptestout/foo"); - } - - /** - * assert that a file exists, relative to the project - * @param message message if there is no mpatch - * @param filename filename to resolve against the project - */ - private void assertFileExists(String message, String filename) { - assertTrue(message, - getProject().resolveFile(filename).exists()); - } - - /** - * assert that a file doesnt exist, relative to the project - * - * @param message message if there is no mpatch - * @param filename filename to resolve against the project - */ - private void assertFileMissing(String message, String filename) { - assertTrue(message, - !getProject().resolveFile(filename).exists()); - } - - /** - * PR 21996 - */ - public void testGlobMapper() { - executeTarget("testGlobMapper"); - assertFileMissing("1/foo is not mapped", "unziptestout/1/foo"); - assertFileExists("1/foo is mapped", "unziptestout/1/foo.txt"); - } - - public void testTwoMappers() { - expectBuildException("testTwoMappers",Expand.ERROR_MULTIPLE_MAPPERS); - } - - public void testResourceCollections() { - executeTarget("testResourceCollection"); - assertFileExists("junit.jar has been extracted", - "unziptestout/junit/framework/Assert.class"); - } - - public void testDocumentationClaimsOnCopy() { - executeTarget("testDocumentationClaimsOnCopy"); - assertFileMissing("1/foo is excluded", "unziptestout/1/foo"); - assertFileExists("2/bar is not excluded", "unziptestout/2/bar"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/UpToDateTest.java b/src/testcases/org/apache/tools/ant/taskdefs/UpToDateTest.java deleted file mode 100755 index 2e8ffa44f..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/UpToDateTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -public class UpToDateTest extends BuildFileTest { - - public UpToDateTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/uptodate.xml"); - } - - public void tearDown() { - executeTarget("tearDown"); - } - - public void testFilesetUpToDate() { - expectPropertySet("testFilesetUpToDate", "foo"); - } - - public void testFilesetOutOfDate() { - expectPropertyUnset("testFilesetOutOfDate", "foo"); - } - - public void testRCUpToDate() { - expectPropertySet("testRCUpToDate", "foo"); - } - - public void testRCOutOfDate() { - expectPropertyUnset("testRCOutOfDate", "foo"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/WarTest.java b/src/testcases/org/apache/tools/ant/taskdefs/WarTest.java deleted file mode 100644 index fea98659a..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/WarTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Testcase for the war task - * - */ -public class WarTest extends BuildFileTest { - public static final String TEST_BUILD_FILE - = "src/etc/testcases/taskdefs/war.xml"; - - public WarTest(String name) { - super(name); - } - - public void setUp() { - configureProject(TEST_BUILD_FILE); - } - - public void tearDown() { - executeTarget("clean"); - } - - /** - * Test direct dependency removal - */ - public void testLibRefs() { - executeTarget("testlibrefs"); - File f = getProject().resolveFile("working/WEB-INF/lib/war.xml"); - assertTrue("File has been put into lib", f.exists()); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/WhichResourceTest.java b/src/testcases/org/apache/tools/ant/taskdefs/WhichResourceTest.java deleted file mode 100644 index 61854e53f..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/WhichResourceTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.BuildFileTest; - -public class WhichResourceTest extends BuildFileTest { - public static final String TEST_BUILD_FILE - = "src/etc/testcases/taskdefs/whichresource.xml"; - - public WhichResourceTest(String name) { - super(name); - } - - public void setUp() { - configureProject(TEST_BUILD_FILE); - } - - public void testClassname() { - executeTarget("testClassname"); - assertNotNull(getProject().getProperty("antmain")); - } - - public void testResourcename() { - executeTarget("testResourcename"); - assertNotNull(getProject().getProperty("defaults")); - } - - public void testResourcenameWithLeadingSlash() { - executeTarget("testResourcenameWithLeadingSlash"); - assertNotNull(getProject().getProperty("defaults")); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java b/src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java deleted file mode 100644 index c8a46ea1a..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/XmlPropertyTest.java +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs; - -import java.io.File; -import java.io.FileFilter; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Properties; -import java.util.Vector; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.util.FileUtils; - -/** - */ -public class XmlPropertyTest extends BuildFileTest { - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public XmlPropertyTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/xmlproperty.xml"); - } - - public void testFile() { - testProperties("test"); - } - - public void testResource() { - testProperties("testResource"); - } - - private void testProperties(String target) { - executeTarget(target); - assertEquals("true", getProject().getProperty("root-tag(myattr)")); - assertEquals("Text", getProject().getProperty("root-tag.inner-tag")); - assertEquals("val", - getProject().getProperty("root-tag.inner-tag(someattr)")); - assertEquals("false", getProject().getProperty("root-tag.a2.a3.a4")); - assertEquals("CDATA failed", - "", getProject().getProperty("root-tag.cdatatag")); - } - - public void testDTD() { - executeTarget("testdtd"); - assertEquals("Text", getProject().getProperty("root-tag.inner-tag")); - } - - public void testNone () { - doTest("testNone", false, false, false, false, false); - } - - public void testKeeproot() { - doTest("testKeeproot", true, false, false, false, false); - } - - public void testCollapse () { - doTest("testCollapse", false, true, false, false, false); - } - - public void testSemantic () { - doTest("testSemantic", false, false, true, false, false); - } - - public void testKeeprootCollapse () { - doTest("testKeeprootCollapse", true, true, false, false, false); - } - - public void testKeeprootSemantic () { - doTest("testKeeprootSemantic", true, false, true, false, false); - } - - public void testCollapseSemantic () { - doTest("testCollapseSemantic", false, true, true, false, false); - } - - public void testKeeprootCollapseSemantic () { - doTest("testKeeprootCollapseSemantic", true, true, true, false, false); - } - - public void testInclude () { - doTest("testInclude", false, false, false, true, false); - } - - public void testSemanticInclude () { - doTest("testSemanticInclude", false, false, true, true, false); - } - - public void testSemanticLocal () { - doTest("testSemanticInclude", false, false, true, false, true); - } - - public void testNeedsCatalog() { - executeTarget("testneedscat"); - assertEquals("true", getProject().getProperty("skinconfig.foo")); - } - - /** - * Actually run a test, finding all input files (and corresponding - * goldfile) - */ - private void doTest(String msg, boolean keepRoot, boolean collapse, - boolean semantic, boolean include, boolean localRoot) { - Enumeration iter = - getFiles(new File(System.getProperty("root"), "src/etc/testcases/taskdefs/xmlproperty/inputs")); - while (iter.hasMoreElements()) { - File inputFile = (File) iter.nextElement(); - // What's the working directory? If local, then its the - // folder of the input file. Otherwise, its the "current" dir.. - File workingDir; - if ( localRoot ) { - workingDir = inputFile.getParentFile(); - } else { - workingDir = FILE_UTILS.resolveFile(new File("."), "."); - } - - try { - - File propertyFile = getGoldfile(inputFile, keepRoot, collapse, - semantic, include, localRoot); - if (!propertyFile.exists()) { -// System.out.println("Skipping as " -// + propertyFile.getAbsolutePath() -// + ") doesn't exist."); - continue; - } - - // System.out.println(msg + " (" + propertyFile.getName() + ") in (" + workingDir + ")"); - - Project p = new Project(); - - XmlProperty xmlproperty = new XmlProperty(); - xmlproperty.setProject(p); - xmlproperty.setFile(inputFile); - - xmlproperty.setKeeproot(keepRoot); - xmlproperty.setCollapseAttributes(collapse); - xmlproperty.setSemanticAttributes(semantic); - xmlproperty.setIncludeSemanticAttribute(include); - xmlproperty.setRootDirectory(workingDir); - - // Set a property on the project to make sure that loading - // a property with the same name from an xml file will - // *not* change it. - p.setNewProperty("override.property.test", "foo"); - - xmlproperty.execute(); - - Properties props = new Properties(); - props.load(new FileInputStream(propertyFile)); - - //printProperties(p.getProperties()); - - ensureProperties(msg, inputFile, workingDir, p, props); - ensureReferences(msg, inputFile, p.getReferences()); - - } catch (IOException ex) { - fail(ex.toString()); - } - } - } - - /** - * Make sure every property loaded from the goldfile was also - * read from the XmlProperty. We could try and test the other way, - * but some other properties may get set in the XmlProperty due - * to generic Project/Task configuration. - */ - private static void ensureProperties (String msg, File inputFile, - File workingDir, Project p, - Properties properties) { - Hashtable xmlproperties = p.getProperties(); - // Every key identified by the Properties must have been loaded. - Enumeration propertyKeyEnum = properties.propertyNames(); - while(propertyKeyEnum.hasMoreElements()){ - String currentKey = propertyKeyEnum.nextElement().toString(); - String assertMsg = msg + "-" + inputFile.getName() - + " Key=" + currentKey; - - String propertyValue = properties.getProperty(currentKey); - - String xmlValue = (String)xmlproperties.get(currentKey); - - if ( propertyValue.indexOf("ID.") == 0 ) { - // The property is an id's thing -- either a property - // or a path. We need to make sure - // that the object was created with the given id. - // We don't have an adequate way of testing the actual - // *value* of the Path object, though... - String id = currentKey; - Object obj = p.getReferences().get(id); - - if ( obj == null ) { - fail(assertMsg + " Object ID does not exist."); - } - - // What is the property supposed to be? - propertyValue = - propertyValue.substring(3, propertyValue.length()); - if (propertyValue.equals("path")) { - if (!(obj instanceof Path)) { - fail(assertMsg + " Path ID is a " - + obj.getClass().getName()); - } - } else { - assertEquals(assertMsg, propertyValue, obj.toString()); - } - - } else { - - if (propertyValue.indexOf("FILE.") == 0) { - // The property is the name of a file. We are testing - // a location attribute, so we need to resolve the given - // file name in the provided folder. - String fileName = - propertyValue.substring(5, propertyValue.length()); - File f = new File(workingDir, fileName); - propertyValue = f.getAbsolutePath(); - } - - assertEquals(assertMsg, propertyValue, xmlValue); - } - - } - } - - /** - * Debugging method to print the properties in the given hashtable - */ - private static void printProperties(Hashtable xmlproperties) { - Enumeration keyEnum = xmlproperties.keys(); - while (keyEnum.hasMoreElements()) { - String currentKey = keyEnum.nextElement().toString(); - System.out.println(currentKey + " = " - + xmlproperties.get(currentKey)); - } - } - - /** - * Ensure all references loaded by the project are valid. - */ - private static void ensureReferences (String msg, File inputFile, - Hashtable references) { - Enumeration referenceKeyEnum = references.keys(); - while(referenceKeyEnum.hasMoreElements()){ - String currentKey = referenceKeyEnum.nextElement().toString(); - Object currentValue = references.get(currentKey); - - if (currentValue instanceof Path) { - } else if (currentValue instanceof String) { - } else { - if( ! currentKey.startsWith("ant.") ) { - fail(msg + "-" + inputFile.getName() + " Key=" - + currentKey + " is not a recognized type."); - } - } - } - } - - /** - * Munge the name of the input file to find an appropriate goldfile, - * based on hardwired naming conventions. - */ - private static File getGoldfile (File input, boolean keepRoot, - boolean collapse, boolean semantic, - boolean include, boolean localRoot) { - // Substitute .xml with .properties - String baseName = input.getName().toLowerCase(); - if (baseName.endsWith(".xml")) { - baseName = baseName.substring(0, baseName.length() - 4) - + ".properties"; - } - - File dir = input.getParentFile().getParentFile(); - - String goldFileFolder = "goldfiles/"; - - if (keepRoot) { - goldFileFolder += "keeproot-"; - } else { - goldFileFolder += "nokeeproot-"; - } - - if (semantic) { - goldFileFolder += "semantic-"; - if (include) { - goldFileFolder += "include-"; - } - } else { - if (collapse) { - goldFileFolder += "collapse-"; - } else { - goldFileFolder += "nocollapse-"; - } - } - - return new File(dir, goldFileFolder + baseName); - } - - /** - * Retrieve a list of xml files in the specified folder - * and below. - */ - private static Enumeration getFiles (final File startingDir) { - Vector result = new Vector(); - getFiles(startingDir, result); - return result.elements(); - } - - /** - * Collect a list of xml files in the specified folder - * and below. - */ - private static void getFiles (final File startingDir, Vector collect) { - FileFilter filter = new FileFilter() { - public boolean accept (File file) { - if (file.isDirectory()) { - return true; - } else { - return (file.getPath().indexOf("taskdefs") > 0 && - file.getPath().toLowerCase().endsWith(".xml") ); - } - } - }; - - File[] files = startingDir.listFiles(filter); - for (int i=0;i 5"); - entry.addFile("Medicare & review.doc", "1.1"); - entry.addFile("El\u00e8ments de style", "1.2"); - CVSEntry[] entries = { entry }; - - ByteArrayOutputStream output = new ByteArrayOutputStream(); - PrintWriter pwriter = new PrintWriter(new OutputStreamWriter(output, "UTF-8")); - writer.printChangeLog(pwriter, entries); - - // make sure that the parsing does not break - XMLReader xmlReader = JAXPUtils.getXMLReader(); - InputStream input = new ByteArrayInputStream(output.toByteArray()); - xmlReader.setContentHandler(new NullContentHandler()); - xmlReader.parse(new InputSource(input)); - } - - public static class NullContentHandler implements ContentHandler { - public void endDocument() throws SAXException { - } - - public void startDocument() throws SAXException { - } - - public void characters(char ch[], int start, int length) throws SAXException { - String debug = new String(ch, start, length); - } - - public void ignorableWhitespace(char ch[], int start, int length) throws SAXException { - } - - public void endPrefixMapping(String prefix) throws SAXException { - } - - public void skippedEntity(String name) throws SAXException { - } - - public void setDocumentLocator(Locator locator) { - } - - public void processingInstruction(String target, String data) throws SAXException { - } - - public void startPrefixMapping(String prefix, String uri) throws SAXException { - } - - public void endElement(String namespaceURI, String localName, String qName) throws SAXException { - } - - public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/dir1/B.java b/src/testcases/org/apache/tools/ant/taskdefs/dir1/B.java deleted file mode 100644 index 9057fa0cc..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/dir1/B.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.dir1; - -public class B extends org.apache.tools.ant.taskdefs.dir2.A { - static { - System.out.println("B CLASS INITIALIZATION"); - setA(new B()); - } - - public String toString() { - return "I am a B."; - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/dir2/A.java b/src/testcases/org/apache/tools/ant/taskdefs/dir2/A.java deleted file mode 100644 index 5186ac4c7..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/dir2/A.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.dir2; - -public class A { - public static void main(String [] args) { - System.out.println("MAIN"); - System.out.println(a); - } - - static A a=new A(); - - static { - System.out.println("A CLASS INITIALIZATION"); - } - - protected static void setA(A oa) { - a=oa; - } - - public String toString() { - return "I am a A."; - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/email/EmailAddressTest.java b/src/testcases/org/apache/tools/ant/taskdefs/email/EmailAddressTest.java deleted file mode 100644 index 72c87a301..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/email/EmailAddressTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.email; - -import junit.framework.TestCase; - -/** - * @since Ant 1.6 - */ -public class EmailAddressTest extends TestCase { - - public EmailAddressTest(String name) { - super(name); - } - - public void setUp() { - } - - public void test1() { - expectNameAddress( new EmailAddress("address (name)") ); - } - - public void test2() { - expectNameAddress( new EmailAddress("(name) address") ); - } - - public void test3() { - expectNameAddress( new EmailAddress("name

") ); - } - - public void test4() { - expectNameAddress( new EmailAddress("
name") ); - } - - public void test5() { - expectNameAddress( new EmailAddress("
(name)") ); - } - - public void test6() { - expectNameAddress( new EmailAddress("(name)
") ); - } - - public void test7() { - expectNameAddress2( new EmailAddress("address ()") ); - } - - public void test8() { - expectNameAddress2( new EmailAddress("() address") ); - } - - public void test9() { - expectNameAddress3( new EmailAddress("address") ); - } - - public void testA() { - expectNameAddress3( new EmailAddress("
") ); - } - - public void testB() { - expectNameAddress3( new EmailAddress("
") ); - } - - public void testC() { - expectNameAddress3( new EmailAddress("< address >") ); - } - - public void testD() { - expectNameAddress3( new EmailAddress(" < address > ") ); - } - - private void expectNameAddress(EmailAddress e) { - assertEquals( "name", e.getName() ); - assertEquals( "address", e.getAddress() ); - } - - // where the name contains <> - private void expectNameAddress2(EmailAddress e) { - assertEquals( "", e.getName() ); - assertEquals( "address", e.getAddress() ); - } - - // where only an address is supplied - private void expectNameAddress3(EmailAddress e) { - assertTrue( "Expected null, found <" + e.getName() + ">", - e.getName() == null ); - assertEquals( "address", e.getAddress() ); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java b/src/testcases/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java deleted file mode 100644 index 66b89cd27..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/email/EmailTaskTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.email; - -import org.apache.tools.ant.BuildFileTest; - -/** - * TODO : develop these testcases - the email task needs to have attributes allowing - * to simulate sending mail and to catch the output in text files or streams - */ -public class EmailTaskTest extends BuildFileTest { - - public EmailTaskTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/email/mail.xml"); - } - - public void test1() { - expectBuildException("test1", "SMTP auth only possible with MIME mail"); - } - - public void test2() { - expectBuildException("test2", "SSL only possible with MIME mail"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java deleted file mode 100644 index d886d8284..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional; - -import java.io.*; -import org.apache.tools.ant.BuildFileTest; - -/** - * If you want to run tests, it is highly recommended - * to download ANTLR (www.antlr.org), build the 'antlrall.jar' jar - * with make antlr-all.jar and drop the jar (about 300KB) into - * Ant lib. - * - Running w/ the default antlr.jar (70KB) does not work (missing class) - * - * Unless of course you specify the ANTLR classpath in your - * system classpath. (see ANTLR install.html) - * - */ -public class ANTLRTest extends BuildFileTest { - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/antlr/"; - - public ANTLRTest(String name) { - super(name); - } - - public void setUp() { - configureProject(TASKDEFS_DIR + "antlr.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - expectBuildException("test1", "required argument, target, missing"); - } - - public void test2() { - expectBuildException("test2", "Invalid output directory"); - } - - public void test3() { - executeTarget("test3"); - } - - public void test4() { - executeTarget("test4"); - } - - public void test5() { - // should print "panic: Cannot find importVocab file 'JavaTokenTypes.txt'" - // since it needs to run java.g first before java.tree.g - expectBuildException("test5", "ANTLR returned: 1"); - } - - public void test6() { - executeTarget("test6"); - } - - public void test7() { - expectBuildException("test7", "Unable to determine generated class"); - } - - /** - * This is a negative test for the super grammar (glib) option. - */ - public void test8() { - expectBuildException("test8", "Invalid super grammar file"); - } - - /** - * This is a positive test for the super grammar (glib) option. ANTLR - * will throw an error if everything is not correct. - */ - public void test9() { - executeTarget("test9"); - } - - /** - * This test creates an html-ized version of the calculator grammar. - * The sanity check is simply whether or not an html file was generated. - */ - public void test10() { - executeTarget("test10"); - File outputDirectory = new File(System.getProperty("root"), TASKDEFS_DIR + "antlr.tmp"); - String[] calcFiles = outputDirectory.list(new HTMLFilter()); - assertTrue(calcFiles.length > 0); - } - - /** - * This is just a quick sanity check to run the diagnostic option and - * make sure that it doesn't throw any funny exceptions. - */ - public void test11() { - executeTarget("test11"); - } - - /** - * This is just a quick sanity check to run the trace option and - * make sure that it doesn't throw any funny exceptions. - */ - public void test12() { - executeTarget("test12"); - } - - /** - * This is just a quick sanity check to run all the rest of the - * trace options (traceLexer, traceParser, and traceTreeWalker) to - * make sure that they don't throw any funny exceptions. - */ - public void test13() { - executeTarget("test13"); - } - - public void testNoRecompile() { - executeTarget("test9"); - assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); - executeTarget("noRecompile"); - assertTrue(-1 != getFullLog().indexOf("Skipped grammar file.")); - } - - public void testNormalRecompile() { - executeTarget("test9"); - assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); - executeTarget("normalRecompile"); - assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); - } - - // Bugzilla Report 12961 - public void testSupergrammarChangeRecompile() { - executeTarget("test9"); - assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); - executeTarget("supergrammarChangeRecompile"); - assertEquals(-1, getFullLog().indexOf("Skipped grammar file.")); - } -} - -class CalcFileFilter implements FilenameFilter { - public boolean accept(File dir, String name) { - return name.startsWith("Calc"); - } -} - -class HTMLFilter implements FilenameFilter { - public boolean accept(File dir, String name) { - return name.endsWith("html"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java deleted file mode 100644 index 72139e144..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional; - -import java.io.File; -import java.io.FileNotFoundException; -import java.net.URL; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import junit.framework.TestCase; -import org.apache.tools.ant.taskdefs.XSLTLiaison; -import org.apache.tools.ant.util.FileUtils; -import org.w3c.dom.Document; - -/** - * Abtract testcase for XSLTLiaison. - * Override createLiaison for each XSLTLiaison. - * - * Stephane Bailliez - */ -public abstract class AbstractXSLTLiaisonTest extends TestCase { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - protected XSLTLiaison liaison; - - protected AbstractXSLTLiaisonTest(String name){ - super(name); - } - - protected void setUp() throws Exception { - liaison = createLiaison(); - } - - // to override - protected abstract XSLTLiaison createLiaison() throws Exception ; - - /** load the file from the caller classloader that loaded this class */ - protected File getFile(String name) throws FileNotFoundException { - URL url = getClass().getResource(name); - if (url == null){ - throw new FileNotFoundException("Unable to load '" + name + "' from classpath"); - } - return new File(FILE_UTILS.fromURI(url.toExternalForm())); - } - - /** keep it simple stupid */ - public void testTransform() throws Exception { - File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); - liaison.setStylesheet(xsl); - liaison.addParam("param", "value"); - File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); - File out = new File("xsltliaison.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - } finally { - out.delete(); - } - } - - public void testEncoding() throws Exception { - File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl"); - liaison.setStylesheet(xsl); - File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml"); - File out = new File("xsltliaison-encoding.tmp"); - out.deleteOnExit(); // just to be sure - try { - liaison.transform(in, out); - Document doc = parseXML(out); - assertEquals("root",doc.getDocumentElement().getNodeName()); - assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName()); - assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue()); - } finally { - out.delete(); - } - } - - public Document parseXML(File file) throws Exception { - DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dbuilder = dbfactory.newDocumentBuilder(); - return dbuilder.parse(file); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java deleted file mode 100644 index 77358cd35..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/BeanShellScriptTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests the examples of the <script> task docs. - * - * @since Ant 1.5.2 - */ -public class BeanShellScriptTest extends BuildFileTest { - - public BeanShellScriptTest(String name) { - super(name); - } - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/script.xml"); - } - - public void testCanLoad() { - expectLog("useBeanshell", "I'm here"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java deleted file mode 100644 index 79cd72f6a..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/DotnetTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests the Dotnet tasks, based off WsdlToDotnetTest - * - * @since Ant 1.6 - */ -public class DotnetTest extends BuildFileTest { - - /** - * Description of the Field - */ - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - - - /** - * Constructor - * - * @param name testname - */ - public DotnetTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject(TASKDEFS_DIR + "dotnet.xml"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("teardown"); - } - - - /** - * A unit test for JUnit - */ - public void testCSC() throws Exception { - executeTarget("testCSC"); - } - - - /** - * A unit test for JUnit - */ - public void testCSCintrinsicFileset() throws Exception { - executeTarget("testCSCintrinsicFileset"); - } - - - /** - * A unit test for JUnit - */ - public void testCSCdll() throws Exception { - executeTarget("testCSCdll"); - } - - /** - * A unit test for JUnit - */ - public void testCscReferences() throws Exception { - executeTarget("testCscReferences"); - } - - /** - * A unit test for JUnit - */ - public void testCscResources() throws Exception { - executeTarget("testCSCResources"); - } - - /** - * test we can assemble - */ - public void testILASM() throws Exception { - executeTarget("testILASM"); - } - - /** - * test we can disassemble - */ - public void testILDASM() throws Exception { - executeTarget("testILDASM"); - } - - /** - * test we can disassemble - */ - public void testILDASM_empty() throws Exception { - expectBuildExceptionContaining("testILDASM_empty", - "parameter validation", - "invalid"); - } - - /** - * test we can handle jsharp (if found) - */ - public void testJsharp() throws Exception { - executeTarget("jsharp"); - } - - /** - * test we can handle jsharp (if found) - */ - public void testResponseFile() throws Exception { - executeTarget("testCSCresponseFile"); - } - -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java deleted file mode 100644 index ed66e13b5..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/EchoPropertiesTest.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -import java.io.IOException; -import java.io.File; -import java.io.InputStream; -import java.io.BufferedInputStream; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.BufferedReader; -import java.util.Properties; - -/** - * Tests the EchoProperties task. - * - * @created 17-Jan-2002 - * @since Ant 1.5 - */ -public class EchoPropertiesTest extends BuildFileTest { - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - private static final String GOOD_OUTFILE = "test.properties"; - private static final String GOOD_OUTFILE_XML = "test.xml"; - private static final String PREFIX_OUTFILE = "test-prefix.properties"; - private static final String TEST_VALUE = "isSet"; - private static final String BAD_OUTFILE = "."; - - public EchoPropertiesTest(String name) { - super(name); - } - - - public void setUp() { - configureProject(TASKDEFS_DIR + "echoproperties.xml"); - project.setProperty( "test.property", TEST_VALUE ); - } - - - public void tearDown() { - executeTarget("cleanup"); - } - - - public void testEchoToLog() { - expectLogContaining("testEchoToLog", "test.property="+TEST_VALUE); - } - - public void testEchoWithEmptyPrefixToLog() { - expectLogContaining("testEchoWithEmptyPrefixToLog", "test.property="+TEST_VALUE); - } - - - public void testReadBadFile() { - expectBuildExceptionContaining( "testReadBadFile", - "srcfile is a directory", "srcfile is a directory!" ); - } - - - public void testReadBadFileFail() { - expectBuildExceptionContaining( "testReadBadFile", - "srcfile is a directory", "srcfile is a directory!" ); - } - - - public void testReadBadFileNoFail() { - expectLog( "testReadBadFileNoFail", "srcfile is a directory!" ); - } - - - public void testEchoToBadFile() { - expectBuildExceptionContaining( "testEchoToBadFile", - "destfile is a directory", "destfile is a directory!" ); - } - - - public void testEchoToBadFileFail() { - expectBuildExceptionContaining( "testEchoToBadFileFail", - "destfile is a directory", "destfile is a directory!" ); - } - - - public void testEchoToBadFileNoFail() { - expectLog( "testEchoToBadFileNoFail", "destfile is a directory!"); - } - - - public void testEchoToGoodFile() throws Exception { - executeTarget( "testEchoToGoodFile" ); - assertGoodFile(); - } - - - public void testEchoToGoodFileXml() throws Exception { - executeTarget( "testEchoToGoodFileXml" ); - - // read in the file - File f = createRelativeFile( GOOD_OUTFILE_XML ); - FileReader fr = new FileReader( f ); - try { - BufferedReader br = new BufferedReader( fr ); - String read = null; - while ( (read = br.readLine()) != null) { - if (read.indexOf("") >= 0) { - // found the property we set - it's good. - return; - } - } - fail( "did not encounter set property in generated file." ); - } finally { - try { - fr.close(); - } catch(IOException e) {} - } - } - - - public void testEchoToGoodFileFail() throws Exception { - executeTarget( "testEchoToGoodFileFail" ); - assertGoodFile(); - } - - - public void testEchoToGoodFileNoFail() throws Exception { - executeTarget( "testEchoToGoodFileNoFail" ); - assertGoodFile(); - } - - - public void testEchoPrefix() throws Exception { - testEchoPrefixVarious("testEchoPrefix"); - } - - public void testEchoPrefixAsPropertyset() throws Exception { - testEchoPrefixVarious("testEchoPrefixAsPropertyset"); - } - - public void testEchoPrefixAsNegatedPropertyset() throws Exception { - testEchoPrefixVarious("testEchoPrefixAsNegatedPropertyset"); - } - - public void testEchoPrefixAsDoublyNegatedPropertyset() throws Exception { - testEchoPrefixVarious("testEchoPrefixAsDoublyNegatedPropertyset"); - } - - private void testEchoPrefixVarious(String target) throws Exception { - executeTarget(target); - Properties props = loadPropFile(PREFIX_OUTFILE); - assertEquals("prefix didn't include 'a.set' property", - "true", props.getProperty("a.set")); - assertNull("prefix failed to filter out property 'b.set'", - props.getProperty("b.set")); - } - - protected Properties loadPropFile(String relativeFilename) - throws IOException { - File f = createRelativeFile( relativeFilename ); - Properties props=new Properties(); - InputStream in=null; - try { - in=new BufferedInputStream(new FileInputStream(f)); - props.load(in); - } finally { - if(in!=null) { - try { in.close(); } catch(IOException e) {} - } - } - return props; - } - - protected void assertGoodFile() throws Exception { - File f = createRelativeFile( GOOD_OUTFILE ); - assertTrue( - "Did not create "+f.getAbsolutePath(), - f.exists() ); - Properties props=loadPropFile(GOOD_OUTFILE); - props.list(System.out); - assertEquals("test property not found ", - TEST_VALUE, props.getProperty("test.property")); -/* - // read in the file - FileReader fr = new FileReader( f ); - try { - BufferedReader br = new BufferedReader( fr ); - String read = null; - while ( (read = br.readLine()) != null) - { - if (read.indexOf("test.property" + TEST_VALUE) >= 0) - { - // found the property we set - it's good. - return; - } - } - fail( "did not encounter set property in generated file." ); - } finally { - try { fr.close(); } catch(IOException e) {} - } -*/ - } - - - protected String toAbsolute( String filename ) { - return createRelativeFile( filename ).getAbsolutePath(); - } - - - protected File createRelativeFile( String filename ) { - if (filename.equals( "." )) { - return getProjectDir(); - } - // else - return new File( getProjectDir(), filename ); - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/JavahTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/JavahTest.java deleted file mode 100644 index 2068647d2..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/JavahTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -public class JavahTest extends BuildFileTest { - - private final static String BUILD_XML = - "src/etc/testcases/taskdefs/optional/javah/build.xml"; - - public JavahTest(String name) { - super(name); - } - - public void setUp() { - configureProject(BUILD_XML); - } - - public void tearDown() { - executeTarget("tearDown"); - } - - public void testSimpleCompile() { - executeTarget("simple-compile"); - assertTrue(getProject().resolveFile("output/org_example_Foo.h") - .exists()); - } - -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/JspcTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/JspcTest.java deleted file mode 100644 index 7e810b1dc..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/JspcTest.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import java.io.File; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.taskdefs.optional.jsp.Jasper41Mangler; -import org.apache.tools.ant.taskdefs.optional.jsp.JspMangler; -import org.apache.tools.ant.taskdefs.optional.jsp.JspNameMangler; -import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapter; -import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapterFactory; - -/** - * Tests the Jspc task. - * - * @created 07 March 2002 - * @since Ant 1.5 - */ -public class JspcTest extends BuildFileTest { - /** - * Description of the Field - */ - private File baseDir; - /** - * Description of the Field - */ - private File outDir; - - /** - * Description of the Field - */ - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - - - /** - * Constructor for the JspcTest object - * - * @param name Description of Parameter - */ - public JspcTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject(TASKDEFS_DIR + "jspc.xml"); - baseDir = new File(System.getProperty("root"), TASKDEFS_DIR); - outDir = new File(baseDir, "jsp/java"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("cleanup"); - } - - - /** - * A unit test for JUnit - */ - public void testSimple() throws Exception { - executeJspCompile("testSimple", "simple_jsp.java"); - } - - - /** - * A unit test for JUnit - */ - public void testUriroot() throws Exception { - executeJspCompile("testUriroot", "uriroot_jsp.java"); - } - - - /** - * A unit test for JUnit - */ - public void testXml() throws Exception { - executeJspCompile("testXml", "xml_jsp.java"); - } - - - /** - * try a keyword in a file - */ - public void testKeyword() throws Exception { - executeJspCompile("testKeyword", "default_jsp.java"); - } - - - /** - * what happens to 1nvalid-classname - */ - public void testInvalidClassname() throws Exception { - executeJspCompile("testInvalidClassname", - "_1nvalid_0002dclassname_jsp.java"); - } - - - /** - * A unit test for JUnit - */ - public void testNoTld() throws Exception { -// expectBuildExceptionContaining("testNoTld", -// "Jasper found an error in a file", -// "Java returned: 9"); - expectBuildExceptionContaining("testNoTld", - "not found", - "Java returned: 9"); - } - - - /** - * A unit test for JUnit - */ - public void testNotAJspFile() throws Exception { - executeTarget("testNotAJspFile"); - } - - /** - * webapp test is currently broken, because it picks up - * on the missing_tld file, and bails. - */ -/* - public void testWebapp() throws Exception { - executeTarget("testWebapp"); - } -*/ - /** - * run a target then verify the named file gets created - * - * @param target Description of Parameter - * @param javafile Description of Parameter - * @exception Exception trouble - */ - protected void executeJspCompile(String target, String javafile) - throws Exception { - executeTarget(target); - assertJavaFileCreated(javafile); - } - - - /** - * verify that a named file was created - * - * @param filename Description of Parameter - * @exception Exception trouble - */ - protected void assertJavaFileCreated(String filename) - throws Exception { - File file = getOutputFile(filename); - assertTrue("file " + filename + " not found", file.exists()); - assertTrue("file " + filename + " is empty", file.length() > 0); - } - - /** - * Gets the OutputFile attribute of the JspcTest object - * - * @param subpath Description of Parameter - * @return The OutputFile value - */ - protected File getOutputFile(String subpath) { - return new File(outDir, subpath); - } - - /** - * verify that we select the appropriate mangler - */ - public void testJasperNameManglerSelection() { - JspCompilerAdapter adapter= - JspCompilerAdapterFactory.getCompiler("jasper", null,null); - JspMangler mangler=adapter.createMangler(); - assertTrue(mangler instanceof JspNameMangler); - adapter= JspCompilerAdapterFactory.getCompiler("jasper41", null, null); - mangler = adapter.createMangler(); - assertTrue(mangler instanceof Jasper41Mangler); - } - - public void testJasper41() { - JspMangler mangler = new Jasper41Mangler(); - //java keywords are not special - assertMapped(mangler, "for.jsp", "for_jsp"); - //underscores go in front of invalid start chars - assertMapped(mangler, "0.jsp", "_0_jsp"); - //underscores at the front get an underscore too - assertMapped(mangler, "_.jsp", "___jsp"); - //non java char at start => underscore then the the _hex value - assertMapped(mangler, "-.jsp", "__0002d_jsp"); - //and paths are stripped - char s = File.separatorChar; - assertMapped(mangler, "" + s + s + "somewhere" + s + "file" + s + "index.jsp", "index_jsp"); - } - - /** - * assert our mapping rules - * @param mangler - * @param filename - * @param classname - */ - protected void assertMapped(JspMangler mangler, String filename, String classname) { - String mappedname = mangler.mapJspToJavaName(new File(filename)); - assertTrue(filename+" should have mapped to "+classname - +" but instead mapped to "+mappedname, - classname.equals(mappedname)); - } - - -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java deleted file mode 100644 index d18c82ad6..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/Native2AsciiTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional; - -import java.io.File; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -public class Native2AsciiTest extends BuildFileTest { - - private final static String BUILD_XML = - "src/etc/testcases/taskdefs/optional/native2ascii/build.xml"; - - public Native2AsciiTest(String name) { - super(name); - } - - public void setUp() { - configureProject(BUILD_XML); - } - - public void tearDown() { - executeTarget("tearDown"); - } - - public void testIso8859_1() throws java.io.IOException { - executeTarget("testIso8859-1"); - File in = getProject().resolveFile("expected/iso8859-1.test"); - File out = getProject().resolveFile("output/iso8859-1.test"); - assertTrue(FileUtils.getFileUtils().contentEquals(in, out, true)); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java deleted file mode 100644 index 795d52cd4..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/PropertyFileTest.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.util.Properties; - -import org.apache.tools.ant.BuildFileTest; - -/** - * JUnit testcase that excercises the optional PropertyFile task in ant. - * (this is really more of a functional test so far.., but it's enough to let - * me start refactoring...) - * - *@created October 2, 2001 - */ - -public class PropertyFileTest extends BuildFileTest { - - public PropertyFileTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() throws Exception { - destroyTempFiles(); - initTestPropFile(); - initBuildPropFile(); - configureProject(projectFilePath); - project.setProperty(valueDoesNotGetOverwrittenPropertyFileKey,valueDoesNotGetOverwrittenPropertyFile); - } - - - /** - * The JUnit tearDown method - */ - public void tearDown() { - destroyTempFiles(); - } - - public void testNonExistingFile() { - PropertyFile props = new PropertyFile(); - props.setProject( getProject() ); - File file = new File("this-file-does-not-exist.properties"); - props.setFile(file); - assertFalse("Properties file exists before test.", file.exists()); - props.execute(); - assertTrue("Properties file does not exist after test.", file.exists()); - file.delete(); - } - - /** - * A unit test for JUnit- Excercises the propertyfile tasks ability to - * update properties that are already defined- - */ - public void testUpdatesExistingProperties() throws Exception { - Properties beforeUpdate = getTestProperties(); - assertEquals(FNAME, beforeUpdate.getProperty(FNAME_KEY)); - assertEquals(LNAME, beforeUpdate.getProperty(LNAME_KEY)); - assertEquals(EMAIL, beforeUpdate.getProperty(EMAIL_KEY)); - assertEquals(null, beforeUpdate.getProperty(PHONE_KEY)); - assertEquals(null, beforeUpdate.getProperty(AGE_KEY)); - assertEquals(null, beforeUpdate.getProperty(DATE_KEY)); - - // ask ant to update the properties... - executeTarget("update-existing-properties"); - - Properties afterUpdate = getTestProperties(); - assertEquals(NEW_FNAME, afterUpdate.getProperty(FNAME_KEY)); - assertEquals(NEW_LNAME, afterUpdate.getProperty(LNAME_KEY)); - assertEquals(NEW_EMAIL, afterUpdate.getProperty(EMAIL_KEY)); - assertEquals(NEW_PHONE, afterUpdate.getProperty(PHONE_KEY)); - assertEquals(NEW_AGE, afterUpdate.getProperty(AGE_KEY)); - assertEquals(NEW_DATE, afterUpdate.getProperty(DATE_KEY)); - } - - public void testExerciseDefaultAndIncrement() throws Exception { - executeTarget("exercise"); - assertEquals("3",project.getProperty("int.with.default")); - assertEquals("1",project.getProperty("int.without.default")); - assertEquals("-->",project.getProperty("string.with.default")); - assertEquals(".",project.getProperty("string.without.default")); - assertEquals("2002/01/21 12:18", project.getProperty("ethans.birth")); - assertEquals("2003/01/21", project.getProperty("first.birthday")); - assertEquals("0124", project.getProperty("olderThanAWeek")); - assertEquals("37", project.getProperty("existing.prop")); - assertEquals("6",project.getProperty("int.without.value")); - } - - public void testValueDoesNotGetOverwritten() { - // this test shows that the bug report 21505 is fixed - executeTarget("bugDemo1"); - executeTarget("bugDemo2"); - assertEquals("5", project.getProperty("foo")); - } -/* - public void testDirect() throws Exception { - PropertyFile pf = new PropertyFile(); - pf.setProject(project); - pf.setFile(new File(System.getProperty("root"), testPropsFilePath)); - PropertyFile.Entry entry = pf.createEntry(); - - entry.setKey("date"); - entry.setValue("123"); - PropertyFile.Entry.Type type = new PropertyFile.Entry.Type(); - type.setValue("date"); - entry.setType(type); - - entry.setPattern("yyyy/MM/dd"); - - PropertyFile.Entry.Operation operation = new PropertyFile.Entry.Operation(); - operation.setValue("+"); - pf.execute(); - - Properties props = getTestProperties(); - assertEquals("yeehaw", props.getProperty("date")); - } -*/ - - private Properties getTestProperties() throws Exception { - Properties testProps = new Properties(); - FileInputStream propsFile = new FileInputStream(new File(System.getProperty("root"), testPropsFilePath)); - testProps.load(propsFile); - propsFile.close(); - return testProps; - } - - - private void initTestPropFile() throws Exception { - Properties testProps = new Properties(); - testProps.put(FNAME_KEY, FNAME); - testProps.put(LNAME_KEY, LNAME); - testProps.put(EMAIL_KEY, EMAIL); - testProps.put("existing.prop", "37"); - - FileOutputStream fos = new FileOutputStream(new File(System.getProperty("root"), testPropsFilePath)); - testProps.store(fos, "defaults"); - fos.close(); - } - - - private void initBuildPropFile() throws Exception { - Properties buildProps = new Properties(); - buildProps.put(testPropertyFileKey, testPropertyFile); - buildProps.put(FNAME_KEY, NEW_FNAME); - buildProps.put(LNAME_KEY, NEW_LNAME); - buildProps.put(EMAIL_KEY, NEW_EMAIL); - buildProps.put(PHONE_KEY, NEW_PHONE); - buildProps.put(AGE_KEY, NEW_AGE); - buildProps.put(DATE_KEY, NEW_DATE); - - FileOutputStream fos = new FileOutputStream(new File(System.getProperty("root"), buildPropsFilePath)); - buildProps.store(fos, null); - fos.close(); - } - - - private void destroyTempFiles() { - File tempFile = new File(System.getProperty("root"), testPropsFilePath); - tempFile.delete(); - tempFile = null; - - tempFile = new File(System.getProperty("root"), buildPropsFilePath); - tempFile.delete(); - tempFile = null; - - tempFile = new File(System.getProperty("root"), valueDoesNotGetOverwrittenPropsFilePath); - tempFile.delete(); - tempFile = null; - } - - - - private static final String - projectFilePath = "src/etc/testcases/taskdefs/optional/propertyfile.xml", - - testPropertyFile = "propertyfile.test.properties", - testPropertyFileKey = "test.propertyfile", - testPropsFilePath = "src/etc/testcases/taskdefs/optional/" + testPropertyFile, - - valueDoesNotGetOverwrittenPropertyFile = "overwrite.test.properties", - valueDoesNotGetOverwrittenPropertyFileKey = "overwrite.test.propertyfile", - valueDoesNotGetOverwrittenPropsFilePath = "src/etc/testcases/taskdefs/optional/" + valueDoesNotGetOverwrittenPropertyFile, - - buildPropsFilePath = "src/etc/testcases/taskdefs/optional/propertyfile.build.properties", - - FNAME = "Bruce", - NEW_FNAME = "Clark", - FNAME_KEY = "firstname", - - LNAME = "Banner", - NEW_LNAME = "Kent", - LNAME_KEY = "lastname", - - EMAIL = "incredible@hulk.com", - NEW_EMAIL = "kc@superman.com", - EMAIL_KEY = "email", - - NEW_PHONE = "(520) 555-1212", - PHONE_KEY = "phone", - - NEW_AGE = "30", - AGE_KEY = "age", - - NEW_DATE = "2001/01/01 12:45", - DATE_KEY = "date"; -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/PvcsTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/PvcsTest.java deleted file mode 100644 index 0dc1d7092..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/PvcsTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class PvcsTest extends BuildFileTest { - - public PvcsTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/pvcs.xml"); - } - - public void test1() { - expectBuildException("test1", "Required argument repository not specified"); - } - - public void test2() { - executeTarget("test2"); - } - - public void test3() { - executeTarget("test3"); - } - - public void test4() { - executeTarget("test4"); - } - - public void test5() { - executeTarget("test5"); - } - - public void test6() { - expectBuildException("test6", "Failed executing: /never/heard/of/a/directory/structure/like/this/pcli lvf -z -aw -pr//ct4serv2/pvcs/monitor /. Exception: /never/heard/of/a/directory/structure/like/this/pcli: not found"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java deleted file mode 100644 index bc18d05cf..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/ReplaceRegExpTest.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -import java.util.Properties; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -/** - * JUnit Testcase for the optional replaceregexp task. - * - */ -public class ReplaceRegExpTest extends BuildFileTest { - private static final String PROJECT_PATH = "src/etc/testcases/taskdefs/optional"; - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public ReplaceRegExpTest(String name) { - super(name); - } - - public void setUp() { - configureProject(PROJECT_PATH + "/replaceregexp.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testReplace() throws IOException { - Properties original = new Properties(); - FileInputStream propsFile = null; - try { - propsFile = new FileInputStream(new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp.properties")); - original.load(propsFile); - } finally { - if (propsFile != null) { - propsFile.close(); - propsFile = null; - } - } - - assertEquals("Def", original.get("OldAbc")); - - executeTarget("testReplace"); - - Properties after = new Properties(); - try { - propsFile = new FileInputStream(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties")); - after.load(propsFile); - } finally { - if (propsFile != null) { - propsFile.close(); - propsFile = null; - } - } - - assertNull(after.get("OldAbc")); - assertEquals("AbcDef", after.get("NewProp")); - } - // inspired by bug 22541 - public void testDirectoryDateDoesNotChange() { - executeTarget("touchDirectory"); - File myFile = new File(System.getProperty("root"), PROJECT_PATH + "/" + getProject().getProperty("tmpregexp")); - long timeStampBefore = myFile.lastModified(); - executeTarget("testDirectoryDateDoesNotChange"); - long timeStampAfter = myFile.lastModified(); - assertEquals("directory date should not change", - timeStampBefore, timeStampAfter); - } - public void testDontAddNewline1() throws IOException { - executeTarget("testDontAddNewline1"); - assertTrue("Files match", - FILE_UTILS - .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"), - new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties"))); - } - - public void testDontAddNewline2() throws IOException { - executeTarget("testDontAddNewline2"); - assertTrue("Files match", - FILE_UTILS - .contentEquals(new File(System.getProperty("root"), PROJECT_PATH + "/test.properties"), - new File(System.getProperty("root"), PROJECT_PATH + "/replaceregexp2.result.properties"))); - } - -}// ReplaceRegExpTest diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java deleted file mode 100644 index 64ae4f4a7..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoReferenceTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests using an undefined reference. - * - * @since Ant 1.6 - */ -public class RhinoReferenceTest extends BuildFileTest { - - public RhinoReferenceTest(String name) { - super(name); - } - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject( - "src/etc/testcases/taskdefs/optional/script_reference.xml"); - } - - public void testScript() { - executeTarget("script"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java deleted file mode 100644 index b754058b0..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/RhinoScriptTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests the examples of the <script> task docs. - * - * @since Ant 1.5.2 - */ -public class RhinoScriptTest extends BuildFileTest { - - public RhinoScriptTest(String name) { - super(name); - } - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/script.xml"); - } - - public void testExample1() { - executeTarget("example1"); - int index = getLog().indexOf("1"); - assertTrue(index > -1); - index = getLog().indexOf("4", index); - assertTrue(index > -1); - index = getLog().indexOf("9", index); - assertTrue(index > -1); - index = getLog().indexOf("16", index); - assertTrue(index > -1); - index = getLog().indexOf("25", index); - assertTrue(index > -1); - index = getLog().indexOf("36", index); - assertTrue(index > -1); - index = getLog().indexOf("49", index); - assertTrue(index > -1); - index = getLog().indexOf("64", index); - assertTrue(index > -1); - index = getLog().indexOf("81", index); - assertTrue(index > -1); - index = getLog().indexOf("100", index); - assertTrue(index > -1); - } - - public void testExample2() { - executeTarget("example2"); - assertTrue(getLog().indexOf("In sub1") > -1); - assertTrue(getLog().indexOf("In sub2") > -1); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/RpmTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/RpmTest.java deleted file mode 100644 index aca68d2eb..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/RpmTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.Execute; -import org.apache.tools.ant.taskdefs.ExecuteStreamHandler; -import org.apache.tools.ant.types.Commandline; -import junit.framework.TestCase; - -public class RpmTest extends TestCase { - - public void testShouldThrowExceptionWhenRpmFails() throws Exception { - Rpm rpm = new MyRpm(); - rpm.setProject(new org.apache.tools.ant.Project()); - rpm.setFailOnError(true); - // execute - try { - rpm.execute(); - fail("should have thrown a build exception"); - } catch (BuildException ex) { - assertTrue(ex.getMessage() - .indexOf("' failed with exit code 2") != -1); - } - } - - public void testShouldNotThrowExceptionWhenRpmFails() throws Exception { - Rpm rpm = new MyRpm(); - rpm.execute(); - } - - // override some of the code so we can test the handling of the - // return code only. - public static class MyRpm extends Rpm { - protected Execute getExecute(Commandline toExecute, - ExecuteStreamHandler streamhandler) { - return new Execute() { - public int execute() { - // 2 is != 0 and even, so it is considered - // failure on any platform currently supported - // by Execute#isFailure. - return 2; - } - }; - } - - public void log(String msg, int msgLevel) { - } - } - -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java deleted file mode 100644 index 3793e2fdc..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/SchemaValidateTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Test schema validation - */ - -public class SchemaValidateTest extends BuildFileTest { - - /** - * where tasks run - */ - private final static String TASKDEFS_DIR = - "src/etc/testcases/taskdefs/optional/"; - - /** - * Constructor - * - * @param name testname - */ - public SchemaValidateTest(String name) { - super(name); - } - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject(TASKDEFS_DIR + "schemavalidate.xml"); - } - - /** - * test with no namespace - */ - public void testNoNamespace() throws Exception { - executeTarget("testNoNamespace"); - } - - /** - * add namespace awareness. - */ - public void testNSMapping() throws Exception { - executeTarget("testNSMapping"); - } - - public void testNoEmptySchemaNamespace() throws Exception { - expectBuildExceptionContaining("testNoEmptySchemaNamespace", - "empty namespace URI",SchemaValidate.SchemaLocation.ERROR_NO_URI); - } - - public void testNoEmptySchemaLocation() throws Exception { - expectBuildExceptionContaining("testNoEmptySchemaLocation", - "empty schema location", - SchemaValidate.SchemaLocation.ERROR_NO_LOCATION); - } - - public void testNoFile() throws Exception { - expectBuildExceptionContaining("testNoFile", - "no file at file attribute", - SchemaValidate.SchemaLocation.ERROR_NO_FILE); - } - - public void testNoDoubleSchemaLocation() throws Exception { - expectBuildExceptionContaining("testNoDoubleSchemaLocation", - "two locations for schemas", - SchemaValidate.SchemaLocation.ERROR_TWO_LOCATIONS); - } - public void testNoDuplicateSchema() throws Exception { - expectBuildExceptionContaining("testNoDuplicateSchema", - "duplicate schemas with different values", - SchemaValidate.ERROR_DUPLICATE_SCHEMA); - } - - public void testEqualsSchemasOK() throws Exception { - executeTarget("testEqualsSchemasOK"); - } - - public void testFileset() throws Exception { - executeTarget("testFileset"); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java deleted file mode 100644 index 55427ab5e..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.taskdefs.XSLTLiaison; -import org.apache.tools.ant.taskdefs.XSLTLogger; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.util.JAXPUtils; - -import java.io.File; - -import junit.framework.AssertionFailedError; - -/* - * 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. - * - */ - -/** - * TraX XSLTLiaison testcase - */ -public class TraXLiaisonTest extends AbstractXSLTLiaisonTest - implements XSLTLogger { - - public TraXLiaisonTest(String name){ - super(name); - } - - public void tearDown() { - File f = new File("xalan2-redirect-out.tmp"); - if (f.exists()) { - f.delete(); - } - } - - public XSLTLiaison createLiaison() throws Exception { - TraXLiaison l = new TraXLiaison(); - l.setLogger(this); - return l; - } - - public void testXalan2Redirect() throws Exception { - File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl"); - liaison.setStylesheet(xsl); - File out = new File("xalan2-redirect-out-dummy.tmp"); - File in = getFile("/taskdefs/optional/xsltliaison-in.xsl"); - try { - liaison.addParam("xalan-version", "2"); - liaison.transform(in, out); - } finally { - out.delete(); - } - } - - public void testMultipleTransform() throws Exception { - File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl"); - liaison.setStylesheet(xsl); - liaison.addParam("param", "value"); - File in = getFile("/taskdefs/optional/xsltliaison-in.xml"); - // test for 10 consecutives transform - for (int i = 0; i < 50; i++){ - File out = new File("xsltliaison" + i + ".tmp"); - try { - liaison.transform(in, out); - } catch (Exception e){ - throw new BuildException("failed in transform " + i, e); - } finally { - out.delete(); - } - } - } - - public void testSystemId(){ - File file = null; - if ( File.separatorChar == '\\' ){ - file = new File("d:\\jdk"); - } else { - file = new File("/user/local/bin"); - } - String systemid = JAXPUtils.getSystemId(file); - assertTrue("SystemIDs should start by file:/", systemid.startsWith("file:/")); - assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////")); - } - - public void log(String message) { - throw new AssertionFailedError("Liaison sent message: "+message); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/WsdlToDotnetTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/WsdlToDotnetTest.java deleted file mode 100644 index 9d3d4ea7f..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/WsdlToDotnetTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.taskdefs.optional.dotnet.WsdlToDotnet; - -/** - * Tests the WsdlToDotnet task. - * - * @since Ant 1.5 - */ -public class WsdlToDotnetTest extends BuildFileTest { - - /** - * dir for taskdefs - */ - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - - /** - * message from exec - */ - private static final String WSDL_FAILED = "WSDL returned:"; - - - /** - * Constructor - * - * @param name testname - */ - public WsdlToDotnetTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject(TASKDEFS_DIR + "WsdlToDotnet.xml"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("teardown"); - } - - - - /** - * A unit test for JUnit - */ - public void testNoParams() throws Exception { - expectBuildExceptionContaining("testNoParams", - "expected failure", - WsdlToDotnet.ERROR_NO_DEST_FILE); - } - - /** - * A unit test for JUnit - */ - public void testNoSrc() throws Exception { - expectBuildExceptionContaining("testNoSrc", - "expected failure", - WsdlToDotnet.Schema.ERROR_NONE_DECLARED); - } - - /** - * A unit test for JUnit - */ - public void testDestIsDir() throws Exception { - expectBuildExceptionContaining("testDestIsDir", - "expected failure", - WsdlToDotnet.ERROR_DEST_FILE_IS_DIR); - } - - /** - * A unit test for JUnit - */ - public void testBothSrc() throws Exception { - expectBuildExceptionContaining("testBothSrc", - "expected failure", - WsdlToDotnet.Schema.ERROR_BOTH_DECLARED); - } - /** - * A unit test for JUnit - */ - public void testSrcIsDir() throws Exception { - expectBuildExceptionContaining("testSrcIsDir", - "expected failure", - WsdlToDotnet.Schema.ERROR_FILE_IS_DIR); - } - - /** - * A unit test for JUnit - */ - public void testSrcIsMissing() throws Exception { - expectBuildExceptionContaining("testSrcIsMissing", - "expected failure", - WsdlToDotnet.Schema.ERROR_FILE_NOT_FOUND); - } - - /** - * A unit test for JUnit - */ - public void testLocalWsdl() throws Exception { - executeTarget("testLocalWsdl"); - } - /** - * A unit test for JUnit - */ - public void testLocalWsdlServer() throws Exception { - executeTarget("testLocalWsdlServer"); - } - /** - * A unit test for JUnit - */ - public void testInvalidExtraOps() throws Exception { - expectBuildExceptionContaining("testInvalidExtraOps", - "expected failure", - WSDL_FAILED); - } - - /** - * A unit test for JUnit - */ - public void testLocalWsdlVB() throws Exception { - executeTarget("testLocalWsdlVB"); - } - /** - * A unit test for JUnit - */ - public void testLocalWsdlServerVB() throws Exception { - executeTarget("testLocalWsdlServerVB"); - } - /** - * A unit test for JUnit - */ - public void testInvalidExtraOpsVB() throws Exception { - expectBuildExceptionContaining("testInvalidExtraOpsVB", - "expected failure", - WSDL_FAILED); - } - - /** - * as if parseable errors were not ignored, mono and WSE1.0 would - * crash and burn. So here we verify the property exists, - * and that it is not passed to the app when false - */ - public void testParseableErrorsIgnoredWhenFalse() throws Exception { - executeTarget("testLocalWsdl"); - } - - /** - * A unit test for JUnit - */ - public void testSchemaFileMustExist() throws Exception { - expectBuildExceptionContaining("testSchemaFileMustExist", - "expected failure", - WsdlToDotnet.Schema.ERROR_FILE_NOT_FOUND); - } - - /** - * A unit test for JUnit - */ - public void testSchemaFileMustHaveOneOptionOnly() throws Exception { - expectBuildExceptionContaining("testSchemaFileMustHaveOneOptionOnly", - "expected failure", - WsdlToDotnet.Schema.ERROR_BOTH_DECLARED); - } - - /** - * A unit test for JUnit - */ - public void testSchemaMustBeSet() throws Exception { - expectBuildExceptionContaining("testSchemaMustBeSet", - "expected failure", - WsdlToDotnet.Schema.ERROR_NONE_DECLARED); - } - - -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java deleted file mode 100644 index 64db8e742..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateCatalogTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests the XMLValidate optional task with nested external catalogs. - * - * @see XmlValidateTest - * @since Ant 1.6 - */ -public class XmlValidateCatalogTest extends BuildFileTest { - - /** - * where tasks run - */ - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - - - /** - * Constructor - * - * @param name testname - */ - public XmlValidateCatalogTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject(TASKDEFS_DIR + "xmlvalidate.xml"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - - } - - /** - * catalogfiles fileset should be ignored - * if resolver.jar is not present, but will - * be used if it is. either way, test should - * work b/c we have a nested dtd with the same - * entity - */ - public void testXmlCatalogFiles() { - executeTarget("xmlcatalogfiles"); - } - - /** - * Test nested catalogpath. - * It should be ignored if resolver.jar is not - * present, but will be used if it is. either - * way, test should work b/c we have a nested - * dtd with the same entity - */ - public void testXmlCatalogPath() { - executeTarget("xmlcatalogpath"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java deleted file mode 100644 index 27be8a415..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/XmlValidateTest.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests the XMLValidate optional task, by running targets in the test script - * src/etc/testcases/taskdefs/optional/xmlvalidate.xml - *

- * - * @see XmlValidateCatalogTest - * @since Ant 1.5 - */ -public class XmlValidateTest extends BuildFileTest { - - /** - * where tasks run - */ - private final static String TASKDEFS_DIR = - "src/etc/testcases/taskdefs/optional/"; - - /** - * Constructor - * - * @param name testname - */ - public XmlValidateTest(String name) { - super(name); - } - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject(TASKDEFS_DIR + "xmlvalidate.xml"); - } - - /** - * The teardown method for JUnit - */ - public void tearDown() {} - - /** - * Basic inline 'dtd' element test. - */ - public void testValidate() throws Exception { - executeTarget("testValidate"); - } - - /** - * Test indirect validation. - */ - public void testDeepValidate() throws Exception { - executeTarget("testDeepValidate"); - } - - /** - * - */ - public void testXmlCatalog() { - executeTarget("xmlcatalog"); - } - - /** - * - */ - public void testXmlCatalogViaRefid() { - executeTarget("xmlcatalogViaRefid"); - } - - /** - * Test that the nested dtd element is used when resolver.jar is not - * present. This test should pass either way. - */ - public void testXmlCatalogFiles() { - executeTarget("xmlcatalogfiles-override"); - } - - /** - * Test nested catalogpath. - * Test that the nested dtd element is used when resolver.jar is not - * present. This test should pass either way. - */ - public void testXmlCatalogPath() { - executeTarget("xmlcatalogpath-override"); - } - - /** - * Test nested xmlcatalog definitions - */ - public void testXmlCatalogNested() { - executeTarget("xmlcatalognested"); - } - - /** - * Test xml schema validation - */ - public void testXmlSchemaGood() throws BuildException { - try { - executeTarget("testSchemaGood"); - } catch (BuildException e) { - if (e - .getMessage() - .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema") - || e.getMessage().endsWith( - " doesn't support feature http://apache.org/xml/features/validation/schema")) { - System.err.println(" skipped, parser doesn't support schema"); - } else { - throw e; - } - } - } - /** - * Test xml schema validation - */ - public void testXmlSchemaBad() { - try { - executeTarget("testSchemaBad"); - fail("Should throw BuildException because 'Bad Schema Validation'"); - - expectBuildExceptionContaining( - "testSchemaBad", - "Bad Schema Validation", - "not a valid XML document"); - } catch (BuildException e) { - if (e - .getMessage() - .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema") - || e.getMessage().endsWith( - " doesn't support feature http://apache.org/xml/features/validation/schema")) { - System.err.println(" skipped, parser doesn't support schema"); - } else { - assertTrue( - e.getMessage().indexOf("not a valid XML document") > -1); - } - } - } - - /** - * iso-2022-jp.xml is valid but wouldn't get recognized on systems - * with a different native encoding. - * - * Bug 11279 - */ - public void testIso2022Jp() { - executeTarget("testIso2022Jp"); - } - - /** - * utf-8.xml is invalid as it contains non-UTF-8 characters, but - * would pass on systems with a native iso-8859-1 (or similar) - * encoding. - * - * Bug 11279 - */ - public void testUtf8() { - expectBuildException("testUtf8", "invalid characters in file"); - } - - // Tests property element, using XML schema properties as an example. - - public void testPropertySchemaForValidXML() { - executeTarget("testProperty.validXML"); - } - - public void testPropertySchemaForInvalidXML() { - expectBuildException( - "testProperty.invalidXML", - "XML file does not satisfy schema."); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/XsltTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/XsltTest.java deleted file mode 100644 index c28551dfd..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/XsltTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Tests the {@link XSLTProcess} task. - * XXX merge with {@link StyleTest}? - * @since Ant 1.5 - */ -public class XsltTest extends BuildFileTest { - - /** - * where tasks run - */ - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/"; - - - /** - * Constructor - * - * @param name testname - */ - public XsltTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject(TASKDEFS_DIR + "xslt.xml"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("teardown"); - } - - - - /** - * A unit test for JUnit - */ - public void testCatchNoDtd() throws Exception { - expectBuildExceptionContaining("testCatchNoDtd", - "expected failure", - "Fatal error during transformation"); - } - - /** - * A unit test for JUnit - */ - public void testCatalog() throws Exception { - executeTarget("testCatalog"); - } - - public void testOutputProperty() throws Exception { - executeTarget("testOutputProperty"); - } - - public void testFactory() throws Exception { - executeTarget("testFactory"); - } - - public void testAttribute() throws Exception { - executeTarget("testAttribute"); - } - public void testXMLWithEntitiesInNonAsciiPath() throws Exception { - executeTarget("testXMLWithEntitiesInNonAsciiPath"); - } - - /** - * check that the system id gets set properly on stylesheets. - * @throws Exception if something goes wrong. - */ - public void testStyleSheetWithInclude() throws Exception { - executeTarget("testStyleSheetWithInclude"); - if (getLog().indexOf("java.io.FileNotFoundException") != -1) { - fail("xsl:include was not found"); - } - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java deleted file mode 100644 index 82f301e8b..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/depend/DependTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.depend; - -import java.util.Hashtable; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.types.FileSet; - -/** - * Testcase for the Depend optional task. - * - */ -public class DependTest extends BuildFileTest { - public static final String RESULT_FILESET = "result"; - - public static final String TEST_BUILD_FILE - = "src/etc/testcases/taskdefs/optional/depend/depend.xml"; - - public DependTest(String name) { - super(name); - } - - public void setUp() { - configureProject(TEST_BUILD_FILE); - } - - public void tearDown() { - executeTarget("clean"); - } - - /** - * Test direct dependency removal - */ - public void testDirect() { - executeTarget("testdirect"); - Hashtable files = getResultFiles(); - assertEquals("Depend did not leave correct number of files", 3, - files.size()); - assertTrue("Result did not contain A.class", - files.containsKey("A.class")); - assertTrue("Result did not contain D.class", - files.containsKey("D.class")); - } - - /** - * Test dependency traversal (closure) - */ - public void testClosure() { - executeTarget("testclosure"); - Hashtable files = getResultFiles(); - assertTrue("Depend did not leave correct number of files", - files.size() <= 2); - assertTrue("Result did not contain D.class", - files.containsKey("D.class")); - } - - /** - * Test that inner class dependencies trigger deletion of the outer class - */ - public void testInner() { - executeTarget("testinner"); - assertEquals("Depend did not leave correct number of files", 0, - getResultFiles().size()); - } - - /** - * Test that multi-leve inner class dependencies trigger deletion of - * the outer class - */ - public void testInnerInner() { - executeTarget("testinnerinner"); - assertEquals("Depend did not leave correct number of files", 0, - getResultFiles().size()); - } - - /** - * Test that an exception is thrown when there is no source - */ - public void testNoSource() { - expectBuildExceptionContaining("testnosource", - "No source specified", "srcdir attribute must be set"); - } - - /** - * Test that an exception is thrown when the source attribute is empty - */ - public void testEmptySource() { - expectBuildExceptionContaining("testemptysource", - "No source specified", "srcdir attribute must be non-empty"); - } - - /** - * Read the result fileset into a Hashtable - * - * @return a Hashtable containing the names of the files in the result - * fileset - */ - private Hashtable getResultFiles() { - FileSet resultFileSet = (FileSet) project.getReference(RESULT_FILESET); - DirectoryScanner scanner = resultFileSet.getDirectoryScanner(project); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); - } - return files; - } - - - /** - * Test mutual dependency between inner and outer do not cause both to be - * deleted - */ - public void testInnerClosure() { - executeTarget("testinnerclosure"); - assertEquals("Depend did not leave correct number of files", 4, - getResultFiles().size()); - } - - /** - * Test the operation of the cache - */ - public void testCache() { - executeTarget("testcache"); - } - - /** - * Test the detection and warning of non public classes - */ - public void testNonPublic() { - executeTarget("testnonpublic"); - String log = getLog(); - assertTrue("Expected warning about APrivate", - log.indexOf("The class APrivate in file") != -1); - assertTrue("but has not been deleted because its source file " - + "could not be determined", - log.indexOf("The class APrivate in file") != -1); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java deleted file mode 100644 index 64b588580..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/i18n/TranslateTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.i18n; - -import org.apache.tools.ant.BuildFileTest; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; - -/** - * Tests the Translate task. - * - * @since Ant 1.6 - */ -public class TranslateTest extends BuildFileTest { - static private final int BUF_SIZE = 32768; - - private final static String TASKDEFS_DIR = "src/etc/testcases/taskdefs/optional/i18n/translate"; - - public TranslateTest(String name) { - super(name); - } - - - public void setUp() { - configureProject(TASKDEFS_DIR + "/translate.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - executeTarget("test1"); - assertTrue("translation of "+ TASKDEFS_DIR + "/input/template.txt",compareFiles(TASKDEFS_DIR+"/expected/de/template.txt",TASKDEFS_DIR+"/output/de/template.txt")); - } - private boolean compareFiles(String name1, String name2) { - File file1 = new File(System.getProperty("root"), name1); - File file2 = new File(System.getProperty("root"), name2); - - try { - if (!file1.exists() || !file2.exists()) { - System.out.println("One or both files do not exist:" + name1 + ", " + name2); - return false; - } - - if (file1.length() != file2.length()) { - System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " + - name2 + "(" + file2.length() + ")"); - return false; - } - - // byte - byte compare - byte[] buffer1 = new byte[BUF_SIZE]; - byte[] buffer2 = new byte[BUF_SIZE]; - - FileInputStream fis1 = new FileInputStream(file1); - FileInputStream fis2 = new FileInputStream(file2); - int index = 0; - int read = 0; - while ((read = fis1.read(buffer1)) != -1) { - fis2.read(buffer2); - for (int i = 0; i < read; ++i, ++index) { - if (buffer1[i] != buffer2[i]) { - System.out.println("Bytes mismatch:" + name1 + ", " + name2 + - " at byte " + index); - return false; - } - } - } - return true; - } - catch (IOException e) { - System.out.println("IOException comparing files: " + name1 + ", " + name2); - return false; - } - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java deleted file mode 100644 index 25b42457d..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/image/ImageTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.image; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -import java.io.File; - - -/** - * Tests the Image task. - * - * @since Ant 1.5 - */ -public class ImageTest extends BuildFileTest { - - private final static String TASKDEFS_DIR = - "src/etc/testcases/taskdefs/optional/image/"; - private final static String LARGEIMAGE = "largeimage.jpg"; - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public ImageTest(String name) { - super(name); - } - - - public void setUp() { - configureProject(TASKDEFS_DIR + "image.xml"); - } - - - public void tearDown() { - executeTarget("cleanup"); - } - - public void testEchoToLog() { - expectLogContaining("testEchoToLog", "Processing File"); - } - - public void testSimpleScale(){ - expectLogContaining("testSimpleScale", "Processing File"); - File f = createRelativeFile("/dest/" + LARGEIMAGE); - assertTrue( - "Did not create "+f.getAbsolutePath(), - f.exists()); - - } - - public void testOverwriteTrue() { - expectLogContaining("testSimpleScale", "Processing File"); - File f = createRelativeFile("/dest/" + LARGEIMAGE); - long lastModified = f.lastModified(); - try { - Thread.sleep(FILE_UTILS - .getFileTimestampGranularity()); - } - catch (InterruptedException e) {} - expectLogContaining("testOverwriteTrue", "Processing File"); - f = createRelativeFile("/dest/" + LARGEIMAGE); - long overwrittenLastModified = f.lastModified(); - assertTrue("File was not overwritten.", - lastModified < overwrittenLastModified); - } - - public void testOverwriteFalse() { - expectLogContaining("testSimpleScale", "Processing File"); - File f = createRelativeFile("/dest/" + LARGEIMAGE); - long lastModified = f.lastModified(); - expectLogContaining("testOverwriteFalse", "Processing File"); - f = createRelativeFile("/dest/" + LARGEIMAGE); - long overwrittenLastModified = f.lastModified(); - assertTrue("File was overwritten.", - lastModified == overwrittenLastModified); - } - - - public void off_testFailOnError() { - try { - expectLogContaining("testFailOnError", - "Unable to process image stream"); - } - catch (RuntimeException re){ - assertTrue("Run time exception should say " - + "'Unable to process image stream'. :" - + re.toString(), - re.toString() - .indexOf("Unable to process image stream") > -1); - } - } - - - - protected File createRelativeFile(String filename) { - if (filename.equals(".")) { - return getProjectDir(); - } - // else - return new File(getProjectDir(), filename); - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java deleted file mode 100644 index 4e91d9c60..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.jdepend; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Testcase for the JDepend optional task. - * - */ -public class JDependTest extends BuildFileTest { - public static final String RESULT_FILESET = "result"; - - public JDependTest(String name) { - super(name); - } - - public void setUp() { - configureProject( - "src/etc/testcases/taskdefs/optional/jdepend/jdepend.xml"); - } - - /** - * Test simple - */ - public void testSimple() { - expectOutputContaining( - "simple", "Package: org.apache.tools.ant.util.facade"); - } - - /** - * Test xml - */ - public void testXml() { - expectOutputContaining( - "xml", ""); - } - - /** - * Test fork - * - forked output goes to log - */ - public void testFork() { - expectLogContaining( - "fork", "Package: org.apache.tools.ant.util.facade"); - } - - /** - * Test fork xml - */ - public void testForkXml() { - expectLogContaining( - "fork-xml", ""); - } - - /** - * Test timeout - */ - public void testTimeout() { - expectLogContaining( - "fork-timeout", "JDepend FAILED - Timed out"); - } - - - /** - * Test timeout without timing out - */ - public void testTimeoutNot() { - expectLogContaining( - "fork-timeout-not", "Package: org.apache.tools.ant.util.facade"); - } - - /** - * Assert that the given message has been outputted - */ - protected void expectOutputContaining(String target, String substring) { - executeTarget(target); - assertOutputContaining(substring); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java deleted file mode 100644 index 36f5d6efd..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitClassLoaderTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import junit.framework.TestCase; - -/** - * Test to ensure that the classloader loading JUnit testcase - * is also the context classloader. - * - */ -public class JUnitClassLoaderTest extends TestCase { - - public JUnitClassLoaderTest(String s) { - super(s); - } - - public void testContextClassLoader(){ - ClassLoader context = Thread.currentThread().getContextClassLoader(); - ClassLoader caller = getClass().getClassLoader(); - assertSame(context, caller); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java deleted file mode 100644 index d19529369..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java +++ /dev/null @@ -1,206 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.junit; - -import java.io.File; -import java.io.FileReader; -import java.io.InputStream; -import java.net.URL; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -/** - * Small testcase for the junitreporttask. - * First test added to reproduce an fault, still a lot to improve - * - */ -public class JUnitReportTest extends BuildFileTest { - - public JUnitReportTest(String name){ - super(name); - } - - protected void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/junitreport.xml"); - } - - protected void tearDown() { - executeTarget("clean"); - } - - /** - * Verifies that no empty junit-noframes.html is generated when frames - * output is selected via the default. - * Needs reports1 task from junitreport.xml. - */ - public void testNoFileJUnitNoFrames() { - executeTarget("reports1"); - if (new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html").exists()) - { - fail("No file junit-noframes.html expected"); - } - } - - public void assertIndexCreated() { - if (!new File(System.getProperty("root"), - "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html").exists()) { - fail("No file index file found"); - } - - } - - /** - * run a target, assert the index file is there, look for text in the log - * @param targetName target - * @param text optional text to look for - */ - private void expectReportWithText(String targetName, String text) { - executeTarget(targetName); - assertIndexCreated(); - if(text!=null) { - assertLogContaining(text); - } - } - - - public void testEmptyFile() throws Exception { - expectReportWithText("testEmptyFile", - XMLResultAggregator.WARNING_EMPTY_FILE); - } - - public void testIncompleteFile() throws Exception { - expectReportWithText("testIncompleteFile", - XMLResultAggregator.WARNING_IS_POSSIBLY_CORRUPTED); - } - public void testWrongElement() throws Exception { - expectReportWithText("testWrongElement", - XMLResultAggregator.WARNING_INVALID_ROOT_ELEMENT); - } - - // Bugzilla Report 34963 - public void testStackTraceLineBreaks() throws Exception { - expectReportWithText("testStackTraceLineBreaks", null); - FileReader r = null; - try { - r = new FileReader(new File(System.getProperty("root"), - "src/etc/testcases/taskdefs/optional/junitreport/test/html/sampleproject/coins/0_CoinTest.html")); - String report = FileUtils.readFully(r); - assertTrue("output must contain
", - report.indexOf("junit.framework.AssertionFailedError: DOEG
") - > -1); - } finally { - FileUtils.close(r); - } - } - - - // Bugzilla Report 38477 - public void testSpecialSignsInSrcPath() throws Exception { - executeTarget("testSpecialSignsInSrcPath"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); - } - - public void testSpecialSignsInHtmlPath() throws Exception { - executeTarget("testSpecialSignsInHtmlPath"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html# $%\u00A7&-!report/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); - } - - //Bugzilla Report 39708 - public void testWithStyleFromDir() throws Exception { - executeTarget("testWithStyleFromDir"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); - } - - //Bugzilla Report 40021 - public void testNoFrames() throws Exception { - executeTarget("testNoFrames"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/junit-noframes.html"); - // tests one the file object - assertTrue("No junit-noframes.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); - } - //Bugzilla Report 39708 - public void testWithStyleFromDirAndXslImport() throws Exception { - executeTarget("testWithStyleFromDirAndXslImport"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); - } - - public void testWithStyleFromClasspath() throws Exception { - executeTarget("testWithStyleFromClasspath"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); - } - - public void testWithParams() throws Exception { - expectLogContaining("testWithParams", "key1=value1,key2=value2"); - File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); - // tests one the file object - assertTrue("No index.html present. Not generated?", reportFile.exists() ); - assertTrue("Cant read the report file.", reportFile.canRead() ); - assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); - // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report - URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); - InputStream reportStream = reportUrl.openStream(); - assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java deleted file mode 100644 index bce4d3791..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTaskTest.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import org.apache.tools.ant.BuildFileTest; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; - -public class JUnitTaskTest extends BuildFileTest { - - /** - * Constructor for the JUnitTaskTest object - */ - public JUnitTaskTest(String name) { - super(name); - } - - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/junit.xml"); - } - - - /** - * The teardown method for JUnit - */ - public void tearDown() { - executeTarget("cleanup"); - } - - public void testCrash() { - expectPropertySet("crash", "crashed"); - } - - public void testNoCrash() { - expectPropertyUnset("nocrash", "crashed"); - } - - public void testTimeout() { - expectPropertySet("timeout", "timeout"); - } - - public void testNoTimeout() { - expectPropertyUnset("notimeout", "timeout"); - } - - public void testNonForkedCapture() throws IOException { - executeTarget("capture"); - assertNoPrint(getLog(), "log"); - assertNoPrint(getFullLog(), "debug log"); - } - - public void testForkedCapture() throws IOException { - getProject().setProperty("fork", "true"); - testNonForkedCapture(); - // those would fail because of the way BuildFileTest captures output - assertNoPrint(getOutput(), "output"); - assertNoPrint(getError(), "error output"); - assertOutput(); - } - - public void testBatchTestForkOnceToDir() { - assertResultFilesExist("testBatchTestForkOnceToDir", ".xml"); - } - - /** Bugzilla Report 32973 */ - public void testBatchTestForkOnceExtension() { - assertResultFilesExist("testBatchTestForkOnceExtension", ".foo"); - } - - public void testBatchTestForkOnceCustomFormatter() { - assertResultFilesExist("testBatchTestForkOnceCustomFormatter", "foo"); - } - - private void assertResultFilesExist(String target, String extension) { - executeTarget(target); - assertResultFileExists("JUnitClassLoader", extension); - assertResultFileExists("JUnitTestRunner", extension); - assertResultFileExists("JUnitVersionHelper", extension); - } - - private void assertResultFileExists(String classNameFragment, String ext) { - assertTrue("result for " + classNameFragment + "Test" + ext + " exists", - getProject().resolveFile("out/TEST-org.apache.tools.ant." - + "taskdefs.optional.junit." - + classNameFragment + "Test" + ext) - .exists()); - } - - private void assertNoPrint(String result, String where) { - assertTrue(where + " '" + result + "' must not contain print statement", - result.indexOf("print to System.") == -1); - } - - private void assertOutput() throws IOException { - FileReader inner = new FileReader(getProject() - .resolveFile("testlog.txt")); - BufferedReader reader = new BufferedReader(inner); - try { - String line = reader.readLine(); - assertEquals("Testsuite: org.apache.tools.ant.taskdefs.optional.junit.Printer", - line); - line = reader.readLine(); - assertNotNull(line); - assertTrue(line.startsWith("Tests run: 1, Failures: 0, Errors: 0, Time elapsed:")); - line = reader.readLine(); - assertEquals("------------- Standard Output ---------------", - line); - assertPrint(reader.readLine(), "static", "out"); - assertPrint(reader.readLine(), "constructor", "out"); - assertPrint(reader.readLine(), "method", "out"); - line = reader.readLine(); - assertEquals("------------- ---------------- ---------------", - line); - line = reader.readLine(); - assertEquals("------------- Standard Error -----------------", - line); - assertPrint(reader.readLine(), "static", "err"); - assertPrint(reader.readLine(), "constructor", "err"); - assertPrint(reader.readLine(), "method", "err"); - line = reader.readLine(); - assertEquals("------------- ---------------- ---------------", - line); - line = reader.readLine(); - assertEquals("", line); - line = reader.readLine(); - assertNotNull(line); - assertTrue(line.startsWith("Testcase: testNoCrash took ")); - } finally { - inner.close(); - } - } - - private void assertPrint(String line, String from, String to) { - String search = from + " print to System." + to; - assertEquals(search, line); - } - -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java deleted file mode 100644 index ac36af226..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestListenerTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.junit; - -import org.apache.tools.ant.BuildFileTest; - -public class JUnitTestListenerTest extends BuildFileTest { - - // The captureToSummary test writes to stdout and stderr, good for - // verifying that the TestListener support doesn't break anything. - private static final String PASS_TEST_TARGET = "captureToSummary"; - - // testNoCrash is the test invoked by the captureToSummary's junit task - private static final String PASS_TEST = "testNoCrash"; - - public JUnitTestListenerTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/junit.xml"); - } - - public void testFullLogOutput() { - executeTarget(PASS_TEST_TARGET); - assertTrue("expecting full log to have BuildListener events", - hasBuildListenerEvents(getFullLog())); - } - - public void testNoLogOutput() { - executeTarget(PASS_TEST_TARGET); - assertFalse("expecting log to not have BuildListener events", - hasBuildListenerEvents(getLog())); - } - - public void testTestCountFired() { - executeTarget(PASS_TEST_TARGET); - assertTrue("expecting test count message", - hasEventMessage(JUnitTask.TESTLISTENER_PREFIX + - "tests to run: ")); - } - - public void testStartTestFired() { - executeTarget(PASS_TEST_TARGET); - assertTrue("expecting test started message", - hasEventMessage(JUnitTask.TESTLISTENER_PREFIX + - "startTest(" + PASS_TEST + ")")); - } - - public void testEndTestFired() { - executeTarget(PASS_TEST_TARGET); - assertTrue("expecting test ended message", - hasEventMessage(JUnitTask.TESTLISTENER_PREFIX + - "endTest(" + PASS_TEST + ")")); - } - - private boolean hasBuildListenerEvents(String log) { - return log.indexOf(JUnitTask.TESTLISTENER_PREFIX) >= 0; - } - - private boolean hasEventMessage(String eventPrefix) { - return getFullLog().indexOf(eventPrefix) >= 0; - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java deleted file mode 100644 index a06bdb8cd..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunnerTest.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import java.io.*; -import junit.framework.*; -import org.apache.tools.ant.BuildException; - -/** - * Small testcase for the runner, tests are very very very basics. - * They must be enhanced with time. - * - */ -public class JUnitTestRunnerTest extends TestCase { - - // mandatory constructor - public JUnitTestRunnerTest(String name){ - super(name); - } - - // check that having no suite generates no errors - public void testNoSuite(){ - TestRunner runner = createRunner(NoSuiteTestCase.class); - runner.run(); - assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode()); - } - - // check that a suite generates no errors - public void testSuite(){ - TestRunner runner = createRunner(SuiteTestCase.class); - runner.run(); - assertEquals(runner.getFormatter().getError(), JUnitTestRunner.SUCCESS, runner.getRetCode()); - } - - // check that an invalid suite generates an error. - public void testInvalidSuite(){ - TestRunner runner = createRunner(InvalidSuiteTestCase.class); - runner.run(); - String error = runner.getFormatter().getError(); - assertEquals(error, JUnitTestRunner.ERRORS, runner.getRetCode()); - assertTrue(error, error.indexOf("thrown on purpose") != -1); - } - - // check that something which is not a testcase generates no errors - // at first even though this is incorrect. - public void testNoTestCase(){ - TestRunner runner = createRunner(NoTestCase.class); - runner.run(); - assertEquals(runner.getFormatter().getError(), JUnitTestRunner.FAILURES, runner.getRetCode()); - } - - // check that an exception in the constructor is noticed - public void testInvalidTestCase(){ - TestRunner runner = createRunner(InvalidTestCase.class); - runner.run(); - String error = runner.getFormatter().getError(); - assertEquals(error, JUnitTestRunner.FAILURES, runner.getRetCode()); - //@fixme as of now does not report the original stacktrace. - //assertTrue(error, error.indexOf("thrown on purpose") != -1); - } - - protected TestRunner createRunner(Class clazz){ - return new TestRunner(new JUnitTest(clazz.getName()), true, true, true); - } - - // the test runner that wrap the dummy formatter that interests us - private final static class TestRunner extends JUnitTestRunner { - private ResultFormatter formatter = new ResultFormatter(); - TestRunner(JUnitTest test, boolean haltonerror, boolean filtertrace, boolean haltonfailure){ - super(test, haltonerror, filtertrace, haltonfailure, TestRunner.class.getClassLoader()); - // use the classloader that loaded this class otherwise - // it will not be able to run inner classes if this test - // is ran in non-forked mode. - addFormatter(formatter); - } - ResultFormatter getFormatter(){ - return formatter; - } - } - - // dummy formatter just to catch the error - private final static class ResultFormatter implements JUnitResultFormatter { - private Throwable error; - public void setSystemOutput(String output){} - public void setSystemError(String output){} - public void startTestSuite(JUnitTest suite) throws BuildException{} - public void endTestSuite(JUnitTest suite) throws BuildException{} - public void setOutput(java.io.OutputStream out){} - public void startTest(Test t) {} - public void endTest(Test test) {} - public void addFailure(Test test, Throwable t) { } - public void addFailure(Test test, AssertionFailedError t) { } - public void addError(Test test, Throwable t) { - error = t; - } - String getError(){ - if (error == null){ - return ""; - } - StringWriter sw = new StringWriter(); - error.printStackTrace(new PrintWriter(sw)); - return sw.toString(); - } - } - - public static class NoTestCase { - } - - public static class InvalidTestCase extends TestCase { - public InvalidTestCase(String name){ - super(name); - throw new NullPointerException("thrown on purpose"); - } - } - - public static class NoSuiteTestCase extends TestCase { - public NoSuiteTestCase(String name){ super(name); } - public void testA(){} - } - - public static class SuiteTestCase extends NoSuiteTestCase { - public SuiteTestCase(String name){ super(name); } - public static Test suite(){ - return new TestSuite(SuiteTestCase.class); - } - } - - public static class InvalidSuiteTestCase extends NoSuiteTestCase { - public InvalidSuiteTestCase(String name){ super(name); } - public static Test suite(){ - throw new NullPointerException("thrown on purpose"); - } - } - public static void main(String[] args){ - junit.textui.TestRunner.run(JUnitTestRunnerTest.class); - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java deleted file mode 100644 index a23b840b7..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitVersionHelperTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestResult; - -/** - */ -public class JUnitVersionHelperTest extends TestCase { - - public JUnitVersionHelperTest(String name) { - super(name); - } - - public void testMyOwnName() { - assertEquals("testMyOwnName", - JUnitVersionHelper.getTestCaseName(this)); - } - - public void testNonTestCaseName() { - assertEquals("I'm a foo", - JUnitVersionHelper.getTestCaseName(new Foo1())); - } - - public void testNoStringReturn() { - assertEquals("unknown", - JUnitVersionHelper.getTestCaseName(new Foo2())); - } - - public void testNoGetName() { - assertEquals("unknown", - JUnitVersionHelper.getTestCaseName(new Foo3())); - } - - public void testNameNotGetName() { - assertEquals("I'm a foo, too", - JUnitVersionHelper.getTestCaseName(new Foo4())); - } - - public void testNull() { - assertEquals("unknown", JUnitVersionHelper.getTestCaseName(null)); - } - - public void testTestCaseSubClass() { - assertEquals("overridden getName", - JUnitVersionHelper.getTestCaseName(new Foo5())); - } - - public static class Foo implements Test { - public int countTestCases() {return 0;} - public void run(TestResult result) {} - } - - public static class Foo1 extends Foo { - public String getName() {return "I'm a foo";} - } - - public static class Foo2 extends Foo { - public int getName() {return 1;} - } - - public static class Foo3 extends Foo { - } - - public static class Foo4 extends Foo { - public String name() {return "I'm a foo, too";} - } - - public static class Foo5 extends TestCase { - public String getName() {return "overridden getName";} - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java deleted file mode 100644 index 601eab2b9..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/NoVmCrash.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import junit.framework.TestCase; - -/** - */ -public class NoVmCrash extends TestCase { - - public NoVmCrash(String name) { - super(name); - } - - public void testNoCrash() { - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Printer.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Printer.java deleted file mode 100644 index c0acc1cf7..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Printer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import junit.framework.TestCase; - -/** - */ -public class Printer extends TestCase { - - public Printer(String name) { - super(name); - System.err.println("constructor print to System.err"); - System.out.println("constructor print to System.out"); - } - - static { - System.err.println("static print to System.err"); - System.out.println("static print to System.out"); - } - - public void testNoCrash() { - System.err.println("method print to System.err"); - System.out.println("method print to System.out"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java deleted file mode 100644 index cabc76370..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/Sleeper.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import junit.framework.TestCase; - -/** - */ -public class Sleeper extends TestCase { - - public Sleeper(String name) { - super(name); - } - - public void testSleep() { - try { - Thread.sleep(5 * 1000); - } catch (InterruptedException e) { - } // end of try-catch - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java deleted file mode 100644 index 5f8fd917d..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/SuiteMethodTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import junit.framework.Test; -import junit.framework.TestCase; - -/** - * validates that the suite() method works in classes that don't - * implement Test. - */ -public class SuiteMethodTest { - - public static Test suite() { - return new Nested("testMethod"); - } - - public static class Nested extends TestCase { - public Nested(String name) { - super(name); - } - - public void testMethod() { - assertTrue(true); - } - } -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/TestFormatter.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/TestFormatter.java deleted file mode 100644 index 27420d6f4..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/TestFormatter.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.junit; - -import java.io.IOException; -import java.io.OutputStream; - -import junit.framework.AssertionFailedError; -import junit.framework.Test; - -import org.apache.tools.ant.BuildException; - -public class TestFormatter implements JUnitResultFormatter { - - private static final byte[] grafitto = new byte[] { - (byte) 'T', (byte) 'e', (byte) 's', (byte) 't', (byte) 'F', (byte) 'o', - (byte) 'r', (byte) 'm', (byte) 'a', (byte) 't', (byte) 't', (byte) 'e', - (byte) 'r', (byte) ' ', (byte) 'w', (byte) 'a', (byte) 's', (byte) ' ', - (byte) 'h', (byte) 'e', (byte) 'r', (byte) 'e', 10 - }; - - /** - * Where to write the log to. - */ - private OutputStream out; - - /** - * Empty - */ - public TestFormatter() { - } - - /** - * Empty - */ - public void startTestSuite(JUnitTest suite) { - } - /** - * Empty - */ - public void startTest(Test t) { - } - /** - * Empty - */ - public void endTest(Test test) { - } - /** - * Empty - */ - public void addFailure(Test test, Throwable t) { - } - /** - * Empty - */ - public void addFailure(Test test, AssertionFailedError t) { - } - /** - * Empty - */ - public void addError(Test test, Throwable t) { - } - /** - * Empty - */ - public void setSystemOutput(String out) { - } - /** - * Empty - */ - public void setSystemError(String err) { - } - - public void setOutput(OutputStream out) { - this.out = out; - } - - public void endTestSuite(JUnitTest suite) throws BuildException { - if (out != null) { - try { - out.write(grafitto); - out.flush(); - } catch (IOException ioex) { - throw new BuildException("Unable to write output", ioex); - } finally { - if (out != System.out && out != System.err) { - try { - out.close(); - } catch (IOException e) { - // ignore - } - } - } - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java deleted file mode 100644 index 8ccf17abe..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/VmCrash.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import junit.framework.TestCase; - -/** - */ -public class VmCrash extends TestCase { - - public VmCrash(String name) { - super(name); - } - - public void testCrash() { - System.exit(0); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java deleted file mode 100644 index f93fb889a..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/XMLFormatterWithCDATAOnSystemOut.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.junit; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -public class XMLFormatterWithCDATAOnSystemOut extends BuildFileTest { - - private static String DIR = "src/etc/testcases/taskdefs/optional/junit"; - private static String REPORT = - "TEST-" + XMLFormatterWithCDATAOnSystemOut.class.getName() + ".xml"; - - private static String TESTDATA = - "" + - "" + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - " " + - "]]>" + - ""; - - public XMLFormatterWithCDATAOnSystemOut(String name) { - super(name); - } - - public void testOutput() { - System.out.println(TESTDATA); - } - - public void testBuildfile() throws IOException { - configureProject(DIR + "/cdataoutput.xml"); - if (getProject().getProperty("cdata.inner") == null) { - // avoid endless loop - executeTarget("run-junit"); - File f = getProject().resolveFile(REPORT); - FileReader reader = null; - try { - reader = new FileReader(f); - String content = FileUtils.readFully(reader); - assertTrue(content.indexOf("]]>" - + "") > 0); - } finally { - if (reader != null) { - reader.close(); - } - f.delete(); - } - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java deleted file mode 100644 index ffe7228f7..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/net/FTPTest.java +++ /dev/null @@ -1,895 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.net; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.Vector; - -import org.apache.commons.net.ftp.FTPClient; -import org.apache.tools.ant.BuildEvent; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.DefaultLogger; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.taskdefs.condition.Os; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.util.RetryHandler; -import org.apache.tools.ant.util.Retryable; -import org.apache.tools.ant.util.regexp.RegexpMatcher; -import org.apache.tools.ant.util.regexp.RegexpMatcherFactory; - -public class FTPTest extends BuildFileTest{ - // keep track of what operating systems are supported here. - private boolean supportsSymlinks = Os.isFamily("unix"); - - private FTPClient ftp; - private boolean connectionSucceeded = true; - private boolean loginSuceeded = true; - private String tmpDir = null; - private String remoteTmpDir = null; - private String ftpFileSep = null; - private myFTP myFTPTask = new myFTP(); - - public FTPTest(String name) { - super(name); - } - public void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/net/ftp.xml"); - getProject().executeTarget("setup"); - tmpDir = getProject().getProperty("tmp.dir"); - ftp = new FTPClient(); - ftpFileSep = getProject().getProperty("ftp.filesep"); - myFTPTask.setSeparator(ftpFileSep); - myFTPTask.setProject(getProject()); - remoteTmpDir = myFTPTask.resolveFile(tmpDir); - String remoteHost = getProject().getProperty("ftp.host"); - int port = Integer.parseInt(getProject().getProperty("ftp.port")); - String remoteUser = getProject().getProperty("ftp.user"); - String password = getProject().getProperty("ftp.password"); - try { - ftp.connect(remoteHost, port); - } catch (Exception ex) { - connectionSucceeded = false; - loginSuceeded = false; - System.out.println("could not connect to host " + remoteHost + " on port " + port); - } - if (connectionSucceeded) { - try { - ftp.login(remoteUser, password); - } catch (IOException ioe) { - loginSuceeded = false; - System.out.println("could not log on to " + remoteHost + " as user " + remoteUser); - } - } - } - - public void tearDown() { - try { - ftp.disconnect(); - } catch (IOException ioe) { - // do nothing - } - getProject().executeTarget("cleanup"); - } - private boolean changeRemoteDir(String remoteDir) { - boolean result = true; - try { - ftp.cwd(remoteDir); - } - catch (Exception ex) { - System.out.println("could not change directory to " + remoteTmpDir); - result = false; - } - return result; - } - public void test1() { - if (loginSuceeded) { - if (changeRemoteDir(remoteTmpDir)) { - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha"}); - ds.scan(); - compareFiles(ds, new String[] {} ,new String[] {"alpha"}); - } - } - } - - public void test2() { - if (loginSuceeded) { - if (changeRemoteDir(remoteTmpDir)) { - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - } - } - - public void test3() { - if (loginSuceeded) { - if (changeRemoteDir(remoteTmpDir)) { - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", - "alpha/beta/gamma"}); - } - } - } - - public void testFullPathMatchesCaseSensitive() { - if (loginSuceeded) { - if (changeRemoteDir(remoteTmpDir)) { - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); - ds.scan(); - compareFiles(ds, new String[] {}, new String[] {}); - } - } - } - - public void testFullPathMatchesCaseInsensitive() { - if (loginSuceeded) { - if (changeRemoteDir(remoteTmpDir)) { - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setCaseSensitive(false); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/GAMMA.XML"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); - } - } - } - - public void test2ButCaseInsensitive() { - if (loginSuceeded) { - if (changeRemoteDir(remoteTmpDir)) { - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"ALPHA/"}); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - } - } - public void test2bisButCaseInsensitive() { - if (loginSuceeded) { - if (changeRemoteDir(remoteTmpDir)) { - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/BETA/gamma/"}); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha/beta/gamma"}); - } - } - } - public void testGetWithSelector() { - expectLogContaining("ftp-get-with-selector", - "selectors are not supported in remote filesets"); - FileSet fsDestination = (FileSet) getProject().getReference("fileset-destination-without-selector"); - DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(getProject()); - dsDestination.scan(); - String [] sortedDestinationDirectories = dsDestination.getIncludedDirectories(); - String [] sortedDestinationFiles = dsDestination.getIncludedFiles(); - for (int counter = 0; counter < sortedDestinationDirectories.length; counter++) { - sortedDestinationDirectories[counter] = - sortedDestinationDirectories[counter].replace(File.separatorChar, '/'); - } - for (int counter = 0; counter < sortedDestinationFiles.length; counter++) { - sortedDestinationFiles[counter] = - sortedDestinationFiles[counter].replace(File.separatorChar, '/'); - } - FileSet fsSource = (FileSet) getProject().getReference("fileset-source-without-selector"); - DirectoryScanner dsSource = fsSource.getDirectoryScanner(getProject()); - dsSource.scan(); - compareFiles(dsSource, sortedDestinationFiles, sortedDestinationDirectories); - } - public void testGetFollowSymlinksTrue() { - if (!supportsSymlinks) { - return; - } - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - getProject().executeTarget("ftp-get-directory-symbolic-link"); - FileSet fsDestination = (FileSet) getProject().getReference("fileset-destination-without-selector"); - DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(getProject()); - dsDestination.scan(); - compareFiles(dsDestination, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - public void testGetFollowSymlinksFalse() { - if (!supportsSymlinks) { - return; - } - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - getProject().executeTarget("ftp-get-directory-no-symbolic-link"); - FileSet fsDestination = (FileSet) getProject().getReference("fileset-destination-without-selector"); - DirectoryScanner dsDestination = fsDestination.getDirectoryScanner(getProject()); - dsDestination.scan(); - compareFiles(dsDestination, new String[] {}, - new String[] {}); - } - public void testAllowSymlinks() { - if (!supportsSymlinks) { - return; - } - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - getProject().executeTarget("symlink-setup"); - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/"}); - ds.setFollowSymlinks(true); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha/beta/gamma"}); - } - - public void testProhibitSymlinks() { - if (!supportsSymlinks) { - return; - } - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - getProject().executeTarget("symlink-setup"); - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/"}); - ds.setFollowSymlinks(false); - ds.scan(); - compareFiles(ds, new String[] {}, new String[] {}); - } - public void testFileSymlink() { - if (!supportsSymlinks) { - return; - } - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - getProject().executeTarget("symlink-file-setup"); - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/"}); - ds.setFollowSymlinks(true); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha/beta/gamma"}); - } - // father and child pattern test - public void testOrderOfIncludePatternsIrrelevant() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - String [] expectedFiles = {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}; - String [] expectedDirectories = {"alpha/beta", "alpha/beta/gamma" }; - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/be?a/**", "alpha/beta/gamma/"}); - ds.scan(); - compareFiles(ds, expectedFiles, expectedDirectories); - // redo the test, but the 2 include patterns are inverted - ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/beta/gamma/", "alpha/be?a/**"}); - ds.scan(); - compareFiles(ds, expectedFiles, expectedDirectories); - } - - public void testPatternsDifferInCaseScanningSensitive() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testPatternsDifferInCaseScanningInsensitive() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/"}); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testFullpathDiffersInCaseScanningSensitive() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] { - "alpha/beta/gamma/gamma.xml", - "alpha/beta/gamma/GAMMA.XML" - }); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); - } - - public void testFullpathDiffersInCaseScanningInsensitive() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] { - "alpha/beta/gamma/gamma.xml", - "alpha/beta/gamma/GAMMA.XML" - }); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); - } - - public void testParentDiffersInCaseScanningSensitive() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testParentDiffersInCaseScanningInsensitive() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] {"alpha/", "ALPHA/beta/"}); - ds.setCaseSensitive(false); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml"}, - new String[] {"alpha", "alpha/beta", "alpha/beta/gamma"}); - } - - public void testExcludeOneFile() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] { - "**/*.xml" - }); - ds.setExcludes(new String[] { - "alpha/beta/b*xml" - }); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/gamma/gamma.xml"}, - new String[] {}); - } - public void testExcludeHasPrecedence() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] { - "alpha/**" - }); - ds.setExcludes(new String[] { - "alpha/**" - }); - ds.scan(); - compareFiles(ds, new String[] {}, - new String[] {}); - - } - public void testAlternateIncludeExclude() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setIncludes(new String[] { - "alpha/**", - "alpha/beta/gamma/**" - }); - ds.setExcludes(new String[] { - "alpha/beta/**" - }); - ds.scan(); - compareFiles(ds, new String[] {}, - new String[] {"alpha"}); - - } - public void testAlternateExcludeInclude() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setExcludes(new String[] { - "alpha/**", - "alpha/beta/gamma/**" - }); - ds.setIncludes(new String[] { - "alpha/beta/**" - }); - ds.scan(); - compareFiles(ds, new String[] {}, - new String[] {}); - - } - /** - * Test inspired by Bug#1415. - */ - public void testChildrenOfExcludedDirectory() { - if (!loginSuceeded) { - return; - } - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - getProject().executeTarget("children-of-excluded-dir-setup"); - FTP.FTPDirectoryScanner ds = myFTPTask.newScanner(ftp); - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setExcludes(new String[] {"alpha/**"}); - ds.scan(); - compareFiles(ds, new String[] {"delta/delta.xml"}, - new String[] {"delta"}); - - ds = myFTPTask.newScanner(ftp); - if (!changeRemoteDir(remoteTmpDir)) { - return; - } - ds.setBasedir(new File(getProject().getBaseDir(), "tmp")); - ds.setExcludes(new String[] {"alpha"}); - ds.scan(); - compareFiles(ds, new String[] {"alpha/beta/beta.xml", - "alpha/beta/gamma/gamma.xml", - "delta/delta.xml"}, - new String[] {"alpha/beta", "alpha/beta/gamma", "delta"}); - - } - - /** - * This class enables the use of the log messages as a way of testing - * the number of files actually transferred. - * It uses the ant regular expression mechanism to get a regex parser - * to parse the log output. - */ - private class CountLogListener extends DefaultLogger { - private Vector lastMatchGroups = null; - private RegexpMatcher matcher = new RegexpMatcherFactory().newRegexpMatcher(); - - /** - * The only constructor for a CountLogListener - * @param pattern a regular expression pattern. It should have - * one parenthesized group and that group should contain the - * number desired. - */ - public CountLogListener(String pattern) { - super(); - this.matcher.setPattern(pattern); - } - - - /* - * @param event the build event that is being logged. - */ - public void messageLogged(BuildEvent event) { - String message = event.getMessage(); - if (this.matcher.matches(message)) { - lastMatchGroups = this.matcher.getGroups(message); - } - super.messageLogged(event); - } - - /** - * returns the desired number that results from parsing the log - * message - * @return the number of files indicated in the desired message or -1 - * if a matching log message was never found. - */ - public int getCount() { - if (this.lastMatchGroups == null) { - return -1; - } - return Integer.parseInt((String) this.lastMatchGroups.get(1)); - } - } - - /** - * This class enables the use of the log to count the number - * of times a message has been emitted. - */ - private class LogCounter extends DefaultLogger { - private Map searchMap = new HashMap(); - private int matchCount; - - public void addLogMessageToSearch(String message) { - searchMap.put(message, new Integer(0)); - } - - /* - * @param event the build event that is being logged. - */ - public void messageLogged(BuildEvent event) { - String message = event.getMessage(); - Integer mcnt = (Integer) searchMap.get(message); - if (null != mcnt) { - searchMap.put(message, new Integer(mcnt.intValue() + 1)); - } - super.messageLogged(event); - } - - /** - * @return the number of times that the looked for message was sent - * to the log - */ - public int getMatchCount(String message) { - Integer mcnt = (Integer) searchMap.get(message); - if (null != mcnt) { - return mcnt.intValue(); - } - return 0; - } - } - /** - * Tests the combination of the newer parameter and the - * serverTimezoneConfig parameter in the PUT action. The default - * configuration is an ftp server on localhost which formats - * timestamps as GMT. - */ - public void testTimezonePut() { - CountLogListener log = new CountLogListener("(\\d+) files? sent"); - getProject().executeTarget("timed.test.setup"); - getProject().addBuildListener(log); - getProject().executeTarget("timed.test.put.older"); - assertEquals(1, log.getCount()); - } - - /** - * Tests the combination of the newer parameter and the - * serverTimezoneConfig parameter in the GET action. The default - * configuration is an ftp server on localhost which formats - * timestamps as GMT. - */ - public void testTimezoneGet() { - CountLogListener log = new CountLogListener("(\\d+) files? retrieved"); - getProject().executeTarget("timed.test.setup"); - getProject().addBuildListener(log); - getProject().executeTarget("timed.test.get.older"); - assertEquals(3, log.getCount()); - } - - - /** - * Tests that the presence of one of the server config params forces - * the system type to Unix if not specified. - */ - public void testConfiguration1() { - int[] expectedCounts = { - 1,1,0,1,0,0,0 - }; - performConfigTest("configuration.1", expectedCounts); - - } - - /** - * Tests the systemTypeKey attribute. - */ - public void testConfiguration2() { - int[] expectedCounts = { - 1,0,0,1,1,0,0 - }; - performConfigTest("configuration.2", expectedCounts); - - } - - /** - * Tests the systemTypeKey attribute with UNIX specified. - */ - public void testConfiguration3() { - int[] expectedCounts = { - 1,0,1,0,0,1,0 - }; - performConfigTest("configuration.3", expectedCounts); - - } - - public void testConfigurationLang() { - int[] expectedCounts = { - 1,1,0,0,0,0,1 - }; - performConfigTest("configuration.lang.good", expectedCounts); - - try { - performConfigTest("configuration.lang.bad", expectedCounts); - fail("BuildException Expected"); - } catch (Exception bx) { - assertTrue(bx instanceof BuildException); - } - } - /** - * Tests the systemTypeKey attribute. - */ - public void testConfigurationNone() { - int[] expectedCounts = { - 0,0,0,0,0,0,0 - }; - performConfigTest("configuration.none", expectedCounts); - - } - - private void performConfigTest(String target, int[] expectedCounts) { - String[] messages = new String[]{ - "custom configuration", - "custom config: system key = default (UNIX)", - "custom config: system key = UNIX", - "custom config: server time zone ID = " + getProject().getProperty("ftp.server.timezone"), - "custom config: system key = WINDOWS", - "custom config: default date format = yyyy/MM/dd HH:mm", - "custom config: server language code = de" - - }; - LogCounter counter = new LogCounter(); - for (int i=0; i < messages.length; i++) { - counter.addLogMessageToSearch(messages[i]); - } - - getProject().addBuildListener(counter); - getProject().executeTarget(target); - for (int i=0; i < messages.length; i++) { - assertEquals("target "+target+":message "+ i, expectedCounts[i], counter.getMatchCount(messages[i])); - } - - } - - - /** - * this test is inspired by a user reporting that deletions of directories with the ftp task do not work - */ - public void testFTPDelete() { - getProject().executeTarget("ftp-delete"); - } - private void compareFiles(DirectoryScanner ds, String[] expectedFiles, - String[] expectedDirectories) { - String includedFiles[] = ds.getIncludedFiles(); - String includedDirectories[] = ds.getIncludedDirectories(); - assertEquals("file present: ", expectedFiles.length, - includedFiles.length); - assertEquals("directories present: ", expectedDirectories.length, - includedDirectories.length); - - for (int counter=0; counter < includedFiles.length; counter++) { - includedFiles[counter] = includedFiles[counter].replace(File.separatorChar, '/'); - } - Arrays.sort(includedFiles); - for (int counter=0; counter < includedDirectories.length; counter++) { - includedDirectories[counter] = includedDirectories[counter] - .replace(File.separatorChar, '/'); - } - Arrays.sort(includedDirectories); - for (int counter=0; counter < includedFiles.length; counter++) { - assertEquals(expectedFiles[counter], includedFiles[counter]); - } - for (int counter=0; counter < includedDirectories.length; counter++) { - assertEquals(expectedDirectories[counter], includedDirectories[counter]); - counter++; - } - } - private static class myFTP extends FTP { - public FTP.FTPDirectoryScanner newScanner(FTPClient client) { - return new FTP.FTPDirectoryScanner(client); - } - // provide public visibility - public String resolveFile(String file) { - return super.resolveFile(file); - } - } - - - public abstract static class myRetryableFTP extends FTP { - private final int numberOfFailuresToSimulate; - private int simulatedFailuresLeft; - - protected myRetryableFTP(int numberOfFailuresToSimulate) { - this.numberOfFailuresToSimulate = numberOfFailuresToSimulate; - this.simulatedFailuresLeft = numberOfFailuresToSimulate; - } - - protected void getFile(FTPClient ftp, String dir, String filename) - throws IOException, BuildException - { - if (this.simulatedFailuresLeft > 0) { - this.simulatedFailuresLeft--; - throw new IOException("Simulated failure for testing"); - } - super.getFile(ftp, dir, filename); - } - protected void executeRetryable(RetryHandler h, Retryable r, - String filename) throws IOException - { - this.simulatedFailuresLeft = this.numberOfFailuresToSimulate; - super.executeRetryable(h, r, filename); - } - } - public static class oneFailureFTP extends myRetryableFTP { - public oneFailureFTP() { - super(1); - } - } - public static class twoFailureFTP extends myRetryableFTP { - public twoFailureFTP() { - super(2); - } - } - public static class threeFailureFTP extends myRetryableFTP { - public threeFailureFTP() { - super(3); - } - } - - public static class randomFailureFTP extends myRetryableFTP { - public randomFailureFTP() { - super(new Random().nextInt(Short.MAX_VALUE)); - } - } - public void testGetWithSelectorRetryable1() { - getProject().addTaskDefinition("ftp", oneFailureFTP.class); - try { - getProject().executeTarget("ftp-get-with-selector-retryable"); - } catch (BuildException bx) { - fail("Two retries expected, failed after one."); - } - } - public void testGetWithSelectorRetryable2() { - getProject().addTaskDefinition("ftp", twoFailureFTP.class); - try { - getProject().executeTarget("ftp-get-with-selector-retryable"); - } catch (BuildException bx) { - fail("Two retries expected, failed after two."); - } - } - - public void testGetWithSelectorRetryable3() { - getProject().addTaskDefinition("ftp", threeFailureFTP.class); - try { - getProject().executeTarget("ftp-get-with-selector-retryable"); - fail("Two retries expected, continued after two."); - } catch (BuildException bx) { - } - } - public void testGetWithSelectorRetryableRandom() { - getProject().addTaskDefinition("ftp", randomFailureFTP.class); - try { - getProject().setProperty("ftp.retries", "forever"); - getProject().executeTarget("ftp-get-with-selector-retryable"); - } catch (BuildException bx) { - fail("Retry forever specified, but failed."); - } - } - - public void testInitialCommand() { - performCommandTest("test-initial-command", new int[] { 1,0 }); - } - public void testSiteAction() { - performCommandTest("test-site-action", new int[] { 1,0 }); - } - - private void performCommandTest(String target, int[] expectedCounts) { - String[] messages = new String[]{ - "Doing Site Command: umask 222", - "Failed to issue Site Command: umask 222", - - }; - LogCounter counter = new LogCounter(); - for (int i=0; i < messages.length; i++) { - counter.addLogMessageToSearch(messages[i]); - } - - getProject().addBuildListener(counter); - getProject().executeTarget(target); - for (int i=0; i < messages.length; i++) { - assertEquals("target "+target+":message "+ i, expectedCounts[i], counter.getMatchCount(messages[i])); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/P4ChangeTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/P4ChangeTest.java deleted file mode 100644 index 0a44ae815..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/P4ChangeTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.perforce; - -import junit.framework.TestCase; -import org.apache.oro.text.perl.Perl5Util; - -/** - * Basic testcase to ensure that backslashing is OK. - */ -public class P4ChangeTest extends TestCase { - - protected P4Change p4change; - - public P4ChangeTest(String s) { - super(s); - } - - protected void setUp() throws Exception { - p4change = new P4Change(); - } - - public void testBackslash(){ - String input = "comment with a / inside"; - String output = P4Change.backslash(input); - assertEquals("comment with a \\/ inside", output); - } - - public void testSubstitute(){ - Perl5Util util = new Perl5Util(); - String tosubstitute = "xxxx"; - String input = P4Change.backslash("/a/b/c/"); - String output = util.substitute("s//" + input + "/", tosubstitute); - assertEquals("xx/a/b/c/xx", output); - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/p4integrate.xml b/src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/p4integrate.xml deleted file mode 100644 index 31001ddf8..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/perforce/p4integrate.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java deleted file mode 100644 index 07cb1eb49..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/script/ScriptDefTest.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.script; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.FileSet; -import java.io.File; - -/** - * Tests the examples of the <scriptdef> task. - * - * @since Ant 1.6 - */ -public class ScriptDefTest extends BuildFileTest { - - public ScriptDefTest(String name) { - super(name); - } - - /** - * The JUnit setup method - */ - public void setUp() { - configureProject("src/etc/testcases/taskdefs/optional/script/scriptdef.xml"); - } - - public void testSimple() { - executeTarget("simple"); - // get the fileset and its basedir - Project p = getProject(); - FileSet fileset = (FileSet) p.getReference("testfileset"); - File baseDir = fileset.getDir(p); - String log = getLog(); - assertTrue("Expecting attribute value printed", - log.indexOf("Attribute attr1 = test") != -1); - - assertTrue("Expecting nested element value printed", - log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1); - } - - public void testNoLang() { - expectBuildExceptionContaining("nolang", - "Absence of language attribute not detected", - "requires a language attribute"); - } - - public void testNoName() { - expectBuildExceptionContaining("noname", - "Absence of name attribute not detected", - "scriptdef requires a name attribute"); - } - - public void testNestedByClassName() { - executeTarget("nestedbyclassname"); - // get the fileset and its basedir - Project p = getProject(); - FileSet fileset = (FileSet) p.getReference("testfileset"); - File baseDir = fileset.getDir(p); - String log = getLog(); - assertTrue("Expecting attribute value to be printed", - log.indexOf("Attribute attr1 = test") != -1); - - assertTrue("Expecting nested element value to be printed", - log.indexOf("Fileset basedir = " + baseDir.getAbsolutePath()) != -1); - } - - public void testNoElement() { - expectOutput("noelement", "Attribute attr1 = test"); - } - - public void testException() { - expectBuildExceptionContaining("exception", - "Should have thrown an exception in the script", - "TypeError"); - } - - public void testDoubleDef() { - executeTarget("doubledef"); - String log = getLog(); - assertTrue("Task1 did not execute", - log.indexOf("Task1") != -1); - assertTrue("Task2 did not execute", - log.indexOf("Task2") != -1); - } - - public void testDoubleAttribute() { - expectBuildExceptionContaining("doubleAttributeDef", - "Should have detected duplicate attribute definition", - "attr1 attribute more than once"); - } - - public void testProperty() { - executeTarget("property"); - // get the fileset and its basedir - String log = getLog(); - assertTrue("Expecting property in attribute value replaced", - log.indexOf("Attribute value = test") != -1); - } - - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java deleted file mode 100644 index d36de008c..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/sos/SOSTest.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.sos; - -import java.io.File; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Path; - -/** - * Testcase to ensure that command line generation and required attributes are - * correct. - * - */ -public class SOSTest extends BuildFileTest { - - private Commandline commandline; - - private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini"; - private static final String VSS_PROJECT_PATH = "/SourceRoot/Project"; - private static final String DS_VSS_PROJECT_PATH = "$/SourceRoot/Project"; - private static final String SOS_SERVER_PATH = "192.168.0.1:8888"; - private static final String SOS_USERNAME = "ant"; - private static final String SOS_PASSWORD = "rocks"; - private static final String LOCAL_PATH = "testdir"; - private static final String SRC_FILE = "Class1.java"; - private static final String SRC_LABEL = "label1"; - private static final String SRC_COMMENT = "I fixed a bug"; - private static final String SOS_HOME = "/home/user/.sos"; - private static final String VERSION = "007"; - - /** - * Constructor for the SOSTest object - * - * @param s Test name - */ - public SOSTest(String s) { - super(s); - } - - /** - * The JUnit setup method - * - * @throws Exception - */ - protected void setUp() - throws Exception { - project = new Project(); - project.setBasedir("."); - } - - /** - * The teardown method for JUnit - * - * @throws Exception - */ - protected void tearDown() - throws Exception { - File file = new File(project.getBaseDir(), LOCAL_PATH); - if (file.exists()) { - file.delete(); - } - } - - /** Test SOSGetFile flags & commandline generation */ - public void testGetFileFlags() { - String[] sTestCmdLine = {"soscmd", "-command", "GetFile", "-file", - SRC_FILE, "-revision", "007", "-server", SOS_SERVER_PATH, "-name", - SOS_USERNAME, "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, - "-project", DS_VSS_PROJECT_PATH, "-verbose", "-nocompress", - "-nocache", "-workdir", project.getBaseDir().getAbsolutePath() - + File.separator + LOCAL_PATH}; - - // Set up a SOSGet task - SOSGet sosGet = new SOSGet(); - sosGet.setProject(project); - sosGet.setVssServerPath(VSS_SERVER_PATH); - sosGet.setSosServerPath(SOS_SERVER_PATH); - sosGet.setProjectPath(VSS_PROJECT_PATH); - sosGet.setFile(SRC_FILE); - sosGet.setUsername(SOS_USERNAME); - sosGet.setPassword(SOS_PASSWORD); - sosGet.setVersion(VERSION); - sosGet.setLocalPath(new Path(project, LOCAL_PATH)); - sosGet.setNoCache(true); - sosGet.setNoCompress(true); - sosGet.setVerbose(true); - sosGet.setRecursive(true); - - commandline = sosGet.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Test SOSGetProject flags & commandline generation */ - public void testGetProjectFlags() { - String[] sTestCmdLine = {"soscmd", "-command", "GetProject", "-recursive", - "-label", SRC_LABEL, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", "", "-database", VSS_SERVER_PATH, "-project", - DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", - project.getBaseDir().getAbsolutePath()}; - - // Set up a SOSGet task - SOSGet sosGet = new SOSGet(); - sosGet.setProject(project); - sosGet.setVssServerPath(VSS_SERVER_PATH); - sosGet.setSosServerPath(SOS_SERVER_PATH); - sosGet.setProjectPath(DS_VSS_PROJECT_PATH); - sosGet.setLabel(SRC_LABEL); - sosGet.setUsername(SOS_USERNAME); - sosGet.setSosHome(SOS_HOME); - sosGet.setNoCache(true); - sosGet.setNoCompress(false); - sosGet.setVerbose(false); - sosGet.setRecursive(true); - - commandline = sosGet.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Tests SOSGet required attributes. */ - public void testGetExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); - expectSpecificBuildException("sosget.1", "some cause", "sosserverpath attribute must be set!"); - expectSpecificBuildException("sosget.2", "some cause", "username attribute must be set!"); - expectSpecificBuildException("sosget.3", "some cause", "vssserverpath attribute must be set!"); - expectSpecificBuildException("sosget.4", "some cause", "projectpath attribute must be set!"); - } - - /** Test CheckInFile option flags */ - public void testCheckinFileFlags() { - String[] sTestCmdLine = {"soscmd", "-command", "CheckInFile", "-file", - SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", - DS_VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", - "-workdir", project.getBaseDir().getAbsolutePath() + File.separator - + LOCAL_PATH, "-log", SRC_COMMENT}; - - // Set up a SOSCheckin task - SOSCheckin sosCheckin = new SOSCheckin(); - sosCheckin.setProject(project); - sosCheckin.setVssServerPath(VSS_SERVER_PATH); - sosCheckin.setSosServerPath(SOS_SERVER_PATH); - sosCheckin.setProjectPath(VSS_PROJECT_PATH); - sosCheckin.setFile(SRC_FILE); - sosCheckin.setComment(SRC_COMMENT); - sosCheckin.setUsername(SOS_USERNAME); - sosCheckin.setPassword(SOS_PASSWORD); - sosCheckin.setLocalPath(new Path(project, LOCAL_PATH)); - sosCheckin.setNoCache(true); - sosCheckin.setNoCompress(true); - sosCheckin.setVerbose(true); - sosCheckin.setRecursive(true); - - commandline = sosCheckin.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Test CheckInProject option flags */ - public void testCheckinProjectFlags() { - String[] sTestCmdLine = {"soscmd", "-command", "CheckInProject", - "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", "", "-database", VSS_SERVER_PATH, "-project", - DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", - project.getBaseDir().getAbsolutePath(), "-log", SRC_COMMENT,}; - - // Set up a SOSCheckin task - SOSCheckin sosCheckin = new SOSCheckin(); - sosCheckin.setProject(project); - sosCheckin.setVssServerPath(VSS_SERVER_PATH); - sosCheckin.setSosServerPath(SOS_SERVER_PATH); - sosCheckin.setProjectPath(DS_VSS_PROJECT_PATH); - sosCheckin.setComment(SRC_COMMENT); - sosCheckin.setUsername(SOS_USERNAME); - sosCheckin.setSosHome(SOS_HOME); - sosCheckin.setNoCache(true); - sosCheckin.setNoCompress(false); - sosCheckin.setVerbose(false); - sosCheckin.setRecursive(true); - - commandline = sosCheckin.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Test SOSCheckIn required attributes. */ - public void testCheckinExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); - expectSpecificBuildException("soscheckin.1", "some cause", "sosserverpath attribute must be set!"); - expectSpecificBuildException("soscheckin.2", "some cause", "username attribute must be set!"); - expectSpecificBuildException("soscheckin.3", "some cause", "vssserverpath attribute must be set!"); - expectSpecificBuildException("soscheckin.4", "some cause", "projectpath attribute must be set!"); - } - - /** Test CheckOutFile option flags */ - public void testCheckoutFileFlags() { - String[] sTestCmdLine = {"soscmd", "-command", "CheckOutFile", "-file", - SRC_FILE, "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", SOS_PASSWORD, "-database", VSS_SERVER_PATH, "-project", - DS_VSS_PROJECT_PATH, "-verbose", "-nocompress", "-nocache", - "-workdir", project.getBaseDir().getAbsolutePath() - + File.separator + LOCAL_PATH}; - - // Set up a SOSCheckout task - SOSCheckout sosCheckout = new SOSCheckout(); - sosCheckout.setProject(project); - sosCheckout.setVssServerPath(VSS_SERVER_PATH); - sosCheckout.setSosServerPath(SOS_SERVER_PATH); - sosCheckout.setProjectPath(DS_VSS_PROJECT_PATH); - sosCheckout.setFile(SRC_FILE); - sosCheckout.setUsername(SOS_USERNAME); - sosCheckout.setPassword(SOS_PASSWORD); - sosCheckout.setLocalPath(new Path(project, LOCAL_PATH)); - sosCheckout.setNoCache(true); - sosCheckout.setNoCompress(true); - sosCheckout.setVerbose(true); - sosCheckout.setRecursive(true); - - commandline = sosCheckout.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Test CheckOutProject option flags */ - public void testCheckoutProjectFlags() { - String[] sTestCmdLine = {"soscmd", "-command", "CheckOutProject", - "-recursive", "-server", SOS_SERVER_PATH, "-name", SOS_USERNAME, - "-password", "", "-database", VSS_SERVER_PATH, "-project", - DS_VSS_PROJECT_PATH, "", "", "-soshome", SOS_HOME, "-workdir", - project.getBaseDir().getAbsolutePath()}; - - // Set up a sosCheckout task - SOSCheckout sosCheckout = new SOSCheckout(); - sosCheckout.setProject(project); - sosCheckout.setVssServerPath(VSS_SERVER_PATH); - sosCheckout.setSosServerPath(SOS_SERVER_PATH); - sosCheckout.setProjectPath(VSS_PROJECT_PATH); - sosCheckout.setUsername(SOS_USERNAME); - sosCheckout.setSosHome(SOS_HOME); - sosCheckout.setNoCache(true); - sosCheckout.setNoCompress(false); - sosCheckout.setVerbose(false); - sosCheckout.setRecursive(true); - - commandline = sosCheckout.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Test SOSCheckout required attributes. */ - public void testCheckoutExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); - expectSpecificBuildException("soscheckout.1", "some cause", "sosserverpath attribute must be set!"); - expectSpecificBuildException("soscheckout.2", "some cause", "username attribute must be set!"); - expectSpecificBuildException("soscheckout.3", "some cause", "vssserverpath attribute must be set!"); - expectSpecificBuildException("soscheckout.4", "some cause", "projectpath attribute must be set!"); - } - - /** Test Label option flags */ - public void testLabelFlags() { - String[] sTestCmdLine = {"soscmd", "-command", "AddLabel", "-server", - SOS_SERVER_PATH, "-name", SOS_USERNAME, "-password", "", "-database", - VSS_SERVER_PATH, "-project", DS_VSS_PROJECT_PATH, "-label", - SRC_LABEL, "-verbose", "-log", SRC_COMMENT}; - - // Set up a sosCheckout task - SOSLabel sosLabel = new SOSLabel(); - sosLabel.setVssServerPath(VSS_SERVER_PATH); - sosLabel.setSosServerPath(SOS_SERVER_PATH); - sosLabel.setProjectPath(DS_VSS_PROJECT_PATH); - sosLabel.setUsername(SOS_USERNAME); - sosLabel.setSosHome(SOS_HOME); - sosLabel.setComment(SRC_COMMENT); - sosLabel.setLabel(SRC_LABEL); - sosLabel.setNoCache(true); - sosLabel.setNoCompress(false); - sosLabel.setVerbose(true); - - commandline = sosLabel.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Test SOSLabel required attributes. */ - public void testLabelExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/sos/sos.xml"); - expectSpecificBuildException("soslabel.1", "some cause", "sosserverpath attribute must be set!"); - expectSpecificBuildException("soslabel.2", "some cause", "username attribute must be set!"); - expectSpecificBuildException("soslabel.3", "some cause", "vssserverpath attribute must be set!"); - expectSpecificBuildException("soslabel.4", "some cause", "projectpath attribute must be set!"); - expectSpecificBuildException("soslabel.5", "some cause", "label attribute must be set!"); - } - - /** - * Iterate through the generated command line comparing it to reference - * one. - * - * @param sTestCmdLine The reference command line; - * @param sGeneratedCmdLine The generated command line; - */ - private void checkCommandLines(String[] sTestCmdLine, String[] sGeneratedCmdLine) { - int length = sTestCmdLine.length; - for (int i = 0; i < length; i++) { - try { - assertEquals("arg # " + String.valueOf(i), - sTestCmdLine[i], - sGeneratedCmdLine[i]); - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("missing arg " + sTestCmdLine[i]); - } - } - if (sGeneratedCmdLine.length > sTestCmdLine.length) { - // We have extra elements - fail("extra args"); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/splash/SplashScreenTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/splash/SplashScreenTest.java deleted file mode 100644 index 81da89385..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/splash/SplashScreenTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.splash; - -import org.apache.tools.ant.Project; - -/** - * This is an "interactive" test, it passes if the splash screen - * disappears after the "finished" but before the "exiting" message. - * - * This even isn't a JUnit test case. - * - * @since Ant 1.5.2 - */ -public class SplashScreenTest { - - public static void main(String[] args) { - Project p = new Project(); - SplashTask t = new SplashTask(); - t.setProject(p); - t.execute(); - - // give it some time to display - try { - Thread.currentThread().sleep(2000); - } catch (InterruptedException e) { - } // end of try-catch - - p.fireBuildFinished(null); - System.err.println("finished"); - - try { - Thread.currentThread().sleep(2000); - } catch (InterruptedException e) { - } // end of try-catch - System.err.println("exiting"); - System.exit(0); - } -} - diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java deleted file mode 100644 index 8c21c8d0f..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/ssh/ScpTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.taskdefs.optional.ssh; - -import junit.framework.TestCase; - -import java.io.*; -import java.util.List; -import java.util.ArrayList; -import java.util.Iterator; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.condition.FilesMatch; -import org.apache.tools.ant.types.FileSet; -import org.apache.tools.ant.types.selectors.FilenameSelector; - -/** - * This is a unit test for the Scp task in Ant. It must be - * configured with command line options in order for it to work. - * Here are the options: - * - * scp.tmp This is a local path to a temporary - * directory for this task to use. - * scp.host This is the remote location of the form: - * "user:password@host:/path/to/directory" - * scp.port The port of the listening SSH service. - * Defaults to 22. (optional) - * scp.known.hosts The file containing the public keys of known - * hosts. Must be a SSH2 version file, but - * supports RSA and DSA keys. If it is not present - * this task setTrust() to true. (optional) - */ -public class ScpTest extends TestCase { - - private File tempDir = new File( System.getProperty("scp.tmp") ); - private String sshHostUri = System.getProperty("scp.host"); - private int port = Integer.parseInt( System.getProperty( "scp.port", "22" ) ); - private String knownHosts = System.getProperty("scp.known.hosts"); - - private List cleanUpList = new ArrayList(); - - public ScpTest(String testname) { - super(testname); - } - - protected void setUp() { - cleanUpList.clear(); - } - - protected void tearDown() { - for( Iterator i = cleanUpList.iterator(); i.hasNext(); ) { - File file = (File) i.next(); - file.delete(); - } - } - - public void testSingleFileUploadAndDownload() throws IOException { - File uploadFile = createTemporaryFile(); - - Scp scpTask = createTask(); - scpTask.setFile( uploadFile.getPath() ); - scpTask.setTodir( sshHostUri ); - scpTask.execute(); - - File testFile = new File( tempDir.getPath() + File.separator + - "download-testSingleFileUploadAndDownload.test" ); - addCleanup( testFile ); - assertTrue( "Assert that the testFile does not exist.", - !testFile.exists() ); - - scpTask.setFile( sshHostUri + "/" + uploadFile.getName() ); - scpTask.setTodir( testFile.getPath() ); - scpTask.execute(); - - assertTrue( "Assert that the testFile exists.", testFile.exists() ); - compareFiles( uploadFile, testFile ); - } - - public void testMultiUploadAndDownload() throws IOException { - List uploadList = new ArrayList(); - for( int i = 0; i < 5; i++ ) { - uploadList.add( createTemporaryFile() ); - } - - Scp scp = createTask(); - FilenameSelector selector = new FilenameSelector(); - selector.setName( "scp*" ); - FileSet fileset = new FileSet(); - fileset.setDir( tempDir ); - fileset.addFilename( selector ); - scp.addFileset( fileset ); - scp.setTodir( sshHostUri ); - scp.execute(); - - File multi = new File( tempDir, "multi" ); - multi.mkdir(); - addCleanup( multi ); - - Scp scp2 = createTask(); - scp2.setFile( sshHostUri + "/scp*" ); - scp2.setTodir( multi.getPath() ); - scp2.execute(); - - FilesMatch match = new FilesMatch(); - for( Iterator i = uploadList.iterator(); i.hasNext(); ) { - File f = (File)i.next(); - match.setFile1( f ); - File f2 = new File( multi, f.getName() ); - match.setFile2( f2 ); - assertTrue("Assert file '" + f.getPath() + "' and file '" + - f2.getPath() + "'", match.eval() ); - } - } - - public void addCleanup( File file ) { - cleanUpList.add( file ); - } - - private void compareFiles(File src, File dest) { - FilesMatch match = new FilesMatch(); - match.setFile1( src ); - match.setFile2( dest ); - - assertTrue( "Assert files are equal.", match.eval() ); - } - - private File createTemporaryFile() throws IOException { - File uploadFile; - uploadFile = File.createTempFile( "scp", "test", tempDir ); - FileWriter writer = new FileWriter( uploadFile ); - writer.write("Can you hear me now?\n"); - writer.close(); - addCleanup( uploadFile ); - return uploadFile; - } - - private Scp createTask() { - Scp scp = new Scp(); - Project p = new Project(); - p.init(); - scp.setProject( p ); - if( knownHosts != null ) { - scp.setKnownhosts( knownHosts ); - } else { - scp.setTrust( true ); - } - scp.setPort( port ); - return scp; - } -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java deleted file mode 100644 index 83f65a399..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/unix/SymlinkTest.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* - * Since the initial version of this file was deveolped on the clock on - * an NSF grant I should say the following boilerplate: - * - * This material is based upon work supported by the National Science - * Foundaton under Grant No. EIA-0196404. Any opinions, findings, and - * conclusions or recommendations expressed in this material are those - * of the author and do not necessarily reflect the views of the - * National Science Foundation. - */ - -package org.apache.tools.ant.taskdefs.optional.unix; - -import org.apache.tools.ant.taskdefs.condition.Os; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; - -/** - * Test cases for the Symlink task. Link creation, link deletion, recording - * of links in multiple directories, and restoration of links recorded are - * all tested. A separate test for the utility method Symlink.deleteSymlink - * is not included because action="delete" only prints a message and calls - * Symlink.deleteSymlink, making a separate test redundant. - * - */ - -public class SymlinkTest extends BuildFileTest { - - private Project p; - private boolean supportsSymlinks = Os.isFamily("unix"); - - public SymlinkTest(String name) { - super(name); - } - - public void setUp() { - if (supportsSymlinks) { - configureProject("src/etc/testcases/taskdefs/optional/unix/symlink.xml"); - executeTarget("setup"); - } - } - - - public void testSingle() { - if (supportsSymlinks) { - executeTarget("test-single"); - p = getProject(); - assertNotNull("Failed to create file", - p.getProperty("test.single.file.created")); - assertNotNull("Failed to create link", - p.getProperty("test.single.link.created")); - } - } - - public void testDelete() { - if (supportsSymlinks) { - executeTarget("test-delete"); - p = getProject(); - String linkDeleted = p.getProperty("test.delete.link.still.there"); - assertNotNull("Actual file deleted by symlink", - p.getProperty("test.delete.file.still.there")); - if (linkDeleted != null) { - fail(linkDeleted); - } - } - } - - public void testRecord() { - if (supportsSymlinks) { - executeTarget("test-record"); - p = getProject(); - - assertNotNull("Failed to create dir1", - p.getProperty("test.record.dir1.created")); - - assertNotNull("Failed to create dir2", - p.getProperty("test.record.dir2.created")); - - assertNotNull("Failed to create file1", - p.getProperty("test.record.file1.created")); - - assertNotNull("Failed to create file2", - p.getProperty("test.record.file2.created")); - - assertNotNull("Failed to create fileA", - p.getProperty("test.record.fileA.created")); - - assertNotNull("Failed to create fileB", - p.getProperty("test.record.fileB.created")); - - assertNotNull("Failed to create fileC", - p.getProperty("test.record.fileC.created")); - - assertNotNull("Failed to create link1", - p.getProperty("test.record.link1.created")); - - assertNotNull("Failed to create link2", - p.getProperty("test.record.link2.created")); - - assertNotNull("Failed to create link3", - p.getProperty("test.record.link3.created")); - - assertNotNull("Failed to create dirlink", - p.getProperty("test.record.dirlink.created")); - - assertNotNull("Failed to create dirlink2", - p.getProperty("test.record.dirlink2.created")); - - assertNotNull("Couldn't record links in dir1", - p.getProperty("test.record.dir1.recorded")); - - assertNotNull("Couldn't record links in dir2", - p.getProperty("test.record.dir2.recorded")); - - String dir3rec = p.getProperty("test.record.dir3.recorded"); - - if (dir3rec != null) { - fail(dir3rec); - } - - } - } - - public void testRecreate() { - if (supportsSymlinks) { - executeTarget("test-recreate"); - p = getProject(); - String link1Rem = p.getProperty("test.recreate.link1.not.removed"); - String link2Rem = p.getProperty("test.recreate.link2.not.removed"); - String link3Rem = p.getProperty("test.recreate.link3.not.removed"); - String dirlinkRem = p.getProperty("test.recreate.dirlink.not.removed"); - if (link1Rem != null) { - fail(link1Rem); - } - if (link2Rem != null) { - fail(link2Rem); - } - if (link3Rem != null) { - fail(link3Rem); - } - if (dirlinkRem != null) { - fail(dirlinkRem); - } - assertNotNull("Failed to recreate link1", - p.getProperty("test.recreate.link1.recreated")); - assertNotNull("Failed to recreate link2", - p.getProperty("test.recreate.link2.recreated")); - assertNotNull("Failed to recreate link3", - p.getProperty("test.recreate.link3.recreated")); - assertNotNull("Failed to recreate dirlink", - p.getProperty("test.recreate.dirlink.recreated")); - - String doubleRecreate = p.getProperty("test.recreate.dirlink2.recreated.twice"); - - if (doubleRecreate != null) { - fail(doubleRecreate); - } - - assertNotNull("Failed to alter dirlink3", - p.getProperty("test.recreate.dirlink3.was.altered")); - - } - } - - public void tearDown() { - if (supportsSymlinks) { - executeTarget("teardown"); - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java deleted file mode 100644 index 7891d0b94..000000000 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/vss/MSVSSTest.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.taskdefs.optional.vss; - -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.TimeZone; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Location; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Tstamp; -import org.apache.tools.ant.types.Commandline; -import org.apache.tools.ant.types.Path; - -/** - * Testcase to ensure that command line generation and required attributes are correct. - * - */ -public class MSVSSTest extends BuildFileTest implements MSVSSConstants { - - private Commandline commandline; - - private static final String VSS_SERVER_PATH = "\\\\server\\vss\\srcsafe.ini"; - private static final String VSS_PROJECT_PATH = "/SourceRoot/Project"; - private static final String DS_VSS_PROJECT_PATH = "$/SourceRoot/Project"; - private static final String VSS_USERNAME = "ant"; - private static final String VSS_PASSWORD = "rocks"; - private static final String LOCAL_PATH = "testdir"; - private static final String SRC_FILE = "Class1.java"; - private static final String SRC_LABEL = "label1"; - private static final String LONG_LABEL = "123456789012345678901234567890"; - private static final String SRC_COMMENT = "I fixed a bug"; - private static final String VERSION = "007"; - private static final String DATE = "00-00-00"; - private static final String DATE2 = "01-01-01"; - private static final String OUTPUT = "output.log"; - private static final String SS_DIR = "c:/winnt".replace('/', File.separatorChar); - - /** - * Constructor for the MSVSSTest object - * - * @param s Test name - */ - public MSVSSTest(String s) { - super(s); - } - - /** - * The JUnit setup method - * - * @throws Exception - */ - protected void setUp() - throws Exception { - project = new Project(); - project.setBasedir("."); - } - - /** - * The teardown method for JUnit - * - * @throws Exception - */ - protected void tearDown() - throws Exception { - File file = new File(project.getBaseDir(), LOCAL_PATH); - if (file.exists()) { - file.delete(); - } - } - - /** Tests VSSGet commandline generation. */ - public void testGetCommandLine() { - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_GET, DS_VSS_PROJECT_PATH, - MSVSS.FLAG_OVERRIDE_WORKING_DIR + project.getBaseDir().getAbsolutePath() - + File.separator + LOCAL_PATH, MSVSS.FLAG_AUTORESPONSE_DEF, - MSVSS.FLAG_RECURSION, MSVSS.FLAG_VERSION + VERSION, MSVSS.FLAG_LOGIN - + VSS_USERNAME + "," + VSS_PASSWORD, FLAG_FILETIME_UPDATED, FLAG_SKIP_WRITABLE}; - - // Set up a VSSGet task - MSVSSGET vssGet = new MSVSSGET(); - vssGet.setProject(project); - vssGet.setRecursive(true); - vssGet.setLocalpath(new Path(project, LOCAL_PATH)); - vssGet.setLogin(VSS_USERNAME + "," + VSS_PASSWORD); - vssGet.setVersion(VERSION); - vssGet.setQuiet(false); - vssGet.setDate(DATE); - vssGet.setLabel(SRC_LABEL); - vssGet.setVsspath(VSS_PROJECT_PATH); - MSVSS.CurrentModUpdated cmu = new MSVSS.CurrentModUpdated(); - cmu.setValue(TIME_UPDATED); - vssGet.setFileTimeStamp(cmu); - MSVSS.WritableFiles wf = new MSVSS.WritableFiles(); - wf.setValue(WRITABLE_SKIP); - vssGet.setWritableFiles(wf); - - commandline = vssGet.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Tests VSSGet required attributes. */ - public void testGetExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vssget.1", "some cause", "vsspath attribute must be set!"); - } - - /** Tests Label commandline generation. */ - public void testLabelCommandLine1() { - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_LABEL, DS_VSS_PROJECT_PATH, - MSVSS.FLAG_COMMENT + SRC_COMMENT, MSVSS.FLAG_AUTORESPONSE_YES, - MSVSS.FLAG_LABEL + SRC_LABEL, MSVSS.FLAG_VERSION + VERSION, MSVSS.FLAG_LOGIN - + VSS_USERNAME + "," + VSS_PASSWORD}; - - // Set up a VSSLabel task - MSVSSLABEL vssLabel = new MSVSSLABEL(); - vssLabel.setProject(project); - vssLabel.setComment(SRC_COMMENT); - vssLabel.setLogin(VSS_USERNAME + "," + VSS_PASSWORD); - vssLabel.setVersion(VERSION); - vssLabel.setAutoresponse("Y"); - vssLabel.setLabel(SRC_LABEL); - vssLabel.setVsspath(VSS_PROJECT_PATH); - - commandline = vssLabel.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Tests Label commandline generation with a label of more than 31 chars. */ - public void testLabelCommandLine2() { - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_LABEL, DS_VSS_PROJECT_PATH, - MSVSS.FLAG_COMMENT + SRC_COMMENT, MSVSS.FLAG_AUTORESPONSE_DEF, - MSVSS.FLAG_LABEL + LONG_LABEL, - MSVSS.FLAG_LOGIN + VSS_USERNAME + "," + VSS_PASSWORD}; - - // Set up a VSSLabel task - MSVSSLABEL vssLabel = new MSVSSLABEL(); - vssLabel.setProject(project); - vssLabel.setComment(SRC_COMMENT); - vssLabel.setLogin(VSS_USERNAME + "," + VSS_PASSWORD); - vssLabel.setLabel(LONG_LABEL + "blahblah"); - vssLabel.setVsspath(VSS_PROJECT_PATH); - - commandline = vssLabel.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** - * Test VSSLabel required attributes. - */ - public void testLabelExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vsslabel.1", "some cause", "vsspath attribute must be set!"); - expectSpecificBuildException("vsslabel.2", "some cause", "label attribute must be set!"); - } - - /** Tests VSSHistory commandline generation with from label. */ - public void testHistoryCommandLine1() { - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_HISTORY, DS_VSS_PROJECT_PATH, - MSVSS.FLAG_AUTORESPONSE_DEF, MSVSS.FLAG_VERSION_LABEL + LONG_LABEL - + MSVSS.VALUE_FROMLABEL + SRC_LABEL, MSVSS.FLAG_LOGIN + VSS_USERNAME - + "," + VSS_PASSWORD, MSVSS.FLAG_OUTPUT + project.getBaseDir().getAbsolutePath() - + File.separator + OUTPUT}; - - // Set up a VSSHistory task - MSVSSHISTORY vssHistory = new MSVSSHISTORY(); - vssHistory.setProject(project); - - vssHistory.setLogin(VSS_USERNAME + "," + VSS_PASSWORD); - - vssHistory.setFromLabel(SRC_LABEL); - vssHistory.setToLabel(LONG_LABEL + "blahblah"); - vssHistory.setVsspath(VSS_PROJECT_PATH); - vssHistory.setRecursive(false); - vssHistory.setOutput(new File(project.getBaseDir().getAbsolutePath(), OUTPUT)); - - commandline = vssHistory.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Tests VSSHistory commandline generation with from date. */ - public void testHistoryCommandLine2() { - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_HISTORY, DS_VSS_PROJECT_PATH, - MSVSS.FLAG_AUTORESPONSE_DEF, MSVSS.FLAG_VERSION_DATE + DATE + MSVSS.VALUE_FROMDATE - + DATE2, MSVSS.FLAG_RECURSION, MSVSS.FLAG_LOGIN + VSS_USERNAME + "," + VSS_PASSWORD}; - - // Set up a VSSHistory task - MSVSSHISTORY vssHistory = new MSVSSHISTORY(); - vssHistory.setProject(project); - vssHistory.setLogin(VSS_USERNAME + "," + VSS_PASSWORD); - vssHistory.setFromDate(DATE2); - vssHistory.setToDate(DATE); - vssHistory.setVsspath(VSS_PROJECT_PATH); - vssHistory.setRecursive(true); - - commandline = vssHistory.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** Tests VSSHistory commandline generation with date calculation. */ - public void testHistoryCommandLine3() { - // Set up a Timestamp - Tstamp tstamp = new Tstamp(); - Location location = new Location("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - tstamp.setLocation(location); - tstamp.setProject(project); - Tstamp.CustomFormat format = tstamp.createFormat(); - format.setProperty("today"); - format.setPattern("HH:mm:ss z"); - format.setTimezone("GMT"); - Date date = Calendar.getInstance().getTime(); - format.execute(project, date, location); - String today = project.getProperty("today"); - - // Get today's date - SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss z"); - sdf.setTimeZone( TimeZone.getTimeZone("GMT") ); - String expected = sdf.format(date); - - // Set up a VSSHistory task - MSVSSHISTORY vssHistory = new MSVSSHISTORY(); - vssHistory.setProject(project); - vssHistory.setLogin(VSS_USERNAME); - vssHistory.setToDate(today); - vssHistory.setVsspath(VSS_PROJECT_PATH); - - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_HISTORY, DS_VSS_PROJECT_PATH, - MSVSS.FLAG_AUTORESPONSE_DEF, MSVSS.FLAG_VERSION_DATE + expected, MSVSS.FLAG_LOGIN + VSS_USERNAME}; - - commandline = vssHistory.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** - * Tests VSSHistory required attributes. - */ - public void testHistoryExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vsshistory.1", "some cause", "vsspath attribute must be set!"); - } - - /** Tests CheckIn commandline generation. */ - public void testCheckinCommandLine() { - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_CHECKIN, DS_VSS_PROJECT_PATH, - MSVSS.FLAG_AUTORESPONSE_NO, MSVSS.FLAG_WRITABLE, MSVSS.FLAG_LOGIN + VSS_USERNAME, - MSVSS.FLAG_COMMENT + SRC_COMMENT}; - - // Set up a VSSCheckIn task - MSVSSCHECKIN vssCheckin = new MSVSSCHECKIN(); - vssCheckin.setProject(project); - vssCheckin.setComment(SRC_COMMENT); - vssCheckin.setLogin(VSS_USERNAME); - vssCheckin.setAutoresponse("N"); - vssCheckin.setVsspath(VSS_PROJECT_PATH); - vssCheckin.setWritable(true); - - commandline = vssCheckin.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** - * Test VSSCheckIn required attributes. - */ - public void testCheckinExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vsscheckin.1", "some cause", "vsspath attribute must be set!"); - } - - /** Tests CheckOut commandline generation. */ - public void testCheckoutCommandLine() { - String[] sTestCmdLine = {SS_DIR + File.separator + MSVSS.SS_EXE, MSVSS.COMMAND_CHECKOUT, - DS_VSS_PROJECT_PATH, MSVSS.FLAG_AUTORESPONSE_DEF, MSVSS.FLAG_RECURSION, - MSVSS.FLAG_VERSION_DATE + DATE, MSVSS.FLAG_LOGIN + VSS_USERNAME, - FLAG_FILETIME_MODIFIED, FLAG_NO_GET}; - - // Set up a VSSCheckOut task - MSVSSCHECKOUT vssCheckout = new MSVSSCHECKOUT(); - vssCheckout.setProject(project); - vssCheckout.setLogin(VSS_USERNAME); - vssCheckout.setVsspath(DS_VSS_PROJECT_PATH); - vssCheckout.setRecursive(true); - vssCheckout.setDate(DATE); - vssCheckout.setLabel(SRC_LABEL); - vssCheckout.setSsdir(SS_DIR); - MSVSS.CurrentModUpdated cmu = new MSVSS.CurrentModUpdated(); - cmu.setValue(TIME_MODIFIED); - vssCheckout.setFileTimeStamp(cmu); - vssCheckout.setGetLocalCopy(false); - - commandline = vssCheckout.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** - * Test VSSCheckout required attributes. - */ - public void testCheckoutExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vsscheckout.1", "some cause", "vsspath attribute must be set!"); - expectSpecificBuildException("vsscheckout.2", "some cause", "blah is not a legal value for this attribute"); - } - - /** Tests Add commandline generation. */ - public void testAddCommandLine() { - String[] sTestCmdLine = {SS_DIR + File.separator + MSVSS.SS_EXE, MSVSS.COMMAND_ADD, - project.getBaseDir().getAbsolutePath() + File.separator + LOCAL_PATH, - MSVSS.FLAG_AUTORESPONSE_DEF, MSVSS.FLAG_RECURSION, - MSVSS.FLAG_LOGIN + VSS_USERNAME + "," + VSS_PASSWORD, MSVSS.FLAG_COMMENT + "-"}; - - // Set up a VSSAdd task - MSVSSADD vssAdd = new MSVSSADD(); - vssAdd.setProject(project); - vssAdd.setLogin(VSS_USERNAME + "," + VSS_PASSWORD); - vssAdd.setVsspath(DS_VSS_PROJECT_PATH); - vssAdd.setRecursive(true); - vssAdd.setSsdir(SS_DIR); - vssAdd.setWritable(false); - vssAdd.setLocalpath(new Path(project, LOCAL_PATH)); - - commandline = vssAdd.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** - * Test VSSAdd required attributes. - */ - public void testAddExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vssadd.1", "some cause", "localPath attribute must be set!"); - } - - /** Tests CP commandline generation. */ - public void testCpCommandLine() { - String[] sTestCmdLine = {MSVSS.SS_EXE, MSVSS.COMMAND_CP, - DS_VSS_PROJECT_PATH, MSVSS.FLAG_AUTORESPONSE_DEF, MSVSS.FLAG_LOGIN + - VSS_USERNAME}; - - // Set up a VSSCp task - MSVSSCP vssCp = new MSVSSCP(); - vssCp.setProject(project); - vssCp.setLogin(VSS_USERNAME); - vssCp.setVsspath(DS_VSS_PROJECT_PATH); - - commandline = vssCp.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** - * Test VSSCP required attributes. - */ - public void testCpExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vsscp.1", "some cause", "vsspath attribute must be set!"); - } - - /** Tests Create commandline generation. */ - public void testCreateCommandLine() { - String[] sTestCmdLine = { MSVSS.SS_EXE, MSVSS.COMMAND_CREATE, - DS_VSS_PROJECT_PATH, MSVSS.FLAG_COMMENT + SRC_COMMENT, MSVSS.FLAG_AUTORESPONSE_NO, - MSVSS.FLAG_QUIET, MSVSS.FLAG_LOGIN + VSS_USERNAME}; - - // Set up a VSSCreate task - MSVSSCREATE vssCreate = new MSVSSCREATE(); - vssCreate.setProject(project); - vssCreate.setComment(SRC_COMMENT); - vssCreate.setLogin(VSS_USERNAME); - vssCreate.setVsspath(DS_VSS_PROJECT_PATH); - vssCreate.setFailOnError(true); - vssCreate.setAutoresponse("N"); - vssCreate.setQuiet(true); - - commandline = vssCreate.buildCmdLine(); - - checkCommandLines(sTestCmdLine, commandline.getCommandline()); - } - - /** - * Test VSSCreate required attributes. - */ - public void testCreateExceptions() { - configureProject("src/etc/testcases/taskdefs/optional/vss/vss.xml"); - expectSpecificBuildException("vsscreate.1", "some cause", "vsspath attribute must be set!"); - } - - /** - * Iterate through the generated command line comparing it to reference one. - * @param sTestCmdLine The reference command line; - * @param sGeneratedCmdLine The generated command line; - */ - private void checkCommandLines(String[] sTestCmdLine, String[] sGeneratedCmdLine) { - int testLength = sTestCmdLine.length; - int genLength = sGeneratedCmdLine.length; - - int genIndex = 0; - int testIndex = 0; - - while (testIndex < testLength) { - try { - if (sGeneratedCmdLine[genIndex] == "") { - genIndex++; - continue; - } - assertEquals("arg # " + testIndex, - sTestCmdLine[testIndex], - sGeneratedCmdLine[genIndex]); - testIndex++; - genIndex++; - } catch (ArrayIndexOutOfBoundsException aioob) { - fail("missing arg " + sTestCmdLine[testIndex]); - } - } - - // Count the number of empty strings - int cnt = 0; - for (int i = 0; i < genLength; i++) { - if (sGeneratedCmdLine[i] == "") { - cnt++; - } - } - if (genLength - cnt > sTestCmdLine.length) { - // We have extra elements - fail("extra args"); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/types/AbstractFileSetTest.java b/src/testcases/org/apache/tools/ant/types/AbstractFileSetTest.java deleted file mode 100644 index 63adb615a..000000000 --- a/src/testcases/org/apache/tools/ant/types/AbstractFileSetTest.java +++ /dev/null @@ -1,245 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * Base class for FileSetTest and DirSetTest. - * - *

This doesn't actually test much, mainly reference handling. - * - */ - -public abstract class AbstractFileSetTest extends TestCase { - - private Project project; - - public AbstractFileSetTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.setBasedir("."); - } - - protected abstract AbstractFileSet getInstance(); - - protected final Project getProject() { - return project; - } - - public final void testEmptyElementIfIsReference() { - AbstractFileSet f = getInstance(); - f.setIncludes("**/*.java"); - try { - f.setRefid(new Reference("dummyref")); - fail("Can add reference to " - + f.getDataTypeName() - + " with elements from setIncludes"); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute " - + "when using refid", be.getMessage()); - } - - f = getInstance(); - f.createPatternSet(); - try { - f.setRefid(new Reference("dummyref")); - fail("Can add reference to " - + f.getDataTypeName() - + " with nested patternset element."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when " - + "using refid", be.getMessage()); - } - - f = getInstance(); - f.createInclude(); - try { - f.setRefid(new Reference("dummyref")); - fail("Can add reference to " - + f.getDataTypeName() - + " with nested include element."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute " - + "when using refid", be.getMessage()); - } - - f = getInstance(); - f.setRefid(new Reference("dummyref")); - try { - f.setIncludes("**/*.java"); - fail("Can set includes in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute " - + "when using refid", be.getMessage()); - } - try { - f.setIncludesfile(new File("/a")); - fail("Can set includesfile in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute " - + "when using refid", be.getMessage()); - } - try { - f.setExcludes("**/*.java"); - fail("Can set excludes in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute " - + "when using refid", be.getMessage()); - } - try { - f.setExcludesfile(new File("/a")); - fail("Can set excludesfile in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute " - + "when using refid", be.getMessage()); - } - try { - f.setDir(project.resolveFile(".")); - fail("Can set dir in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute " - + "when using refid", be.getMessage()); - } - try { - f.createInclude(); - fail("Can add nested include in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using " - + "refid", be.getMessage()); - } - try { - f.createExclude(); - fail("Can add nested exclude in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using " - + "refid", be.getMessage()); - } - try { - f.createIncludesFile(); - fail("Can add nested includesfile in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using " - + "refid", be.getMessage()); - } - try { - f.createExcludesFile(); - fail("Can add nested excludesfile in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using " - + "refid", be.getMessage()); - } - try { - f.createPatternSet(); - fail("Can add nested patternset in " - + f.getDataTypeName() - + " that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using " - + "refid", be.getMessage()); - } - } - - public void testCircularReferenceCheck() { - AbstractFileSet f = getInstance(); - project.addReference("dummy", f); - f.setRefid(new Reference("dummy")); - try { - f.getDir(project); - fail("Can make " + f.getDataTypeName() - + " a Reference to itself."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - try { - f.getDirectoryScanner(project); - fail("Can make " + f.getDataTypeName() - + " a Reference to itself."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 --> dummy1 - AbstractFileSet f1 = getInstance(); - project.addReference("dummy1", f1); - f1.setRefid(new Reference("dummy2")); - AbstractFileSet f2 = getInstance(); - project.addReference("dummy2", f2); - f2.setRefid(new Reference("dummy3")); - AbstractFileSet f3 = getInstance(); - project.addReference("dummy3", f3); - f3.setRefid(new Reference("dummy1")); - try { - f1.getDir(project); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - try { - f1.getDirectoryScanner(project); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 - // (which has the Project's basedir as root). - f1 = getInstance(); - project.addReference("dummy1", f1); - f1.setRefid(new Reference("dummy2")); - f2 = getInstance(); - project.addReference("dummy2", f2); - f2.setRefid(new Reference("dummy3")); - f3 = getInstance(); - project.addReference("dummy3", f3); - f3.setDir(project.resolveFile(".")); - File dir = f1.getDir(project); - assertEquals("Dir is basedir", dir, project.getBaseDir()); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/AddTypeTest.java b/src/testcases/org/apache/tools/ant/types/AddTypeTest.java deleted file mode 100644 index 715cbc1be..000000000 --- a/src/testcases/org/apache/tools/ant/types/AddTypeTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.taskdefs.condition.Condition; - -public class AddTypeTest extends BuildFileTest { - - public AddTypeTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/addtype.xml"); - } - - public void testAddPath() { - executeTarget("addpath"); - } - - public void testAddCondition() { - executeTarget("addcondition"); - } - - public void testAddFilter() { - executeTarget("addfilter"); - } - - public void testAddSelector() { - executeTarget("addselector"); - } - - public void testNestedA() { - expectLogContaining("nested.a", "add A called"); - } - - public void testNestedB() { - expectLogContaining("nested.b", "add B called"); - } - - public void testNestedC() { - expectLogContaining("nested.c", "add C called"); - } - - public void testNestedAB() { - expectBuildExceptionContaining( - "nested.ab", "Should have got ambiguous", "ambiguous"); - } - - public void testConditionType() { - expectLogContaining("condition.type", "beforeafter"); - } - - public void testConditionTask() { - expectLogContaining("condition.task", "My Condition execution"); - } - public void testConditionConditionType() { - expectLogContaining("condition.condition.type", "My Condition eval"); - } - public void testConditionConditionTask() { - expectBuildExceptionContaining( - "condition.condition.task", "task masking condition", - "doesn't support the nested"); - } - - public void testAddConfigured() { - expectLogContaining( - "myaddconfigured", "value is Value Setexecute: value is Value Set"); - } - - public void testAddConfiguredValue() { - expectLogContaining( - "myaddconfiguredvalue", - "value is Value Setexecute: value is Value Set"); - } - - public void testNamespace() { - executeTarget("namespacetest"); - } - - // The following will be used as types and tasks - - public static interface A {} - public static interface B {} - public static interface C extends A {} - public static interface AB extends A, B {} - - public static class AImpl implements A{} - public static class BImpl implements B{} - public static class CImpl implements C{} - public static class ABImpl implements AB{} - - public static class NestedContainer - extends Task - { - public void add(A el) { - log("add A called"); - } - public void add(B el) { - log("add B called"); - } - public void add(C el) { - log("add C called"); - } - } - - public static class MyCondition - implements Condition - { - Project project; - public void setProject(Project project) { - this.project = project; - } - public boolean eval() { - project.log("My Condition eval"); - return true; - } - public void execute() { - project.log("My Condition execution"); - } - } - - public static class MyValue - { - private String text = "NOT SET YET"; - public void addText(String text) { - this.text = text; - } - public String toString() { - return text; - } - } - - public static class MyAddConfigured - extends Task - { - MyValue value; - public void addConfigured(MyValue value) { - log("value is " + value); - this.value = value; - } - public void add(MyValue value) { - throw new BuildException("Should not be called"); - } - public void execute() { - log("execute: value is " + value); - } - } - - public static class MyAddConfiguredValue - extends Task - { - MyValue value; - public void addConfiguredValue(MyValue value) { - log("value is " + value); - this.value = value; - } - public void addValue(MyValue value) { - throw new BuildException("Should not be called"); - } - public void execute() { - log("execute: value is " + value); - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/AssertionsTest.java b/src/testcases/org/apache/tools/ant/types/AssertionsTest.java deleted file mode 100644 index d83018485..000000000 --- a/src/testcases/org/apache/tools/ant/types/AssertionsTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; - -/** - * test assertion handling - */ -public class AssertionsTest extends BuildFileTest { - - public AssertionsTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - configureProject("src/etc/testcases/types/assertions.xml"); - } - - protected void tearDown() throws Exception { - executeTarget("teardown"); - } - - /** - * runs a test and expects an assertion thrown in forked code - * @param target - */ - protected void expectAssertion(String target) { - expectBuildExceptionContaining(target, - "assertion not thrown in "+target, - "Java returned: 1"); - } - - public void testClassname() { - expectAssertion("test-classname"); - } - - public void testPackage() { - expectAssertion("test-package"); - } - - public void testEmptyAssertions() { - executeTarget("test-empty-assertions"); - } - - public void testDisable() { - executeTarget("test-disable"); - } - - public void testOverride() { - expectAssertion("test-override"); - } - - public void testOverride2() { - executeTarget("test-override2"); - } - public void testReferences() { - expectAssertion("test-references"); - } - - public void testMultipleAssertions() { - expectBuildExceptionContaining("test-multiple-assertions", - "multiple assertions rejected", - "Only one assertion declaration is allowed"); - } - - public void testReferenceAbuse() { - expectBuildExceptionContaining("test-reference-abuse", - "reference abuse rejected", - "You must not specify more than one attribute when using refid"); - } - - public void testNofork() { - if (AssertionsTest.class.desiredAssertionStatus()) { - return; // ran Ant tests with -ea and this would fail spuriously - } - expectLogContaining("test-nofork", - "Assertion statements are currently ignored in non-forked mode"); - } - - - public void testJunit() { - executeTarget("test-junit"); - } -} - - diff --git a/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java b/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java deleted file mode 100644 index 8f2ebfcc8..000000000 --- a/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import junit.framework.TestCase; - -import org.apache.tools.ant.MagicNames; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.JavaEnvUtils; - -/** - * JUnit 3 testcases for org.apache.tools.ant.CommandlineJava - * - */ -public class CommandlineJavaTest extends TestCase { - - private String cloneVm; - - public CommandlineJavaTest(String name) { - super(name); - } - - private Project project; - - public void setUp() { - project = new Project(); - project.setBasedir(System.getProperty("root")); - project.setProperty("build.sysclasspath", "ignore"); - cloneVm = System.getProperty("ant.build.clonevm"); - if (cloneVm != null) { - System.setProperty("ant.build.clonevm", "false"); - } - } - - public void tearDown() { - if (cloneVm != null) { - System.setProperty("ant.build.clonevm", cloneVm); - } - } - - public void testGetCommandline() throws Exception { - CommandlineJava c = new CommandlineJava(); - c.createArgument().setValue("org.apache.tools.ant.CommandlineJavaTest"); - c.setClassname("junit.textui.TestRunner"); - c.createVmArgument().setValue("-Djava.compiler=NONE"); - String[] s = c.getCommandline(); - assertEquals("no classpath", 4, s.length); - /* - * After changing CommandlineJava to search for the java - * executable, I don't know, how to tests the value returned - * here without using the same logic as applied in the class - * itself. - * - * assertTrue("no classpath", "java", s[0]); - */ - assertEquals("no classpath", "-Djava.compiler=NONE", s[1]); - assertEquals("no classpath", "junit.textui.TestRunner", s[2]); - assertEquals("no classpath", - "org.apache.tools.ant.CommandlineJavaTest", s[3]); - try { - CommandlineJava c2 = (CommandlineJava) c.clone(); - } catch (NullPointerException ex) { - fail("cloning should work without classpath specified"); - } - - c.createClasspath(project).setLocation(project.resolveFile("build.xml")); - c.createClasspath(project).setLocation(project.resolveFile( - System.getProperty(MagicNames.ANT_HOME)+"/lib/ant.jar")); - s = c.getCommandline(); - assertEquals("with classpath", 6, s.length); - // assertEquals("with classpath", "java", s[0]); - assertEquals("with classpath", "-Djava.compiler=NONE", s[1]); - assertEquals("with classpath", "-classpath", s[2]); - assertTrue("build.xml contained", - s[3].indexOf("build.xml"+java.io.File.pathSeparator) >= 0); - assertTrue("ant.jar contained", s[3].endsWith("ant.jar")); - assertEquals("with classpath", "junit.textui.TestRunner", s[4]); - assertEquals("with classpath", - "org.apache.tools.ant.CommandlineJavaTest", s[5]); - } - - public void testJarOption() throws Exception { - CommandlineJava c = new CommandlineJava(); - c.createArgument().setValue("arg1"); - c.setJar("myfile.jar"); - c.createVmArgument().setValue("-classic"); - c.createVmArgument().setValue("-Dx=y"); - String[] s = c.getCommandline(); - assertEquals("-classic", s[1]); - assertEquals("-Dx=y", s[2]); - assertEquals("-jar", s[3]); - assertEquals("myfile.jar", s[4]); - assertEquals("arg1", s[5]); - } - - public void testSysproperties() { - String currentClasspath = System.getProperty("java.class.path"); - assertNotNull(currentClasspath); - assertNull(System.getProperty("key")); - CommandlineJava c = new CommandlineJava(); - Environment.Variable v = new Environment.Variable(); - v.setKey("key"); - v.setValue("value"); - c.addSysproperty(v); - - project.setProperty("key2", "value2"); - PropertySet ps = new PropertySet(); - ps.setProject(project); - ps.appendName("key2"); - c.addSyspropertyset(ps); - - try { - c.setSystemProperties(); - String newClasspath = System.getProperty("java.class.path"); - assertNotNull(newClasspath); - assertEquals(currentClasspath, newClasspath); - assertNotNull(System.getProperty("key")); - assertEquals("value", System.getProperty("key")); - assertTrue(System.getProperties().containsKey("java.class.path")); - assertNotNull(System.getProperty("key2")); - assertEquals("value2", System.getProperty("key2")); - } finally { - c.restoreSystemProperties(); - } - assertNull(System.getProperty("key")); - assertNull(System.getProperty("key2")); - } - - public void testAssertions() throws Exception { - if (JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) - || JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3)) { - return; - } - - CommandlineJava c = new CommandlineJava(); - c.createArgument().setValue("org.apache.tools.ant.CommandlineJavaTest"); - c.setClassname("junit.textui.TestRunner"); - c.createVmArgument().setValue("-Djava.compiler=NONE"); - Assertions a = new Assertions(); - a.setProject(project); - Assertions.EnabledAssertion ea = new Assertions.EnabledAssertion(); - ea.setClass("junit.textui.TestRunner"); - a.addEnable(ea); - c.setAssertions(a); - - String[] expected = new String[] { - null, - "-Djava.compiler=NONE", - "-ea:junit.textui.TestRunner", - "junit.textui.TestRunner", - "org.apache.tools.ant.CommandlineJavaTest", - }; - - // only the second iteration would pass because of PR 27218 - for (int i = 0; i < 3; i++) { - String[] s = c.getCommandline(); - assertEquals(expected.length, s.length); - for (int j = 1; j < expected.length; j++) { - assertEquals(expected[j], s[j]); - } - } - CommandlineJava c2 = (CommandlineJava) c.clone(); - String[] s = c2.getCommandline(); - assertEquals(expected.length, s.length); - for (int j = 1; j < expected.length; j++) { - assertEquals(expected[j], s[j]); - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/CommandlineTest.java b/src/testcases/org/apache/tools/ant/types/CommandlineTest.java deleted file mode 100644 index 559c5f76d..000000000 --- a/src/testcases/org/apache/tools/ant/types/CommandlineTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; - -/** - * JUnit 3 testcases for org.apache.tools.ant.CommandLine - * - */ -public class CommandlineTest extends TestCase { - - public CommandlineTest(String name) { - super(name); - } - - public void testTokenizer() { - String[] s = Commandline.translateCommandline("1 2 3"); - assertEquals("Simple case", 3, s.length); - for (int i=0; i<3; i++) { - assertEquals(""+(i+1), s[i]); - } - - s = Commandline.translateCommandline(""); - assertEquals("empty string", 0, s.length); - - s = Commandline.translateCommandline(null); - assertEquals("null", 0, s.length); - - s = Commandline.translateCommandline("1 \'2\' 3"); - assertEquals("Simple case with single quotes", 3, s.length); - assertEquals("Single quotes have been stripped", "2", s[1]); - - s = Commandline.translateCommandline("1 \"2\" 3"); - assertEquals("Simple case with double quotes", 3, s.length); - assertEquals("Double quotes have been stripped", "2", s[1]); - - s = Commandline.translateCommandline("1 \"2 3\" 4"); - assertEquals("Case with double quotes and whitespace", 3, s.length); - assertEquals("Double quotes stripped, space included", "2 3", s[1]); - - s = Commandline.translateCommandline("1 \"2\'3\" 4"); - assertEquals("Case with double quotes around single quote", 3, s.length); - assertEquals("Double quotes stripped, single quote included", "2\'3", - s[1]); - - s = Commandline.translateCommandline("1 \'2 3\' 4"); - assertEquals("Case with single quotes and whitespace", 3, s.length); - assertEquals("Single quotes stripped, space included", "2 3", s[1]); - - s = Commandline.translateCommandline("1 \'2\"3\' 4"); - assertEquals("Case with single quotes around double quote", 3, s.length); - assertEquals("Single quotes stripped, double quote included", "2\"3", - s[1]); - - // \ doesn't have a special meaning anymore - this is different from - // what the Unix sh does but causes a lot of problems on DOS - // based platforms otherwise - s = Commandline.translateCommandline("1 2\\ 3 4"); - assertEquals("case with quoted whitespace", 4, s.length); - assertEquals("backslash included", "2\\", s[1]); - - // "" should become a single empty argument, same for '' - // PR 5906 - s = Commandline.translateCommandline("\"\" a"); - assertEquals("Doublequoted null arg prepend", 2, s.length); - assertEquals("Doublequoted null arg prepend", "", s[0]); - assertEquals("Doublequoted null arg prepend", "a", s[1]); - s = Commandline.translateCommandline("a \"\""); - assertEquals("Doublequoted null arg append", 2, s.length); - assertEquals("Doublequoted null arg append", "a", s[0]); - assertEquals("Doublequoted null arg append", "", s[1]); - s = Commandline.translateCommandline("\"\""); - assertEquals("Doublequoted null arg", 1, s.length); - assertEquals("Doublequoted null arg", "", s[0]); - - s = Commandline.translateCommandline("\'\' a"); - assertEquals("Singlequoted null arg prepend", 2, s.length); - assertEquals("Singlequoted null arg prepend", "", s[0]); - assertEquals("Singlequoted null arg prepend", "a", s[1]); - s = Commandline.translateCommandline("a \'\'"); - assertEquals("Singlequoted null arg append", 2, s.length); - assertEquals("Singlequoted null arg append", "a", s[0]); - assertEquals("Singlequoted null arg append", "", s[1]); - s = Commandline.translateCommandline("\'\'"); - assertEquals("Singlequoted null arg", 1, s.length); - assertEquals("Singlequoted null arg", "", s[0]); - - // now to the expected failures - - try { - s = Commandline.translateCommandline("a \'b c"); - fail("unbalanced single quotes undetected"); - } catch (BuildException be) { - assertEquals("unbalanced quotes in a \'b c", be.getMessage()); - } - - try { - s = Commandline.translateCommandline("a \"b c"); - fail("unbalanced double quotes undetected"); - } catch (BuildException be) { - assertEquals("unbalanced quotes in a \"b c", be.getMessage()); - } - } - - public void testToString() { - assertEquals("", Commandline.toString(new String[0])); - assertEquals("", Commandline.toString(null)); - assertEquals("1 2 3", Commandline.toString(new String[] {"1", "2", "3"})); - assertEquals("1 \"2 3\"", Commandline.toString(new String[] {"1", "2 3"})); - assertEquals("1 \"2\'3\"", Commandline.toString(new String[] {"1", "2\'3"})); - assertEquals("1 \'2\"3\'", Commandline.toString(new String[] {"1", "2\"3"})); - } - - public void testAwkCommand(){ - Commandline c = new Commandline(); - c.setExecutable("awk"); - c.createArgument().setValue("'NR == 2 { print $NF }'"); - String[] s = c.getCommandline(); - assertNotNull(s); - assertEquals(2, s.length); - assertEquals("awk", s[0]); - assertEquals("'NR == 2 { print $NF }'", s[1]); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/DescriptionTest.java b/src/testcases/org/apache/tools/ant/types/DescriptionTest.java deleted file mode 100644 index 966465dc0..000000000 --- a/src/testcases/org/apache/tools/ant/types/DescriptionTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; - -/** - * FilterSet testing - * - */ -public class DescriptionTest extends BuildFileTest { - - public DescriptionTest(String name) { - super(name); - } - - public void setUp() { - } - - public void tearDown() { - } - - public void test1() { - configureProject("src/etc/testcases/types/description1.xml"); - assertEquals("Single description failed", "Test Project Description", project.getDescription()); - } - - public void test2() { - configureProject("src/etc/testcases/types/description2.xml"); - assertEquals("Multi line description failed", "Multi Line\nProject Description", project.getDescription()); - } - - public void test3() { - configureProject("src/etc/testcases/types/description3.xml"); - assertEquals("Multi instance description failed", "Multi Instance Project Description", project.getDescription()); - } - - public void test4() { - configureProject("src/etc/testcases/types/description4.xml"); - assertEquals("Multi instance nested description failed", "Multi Instance Nested Project Description", project.getDescription()); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/DirSetTest.java b/src/testcases/org/apache/tools/ant/types/DirSetTest.java deleted file mode 100644 index c17ef55cb..000000000 --- a/src/testcases/org/apache/tools/ant/types/DirSetTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; -import java.io.FileOutputStream; -import org.apache.tools.ant.BuildException; - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.DirSet. - * - */ -public class DirSetTest extends AbstractFileSetTest { - - public DirSetTest(String name) { - super(name); - } - - protected AbstractFileSet getInstance() { - return new DirSet(); - } - - public void testFileSetIsNoDirSet() { - DirSet ds = (DirSet) getInstance(); - ds.setProject(getProject()); - FileSet fs = new FileSet(); - fs.setProject(getProject()); - getProject().addReference("dummy", fs); - ds.setRefid(new Reference(getProject(), "dummy")); - try { - ds.getDir(getProject()); - fail("DirSet created from FileSet reference"); - } catch (BuildException e) { - assertEquals("dummy doesn\'t denote a DirSet", e.getMessage()); - } - - ds = (DirSet) getInstance(); - ds.setProject(getProject()); - getProject().addReference("dummy2", ds); - fs.setRefid(new Reference(getProject(), "dummy2")); - try { - fs.getDir(getProject()); - fail("FileSet created from DirSet reference"); - } catch (BuildException e) { - assertEquals("dummy2 doesn\'t denote a FileSet", e.getMessage()); - } - } - - public void testToString() throws Exception { - File tmp = File.createTempFile("DirSetTest", ""); - tmp.delete(); - File a = new File(tmp, "a"); - a.mkdirs(); - File b = new File(tmp, "b"); - File bc = new File(b, "c"); - bc.mkdirs(); - new FileOutputStream(new File(a, "x")).close(); - new FileOutputStream(new File(b, "x")).close(); - new FileOutputStream(new File(bc, "x")).close(); - DirSet ds = new DirSet(); - ds.setProject(getProject()); - ds.setDir(tmp); - ds.setIncludes("b/"); - assertEquals("b;b" + File.separator + "c", ds.toString()); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java b/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java deleted file mode 100644 index 246686a4b..000000000 --- a/src/testcases/org/apache/tools/ant/types/EnumeratedAttributeTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; - -/** - * JUnit 3 testcases for org.apache.tools.ant.EnumeratedAttribute. - * - */ - -public class EnumeratedAttributeTest extends TestCase { - - private static String[] expected = {"a", "b", "c"}; - - public EnumeratedAttributeTest(String name) { - super(name); - } - - public void testContains() { - EnumeratedAttribute t1 = new TestNormal(); - for (int i=0; i dummy2 --> dummy3 --> dummy1 - FileList f1 = new FileList(); - project.addReference("dummy1", f1); - f1.setRefid(new Reference("dummy2")); - FileList f2 = new FileList(); - project.addReference("dummy2", f2); - f2.setRefid(new Reference("dummy3")); - FileList f3 = new FileList(); - project.addReference("dummy3", f3); - f3.setRefid(new Reference("dummy1")); - try { - f1.getDir(project); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - try { - f1.getFiles(project); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 - // (which has the Project's basedir as root). - f1 = new FileList(); - project.addReference("dummy1", f1); - f1.setRefid(new Reference("dummy2")); - f2 = new FileList(); - project.addReference("dummy2", f2); - f2.setRefid(new Reference("dummy3")); - f3 = new FileList(); - project.addReference("dummy3", f3); - f3.setDir(project.resolveFile(".")); - File dir = f1.getDir(project); - assertEquals("Dir is basedir", dir, project.getBaseDir()); - } - - public void testSimple() { - expectLog("simple", "/abc/a"); - } - - public void testDouble() { - expectLog("double", "/abc/a:/abc/b"); - } - - public void testNested() { - expectLog("nested", "/abc/a:/abc/b"); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/FileSetTest.java b/src/testcases/org/apache/tools/ant/types/FileSetTest.java deleted file mode 100644 index 359598690..000000000 --- a/src/testcases/org/apache/tools/ant/types/FileSetTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.FileSet. - * - *

This doesn't actually test much, mainly reference handling. - * - */ - -public class FileSetTest extends AbstractFileSetTest { - - public FileSetTest(String name) { - super(name); - } - - protected AbstractFileSet getInstance() { - return new FileSet(); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/FilterSetTest.java b/src/testcases/org/apache/tools/ant/types/FilterSetTest.java deleted file mode 100644 index 4f014285f..000000000 --- a/src/testcases/org/apache/tools/ant/types/FilterSetTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Hashtable; - -import org.apache.tools.ant.BuildFileTest; - -/** - * FilterSet testing - * - */ -public class FilterSetTest extends BuildFileTest { - - static private final int BUF_SIZE = 32768; - - public FilterSetTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/filterset.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - executeTarget("test1"); - assertTrue("Filterset 1 failed", compareFiles("src/etc/testcases/types/gold/filterset1.txt", - "src/etc/testcases/types/dest1.txt")); - } - - public void test2() { - executeTarget("test2"); - assertTrue("Filterset 2 failed", compareFiles("src/etc/testcases/types/gold/filterset2.txt", - "src/etc/testcases/types/dest2.txt")); - } - - public void test3() { - executeTarget("test3"); - assertTrue("Filterset 3 failed", compareFiles("src/etc/testcases/types/gold/filterset3.txt", - "src/etc/testcases/types/dest3.txt")); - } - - /** - * This will test the recursive FilterSet. Which means that if - * the filter value @test@ contains another filter value, it will - * actually resolve. - */ - public void testRecursive() { - String result = "it works line"; - String line="@test@ line"; - FilterSet fs = new FilterSet(); - fs.addFilter("test", "@test1@"); - fs.addFilter("test1","@test2@"); - fs.addFilter("test2", "it works"); - fs.setBeginToken("@"); - fs.setEndToken("@"); - assertEquals(result, fs.replaceTokens(line)); - } - - /** - * Test to see what happens when the resolving occurs in an - * infinite loop. - */ - public void testInfinite() { - String result = "@test@ line testvalue"; - String line = "@test@ line @test3@"; - FilterSet fs = new FilterSet(); - fs.addFilter("test", "@test1@"); - fs.addFilter("test1","@test2@"); - fs.addFilter("test2", "@test@"); - fs.addFilter("test3", "testvalue"); - fs.setBeginToken("@"); - fs.setEndToken("@"); - assertEquals(result, fs.replaceTokens(line)); - } - - /** - * Test to see what happens when the resolving occurs in - * what would be an infinite loop, but with recursion disabled. - */ - public void testRecursionDisabled() { - String result = "@test1@ line testvalue"; - String line = "@test@ line @test2@"; - FilterSet fs = new FilterSet(); - fs.addFilter("test", "@test1@"); - fs.addFilter("test1","@test@"); - fs.addFilter("test2", "testvalue"); - fs.setBeginToken("@"); - fs.setEndToken("@"); - fs.setRecurse(false); - assertEquals(result, fs.replaceTokens(line)); - } - - public void testNonInfiniteRecursiveMultipleOnSingleLine() { - FilterSet filters = new FilterSet(); - - filters.setBeginToken("<"); - filters.setEndToken(">"); - - filters.addFilter("ul", ""); - filters.addFilter("/ul", ""); - filters.addFilter("li", ""); - filters.addFilter("/li", ""); - - String result = "Item 1 Item 2"; - String line = "

  • Item 1
  • Item 2
"; - - assertEquals(result, filters.replaceTokens(line)); - } - - public void testNestedFilterSets() { - executeTarget("test-nested-filtersets"); - - FilterSet fs = (FilterSet) getProject().getReference("1"); - Hashtable filters = fs.getFilterHash(); - assertEquals(1, filters.size()); - assertEquals("value1", filters.get("token1")); - - fs = (FilterSet) getProject().getReference("2"); - filters = fs.getFilterHash(); - assertEquals(2, filters.size()); - assertEquals("1111", filters.get("aaaa")); - assertEquals("2222", filters.get("bbbb")); - - fs = (FilterSet) getProject().getReference("3"); - filters = fs.getFilterHash(); - assertEquals(1, filters.size()); - assertEquals("value4", filters.get("token4")); - - fs = (FilterSet) getProject().getReference("5"); - filters = fs.getFilterHash(); - assertEquals(1, filters.size()); - assertEquals("value1", filters.get("token1")); - } - - public void testFiltersFileElement() { - executeTarget("testFiltersFileElement"); - } - - public void testFiltersFileAttribute() { - executeTarget("testFiltersFileAttribute"); - } - - public void testMultipleFiltersFiles() { - executeTarget("testMultipleFiltersFiles"); - } - - public void testMissingFiltersFile() { - expectBuildException("testMissingFiltersFile", - "should fail due to missing filtersfile"); - } - - public void testAllowMissingFiltersFile() { - executeTarget("testAllowMissingFiltersFile"); - } - - private boolean compareFiles(String name1, String name2) { - File file1 = new File(System.getProperty("root"), name1); - File file2 = new File(System.getProperty("root"), name2); - - try { - if (!file1.exists() || !file2.exists()) { - System.out.println("One or both files do not exist:" + name1 + ", " + name2); - return false; - } - - if (file1.length() != file2.length()) { - System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " + - name2 + "(" + file2.length() + ")"); - return false; - } - - // byte - byte compare - byte[] buffer1 = new byte[BUF_SIZE]; - byte[] buffer2 = new byte[BUF_SIZE]; - - FileInputStream fis1 = new FileInputStream(file1); - FileInputStream fis2 = new FileInputStream(file2); - int index = 0; - int read = 0; - while ((read = fis1.read(buffer1)) != -1) { - fis2.read(buffer2); - for (int i = 0; i < read; ++i, ++index) { - if (buffer1[i] != buffer2[i]) { - System.out.println("Bytes mismatch:" + name1 + ", " + name2 + - " at byte " + index); - return false; - } - } - } - return true; - } - catch (IOException e) { - System.out.println("IOException comparing files: " + name1 + ", " + name2); - return false; - } - } -} diff --git a/src/testcases/org/apache/tools/ant/types/FlexIntegerTest.java b/src/testcases/org/apache/tools/ant/types/FlexIntegerTest.java deleted file mode 100644 index d618b7692..000000000 --- a/src/testcases/org/apache/tools/ant/types/FlexIntegerTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.BuildException; - -public class FlexIntegerTest extends BuildFileTest { - - public FlexIntegerTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/flexinteger.xml"); - } - - public void testFlexInteger() { - executeTarget("test"); - assertEquals(project.getProperty("flexint.value1"), "10"); - assertEquals(project.getProperty("flexint.value2"), "8"); - } - - // This class acts as a custom Ant task also - // and uses these variables/methods in that mode - private Project taskProject; - String propName; - private FlexInteger value; - - /** - * To make taskdef happy - */ - public FlexIntegerTest() { - super("FlexIntegerTest"); - } - - public void setPropName(String propName) { - this.propName = propName; - } - - public void setValue(FlexInteger value) { - this.value = value; - } - - public void setProject(Project project) { - taskProject = project; - } - - public void execute() { - if (propName == null || value == null) { - throw new BuildException("name and value required"); - } - - taskProject.setNewProperty(propName, value.toString()); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/MapperTest.java b/src/testcases/org/apache/tools/ant/types/MapperTest.java deleted file mode 100644 index 6770c7826..000000000 --- a/src/testcases/org/apache/tools/ant/types/MapperTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.util.Arrays; -import java.util.List; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.ChainedMapper; -import org.apache.tools.ant.util.FileNameMapper; -import org.apache.tools.ant.util.FlatFileNameMapper; -import org.apache.tools.ant.util.GlobPatternMapper; -import org.apache.tools.ant.util.MergingMapper; - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.Mapper. - * - */ - -public class MapperTest extends TestCase { - - private Project project; - - public MapperTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.setBasedir("."); - } - - public void testEmptyElementIfIsReference() { - Mapper m = new Mapper(project); - m.setFrom("*.java"); - try { - m.setRefid(new Reference("dummyref")); - fail("Can add reference to Mapper with from attribute set"); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - m = new Mapper(project); - m.setRefid(new Reference("dummyref")); - try { - m.setFrom("*.java"); - fail("Can set from in Mapper that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - m = new Mapper(project); - m.setRefid(new Reference("dummyref")); - try { - m.setTo("*.java"); - fail("Can set to in Mapper that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - try { - Mapper.MapperType mt = new Mapper.MapperType(); - mt.setValue("glob"); - m.setType(mt); - fail("Can set type in Mapper that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - } - - public void testCircularReferenceCheck() { - Mapper m = new Mapper(project); - project.addReference("dummy", m); - m.setRefid(new Reference("dummy")); - try { - m.getImplementation(); - fail("Can make Mapper a Reference to itself."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 --> dummy1 - Mapper m1 = new Mapper(project); - project.addReference("dummy1", m1); - m1.setRefid(new Reference("dummy2")); - Mapper m2 = new Mapper(project); - project.addReference("dummy2", m2); - m2.setRefid(new Reference("dummy3")); - Mapper m3 = new Mapper(project); - project.addReference("dummy3", m3); - m3.setRefid(new Reference("dummy1")); - try { - m1.getImplementation(); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 - // (which holds a glob mapper from "*.java" to "*.class" - m1 = new Mapper(project); - project.addReference("dummy1", m1); - m1.setRefid(new Reference("dummy2")); - m2 = new Mapper(project); - project.addReference("dummy2", m2); - m2.setRefid(new Reference("dummy3")); - m3 = new Mapper(project); - project.addReference("dummy3", m3); - Mapper.MapperType mt = new Mapper.MapperType(); - mt.setValue("glob"); - m3.setType(mt); - m3.setFrom("*.java"); - m3.setTo("*.class"); - FileNameMapper fmm = m1.getImplementation(); - assertTrue("should be glob", fmm instanceof GlobPatternMapper); - String[] result = fmm.mapFileName("a.java"); - assertEquals("a.java should match", 1, result.length); - assertEquals("a.class", result[0]); - } - - public void testNested() { - Mapper mapper1 = new Mapper(project); - Mapper.MapperType mt = new Mapper.MapperType(); - mt.setValue("glob"); - mapper1.setType(mt); - mapper1.setFrom("from*"); - mapper1.setTo("to*"); - - //mix element types - FileNameMapper mapper2 = new FlatFileNameMapper(); - FileNameMapper mapper3 = new MergingMapper(); - mapper3.setTo("mergefile"); - - Mapper container = new Mapper(project); - container.addConfiguredMapper(mapper1); - container.add(mapper2); - container.add(mapper3); - - FileNameMapper fileNameMapper = container.getImplementation(); - String[] targets = fileNameMapper.mapFileName("fromfilename"); - assertNotNull("no filenames mapped", targets); - assertEquals("wrong number of filenames mapped", 3, targets.length); - List list = Arrays.asList(targets); - assertTrue("cannot find expected target \"tofilename\"", - list.contains("tofilename")); - assertTrue("cannot find expected target \"fromfilename\"", - list.contains("fromfilename")); - assertTrue("cannot find expected target \"mergefile\"", - list.contains("mergefile")); - } - - public void testChained() { - - // a --> b --> c --- def - // \-- ghi - - FileNameMapper mapperAB = new GlobPatternMapper(); - mapperAB.setFrom("a"); - mapperAB.setTo("b"); - - FileNameMapper mapperBC = new GlobPatternMapper(); - mapperBC.setFrom("b"); - mapperBC.setTo("c"); - - //implicit composite - Mapper mapperCX = new Mapper(project); - - FileNameMapper mapperDEF = new GlobPatternMapper(); - mapperDEF.setFrom("c"); - mapperDEF.setTo("def"); - - FileNameMapper mapperGHI = new GlobPatternMapper(); - mapperGHI.setFrom("c"); - mapperGHI.setTo("ghi"); - - mapperCX.add(mapperDEF); - mapperCX.add(mapperGHI); - - Mapper chained = new Mapper(project); - chained.setClassname(ChainedMapper.class.getName()); - chained.add(mapperAB); - chained.add(mapperBC); - chained.addConfiguredMapper(mapperCX); - - FileNameMapper fileNameMapper = chained.getImplementation(); - String[] targets = fileNameMapper.mapFileName("a"); - assertNotNull("no filenames mapped", targets); - assertEquals("wrong number of filenames mapped", 2, targets.length); - List list = Arrays.asList(targets); - assertTrue("cannot find expected target \"def\"", list.contains("def")); - assertTrue("cannot find expected target \"ghi\"", list.contains("ghi")); - } - - public void testCopyTaskWithTwoFilesets() { - TaskdefForCopyTest t = new TaskdefForCopyTest("test1"); - try { - t.setUp(); - t.test1(); - } finally { - t.tearDown(); - } - } - - private class TaskdefForCopyTest extends BuildFileTest { - TaskdefForCopyTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/mapper.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void test1() { - executeTarget("test1"); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/types/PathTest.java b/src/testcases/org/apache/tools/ant/types/PathTest.java deleted file mode 100644 index 25fd99349..000000000 --- a/src/testcases/org/apache/tools/ant/types/PathTest.java +++ /dev/null @@ -1,552 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; -import java.util.Locale; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.condition.Os; - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.Path - * - */ - -public class PathTest extends TestCase { - - public static boolean isUnixStyle = File.pathSeparatorChar == ':'; - public static boolean isNetWare = Os.isFamily("netware"); - - private Project project; - - public PathTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.setBasedir(System.getProperty("root")); - } - - // actually tests constructor as well as setPath - public void testConstructorUnixStyle() { - Path p = new Path(project, "/a:/b"); - String[] l = p.list(); - assertEquals("two items, Unix style", 2, l.length); - if (isUnixStyle) { - assertEquals("/a", l[0]); - assertEquals("/b", l[1]); - } else if (isNetWare) { - assertEquals("\\a", l[0]); - assertEquals("\\b", l[1]); - } else { - String base = new File(File.separator).getAbsolutePath().toUpperCase(); - assertEquals(base + "a", l[0]); - assertEquals(base + "b", l[1]); - } - } - - public void testRelativePathUnixStyle() { - project.setBasedir(new File(System.getProperty("root"), "src/etc").getAbsolutePath()); - Path p = new Path(project, "..:testcases"); - String[] l = p.list(); - assertEquals("two items, Unix style", 2, l.length); - if (isUnixStyle) { - assertTrue("test resolved relative to src/etc", - l[0].endsWith("/src")); - assertTrue("test resolved relative to src/etc", - l[1].endsWith("/src/etc/testcases")); - } else if (isNetWare) { - assertTrue("test resolved relative to src/etc", - l[0].endsWith("\\src")); - assertTrue("test resolved relative to src/etc", - l[1].endsWith("\\src\\etc\\testcases")); - } else { - assertTrue("test resolved relative to src/etc", - l[0].endsWith("\\src")); - assertTrue("test resolved relative to src/etc", - l[1].endsWith("\\src\\etc\\testcases")); - } - } - - public void testConstructorWindowsStyle() { - Path p = new Path(project, "\\a;\\b"); - String[] l = p.list(); - assertEquals("two items, DOS style", 2, l.length); - if (isUnixStyle) { - assertEquals("/a", l[0]); - assertEquals("/b", l[1]); - } else if (isNetWare) { - assertEquals("\\a", l[0]); - assertEquals("\\b", l[1]); - } else { - String base = new File(File.separator).getAbsolutePath().toUpperCase(); - assertEquals(base + "a", l[0]); - assertEquals(base + "b", l[1]); - } - - p = new Path(project, "c:\\test"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 2, l.length); - assertTrue("c resolved relative to project\'s basedir", - l[0].endsWith("/c")); - assertEquals("/test", l[1]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 1, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - } else { - assertEquals("drives on DOS", 1, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - } - - p = new Path(project, "c:\\test;d:\\programs"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 4, l.length); - assertTrue("c resolved relative to project\'s basedir", - l[0].endsWith("/c")); - assertEquals("/test", l[1]); - assertTrue("d resolved relative to project\'s basedir", - l[2].endsWith("/d")); - assertEquals("/programs", l[3]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 2, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - assertEquals("d:\\programs", l[1].toLowerCase(Locale.US)); - } else { - assertEquals("drives on DOS", 2, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - assertEquals("d:\\programs", l[1].toLowerCase(Locale.US)); - } - - p = new Path(project, "c:/test"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 2, l.length); - assertTrue("c resolved relative to project\'s basedir", - l[0].endsWith("/c")); - assertEquals("/test", l[1]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 1, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - } else { - assertEquals("drives on DOS", 1, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - } - - p = new Path(project, "c:/test;d:/programs"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 4, l.length); - assertTrue("c resolved relative to project\'s basedir", - l[0].endsWith("/c")); - assertEquals("/test", l[1]); - assertTrue("d resolved relative to project\'s basedir", - l[2].endsWith("/d")); - assertEquals("/programs", l[3]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 2, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - assertEquals("d:\\programs", l[1].toLowerCase(Locale.US)); - } else { - assertEquals("drives on DOS", 2, l.length); - assertEquals("c:\\test", l[0].toLowerCase(Locale.US)); - assertEquals("d:\\programs", l[1].toLowerCase(Locale.US)); - } - } - - public void testConstructorNetWareStyle() { - // try a netware-volume length path, see how it is handled - Path p = new Path(project, "sys:\\test"); - String[] l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 2, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("/sys")); - assertEquals("/test", l[1]); - } else if (isNetWare) { - assertEquals("sys:\\test", l[0].toLowerCase(Locale.US)); - assertEquals("volumes on NetWare", 1, l.length); - } else { - assertEquals("no multiple character-length volumes on Windows", 2, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("\\sys")); - assertTrue("test resolved relative to project\'s basedir", - l[1].endsWith("\\test")); - } - - // try a multi-part netware-volume length path, see how it is handled - p = new Path(project, "sys:\\test;dev:\\temp"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 4, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("/sys")); - assertEquals("/test", l[1]); - assertTrue("dev resolved relative to project\'s basedir", - l[2].endsWith("/dev")); - assertEquals("/temp", l[3]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 2, l.length); - assertEquals("sys:\\test", l[0].toLowerCase(Locale.US)); - assertEquals("dev:\\temp", l[1].toLowerCase(Locale.US)); - } else { - assertEquals("no multiple character-length volumes on Windows", 4, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("\\sys")); - assertTrue("test resolved relative to project\'s basedir", - l[1].endsWith("\\test")); - assertTrue("dev resolved relative to project\'s basedir", - l[2].endsWith("\\dev")); - assertTrue("temp resolved relative to project\'s basedir", - l[3].endsWith("\\temp")); - } - - // try a netware-volume length path w/forward slash, see how it is handled - p = new Path(project, "sys:/test"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 2, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("/sys")); - assertEquals("/test", l[1]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 1, l.length); - assertEquals("sys:\\test", l[0].toLowerCase(Locale.US)); - } else { - assertEquals("no multiple character-length volumes on Windows", 2, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("\\sys")); - assertTrue("test resolved relative to project\'s basedir", - l[1].endsWith("\\test")); - } - - // try a multi-part netware-volume length path w/forward slash, see how it is handled - p = new Path(project, "sys:/test;dev:/temp"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 4, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("/sys")); - assertEquals("/test", l[1]); - assertTrue("dev resolved relative to project\'s basedir", - l[2].endsWith("/dev")); - assertEquals("/temp", l[3]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 2, l.length); - assertEquals("sys:\\test", l[0].toLowerCase(Locale.US)); - assertEquals("dev:\\temp", l[1].toLowerCase(Locale.US)); - } else { - assertEquals("no multiple character-length volumes on Windows", 4, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("\\sys")); - assertTrue("test resolved relative to project\'s basedir", - l[1].endsWith("\\test")); - assertTrue("dev resolved relative to project\'s basedir", - l[2].endsWith("\\dev")); - assertTrue("temp resolved relative to project\'s basedir", - l[3].endsWith("\\temp")); - } - - // try a multi-part netware-volume length path with UNIX - // separator (this testcase if from an actual bug that was - // found, in AvailableTest, which uses PathTokenizer) - p = new Path(project, - "SYS:\\JAVA/lib/rt.jar:SYS:\\JAVA/lib/classes.zip"); - l = p.list(); - if (isUnixStyle) { - assertEquals("no drives on Unix", 3, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("/SYS")); - assertEquals("/JAVA/lib/rt.jar", l[1]); - assertEquals("/JAVA/lib/classes.zip", l[2]); - } else if (isNetWare) { - assertEquals("volumes on NetWare", 2, l.length); - assertEquals("sys:\\java\\lib\\rt.jar", l[0].toLowerCase(Locale.US)); - assertEquals("sys:\\java\\lib\\classes.zip", l[1].toLowerCase(Locale.US)); - } else { - assertEquals("no multiple character-length volumes on Windows", 3, l.length); - assertTrue("sys resolved relative to project\'s basedir", - l[0].endsWith("\\SYS")); - assertTrue("java/lib/rt.jar resolved relative to project\'s basedir", - l[1].endsWith("\\JAVA\\lib\\rt.jar")); - assertTrue("java/lib/classes.zip resolved relative to project\'s basedir", - l[2].endsWith("\\JAVA\\lib\\classes.zip")); - } - } - - public void testConstructorMixedStyle() { - Path p = new Path(project, "\\a;\\b:/c"); - String[] l = p.list(); - assertEquals("three items, mixed style", 3, l.length); - if (isUnixStyle) { - assertEquals("/a", l[0]); - assertEquals("/b", l[1]); - assertEquals("/c", l[2]); - } else if (isNetWare) { - assertEquals("\\a", l[0]); - assertEquals("\\b", l[1]); - assertEquals("\\c", l[2]); - } else { - String base = new File(File.separator).getAbsolutePath().toUpperCase(); - assertEquals(base + "a", l[0]); - assertEquals(base + "b", l[1]); - assertEquals(base + "c", l[2]); - } - } - - public void testSetLocation() { - Path p = new Path(project); - p.setLocation(new File(File.separatorChar+"a")); - String[] l = p.list(); - if (isUnixStyle) { - assertEquals(1, l.length); - assertEquals("/a", l[0]); - } else if (isNetWare) { - assertEquals(1, l.length); - assertEquals("\\a", l[0]); - } else { - assertEquals(1, l.length); - assertEquals(":\\a", l[0].substring(1)); - } - } - - public void testAppending() { - Path p = new Path(project, "/a:/b"); - String[] l = p.list(); - assertEquals("2 after construction", 2, l.length); - p.setLocation(new File("/c")); - l = p.list(); - assertEquals("3 after setLocation", 3, l.length); - p.setPath("\\d;\\e"); - l = p.list(); - assertEquals("5 after setPath", 5, l.length); - p.append(new Path(project, "\\f")); - l = p.list(); - assertEquals("6 after append", 6, l.length); - p.createPath().setLocation(new File("/g")); - l = p.list(); - assertEquals("7 after append", 7, l.length); - } - - public void testEmpyPath() { - Path p = new Path(project, ""); - String[] l = p.list(); - assertEquals("0 after construction", 0, l.length); - p.setPath(""); - l = p.list(); - assertEquals("0 after setPath", 0, l.length); - p.append(new Path(project)); - l = p.list(); - assertEquals("0 after append", 0, l.length); - p.createPath(); - l = p.list(); - assertEquals("0 after append", 0, l.length); - } - - public void testUnique() { - Path p = new Path(project, "/a:/a"); - String[] l = p.list(); - assertEquals("1 after construction", 1, l.length); - String base = new File(File.separator).getAbsolutePath().toUpperCase(); - p.setLocation(new File(base, "a")); - l = p.list(); - assertEquals("1 after setLocation", 1, l.length); - p.setPath("\\a;/a"); - l = p.list(); - assertEquals("1 after setPath", 1, l.length); - p.append(new Path(project, "/a;\\a:\\a")); - l = p.list(); - assertEquals("1 after append", 1, l.length); - p.createPath().setPath("\\a:/a"); - l = p.list(); - assertEquals("1 after append", 1, l.length); - } - - public void testEmptyElementIfIsReference() { - Path p = new Path(project, "/a:/a"); - try { - p.setRefid(new Reference("dummyref")); - fail("Can add reference to Path with elements from constructor"); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - p = new Path(project); - p.setLocation(new File("/a")); - try { - p.setRefid(new Reference("dummyref")); - fail("Can add reference to Path with elements from setLocation"); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - Path another = new Path(project, "/a:/a"); - project.addReference("dummyref", another); - p = new Path(project); - p.setRefid(new Reference("dummyref")); - try { - p.setLocation(new File("/a")); - fail("Can set location in Path that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - try { - p.setPath("/a;\\a"); - fail("Can set path in Path that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - try { - p.createPath(); - fail("Can create nested Path in Path that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - - try { - p.createPathElement(); - fail("Can create nested PathElement in Path that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - - try { - p.addFileset(new FileSet()); - fail("Can add nested FileSet in Path that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - - try { - p.addFilelist(new FileList()); - fail("Can add nested FileList in Path that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - - try { - p.addDirset(new DirSet()); - fail("Can add nested Dirset in Path that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - } - - public void testCircularReferenceCheck() { - Path p = new Path(project); - project.addReference("dummy", p); - p.setRefid(new Reference("dummy")); - try { - p.list(); - fail("Can make Path a Reference to itself."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 --> dummy1 - Path p1 = new Path(project); - project.addReference("dummy1", p1); - Path p2 = p1.createPath(); - project.addReference("dummy2", p2); - Path p3 = p2.createPath(); - project.addReference("dummy3", p3); - p3.setRefid(new Reference("dummy1")); - try { - p1.list(); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 (with Path "/a") - p1 = new Path(project); - project.addReference("dummy1", p1); - p2 = p1.createPath(); - project.addReference("dummy2", p2); - p3 = p2.createPath(); - project.addReference("dummy3", p3); - p3.setLocation(new File("/a")); - String[] l = p1.list(); - assertEquals("One element buried deep inside a nested path structure", - 1, l.length); - if (isUnixStyle) { - assertEquals("/a", l[0]); - } else if (isNetWare) { - assertEquals("\\a", l[0]); - } else { - assertEquals(":\\a", l[0].substring(1)); - } - } - - public void testFileList() { - Path p = new Path(project); - FileList f = new FileList(); - f.setProject(project); - f.setDir(project.resolveFile(".")); - f.setFiles("build.xml"); - p.addFilelist(f); - String[] l = p.list(); - assertEquals(1, l.length); - assertEquals(project.resolveFile("build.xml").getAbsolutePath(), l[0]); - } - - public void testFileSet() { - Path p = new Path(project); - FileSet f = new FileSet(); - f.setProject(project); - f.setDir(project.resolveFile(".")); - f.setIncludes("build.xml"); - p.addFileset(f); - String[] l = p.list(); - assertEquals(1, l.length); - assertEquals(project.resolveFile("build.xml").getAbsolutePath(), l[0]); - } - - public void testDirSet() { - Path p = new Path(project); - DirSet d = new DirSet(); - d.setProject(project); - d.setDir(project.resolveFile(".")); - d.setIncludes("build"); - p.addDirset(d); - String[] l = p.list(); - assertEquals(1, l.length); - assertEquals(project.resolveFile("build").getAbsolutePath(), l[0]); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/PatternSetTest.java b/src/testcases/org/apache/tools/ant/types/PatternSetTest.java deleted file mode 100644 index 45cda7d4e..000000000 --- a/src/testcases/org/apache/tools/ant/types/PatternSetTest.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.PatternSet. - * - *

This doesn't actually test much, mainly reference handling.

- * - */ - -public class PatternSetTest extends TestCase { - - private Project project; - - public PatternSetTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.setBasedir("."); - } - - public void testEmptyElementIfIsReference() { - PatternSet p = new PatternSet(); - p.setIncludes("**/*.java"); - try { - p.setRefid(new Reference("dummyref")); - fail("Can add reference to PatternSet with elements from setIncludes"); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - p = new PatternSet(); - p.setRefid(new Reference("dummyref")); - try { - p.setIncludes("**/*.java"); - fail("Can set includes in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - - p = new PatternSet(); - p.setRefid(new Reference("dummyref")); - try { - p.setIncludesfile(new File("/a")); - fail("Can set includesfile in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - try { - p.setExcludes("**/*.java"); - fail("Can set excludes in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - try { - p.setExcludesfile(new File("/a")); - fail("Can set excludesfile in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify more than one attribute when using refid", - be.getMessage()); - } - try { - p.createInclude(); - fail("Can add nested include in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - try { - p.createExclude(); - fail("Can add nested exclude in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - try { - p.createIncludesFile(); - fail("Can add nested includesfile in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - try { - p.createExcludesFile(); - fail("Can add nested excludesfile in PatternSet that is a reference."); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - } - - public void testCircularReferenceCheck() { - PatternSet p = new PatternSet(); - project.addReference("dummy", p); - p.setRefid(new Reference("dummy")); - try { - p.getIncludePatterns(project); - fail("Can make PatternSet a Reference to itself."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - try { - p.getExcludePatterns(project); - fail("Can make PatternSet a Reference to itself."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 --> dummy1 - PatternSet p1 = new PatternSet(); - project.addReference("dummy1", p1); - p1.setRefid(new Reference("dummy2")); - PatternSet p2 = new PatternSet(); - project.addReference("dummy2", p2); - p2.setRefid(new Reference("dummy3")); - PatternSet p3 = new PatternSet(); - project.addReference("dummy3", p3); - p3.setRefid(new Reference("dummy1")); - try { - p1.getIncludePatterns(project); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - try { - p1.getExcludePatterns(project); - fail("Can make circular reference."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } - - // dummy1 --> dummy2 --> dummy3 - // (which holds patterns "include" and "exclude") - p1 = new PatternSet(); - project.addReference("dummy1", p1); - p1.setRefid(new Reference("dummy2")); - p2 = new PatternSet(); - project.addReference("dummy2", p2); - p2.setRefid(new Reference("dummy3")); - p3 = new PatternSet(); - project.addReference("dummy3", p3); - p3.setIncludes("include"); - p3.createExclude().setName("exclude"); - String[] i = p1.getIncludePatterns(project); - assertEquals("One include pattern buried deep inside a nested patternset structure", - 1, i.length); - assertEquals("include", i[0]); - i = p3.getExcludePatterns(project); - assertEquals("One exclude pattern buried deep inside a nested patternset structure", - 1, i.length); - assertEquals("exclude", i[0]); - } - - public void testNestedPatternset() { - PatternSet p = new PatternSet(); - p.setIncludes("**/*.java"); - - PatternSet nested = new PatternSet(); - nested.setExcludes("**/*.class"); - - p.addConfiguredPatternset(nested); - - String[] excludes = p.getExcludePatterns(project); - String[] includes = p.getIncludePatterns(project); - - assertEquals("Includes","**/*.java", includes[0]); - assertEquals("Excludes","**/*.class", excludes[0]); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/PermissionsTest.java b/src/testcases/org/apache/tools/ant/types/PermissionsTest.java deleted file mode 100644 index 7c6e062c6..000000000 --- a/src/testcases/org/apache/tools/ant/types/PermissionsTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import junit.framework.TestCase; - -import org.apache.tools.ant.ExitException; - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.Permissions. - * - */ -public class PermissionsTest extends TestCase { - - Permissions perms; - - public PermissionsTest(String name) { - super(name); - } - - public void setUp() { - perms = new Permissions(); - Permissions.Permission perm = new Permissions.Permission(); - // Grant extra permissions to read and write the user.* properties and read to the - // java.home property - perm.setActions("read, write"); - perm.setName("user.*"); - perm.setClass("java.util.PropertyPermission"); - perms.addConfiguredGrant(perm); - - perm = new Permissions.Permission(); - perm.setActions("read"); - perm.setName("java.home"); - perm.setClass("java.util.PropertyPermission"); - perms.addConfiguredGrant(perm); - - perm = new Permissions.Permission(); - perm.setActions("read"); - perm.setName("file.encoding"); - perm.setClass("java.util.PropertyPermission"); - perms.addConfiguredGrant(perm); - - // Revoke permission to write user.home (granted above via user.*), still able to read though. - // and the default granted permission to read os.name. - perm = new Permissions.Permission(); - perm.setActions("write"); - perm.setName("user.home"); - perm.setClass("java.util.PropertyPermission"); - perms.addConfiguredRevoke(perm); - - perm = new Permissions.Permission(); - perm.setActions("read"); - perm.setName("os.*"); - perm.setClass("java.util.PropertyPermission"); - perms.addConfiguredRevoke(perm); - } - - /** Tests a permission that is granted per default. */ - public void testDefaultGranted() { - perms.setSecurityManager(); - try { - String s = System.getProperty("line.separator"); - } finally { - perms.restoreSecurityManager(); - } - } - - /** Tests a permission that has been granted later via wildcard. */ - public void testGranted() { - perms.setSecurityManager(); - try { - String s = System.getProperty("user.name"); - System.setProperty("user.name", s); - } finally { - perms.restoreSecurityManager(); - } - } - - /** Tests a permission that has been granted and revoked later. */ - public void testGrantedAndRevoked() { - perms.setSecurityManager(); - try { - String s = System.getProperty("user.home"); - System.setProperty("user.home", s); - fail("Could perform an action that should have been forbidden."); - } catch (SecurityException e){ - // Was expected, test passes - } finally { - perms.restoreSecurityManager(); - } - } - - /** Tests a permission that is granted as per default but revoked later via wildcard. */ - public void testDefaultRevoked() { - perms.setSecurityManager(); - try { - System.getProperty("os.name"); - fail("Could perform an action that should have been forbidden."); - } catch (SecurityException e){ - // Was expected, test passes - } finally { - perms.restoreSecurityManager(); - } - } - /** Tests a permission that has not been granted or revoked. */ - public void testOther() { - String ls = System.getProperty("line.separator"); - perms.setSecurityManager(); - try { - String s = System.setProperty("line.separator",ls); - fail("Could perform an action that should have been forbidden."); - } catch (SecurityException e){ - // Was expected, test passes - } finally { - perms.restoreSecurityManager(); - } - } - - /** Tests an exit condition. */ - public void testExit() { - perms.setSecurityManager(); - try { - System.out.println("If this is the last line on standard out the testExit f.a.i.l.e.d"); - System.exit(3); - fail("Totaly impossible that this fail is ever executed. Please let me know if it is!"); - } catch (ExitException e) { - if (e.getStatus() != 3) { - fail("Received wrong exit status in Exit Exception."); - } - System.out.println("testExit successful."); - } finally { - perms.restoreSecurityManager(); - } - } - - - public void tearDown() { - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/PolyTest.java b/src/testcases/org/apache/tools/ant/types/PolyTest.java deleted file mode 100644 index fe6d28616..000000000 --- a/src/testcases/org/apache/tools/ant/types/PolyTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; - -public class PolyTest extends BuildFileTest { - - public PolyTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/poly.xml"); - } - - public void testFileSet() { - expectLogContaining("fileset", "types.FileSet"); - } - - public void testFileSetAntType() { - expectLogContaining("fileset-ant-type", "types.PolyTest$MyFileSet"); - } - - public void testPath() { - expectLogContaining("path", "types.Path"); - } - - public void testPathAntType() { - expectLogContaining("path-ant-type", "types.PolyTest$MyPath"); - } - - public static class MyFileSet extends FileSet {} - - public static class MyPath extends Path { - public MyPath(Project project) { - super(project); - } - } - - public static class MyTask extends Task { - public void addPath(Path path) { - log("class of path is " + path.getClass()); - } - public void addFileset(FileSet fileset) { - log("class of fileset is " + fileset.getClass()); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/types/PropertySetTest.java b/src/testcases/org/apache/tools/ant/types/PropertySetTest.java deleted file mode 100644 index aea7f9215..000000000 --- a/src/testcases/org/apache/tools/ant/types/PropertySetTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; - -public class PropertySetTest extends BuildFileTest { - - public PropertySetTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/propertyset.xml"); - } - - public void testReferenceToTwoReferences() { - executeTarget("reference-to-two-references"); - } - - public void testNestedMapped() { - executeTarget("nested-mapped"); - } - - public void testNestedMappedMapped() { - executeTarget("nested-mapped-mapped"); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java b/src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java deleted file mode 100755 index 678b7b21e..000000000 --- a/src/testcases/org/apache/tools/ant/types/RedirectorElementTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.BuildFileTest; - -public class RedirectorElementTest extends BuildFileTest { - - public RedirectorElementTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/redirector.xml", Project.MSG_VERBOSE); - } - - public void test1() { - executeTarget("test1"); - assertTrue((getProject().getReference("test1") - instanceof RedirectorElement)); - } - - public void test2() { - expectBuildException("test2", "You must not specify more than one " - + "attribute when using refid"); - } - - public void test3() { - expectBuildException("test3", "You must not specify nested elements " - + "when using refid"); - } - - public void test4() { - executeTarget("test4"); - } - - public void testLogInputString() { - executeTarget("testLogInputString"); - if (super.getLog().indexOf("testLogInputString can-cat") >=0 ) { - assertDebuglogContaining("Using input string"); - } - } - - public void testRefid() { - executeTarget("testRefid"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/ResourceCollectionsTest.java b/src/testcases/org/apache/tools/ant/types/ResourceCollectionsTest.java deleted file mode 100755 index eaf47a454..000000000 --- a/src/testcases/org/apache/tools/ant/types/ResourceCollectionsTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; - -public class ResourceCollectionsTest extends BuildFileTest { - - public ResourceCollectionsTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/resources/build.xml"); - } - - public void tearDown() { - executeTarget("tearDown"); - } - - public void testdifference() { - executeTarget("testdifference"); - } - - public void testdirset() { - executeTarget("testdirset"); - } - - public void testfile() { - executeTarget("testfile"); - } - - public void testfilelist() { - executeTarget("testfilelist"); - } - - public void testfiles1() { - executeTarget("testfiles1"); - } - - public void testfiles2() { - executeTarget("testfiles2"); - } - - public void testfiles3() { - executeTarget("testfiles3"); - } - - public void testfileset() { - executeTarget("testfileset"); - } - - public void testfileurl() { - executeTarget("testfileurl"); - } - - public void testfileurlref() { - executeTarget("testfileurlref"); - } - - public void testfirst1() { - executeTarget("testfirst1"); - } - - public void testfirst2() { - executeTarget("testfirst2"); - } - - public void testhttpurl1() { - executeTarget("testhttpurl1"); - } - - public void testhttpurl2() { - executeTarget("testhttpurl2"); - } - - public void testintersect() { - executeTarget("testintersect"); - } - - public void testjarurl() { - executeTarget("testjarurl"); - } - - public void testnestedresources() { - executeTarget("testnestedresources"); - } - - public void testpath() { - executeTarget("testpath"); - } - - public void testpropertyset() { - executeTarget("testpropertyset"); - } - - public void testresource() { - executeTarget("testresource"); - } - - public void testresourcesref() { - executeTarget("testresourcesref"); - } - - public void teststring1() { - executeTarget("teststring1"); - } - - public void teststring2() { - executeTarget("teststring2"); - } - - public void testunion() { - executeTarget("testunion"); - } - - public void testzipentry() { - executeTarget("testzipentry"); - } - - public void testzipfileset() { - executeTarget("testzipfileset"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/ResourceComparatorsTest.java b/src/testcases/org/apache/tools/ant/types/ResourceComparatorsTest.java deleted file mode 100755 index 0b39a60e5..000000000 --- a/src/testcases/org/apache/tools/ant/types/ResourceComparatorsTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; - -public class ResourceComparatorsTest extends BuildFileTest { - - public ResourceComparatorsTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/resources/comparators/build.xml"); - } - - public void tearDown() { - executeTarget("tearDown"); - } - - public void testcompoundsort1() { - executeTarget("testcompoundsort1"); - } - - public void testcompoundsort2() { - executeTarget("testcompoundsort2"); - } - - public void testcontent() { - executeTarget("testcontent"); - } - - public void testexists() { - executeTarget("testexists"); - } - - public void testdate() { - executeTarget("testdate"); - } - - public void testname() { - executeTarget("testname"); - } - - public void testrvcontent() { - executeTarget("testrvcontent"); - } - - public void testrvdefault() { - executeTarget("testrvdefault"); - } - - public void testrvexists() { - executeTarget("testrvexists"); - } - - public void testrvdate() { - executeTarget("testrvdate"); - } - - public void testrvname() { - executeTarget("testrvname"); - } - - public void testrvsize() { - executeTarget("testrvsize"); - } - - public void testrvtype() { - executeTarget("testrvtype"); - } - - public void testsize() { - executeTarget("testsize"); - } - - public void testsortdefault() { - executeTarget("testsortdefault"); - } - - public void testtype() { - executeTarget("testtype"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/ResourceOutputTest.java b/src/testcases/org/apache/tools/ant/types/ResourceOutputTest.java deleted file mode 100755 index f0ec5e428..000000000 --- a/src/testcases/org/apache/tools/ant/types/ResourceOutputTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; -import java.io.IOException; -import java.net.UnknownServiceException; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Zip; -import org.apache.tools.ant.types.resources.ImmutableResourceException; -import org.apache.tools.ant.types.resources.PropertyResource; -import org.apache.tools.ant.types.resources.StringResource; -import org.apache.tools.ant.types.resources.URLResource; -import org.apache.tools.ant.types.resources.ZipResource; -import org.apache.tools.ant.util.FileUtils; -import org.apache.tools.ant.util.ResourceUtils; - -public class ResourceOutputTest extends BuildFileTest { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - private static final File basedir = new File(System.getProperty("root"), - "src/etc/testcases/types/resources"); - - public ResourceOutputTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.init(); - project.setUserProperty("basedir" , basedir.getAbsolutePath()); - } - - public void testresourceoutput() { - try { - testoutputbe(new Resource("foo")); - fail("should have caught UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - } - } - - public void teststringoutput1() { - StringResource r = new StringResource(); - testoutputbe(r); - assertEquals("foo", r.getValue()); - } - - public void teststringoutput2() { - StringResource r = new StringResource("bar"); - try { - testoutput(r); - fail("should have caught ImmutableResourceException"); - } catch (ImmutableResourceException e) { - } catch (IOException e) { - fail("caught some other IOException: " + e); - } - assertEquals("bar", r.getValue()); - } - - public void testpropertyoutput1() { - PropertyResource r = new PropertyResource(getProject(), "bar"); - testoutputbe(r); - assertPropertyEquals("bar", "foo"); - } - - public void testpropertyoutput2() { - getProject().setNewProperty("bar", "bar"); - PropertyResource r = new PropertyResource(getProject(), "bar"); - try { - testoutput(r); - fail("should have caught ImmutableResourceException"); - } catch (ImmutableResourceException e) { - } catch (IOException e) { - fail("caught some other IOException: " + e); - } - assertPropertyEquals("bar", "bar"); - } - - public void testurloutput() { - File f = getProject().resolveFile("testurloutput"); - try { - FILE_UTILS.createNewFile(f); - testoutput(new URLResource(f)); - fail("should have caught UnknownServiceException"); - } catch (UnknownServiceException e) { - } catch (IOException e) { - e.printStackTrace(System.err); - fail("caught some other IOException: " + e); - } finally { - if (!f.delete()) { - f.deleteOnExit(); - } - } - } - - public void testzipentryoutput() { - Zip z = new Zip(); - z.setProject(getProject()); - Zip.WhenEmpty create = new Zip.WhenEmpty(); - create.setValue("create"); - z.setWhenempty(create); - z.setBasedir(basedir); - z.setExcludes("**/*"); - File f = getProject().resolveFile("foo"); - z.setDestFile(f); - z.execute(); - ZipResource r = new ZipResource(); - r.setZipfile(f); - r.setName("foo"); - try { - testoutputbe(r); - fail("should have caught UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - } finally { - if (!f.delete()) { - f.deleteOnExit(); - } - } - } - - private void testoutputbe(Resource dest) { - try { - testoutput(dest); - } catch (IOException e) { - throw new BuildException(e); - } - } - - private void testoutput(Resource dest) throws IOException { - ResourceUtils.copyResource(new StringResource("foo"), dest, null); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/ResourceSelectorsTest.java b/src/testcases/org/apache/tools/ant/types/ResourceSelectorsTest.java deleted file mode 100755 index 6c129c889..000000000 --- a/src/testcases/org/apache/tools/ant/types/ResourceSelectorsTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; - -public class ResourceSelectorsTest extends BuildFileTest { - - public ResourceSelectorsTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/resources/selectors/build.xml"); - } - - public void testname1() { - executeTarget("testname1"); - } - - public void testname2() { - executeTarget("testname2"); - } - - public void testexists() { - executeTarget("testexists"); - } - - public void testinstanceoftype1() { - executeTarget("testinstanceoftype1"); - } - - public void testinstanceoftype2() { - executeTarget("testinstanceoftype2"); - } - - public void testinstanceofclass() { - executeTarget("testinstanceofclass"); - } - - public void testtype() { - executeTarget("testtype"); - } - - public void testdate() { - executeTarget("testdate"); - } - - public void testsize() { - executeTarget("testsize"); - } - - public void testand() { - executeTarget("testand"); - } - - public void testor() { - executeTarget("testor"); - } - - public void testnot() { - executeTarget("testnot"); - } - - public void testnone() { - executeTarget("testnone"); - } - - public void testmajority1() { - executeTarget("testmajority1"); - } - - public void testmajority2() { - executeTarget("testmajority2"); - } - - public void testmajority3() { - executeTarget("testmajority3"); - } - - public void testmajority4() { - executeTarget("testmajority4"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/TarFileSetTest.java b/src/testcases/org/apache/tools/ant/types/TarFileSetTest.java deleted file mode 100755 index 8a5680bec..000000000 --- a/src/testcases/org/apache/tools/ant/types/TarFileSetTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; - -import org.apache.tools.ant.BuildException; - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.TarFileSet. - * - *

This doesn't actually test much, mainly reference handling. - * - */ - -public class TarFileSetTest extends AbstractFileSetTest { - - public TarFileSetTest(String name) { - super(name); - } - - protected AbstractFileSet getInstance() { - return new TarFileSet(); - } - public final void testAttributes() { - TarFileSet f = (TarFileSet)getInstance(); - //check that dir and src are incompatible - f.setSrc(new File("example.tar")); - try { - f.setDir(new File("examples")); - fail("can add dir to " - + f.getDataTypeName() - + " when a src is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both dir and src attributes",be.getMessage()); - } - f = (TarFileSet)getInstance(); - //check that dir and src are incompatible - f.setDir(new File("examples")); - try { - f.setSrc(new File("example.tar")); - fail("can add src to " - + f.getDataTypeName() - + " when a dir is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both dir and src attributes",be.getMessage()); - } - //check that fullpath and prefix are incompatible - f = (TarFileSet)getInstance(); - f.setSrc(new File("example.tar")); - f.setPrefix("/examples"); - try { - f.setFullpath("/doc/manual/index.html"); - fail("Can add fullpath to " - + f.getDataTypeName() - + " when a prefix is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); - } - f = (TarFileSet)getInstance(); - f.setSrc(new File("example.tar")); - f.setFullpath("/doc/manual/index.html"); - try { - f.setPrefix("/examples"); - fail("Can add prefix to " - + f.getDataTypeName() - + " when a fullpath is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); - } - // check that reference tarfilesets cannot have specific attributes - f = (TarFileSet)getInstance(); - f.setRefid(new Reference("test")); - try { - f.setSrc(new File("example.tar")); - fail("Can add src to " - + f.getDataTypeName() - + " when a refid is already present"); - } catch (BuildException be) { - assertEquals("You must not specify more than one " - + "attribute when using refid", be.getMessage()); - } - // check that a reference tarfileset gets the same attributes as the original - f = (TarFileSet)getInstance(); - f.setSrc(new File("example.tar")); - f.setPrefix("/examples"); - f.setFileMode("600"); - f.setDirMode("530"); - getProject().addReference("test",f); - TarFileSet zid=(TarFileSet)getInstance(); - zid.setRefid(new Reference("test")); - assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject()))); - assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); - assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject())); - assertTrue("dir mode attribute copied by copy constructor",f.getDirMode(getProject())==zid.getDirMode(getProject())); - } - - -} diff --git a/src/testcases/org/apache/tools/ant/types/XMLCatalogBuildFileTest.java b/src/testcases/org/apache/tools/ant/types/XMLCatalogBuildFileTest.java deleted file mode 100644 index 6d487affc..000000000 --- a/src/testcases/org/apache/tools/ant/types/XMLCatalogBuildFileTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import org.apache.tools.ant.BuildFileTest; - -/** - * BuildFileTest testcases for org.apache.tools.ant.types.XMLCatalog - * - * @see org.apache.tools.ant.types.XMLCatalogTest - * - */ -public class XMLCatalogBuildFileTest extends BuildFileTest { - - public XMLCatalogBuildFileTest(String name) { - super(name); - } - - public void setUp() { - } - - public void tearDown() { - } - - // - // Ensure that an external entity resolves as expected with NO - // XMLCatalog involvement: - // - // Transform an XML file that refers to the entity into a text - // file, stuff result into property: val1 - // - public void testEntityNoCatalog() { - configureProject("src/etc/testcases/types/xmlcatalog.xml"); - expectPropertySet("testentitynocatalog", "val1", - "A stitch in time saves nine"); - } - - // - // Ensure that an external entity resolves as expected Using an - // XMLCatalog: - // - // Transform an XML file that refers to the entity into a text - // file, entity is listed in the XMLCatalog pointing to a - // different file. Stuff result into property: val2 - // - public void testEntityWithCatalog() { - configureProject("src/etc/testcases/types/xmlcatalog.xml"); - expectPropertySet("testentitywithcatalog", "val2", - "No news is good news"); - } - - // - // Ensure that an external entity resolves as expected with NO - // XMLCatalog involvement: - // - // Transform an XML file that contains a reference to a _second_ XML file - // via the document() function. The _second_ XML file refers to an entity. - // Stuff result into the property: val3 - // - public void testDocumentNoCatalog() { - configureProject("src/etc/testcases/types/xmlcatalog.xml"); - expectPropertySet("testdocumentnocatalog", "val3", - "A stitch in time saves nine"); - } - - // - // Ensure that an external entity resolves as expected Using an - // XMLCatalog: - // - // Transform an XML file that contains a reference to a _second_ XML file - // via the document() function. The _second_ XML file refers to an entity. - // The entity is listed in the XMLCatalog pointing to a different file. - // Stuff result into the property: val4 - // - public void testDocumentWithCatalog() { - configureProject("src/etc/testcases/types/xmlcatalog.xml"); - expectPropertySet("testdocumentwithcatalog", "val4", - "No news is good news"); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java b/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java deleted file mode 100644 index 532174bbb..000000000 --- a/src/testcases/org/apache/tools/ant/types/XMLCatalogTest.java +++ /dev/null @@ -1,411 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; - -import javax.xml.transform.Source; -import javax.xml.transform.sax.SAXSource; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.util.JAXPUtils; -import org.xml.sax.InputSource; - -/** - * JUnit testcases for org.apache.tools.ant.types.XMLCatalog - * - */ -public class XMLCatalogTest extends TestCase { - - private Project project; - private XMLCatalog catalog; - - private XMLCatalog newCatalog() { - XMLCatalog cat = new XMLCatalog(); - cat.setProject(project); - return cat; - } - - private String toURLString(File file) throws MalformedURLException { - return JAXPUtils.getSystemId(file); - } - - public XMLCatalogTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.setBasedir(System.getProperty("root")); - - // This causes XMLCatalog to print out detailed logging - // messages for debugging - // - // DefaultLogger logger = new DefaultLogger(); - // logger.setMessageOutputLevel(Project.MSG_DEBUG); - // logger.setOutputPrintStream(System.out); - // logger.setErrorPrintStream(System.err); - // project.addBuildListener(logger); - - catalog = newCatalog(); - } - - public void tearDown() { - project = null; - catalog = null; - } - - public void testEmptyCatalog() { - try { - InputSource result = catalog.resolveEntity("PUBLIC ID ONE", - "i/dont/exist.dtd"); - assertNull("Empty catalog should return null", result); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - - try { - Source result = catalog.resolve("i/dont/exist.dtd", null); - String expected = toURLString(new File(project.getBaseDir() + - "/i/dont/exist.dtd")); - // - // These shenanigans are necessary b/c Norm Walsh's resolver - // has a different idea of how file URLs are created on windoze - // ie file://c:/foo instead of file:///c:/foo - // - String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile(); - assertTrue("Empty catalog should return input", - expected.endsWith(resultStr)); - } catch (Exception e) { - fail("resolve() failed!" + e.toString()); - } - } - - public void testNonExistentEntry() { - - ResourceLocation dtd = new ResourceLocation(); - dtd.setPublicId("PUBLIC ID ONE"); - dtd.setLocation("i/dont/exist.dtd"); - - try { - InputSource result = catalog.resolveEntity("PUBLIC ID ONE", - "i/dont/exist.dtd"); - assertNull("Nonexistent Catalog entry should not be returned", result); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - - try { - Source result = catalog.resolve("i/dont/exist.dtd", null); - String expected = toURLString(new File(project.getBaseDir().toURL() + - "/i/dont/exist.dtd")); - String resultStr = new URL(((SAXSource)result).getInputSource().getSystemId()).getFile(); - assertTrue("Nonexistent Catalog entry return input", - expected.endsWith(resultStr)); - } catch (Exception e) { - fail("resolve() failed!" + e.toString()); - } - } - - public void testEmptyElementIfIsReference() { - ResourceLocation dtd = new ResourceLocation(); - dtd.setPublicId("PUBLIC ID ONE"); - dtd.setLocation("i/dont/exist.dtd"); - catalog.addDTD(dtd); - project.addReference("catalog", catalog); - - try { - catalog.setRefid(new Reference("dummyref")); - fail("Can add reference to nonexistent XMLCatalog"); - } catch (BuildException be) { - assertEquals("You must not specify more than one " - + "attribute when using refid", be.getMessage()); - } - - XMLCatalog catalog2 = newCatalog(); - catalog2.setRefid(new Reference("catalog")); - - try { - catalog2.addConfiguredXMLCatalog(catalog); - fail("Can add nested XMLCatalog to XMLCatalog that is a reference"); - } catch (BuildException be) { - assertEquals("You must not specify nested elements when using refid", - be.getMessage()); - } - } - - public void testCircularReferenceCheck() { - - // catalog <--> catalog - project.addReference("catalog", catalog); - catalog.setRefid(new Reference("catalog")); - - try { - InputSource result = catalog.resolveEntity("PUBLIC ID ONE", - "i/dont/exist.dtd"); - fail("Can make XMLCatalog a Reference to itself."); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - - // catalog1 --> catalog2 --> catalog3 --> catalog1 - XMLCatalog catalog1 = newCatalog(); - project.addReference("catalog1", catalog1); - XMLCatalog catalog2 = newCatalog(); - project.addReference("catalog2", catalog2); - XMLCatalog catalog3 = newCatalog(); - project.addReference("catalog3", catalog3); - - catalog3.setRefid(new Reference("catalog1")); - catalog2.setRefid(new Reference("catalog3")); - catalog1.setRefid(new Reference("catalog2")); - - try { - InputSource result = catalog1.resolveEntity("PUBLIC ID ONE", - "i/dont/exist.dtd"); - fail("Can make circular reference"); - } catch (BuildException be) { - assertEquals("This data type contains a circular reference.", - be.getMessage()); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - } - // inspired by Bugzilla Report 23913 - // a problem used to happen under Windows when the location of the DTD was given as an absolute path - // possibly with a mixture of file separators - public void testAbsolutePath() { - ResourceLocation dtd = new ResourceLocation(); - dtd.setPublicId("-//stevo//DTD doc 1.0//EN"); - - String sysid = System.getProperty("root") + File.separator + "src/etc/testcases/taskdefs/optional/xml/doc.dtd"; - dtd.setLocation(sysid); - catalog.addDTD(dtd); - File dtdFile = project.resolveFile(sysid); - - try { - InputSource result = catalog.resolveEntity("-//stevo//DTD doc 1.0//EN", - "nap:chemical+brothers"); - assertNotNull(result); - assertEquals(toURLString(dtdFile), - result.getSystemId()); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - - } - - public void testSimpleEntry() { - - ResourceLocation dtd = new ResourceLocation(); - dtd.setPublicId("-//stevo//DTD doc 1.0//EN"); - String sysid = "src/etc/testcases/taskdefs/optional/xml/doc.dtd"; - dtd.setLocation(sysid); - catalog.addDTD(dtd); - File dtdFile = project.resolveFile(sysid); - - try { - InputSource result = catalog.resolveEntity("-//stevo//DTD doc 1.0//EN", - "nap:chemical+brothers"); - assertNotNull(result); - assertEquals(toURLString(dtdFile), - result.getSystemId()); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - } - - public void testEntryReference() { - - String publicId = "-//stevo//DTD doc 1.0//EN"; - String sysid = "src/etc/testcases/taskdefs/optional/xml/doc.dtd"; - - // catalog2 --> catalog1 --> catalog - ResourceLocation dtd = new ResourceLocation(); - dtd.setPublicId(publicId); - dtd.setLocation(sysid); - catalog.addDTD(dtd); - File dtdFile = project.resolveFile(sysid); - - String uri = "http://foo.com/bar/blah.xml"; - String uriLoc = "src/etc/testcases/taskdefs/optional/xml/about.xml"; - - ResourceLocation entity = new ResourceLocation(); - entity.setPublicId(uri); - entity.setLocation(uriLoc); - catalog.addEntity(entity); - File xmlFile = project.resolveFile(uriLoc); - - project.addReference("catalog", catalog); - - XMLCatalog catalog1 = newCatalog(); - project.addReference("catalog1", catalog1); - XMLCatalog catalog2 = newCatalog(); - project.addReference("catalog2", catalog1); - - catalog1.setRefid(new Reference("catalog")); - catalog2.setRefid(new Reference("catalog1")); - - try { - InputSource result = catalog2.resolveEntity(publicId, - "nap:chemical+brothers"); - - assertNotNull(result); - assertEquals(toURLString(dtdFile), - result.getSystemId()); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - - try { - Source result = catalog.resolve(uri, null); - assertNotNull(result); - assertEquals(toURLString(xmlFile), - result.getSystemId()); - } catch (Exception e) { - fail("resolve() failed!" + e.toString()); - } - } - - public void testNestedCatalog() { - - String publicId = "-//stevo//DTD doc 1.0//EN"; - String dtdLoc = "src/etc/testcases/taskdefs/optional/xml/doc.dtd"; - - ResourceLocation dtd = new ResourceLocation(); - dtd.setPublicId(publicId); - dtd.setLocation(dtdLoc); - catalog.addDTD(dtd); - File dtdFile = project.resolveFile(dtdLoc); - - String uri = "http://foo.com/bar/blah.xml"; - String uriLoc = "src/etc/testcases/taskdefs/optional/xml/about.xml"; - - ResourceLocation entity = new ResourceLocation(); - entity.setPublicId(uri); - entity.setLocation(uriLoc); - catalog.addEntity(entity); - File xmlFile = project.resolveFile(uriLoc); - - XMLCatalog catalog1 = newCatalog(); - catalog1.addConfiguredXMLCatalog(catalog); - - try { - InputSource result = catalog1.resolveEntity(publicId, - "nap:chemical+brothers"); - assertNotNull(result); - assertEquals(toURLString(dtdFile), - result.getSystemId()); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - - try { - Source result = catalog.resolve(uri, null); - assertNotNull(result); - assertEquals(toURLString(xmlFile), - result.getSystemId()); - } catch (Exception e) { - fail("resolve() failed!" + e.toString()); - } - - } - - public void testResolverBase() { - - String uri = "http://foo.com/bar/blah.xml"; - String uriLoc = "etc/testcases/taskdefs/optional/xml/about.xml"; - String base = null; - try { - base = toURLString(project.getBaseDir()) + "/src/"; - } catch (MalformedURLException ex) { - fail (ex.toString()); - } - - ResourceLocation entity = new ResourceLocation(); - entity.setPublicId(uri); - entity.setLocation(uriLoc); - catalog.addEntity(entity); - File xmlFile = project.resolveFile("src/" + uriLoc); - - try { - Source result = catalog.resolve(uri, base); - assertNotNull(result); - assertEquals(toURLString(xmlFile), - result.getSystemId()); - } catch (Exception e) { - fail("resolve() failed!" + e.toString()); - } - } - - public void testClasspath() { - - - String publicId = "-//stevo//DTD doc 1.0//EN"; - String dtdLoc = "testcases/taskdefs/optional/xml/doc.dtd"; - String path1 = project.getBaseDir().toString() + "/src/etc"; - - ResourceLocation dtd = new ResourceLocation(); - dtd.setPublicId(publicId); - dtd.setLocation(dtdLoc); - catalog.addDTD(dtd); - File dtdFile = project.resolveFile("src/etc/" + dtdLoc); - - String uri = "http://foo.com/bar/blah.xml"; - String uriLoc = "etc/testcases/taskdefs/optional/xml/about.xml"; - String path2 = project.getBaseDir().toString() + "/src"; - - ResourceLocation entity = new ResourceLocation(); - entity.setPublicId(uri); - entity.setLocation(uriLoc); - catalog.addEntity(entity); - File xmlFile = project.resolveFile("src/" + uriLoc); - - Path aPath = new Path(project, path1); - aPath.append(new Path(project, path2)); - catalog.setClasspath(aPath); - - try { - InputSource result = catalog.resolveEntity(publicId, - "nap:chemical+brothers"); - assertNotNull(result); - String resultStr = new URL(result.getSystemId()).getFile(); - assertTrue(toURLString(dtdFile).endsWith(resultStr)); - } catch (Exception e) { - fail("resolveEntity() failed!" + e.toString()); - } - - try { - Source result = catalog.resolve(uri, null); - assertNotNull(result); - String resultStr = new URL(result.getSystemId()).getFile(); - assertTrue(toURLString(xmlFile).endsWith(resultStr)); - } catch (Exception e) { - fail("resolve() failed!" + e.toString()); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/types/ZipFileSetTest.java b/src/testcases/org/apache/tools/ant/types/ZipFileSetTest.java deleted file mode 100644 index 665dedda7..000000000 --- a/src/testcases/org/apache/tools/ant/types/ZipFileSetTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types; - -import java.io.File; - -import org.apache.tools.ant.BuildException; - -/** - * JUnit 3 testcases for org.apache.tools.ant.types.ZipFileSet. - * - *

This doesn't actually test much, mainly reference handling. - * - */ - -public class ZipFileSetTest extends AbstractFileSetTest { - - public ZipFileSetTest(String name) { - super(name); - } - - protected AbstractFileSet getInstance() { - return new ZipFileSet(); - } - public final void testAttributes() { - ZipFileSet f = (ZipFileSet)getInstance(); - //check that dir and src are incompatible - f.setSrc(new File("example.zip")); - try { - f.setDir(new File("examples")); - fail("can add dir to " - + f.getDataTypeName() - + " when a src is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both dir and src attributes",be.getMessage()); - } - f = (ZipFileSet)getInstance(); - //check that dir and src are incompatible - f.setDir(new File("examples")); - try { - f.setSrc(new File("example.zip")); - fail("can add src to " - + f.getDataTypeName() - + " when a dir is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both dir and src attributes",be.getMessage()); - } - //check that fullpath and prefix are incompatible - f = (ZipFileSet)getInstance(); - f.setSrc(new File("example.zip")); - f.setPrefix("/examples"); - try { - f.setFullpath("/doc/manual/index.html"); - fail("Can add fullpath to " - + f.getDataTypeName() - + " when a prefix is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); - } - f = (ZipFileSet)getInstance(); - f.setSrc(new File("example.zip")); - f.setFullpath("/doc/manual/index.html"); - try { - f.setPrefix("/examples"); - fail("Can add prefix to " - + f.getDataTypeName() - + " when a fullpath is already present"); - } catch (BuildException be) { - assertEquals("Cannot set both fullpath and prefix attributes", be.getMessage()); - } - // check that reference zipfilesets cannot have specific attributes - f = (ZipFileSet)getInstance(); - f.setRefid(new Reference("test")); - try { - f.setSrc(new File("example.zip")); - fail("Can add src to " - + f.getDataTypeName() - + " when a refid is already present"); - } catch (BuildException be) { - assertEquals("You must not specify more than one " - + "attribute when using refid", be.getMessage()); - } - // check that a reference zipfileset gets the same attributes as the original - f = (ZipFileSet)getInstance(); - f.setSrc(new File("example.zip")); - f.setPrefix("/examples"); - f.setFileMode("600"); - f.setDirMode("530"); - getProject().addReference("test",f); - ZipFileSet zid=(ZipFileSet)getInstance(); - zid.setRefid(new Reference("test")); - assertTrue("src attribute copied by copy constructor",zid.getSrc(getProject()).equals(f.getSrc(getProject()))); - assertTrue("prefix attribute copied by copy constructor",f.getPrefix(getProject()).equals(zid.getPrefix(getProject()))); - assertTrue("file mode attribute copied by copy constructor",f.getFileMode(getProject())==zid.getFileMode(getProject())); - assertTrue("dir mode attribute copied by copy constructor",f.getDirMode(getProject())==zid.getDirMode(getProject())); - } - - -} diff --git a/src/testcases/org/apache/tools/ant/types/mappers/GlobMapperTest.java b/src/testcases/org/apache/tools/ant/types/mappers/GlobMapperTest.java deleted file mode 100644 index 71a79d378..000000000 --- a/src/testcases/org/apache/tools/ant/types/mappers/GlobMapperTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.mappers; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Testcase for the <globmapper> mapper. - * - */ -public class GlobMapperTest extends BuildFileTest { - public GlobMapperTest(String name) { - super(name); - } - public void setUp() { - configureProject("src/etc/testcases/types/mappers/globmapper.xml"); - } - - public void testIgnoreCase() { - executeTarget("ignore.case"); - } - public void testHandleDirSep() { - executeTarget("handle.dirsep"); - } -} - - diff --git a/src/testcases/org/apache/tools/ant/types/mappers/MapperResult.java b/src/testcases/org/apache/tools/ant/types/mappers/MapperResult.java deleted file mode 100644 index 43a7b2962..000000000 --- a/src/testcases/org/apache/tools/ant/types/mappers/MapperResult.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.mappers; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Mapper; -import org.apache.tools.ant.util.FileNameMapper; - -/** - * This is a test task to show the result of a mapper - * on a specific input. - * (Test is not in the name of the class, to make sure that - * it is not treated as a unit test. - */ - -public class MapperResult extends Task { - - private String failMessage = ""; - private String input; - private String output; - private FileNameMapper fileNameMapper; - - /** - * The output on an empty string array - */ - private static final String NULL_MAPPER_RESULT = ""; - - public void setFailMessage(String failMessage) { - this.failMessage = failMessage; - } - - public void setInput(String input) { - this.input = input; - } - - public void setOutput(String output) { - this.output = output; - } - - public void addConfiguredMapper(Mapper mapper) { - add(mapper.getImplementation()); - } - - public void add(FileNameMapper fileNameMapper) { - if (this.fileNameMapper != null) { - throw new BuildException("Only one mapper type nested element allowed"); - } - this.fileNameMapper = fileNameMapper; - } - - public void execute() { - if (input == null) { - throw new BuildException("Missing attribute 'input'"); - } - if (output == null) { - throw new BuildException("Missing attribute 'output'"); - } - if (fileNameMapper == null) { - throw new BuildException("Missing a nested file name mapper type element"); - } - String[] result = fileNameMapper.mapFileName(input); - String flattened; - if (result == null) { - flattened = NULL_MAPPER_RESULT; - } else { - StringBuffer b = new StringBuffer(); - for (int i = 0; i < result.length; ++i) { - if (i != 0) { - b.append("|"); - } - b.append(result[i]); - } - flattened = b.toString(); - } - if (!flattened.equals(output)) { - throw new BuildException( - failMessage - + " " - + "got " - + flattened - + " " - + "expected " - + output); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/types/mappers/RegexpPatternMapperTest.java b/src/testcases/org/apache/tools/ant/types/mappers/RegexpPatternMapperTest.java deleted file mode 100644 index a3c1c3a09..000000000 --- a/src/testcases/org/apache/tools/ant/types/mappers/RegexpPatternMapperTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.mappers; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Testcase for the <regexpmapper> mapper. - * - */ -public class RegexpPatternMapperTest extends BuildFileTest { - public RegexpPatternMapperTest(String name) { - super(name); - } - public void setUp() { - configureProject("src/etc/testcases/types/mappers/regexpmapper.xml"); - } - - public void testIgnoreCase() { - executeTarget("ignore.case"); - } - public void testHandleDirSep() { - executeTarget("handle.dirsep"); - } -} - - diff --git a/src/testcases/org/apache/tools/ant/types/optional/ScriptConditionTest.java b/src/testcases/org/apache/tools/ant/types/optional/ScriptConditionTest.java deleted file mode 100644 index e4d160d37..000000000 --- a/src/testcases/org/apache/tools/ant/types/optional/ScriptConditionTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - */ -public class ScriptConditionTest extends BuildFileTest { - /** - * Constructor for the BuildFileTest object - * - * @param name string to pass up to TestCase constructor - */ - public ScriptConditionTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/scriptcondition.xml"); - } - - public void testNolanguage() { - expectBuildExceptionContaining("testNolanguage", - "Absence of language attribute not detected", - "script language must be specified"); - } - - public void testMacro() { - executeTarget("testMacro"); - } - public void testClearByDefault() { - executeTarget("testClearByDefault"); - } - public void testValueWorks() { - executeTarget("testValueWorks"); - } - - public void testSetWorks() { - executeTarget("testSetWorks"); - } - - public void testClearWorks() { - executeTarget("testClearWorks"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/optional/ScriptMapperTest.java b/src/testcases/org/apache/tools/ant/types/optional/ScriptMapperTest.java deleted file mode 100644 index 208e7a1f9..000000000 --- a/src/testcases/org/apache/tools/ant/types/optional/ScriptMapperTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Test our script mapping - */ -public class ScriptMapperTest extends BuildFileTest { - public ScriptMapperTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/mappers/scriptmapper.xml"); - } - - public void testClear() { - executeTarget("testClear"); - } - public void testSetMultiple() { - executeTarget("testSetMultiple"); - } - public void testPassthrough() { - executeTarget("testPassthrough"); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/optional/ScriptSelectorTest.java b/src/testcases/org/apache/tools/ant/types/optional/ScriptSelectorTest.java deleted file mode 100644 index 1052669e2..000000000 --- a/src/testcases/org/apache/tools/ant/types/optional/ScriptSelectorTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.optional; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Test that scripting selection works. Needs scripting support to work - */ -public class ScriptSelectorTest extends BuildFileTest { - - - public ScriptSelectorTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/selectors/scriptselector.xml"); - } - - public void testNolanguage() { - expectBuildExceptionContaining("testNolanguage", - "Absence of language attribute not detected", - "script language must be specified"); - } - - public void testSelectionSetByDefault() { - executeTarget("testSelectionSetByDefault"); - } - public void testSelectionSetWorks() { - executeTarget("testSelectionSetWorks"); - } - public void testSelectionClearWorks() { - executeTarget("testSelectionClearWorks"); - } - public void testFilenameAttribute() { - executeTarget("testFilenameAttribute"); - } - public void testFileAttribute() { - executeTarget("testFileAttribute"); - } - public void testBasedirAttribute() { - executeTarget("testBasedirAttribute"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java b/src/testcases/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java deleted file mode 100644 index 0f97b8857..000000000 --- a/src/testcases/org/apache/tools/ant/types/optional/depend/ClassFileSetTest.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.optional.depend; - -import java.io.File; -import java.util.Hashtable; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.DirectoryScanner; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.FileSet; - -/** - * Testcase for the Classfileset optional type. - * - */ -public class ClassFileSetTest extends BuildFileTest { - public static final String RESULT_FILESET = "result"; - - public ClassFileSetTest(String name) { - super(name); - } - - public void setUp() { - // share the setup for testing the depend task - configureProject("src/etc/testcases/taskdefs/optional/depend/depend.xml"); - } - - public void tearDown() { - executeTarget("clean"); - } - - /** - * Test basic classfileset - */ - public void testBasicSet() { - Project p = getProject(); - executeTarget("testbasicset"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); - DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); - } - assertEquals("Classfileset did not pick up expected number of " - + "class files", 4, files.size()); - assertTrue("Result did not contain A.class", - files.containsKey("A.class")); - assertTrue("Result did not contain B.class", - files.containsKey("B.class")); - assertTrue("Result did not contain C.class", - files.containsKey("C.class")); - assertTrue("Result did not contain D.class", - files.containsKey("D.class")); - } - - /** - * Test small classfileset - */ - public void testSmallSet() { - Project p = getProject(); - executeTarget("testsmallset"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); - DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); - } - assertEquals("Classfileset did not pick up expected number of " - + "class files", 2, files.size()); - assertTrue("Result did not contain B.class", - files.containsKey("B.class")); - assertTrue("Result did not contain C.class", - files.containsKey("C.class")); - } - - /** - * Test combo classfileset - */ - public void testComboSet() { - Project p = getProject(); - executeTarget("testcomboset"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); - DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); - } - assertEquals("Classfileset did not pick up expected number of " - + "class files", 1, files.size()); - assertTrue("Result did not contain C.class", - files.containsKey("C.class")); - } - - /** - * Test that you can pass a classfileset by reference to a fileset. - */ - public void testByReference() { - executeTarget("testbyreference"); - } - - /** - * Test that classes included in a method "System.out.println(MyClass.class)" are included. - */ - public void testMethodParam() { - Project p = getProject(); - executeTarget("testmethodparam"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); - DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); - } - assertEquals("Classfileset did not pick up expected number of " - + "class files", 5, files.size()); - assertTrue("Result did not contain A.class", - files.containsKey("A.class")); - assertTrue("Result did not contain B.class", - files.containsKey("B.class")); - assertTrue("Result did not contain C.class", - files.containsKey("C.class")); - assertTrue("Result did not contain D.class", - files.containsKey("D.class")); - assertTrue("Result did not contain E.class", - files.containsKey("E.class")); - } - - /** - * Test that classes included in a method "System.out.println(Outer.Inner.class)" are included. - */ - public void testMethodParamInner() { - Project p = getProject(); - executeTarget("testmethodparaminner"); - FileSet resultFileSet = (FileSet)p.getReference(RESULT_FILESET); - DirectoryScanner scanner = resultFileSet.getDirectoryScanner(p); - String[] scannedFiles = scanner.getIncludedFiles(); - Hashtable files = new Hashtable(); - for (int i = 0; i < scannedFiles.length; ++i) { - files.put(scannedFiles[i], scannedFiles[i]); - } - assertEquals("Classfileset did not pick up expected number of " - + "class files", 4, files.size()); - assertTrue("Result did not contain test" + File.separator + "Outer$Inner.class", - files.containsKey("test" + File.separator + "Outer$Inner.class")); - assertTrue("Result did not contain test" + File.separator + "Outer.class", - files.containsKey("test" + File.separator + "Outer.class")); - assertTrue("Result did not contain test" + File.separator + "ContainsOnlyInner.class", - files.containsKey("test" + File.separator + "ContainsOnlyInner.class")); - assertTrue("Result did not contain test" + File.separator + "ContainsOnlyInner.class", - files.containsKey("test" + File.separator + "MethodParam.class")); - } - - public void testResourceCollection() { - executeTarget("testresourcecollection"); - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/resources/JavaResourceTest.java b/src/testcases/org/apache/tools/ant/types/resources/JavaResourceTest.java deleted file mode 100755 index 77a16be81..000000000 --- a/src/testcases/org/apache/tools/ant/types/resources/JavaResourceTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.resources; - -import org.apache.tools.ant.BuildFileTest; - -public class JavaResourceTest extends BuildFileTest { - - public JavaResourceTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/resources/javaresource.xml"); - } - - public void testLoadManifest() { - executeTarget("loadManifest"); - assertNotNull(getProject().getProperty("manifest")); - - // this actually relies on the first manifest being found on - // the classpath (probably rt.jar's) being valid - assertTrue(getProject().getProperty("manifest") - .startsWith("Manifest-Version:")); - } -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/types/resources/TarResourceTest.java b/src/testcases/org/apache/tools/ant/types/resources/TarResourceTest.java deleted file mode 100755 index a247bf604..000000000 --- a/src/testcases/org/apache/tools/ant/types/resources/TarResourceTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.types.resources; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.util.FileUtils; - -public class TarResourceTest extends BuildFileTest { - - private static final FileUtils FU = FileUtils.getFileUtils(); - - public TarResourceTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - configureProject("src/etc/testcases/types/resources/tarentry.xml"); - } - - protected void tearDown() throws Exception { - executeTarget("tearDown"); - } - - public void testUncompressSource() throws java.io.IOException { - executeTarget("uncompressSource"); - assertTrue(FU.contentEquals(project.resolveFile("../../asf-logo.gif"), - project.resolveFile("testout/asf-logo.gif"))); - } -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/types/selectors/BaseSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/BaseSelectorTest.java deleted file mode 100644 index ca0ae51fc..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/BaseSelectorTest.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import java.io.File; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; - -/** - * Base test case for Selectors. Provides a shared test as well as - * a test bed for selecting on, and a helper method for determining - * whether selections are correct. - * - */ -public abstract class BaseSelectorTest extends TestCase { - - private Project project; - private TaskdefForMakingBed tbed = null; - protected String basedirname = "src/etc/testcases/types"; - protected String beddirname = basedirname + "/selectortest"; - protected String mirrordirname = basedirname + "/selectortest2"; - protected File basedir = new File(System.getProperty("root"), basedirname); - protected File beddir = new File(System.getProperty("root"), beddirname); - protected File mirrordir = new File(System.getProperty("root"), mirrordirname); - protected String[] filenames = {".","asf-logo.gif.md5","asf-logo.gif.bz2", - "asf-logo.gif.gz","copy.filterset.filtered","zip/asf-logo.gif.zip", - "tar/asf-logo.gif.tar","tar/asf-logo-huge.tar.gz", - "tar/gz/asf-logo.gif.tar.gz","tar/bz2/asf-logo.gif.tar.bz2", - "tar/bz2/asf-logo-huge.tar.bz2","tar/bz2"}; - protected File[] files = new File[filenames.length]; - protected File[] mirrorfiles = new File[filenames.length]; - - public BaseSelectorTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.init(); - project.setBaseDir(basedir); - for (int x = 0; x < files.length; x++) { - files[x] = new File(beddir,filenames[x]); - mirrorfiles[x] = new File(mirrordir,filenames[x]); - } - } - - /** - * Override this in child classes to return a specific Selector - */ - public abstract BaseSelector getInstance(); - - - /** - * Return a preconfigured selector (with a set reference to - * project instance). - * @return the selector - */ - public BaseSelector getSelector() { - BaseSelector selector = getInstance(); - selector.setProject( getProject() ); - return selector; - } - - - public Project getProject() { - return project; - } - - /** - * This is a test that all Selectors derived from BaseSelector can - * use. It calls the setError() method and checks to ensure that a - * BuildException is thrown as a result. - */ - public void testRespondsToError() { - BaseSelector s = getInstance(); - if (s == null) { - return; - } - s.setError("test error"); - try { - s.isSelected(beddir,filenames[0],files[0]); - fail("Cannot cause BuildException when setError() is called"); - } catch (BuildException be) { - assertEquals("test error", - be.getMessage()); - } - } - - - /** - * This is a helper method that takes a selector and calls its - * isSelected() method on each file in the testbed. It returns - * a string of "T"s amd "F"s - */ - public String selectionString(FileSelector selector) { - return selectionString(beddir,files,selector); - } - - /** - * This is a helper method that takes a selector and calls its - * isSelected() method on each file in the mirror testbed. This - * variation is used for dependency checks and to get around the - * limitations in the touch task when running JDK 1.1. It returns - * a string of "T"s amd "F"s. - */ - public String mirrorSelectionString(FileSelector selector) { - return selectionString(mirrordir,mirrorfiles,selector); - } - - /** - * Worker method for the two convenience methods above. Applies a - * selector on a set of files passed in and returns a string of - * "T"s amd "F"s from applying the selector to each file. - */ - public String selectionString(File basedir, File[] files, FileSelector selector) { - StringBuffer buf = new StringBuffer(); - for (int x = 0; x < files.length; x++) { - if (selector.isSelected(basedir,filenames[x],files[x])) { - buf.append('T'); - } - else { - buf.append('F'); - } - } - return buf.toString(); - } - - /** - * Does the selection test for a given selector and prints the - * filenames of the differing files (selected but shouldn't, - * not selected but should). - * @param selector The selector to test - * @param expected The expected result - */ - public void performTests(FileSelector selector, String expected) { - String result = selectionString(selector); - String diff = diff(expected, result); - String resolved = resolve(diff); - assertEquals("Differing files: " + resolved, result, expected); - } - - /** - * Checks which files are selected and shouldn't be or which - * are not selected but should. - * @param expected String containing 'F's and 'T's - * @param result String containing 'F's and 'T's - * @return Difference as String containing '-' (equal) and - * 'X' (difference). - */ - public String diff(String expected, String result) { - int length1 = expected.length(); - int length2 = result.length(); - int min = (length1 > length2) ? length2 : length1; - StringBuffer sb = new StringBuffer(); - for (int i=0; i filelist.length()) - ? filelist.length() - : filenames.length; - for (int i=0; iCreates a testbed. We avoid the dreaded "test" word so that we - * don't falsely identify this as a test to be run. The actual - * setting up of the testbed is done in the - * src/etc/testcases/types/selectors.xml build file.

- * - *

Note that the right way to call this is within a try block, - * with a finally clause that calls cleanupBed(). You place tests of - * the isSelected() method within the try block.

- */ - protected void makeBed() { - tbed = new TaskdefForMakingBed("setupfiles"); - tbed.setUp(); - tbed.makeTestbed(); - } - - /** - * Cleans up the testbed by calling a target in the - * src/etc/testcases/types/selectors.xml file. - */ - protected void cleanupBed() { - if (tbed != null) { - tbed.tearDown(); - tbed = null; - } - } - - - /** - *

Creates a mirror of the testbed for use in dependency checks.

- * - *

Note that the right way to call this is within a try block, - * with a finally clause that calls cleanupMirror(). You place tests of - * the isSelected() method within the try block.

- */ - protected void makeMirror() { - tbed = new TaskdefForMakingBed("mirrorfiles"); - tbed.setUp(); - tbed.makeMirror(); - } - - /** - * Cleans up the mirror testbed by calling a target in the - * src/etc/testcases/types/selectors.xml file. - */ - protected void cleanupMirror() { - if (tbed != null) { - tbed.deleteMirror(); - tbed = null; - } - } - - private class TaskdefForMakingBed extends BuildFileTest { - - TaskdefForMakingBed(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/selectors.xml"); - } - - public void tearDown() { - executeTarget("cleanup"); - } - - public void makeTestbed() { - executeTarget("setupfiles"); - } - - public void makeMirror() { - executeTarget("mirrorfiles"); - } - - public void deleteMirror() { - executeTarget("cleanup.mirrorfiles"); - } - } - - - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java b/src/testcases/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java deleted file mode 100644 index b3ba47cbe..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/ContainsRegexpTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import java.io.File; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildFileTest; -import org.apache.tools.ant.Project; - - -public class ContainsRegexpTest extends TestCase { - - private Project project; - - public ContainsRegexpTest(String name) { - super(name); - } - - public void setUp() { - project = new Project(); - project.setBasedir("."); - } - - public void testContainsRegexp() { - TaskdefForRegexpTest MyTask = - new TaskdefForRegexpTest("containsregexp"); - try { - MyTask.setUp(); - MyTask.test(); - } finally { - MyTask.tearDown(); - } - } - - private class TaskdefForRegexpTest extends BuildFileTest { - TaskdefForRegexpTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/selectors.xml"); - } - - public void tearDown() { - executeTarget("cleanupregexp"); - } - - public void test() { - File dir = null; - File[] files = null; - int filecount; - - executeTarget("containsregexp"); - - dir = new File(getProjectDir() + "/regexpseltestdest/"); - files = dir.listFiles(); - filecount = files.length; - - if (filecount != 1) - assertEquals("ContainsRegexp test should have copied 1 file", - 1, files.length); - - } - } -} - diff --git a/src/testcases/org/apache/tools/ant/types/selectors/ContainsSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/ContainsSelectorTest.java deleted file mode 100644 index bde5ecef8..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/ContainsSelectorTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; - -/** - * Tests Contains Selectors. - * - */ -public class ContainsSelectorTest extends BaseSelectorTest { - - private Project project; - - public ContainsSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new ContainsSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - ContainsSelector s = (ContainsSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("ContainsSelector did not check for required field 'text'"); - } catch (BuildException be1) { - assertEquals("The text attribute is required", be1.getMessage()); - } - - s = (ContainsSelector)getInstance(); - Parameter param = new Parameter(); - param.setName("garbage in"); - param.setValue("garbage out"); - Parameter[] params = {param}; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("ContainsSelector did not check for valid parameter element"); - } catch (BuildException be2) { - assertEquals("Invalid parameter garbage in", be2.getMessage()); - } - - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - ContainsSelector s; - String results; - - try { - makeBed(); - - s = (ContainsSelector)getInstance(); - s.setText("no such string in test files"); - results = selectionString(s); - assertEquals("TFFFFFFFFFFT", results); - - s = (ContainsSelector)getInstance(); - s.setText("Apache Ant"); - results = selectionString(s); - assertEquals("TFFFTFFFFFFT", results); - - s = (ContainsSelector)getInstance(); - s.setText("apache ant"); - s.setCasesensitive(true); - results = selectionString(s); - assertEquals("TFFFFFFFFFFT", results); - - s = (ContainsSelector)getInstance(); - s.setText("apache ant"); - s.setCasesensitive(false); - results = selectionString(s); - assertEquals("TFFFTFFFFFFT", results); - - s = (ContainsSelector)getInstance(); - s.setText("ApacheAnt"); - s.setIgnorewhitespace(true); - results = selectionString(s); - assertEquals("TFFFTFFFFFFT", results); - - s = (ContainsSelector)getInstance(); - s.setText("A p a c h e A n t"); - s.setIgnorewhitespace(true); - results = selectionString(s); - assertEquals("TFFFTFFFFFFT", results); - - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java deleted file mode 100644 index 2126d4334..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/DateSelectorTest.java +++ /dev/null @@ -1,239 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; - -import java.text.SimpleDateFormat; -import java.text.ParsePosition; -import java.util.Date; - - -/** - * Tests Date Selectors. - * - */ -public class DateSelectorTest extends BaseSelectorTest { - - private Project project; - - public DateSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new DateSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - DateSelector s = (DateSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DateSelector did not check for required fields"); - } catch (BuildException be1) { - assertEquals("You must provide a datetime or the number of " - + "milliseconds.", be1.getMessage()); - } - - s = (DateSelector)getInstance(); - s.setDatetime("01/01/1969 01:01 AM"); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DateSelector did not check for Datetime being in the " - + "allowable range"); - } catch (BuildException be2) { - assertEquals("Date of 01/01/1969 01:01 AM results in negative " - + "milliseconds value relative to epoch (January 1, " - + "1970, 00:00:00 GMT).", be2.getMessage()); - } - - s = (DateSelector)getInstance(); - s.setDatetime("this is not a date"); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DateSelector did not check for Datetime being in a " - + "valid format"); - } catch (BuildException be3) { - assertEquals("Date of this is not a date" - + " Cannot be parsed correctly. It should be in" - + " MM/DD/YYYY HH:MM AM_PM format.", be3.getMessage()); - } - - s = (DateSelector)getInstance(); - Parameter param = new Parameter(); - param.setName("garbage in"); - param.setValue("garbage out"); - Parameter[] params = new Parameter[1]; - params[0] = param; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DateSelector did not check for valid parameter element"); - } catch (BuildException be4) { - assertEquals("Invalid parameter garbage in", be4.getMessage()); - } - - s = (DateSelector)getInstance(); - param = new Parameter(); - param.setName("millis"); - param.setValue("garbage out"); - params[0] = param; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DateSelector did not check for valid millis parameter"); - } catch (BuildException be5) { - assertEquals("Invalid millisecond setting garbage out", - be5.getMessage()); - } - - s = (DateSelector)getInstance(); - param = new Parameter(); - param.setName("granularity"); - param.setValue("garbage out"); - params[0] = param; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DateSelector did not check for valid granularity parameter"); - } catch (BuildException be6) { - assertEquals("Invalid granularity setting garbage out", - be6.getMessage()); - } - - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - DateSelector s; - String results; - - DateSelector.TimeComparisons before = new - DateSelector.TimeComparisons(); - before.setValue("before"); - DateSelector.TimeComparisons equal = new - DateSelector.TimeComparisons(); - equal.setValue("equal"); - DateSelector.TimeComparisons after = new - DateSelector.TimeComparisons(); - after.setValue("after"); - - try { - makeBed(); - - s = (DateSelector)getInstance(); - s.setDatetime("10/10/1999 1:45 PM"); - s.setWhen(before); - results = selectionString(s); - assertEquals("TFFFFFFFFFFT", results); - - s = (DateSelector)getInstance(); - s.setDatetime("10/10/1999 1:45 PM"); - s.setWhen(before); - s.setCheckdirs(true); - results = selectionString(s); - assertEquals("FFFFFFFFFFFF", results); - - s = (DateSelector)getInstance(); - s.setDatetime("10/10/1999 1:45 PM"); - s.setWhen(after); - results = selectionString(s); - assertEquals("TTTTTTTTTTTT", results); - - s = (DateSelector)getInstance(); - s.setDatetime("11/21/2001 4:54 AM"); - s.setWhen(before); - results = selectionString(s); - assertEquals("TFTFFFFFFFFT", results); - - s = (DateSelector)getInstance(); - s.setDatetime("11/21/2001 4:55 AM"); - SimpleDateFormat formatter = new SimpleDateFormat(); - Date d = formatter.parse("11/21/2001 4:55 AM",new ParsePosition(0)); - - long milliseconds = s.getMillis(); - s.setWhen(equal); - results = selectionString(s); - assertEquals("TTFFTFFFTTTT", results); - - s = (DateSelector)getInstance(); - s.setMillis(milliseconds); - s.setWhen(equal); - results = selectionString(s); - assertEquals("TTFFTFFFTTTT", results); - - s = (DateSelector)getInstance(); - s.setDatetime("11/21/2001 4:56 AM"); - s.setWhen(after); - results = selectionString(s); - assertEquals("TFFTFTTTFFFT", results); - - s = (DateSelector)getInstance(); - Parameter param1 = new Parameter(); - Parameter param2 = new Parameter(); - param1.setName("datetime"); - param1.setValue("11/21/2001 4:56 AM"); - param2.setName("when"); - param2.setValue("after"); - Parameter[] params = {param1,param2}; - s.setParameters(params); - results = selectionString(s); - assertEquals("TFFTFTTTFFFT", results); - try { - makeMirror(); - - s = (DateSelector)getInstance(); - long testtime = mirrorfiles[5].lastModified(); - s.setMillis(testtime); - s.setWhen(after); - s.setGranularity(2); - results = mirrorSelectionString(s); - assertEquals("TFFFFTTTTTTT", results); - - s = (DateSelector)getInstance(); - testtime = mirrorfiles[6].lastModified(); - s.setMillis(testtime); - s.setWhen(before); - s.setGranularity(2); - results = mirrorSelectionString(s); - assertEquals("TTTTTTTFFFFT", results); - } - finally { - cleanupMirror(); - } - - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java deleted file mode 100644 index 6dc9e8950..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/DependSelectorTest.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Mapper; - -import java.io.File; - - -/** - * Tests Depend Selectors - * - */ -public class DependSelectorTest extends BaseSelectorTest { - - private Project project; - - public DependSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new DependSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - DependSelector s = (DependSelector)getInstance(); - try { - s.createMapper(); - s.createMapper(); - fail("DependSelector allowed more than one nested mapper."); - } catch (BuildException be1) { - assertEquals("Cannot define more than one mapper", - be1.getMessage()); - } - - s = (DependSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DependSelector did not check for required fields"); - } catch (BuildException be2) { - assertEquals("The targetdir attribute is required.", - be2.getMessage()); - } - - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - DependSelector s; - String results; - File subdir; - Mapper m; - Mapper.MapperType identity = new Mapper.MapperType(); - identity.setValue("identity"); - Mapper.MapperType glob = new Mapper.MapperType(); - glob.setValue("glob"); - Mapper.MapperType merge = new Mapper.MapperType(); - merge.setValue("merge"); - - try { - makeBed(); - - s = (DependSelector)getInstance(); - s.setTargetdir(beddir); - results = selectionString(s); - assertEquals("FFFFFFFFFFFF", results); - - s = (DependSelector)getInstance(); - s.setTargetdir(beddir); - m = s.createMapper(); - m.setType(identity); - results = selectionString(s); - assertEquals("FFFFFFFFFFFF", results); - - s = (DependSelector)getInstance(); - s.setTargetdir(beddir); - m = s.createMapper(); - m.setType(merge); - m.setTo("asf-logo.gif.gz"); - results = selectionString(s); - assertEquals("TFFFFTTTFFF", results.substring(0,11)); - - s = (DependSelector)getInstance(); - s.setTargetdir(beddir); - m = s.createMapper(); - m.setType(merge); - m.setTo("asf-logo.gif.bz2"); - results = selectionString(s); - assertEquals("TTFTTTTTTTTT", results); - - // Test for path relative to project base directory - s = (DependSelector)getInstance(); - subdir = new File("selectortest/tar/bz2"); - s.setTargetdir(subdir); - m = s.createMapper(); - m.setType(glob); - m.setFrom("*.bz2"); - m.setTo("*.tar.bz2"); - results = selectionString(s); - assertEquals("FFTFFFFFFTTF", results); - - s = (DependSelector)getInstance(); - subdir = new File(beddir,"tar/bz2"); - s.setTargetdir(subdir); - m = s.createMapper(); - m.setType(glob); - m.setFrom("*.bz2"); - m.setTo("*.tar.bz2"); - results = selectionString(s); - assertEquals("FFFFFFFFFTTF", results); - - try { - makeMirror(); - - s = (DependSelector)getInstance(); - File testdir = getProject().resolveFile("selectortest2"); - s.setTargetdir(testdir); - results = selectionString(s); - assertEquals("FFFTTFFFFFFF", results); - - s = (DependSelector)getInstance(); - testdir = getProject().resolveFile("selectortest2/tar/bz2"); - s.setTargetdir(testdir); - m = s.createMapper(); - m.setType(glob); - m.setFrom("*.bz2"); - m.setTo("*.tar.bz2"); - results = mirrorSelectionString(s); - assertEquals("FFFFFFFFFTTF", results); - results = selectionString(s); - assertEquals("FFFFFFFFFTTF", results); - } - finally { - cleanupMirror(); - } - - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/DepthSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/DepthSelectorTest.java deleted file mode 100644 index 64c260fe9..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/DepthSelectorTest.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; - -/** - * Tests Depth Selectors - * - */ -public class DepthSelectorTest extends BaseSelectorTest { - - private Project project; - - public DepthSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new DepthSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - DepthSelector s = (DepthSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DepthSelector did not check for required fields"); - } catch (BuildException be1) { - assertEquals("You must set at least one of the min or the " + - "max levels.", be1.getMessage()); - } - - s = (DepthSelector)getInstance(); - s.setMin(5); - s.setMax(2); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DepthSelector did not check for maximum being higher " - + "than minimum"); - } catch (BuildException be2) { - assertEquals("The maximum depth is lower than the minimum.", - be2.getMessage()); - } - - s = (DepthSelector)getInstance(); - Parameter param = new Parameter(); - param.setName("garbage in"); - param.setValue("garbage out"); - Parameter[] params = new Parameter[1]; - params[0] = param; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DepthSelector did not check for valid parameter element"); - } catch (BuildException be3) { - assertEquals("Invalid parameter garbage in", be3.getMessage()); - } - - s = (DepthSelector)getInstance(); - param = new Parameter(); - param.setName("min"); - param.setValue("garbage out"); - params[0] = param; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DepthSelector accepted bad minimum as parameter"); - } catch (BuildException be4) { - assertEquals("Invalid minimum value garbage out", - be4.getMessage()); - } - - s = (DepthSelector)getInstance(); - param = new Parameter(); - param.setName("max"); - param.setValue("garbage out"); - params[0] = param; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("DepthSelector accepted bad maximum as parameter"); - } catch (BuildException be5) { - assertEquals("Invalid maximum value garbage out", - be5.getMessage()); - } - - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - DepthSelector s; - String results; - - try { - makeBed(); - - s = (DepthSelector)getInstance(); - s.setMin(20); - s.setMax(25); - results = selectionString(s); - assertEquals("FFFFFFFFFFFF", results); - - s = (DepthSelector)getInstance(); - s.setMin(0); - results = selectionString(s); - assertEquals("TTTTTTTTTTTT", results); - - s = (DepthSelector)getInstance(); - s.setMin(1); - results = selectionString(s); - assertEquals("FFFFFTTTTTTT", results); - - s = (DepthSelector)getInstance(); - s.setMax(0); - results = selectionString(s); - assertEquals("TTTTTFFFFFFF", results); - - s = (DepthSelector)getInstance(); - s.setMin(1); - s.setMax(1); - results = selectionString(s); - assertEquals("FFFFFTTTFFFT", results); - - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java deleted file mode 100644 index 2083d6341..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/FilenameSelectorTest.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; - -/** - * Tests Filename Selectors - * - */ -public class FilenameSelectorTest extends BaseSelectorTest { - - private Project project; - - public FilenameSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new FilenameSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - FilenameSelector s = (FilenameSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("FilenameSelector did not check for required fields"); - } catch (BuildException be1) { - assertEquals("The name attribute is required", be1.getMessage()); - } - - s = (FilenameSelector)getInstance(); - Parameter param = new Parameter(); - param.setName("garbage in"); - param.setValue("garbage out"); - Parameter[] params = {param}; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("FilenameSelector did not check for valid parameter element"); - } catch (BuildException be2) { - assertEquals("Invalid parameter garbage in", be2.getMessage()); - } - - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - FilenameSelector s; - String results; - - try { - makeBed(); - - s = (FilenameSelector)getInstance(); - s.setName("no match possible"); - results = selectionString(s); - assertEquals("FFFFFFFFFFFF", results); - - s = (FilenameSelector)getInstance(); - s.setName("*.gz"); - results = selectionString(s); - // This is turned off temporarily. There appears to be a bug - // in SelectorUtils.matchPattern() where it is recursive on - // Windows even if no ** is in pattern. - //assertEquals("FFFTFFFFFFFF", results); // Unix - // vs - //assertEquals("FFFTFFFFTFFF", results); // Windows - - s = (FilenameSelector)getInstance(); - s.setName("**/*.gz"); - s.setNegate(true); - results = selectionString(s); - assertEquals("TTTFTTTFFTTT", results); - - s = (FilenameSelector)getInstance(); - s.setName("**/*.GZ"); - s.setCasesensitive(false); - results = selectionString(s); - assertEquals("FFFTFFFTTFFF", results); - - s = (FilenameSelector)getInstance(); - Parameter param1 = new Parameter(); - param1.setName("name"); - param1.setValue("**/*.bz2"); - Parameter[] params = {param1}; - s.setParameters(params); - results = selectionString(s); - assertEquals("FFTFFFFFFTTF", results); - - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/MockAlgorithm.java b/src/testcases/org/apache/tools/ant/types/selectors/MockAlgorithm.java deleted file mode 100644 index 12c9f0828..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/MockAlgorithm.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - - -import java.io.File; -import org.apache.tools.ant.types.selectors.modifiedselector.Algorithm; - -public class MockAlgorithm implements Algorithm { - public boolean isValid() { - return true; - } - - public String getValue(File file) { - return "TEST"; - } - - public String toString() { - return "MockAlgorithm@" + hashCode(); - } -} \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/types/selectors/MockCache.java b/src/testcases/org/apache/tools/ant/types/selectors/MockCache.java deleted file mode 100644 index e60def23d..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/MockCache.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - - -import java.util.Iterator; -import org.apache.tools.ant.types.selectors.modifiedselector.Cache; - -public class MockCache implements Cache { - - public boolean debug = false; - public boolean saved = false; - - - public MockCache() { - log("()"); - } - - public boolean isValid() { - log(".isValid()"); - return true; - } - public void delete() { - log(".delete()"); - } - public void load() { - log(".load()"); - } - public void save() { - log(".save()"); - saved = true; - } - public Object get(Object key) { - log(".get("+key+")"); - return key; - } - public void put(Object key, Object value) { - log(".put("+key+", "+value+")"); - saved = false; - } - public Iterator iterator() { - log("iterator()"); - return null; - } - public String toString() { - return "MockCache@" + hashCode(); - } - - private void log(String msg) { - if (debug) System.out.println(this+msg); - } -}//class-MockCache \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/types/selectors/MockComparator.java b/src/testcases/org/apache/tools/ant/types/selectors/MockComparator.java deleted file mode 100644 index e77ec854f..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/MockComparator.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import java.util.Comparator; - -public class MockComparator implements Comparator { - - public int compare(Object o1, Object o2) { - return 0; - } - - public String toString() { - return "MockComparator"; - } -}//class-MockCache \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java deleted file mode 100644 index adfa7ea8c..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/ModifiedSelectorTest.java +++ /dev/null @@ -1,1017 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - - -// Java -import java.io.File; -import java.text.RuleBasedCollator; -import java.util.Comparator; -import java.util.Iterator; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Target; -import org.apache.tools.ant.Task; -import org.apache.tools.ant.types.Parameter; -import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.selectors.modifiedselector.Algorithm; -import org.apache.tools.ant.types.selectors.modifiedselector.Cache; -import org.apache.tools.ant.types.selectors.modifiedselector.ChecksumAlgorithm; -import org.apache.tools.ant.types.selectors.modifiedselector.DigestAlgorithm; -import org.apache.tools.ant.types.selectors.modifiedselector.EqualComparator; -import org.apache.tools.ant.types.selectors.modifiedselector.HashvalueAlgorithm; -import org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector; -import org.apache.tools.ant.types.selectors.modifiedselector.PropertiesfileCache; -import org.apache.tools.ant.util.FileUtils; - - -/** - * Unit tests for ModifiedSelector. - * - * @since Ant 1.6 - */ -public class ModifiedSelectorTest extends BaseSelectorTest { - - /** Utilities used for file operations */ - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - // ===================== attributes ===================== - - - /** Package of the CacheSelector classes. */ - private static String pkg = "org.apache.tools.ant.types.selectors.modifiedselector"; - - /** Path where the testclasses are. */ - private Path testclasses = null; - - - // ===================== constructors, factories ===================== - - - public ModifiedSelectorTest(String name) { - super(name); - } - - - /** - * Factory method from base class. This should be overriden in child - * classes to return a specific Selector class (like here). - */ - public BaseSelector getInstance() { - return new ModifiedSelector(); - } - - - // ===================== JUnit stuff ===================== - - - public void setUp() { - // project reference is set in super.setUp() - super.setUp(); - // init the testclasses path object - Project prj = getProject(); - if (prj != null) { - testclasses = new Path(prj, prj.getProperty("build.tests.value")); - } - } - - - /* * / - // for test only - ignore tests where we arent work at the moment - public static junit.framework.Test suite() { - junit.framework.TestSuite suite= new junit.framework.TestSuite(); - suite.addTest(new ModifiedSelectorTest("testValidateWrongCache")); - return suite; - } - /* */ - - - // ======= testcases for the attributes and nested elements of the selector ===== - - - /** Test right use of cache names. */ - public void testValidateWrongCache() { - String name = "this-is-not-a-valid-cache-name"; - try { - ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName(); - cacheName.setValue(name); - fail("CacheSelector.CacheName accepted invalid value."); - } catch (BuildException be) { - assertEquals(name + " is not a legal value for this attribute", - be.getMessage()); - } - } - - - /** Test right use of cache names. */ - public void testValidateWrongAlgorithm() { - String name = "this-is-not-a-valid-algorithm-name"; - try { - ModifiedSelector.AlgorithmName algoName - = new ModifiedSelector.AlgorithmName(); - algoName.setValue(name); - fail("CacheSelector.AlgorithmName accepted invalid value."); - } catch (BuildException be) { - assertEquals(name + " is not a legal value for this attribute", - be.getMessage()); - } - } - - - /** Test right use of comparator names. */ - public void testValidateWrongComparator() { - String name = "this-is-not-a-valid-comparator-name"; - try { - ModifiedSelector.ComparatorName compName - = new ModifiedSelector.ComparatorName(); - compName.setValue(name); - fail("ModifiedSelector.ComparatorName accepted invalid value."); - } catch (BuildException be) { - assertEquals(name + " is not a legal value for this attribute", - be.getMessage()); - } - } - - - public void testIllegalCustomAlgorithm() { - try { - String algo = getAlgoName("java.lang.Object"); - fail("Illegal classname used."); - } catch (Exception e) { - assertTrue("Wrong exception type: " + e.getClass().getName(), e instanceof BuildException); - assertEquals("Wrong exception message.", - "Specified class (java.lang.Object) is not an Algorithm.", - e.getMessage()); - - } - } - - - public void testNonExistentCustomAlgorithm() { - boolean noExcThrown = false; - try { - String algo = getAlgoName("non.existent.custom.Algorithm"); - noExcThrown = true; - } catch (Exception e) { - if (noExcThrown) { - fail("does 'non.existent.custom.Algorithm' really exist?"); - } - assertTrue("Wrong exception type: " + e.getClass().getName(), e instanceof BuildException); - assertEquals("Wrong exception message.", - "Specified class (non.existent.custom.Algorithm) not found.", - e.getMessage()); - - } - } - - - public void testCustomAlgorithm() { - String algo = getAlgoName("org.apache.tools.ant.types.selectors.modifiedselector.HashvalueAlgorithm"); - assertTrue("Wrong algorithm used: "+algo, algo.startsWith("HashvalueAlgorithm")); - } - - - public void testCustomAlgorithm2() { - String algo = getAlgoName("org.apache.tools.ant.types.selectors.MockAlgorithm"); - assertTrue("Wrong algorithm used: "+algo, algo.startsWith("MockAlgorithm")); - } - - - public void testCustomClasses() { - BFT bft = new BFT(); - bft.setUp(); - try { - // do the actions - bft.doTarget("modifiedselectortest-customClasses"); - // do the checks - the buildfile stores the fileset as property - String fsFullValue = bft.getProperty("fs.full.value"); - String fsModValue = bft.getProperty("fs.mod.value"); - - assertNotNull("'fs.full.value' must be set.", fsFullValue); - assertTrue("'fs.full.value' must not be null.", !"".equals(fsFullValue)); - assertTrue("'fs.full.value' must contain ant.bat.", fsFullValue.indexOf("ant.bat")>-1); - - assertNotNull("'fs.mod.value' must be set.", fsModValue); - // must be empty according to the Mock* implementations - assertTrue("'fs.mod.value' must be empty.", "".equals(fsModValue)); - // don't catch the JUnit exceptions - } finally { - bft.doTarget("modifiedselectortest-scenario-clean"); - bft.deletePropertiesfile(); - bft.tearDown(); - } - } - - - public void testDelayUpdateTaskFinished() { - doDelayUpdateTest(1); - } - - - public void testDelayUpdateTargetFinished() { - doDelayUpdateTest(2); - } - - - public void testDelayUpdateBuildFinished() { - doDelayUpdateTest(3); - } - - - public void doDelayUpdateTest(int kind) { - // no check for 1<=kind<=3 - only internal use therefore check it - // while development - - // readable form of parameter kind - String[] kinds = {"task", "target", "build"}; - - // setup the "Ant project" - MockProject project = new MockProject(); - File base = new File("base"); - File file1 = new File("file1"); - File file2 = new File("file2"); - - // setup the selector - ModifiedSelector sel = new ModifiedSelector(); - sel.setProject(project); - sel.setUpdate(true); - sel.setDelayUpdate(true); - // sorry - otherwise we will get a ClassCastException because the MockCache - // is loaded by two different classloader ... - sel.setClassLoader(this.getClass().getClassLoader()); - sel.addClasspath(testclasses); - - sel.setAlgorithmClass("org.apache.tools.ant.types.selectors.MockAlgorithm"); - sel.setCacheClass("org.apache.tools.ant.types.selectors.MockCache"); - sel.configure(); - - // get the cache, so we can check our things - MockCache cache = (MockCache)sel.getCache(); - - // the test - assertFalse("Cache must not be saved before 1st selection.", cache.saved); - sel.isSelected(base, "file1", file1); - assertFalse("Cache must not be saved after 1st selection.", cache.saved); - sel.isSelected(base, "file2", file2); - assertFalse("Cache must not be saved after 2nd selection.", cache.saved); - switch (kind) { - case 1 : project.fireTaskFinished(); break; - case 2 : project.fireTargetFinished(); break; - case 3 : project.fireBuildFinished(); break; - } - assertTrue("Cache must be saved after " + kinds[kind-1] + "Finished-Event.", cache.saved); - - // MockCache doesnt create a file - therefore no cleanup needed - } - - - /** - * Extracts the real used algorithm name from the ModifiedSelector using - * its toString() method. - * @param classname the classname from the algorithm to use - * @return the algorithm part from the toString() (without brackets) - */ - private String getAlgoName(String classname) { - ModifiedSelector sel = new ModifiedSelector(); - // add the test classes to its classpath - sel.addClasspath(testclasses); - sel.setAlgorithmClass(classname); - // let the selector do its checks - sel.validate(); - // extract the algorithm name (and config) from the selectors output - String s1 = sel.toString(); - int posStart = s1.indexOf("algorithm=") + 10; - int posEnd = s1.indexOf(" comparator="); - String algo = s1.substring(posStart, posEnd); - // '<' and '>' are only used if the algorithm has properties - if (algo.startsWith("<")) algo = algo.substring(1); - if (algo.endsWith(">")) algo = algo.substring(0, algo.length()-1); - // return the clean value - return algo; - } - - - // ================ testcases for the cache implementations ================ - - - /** - * Propertycache must have a set 'cachefile' attribute. - * The default in ModifiedSelector "cache.properties" is set by the selector. - */ - public void testPropcacheInvalid() { - Cache cache = new PropertiesfileCache(); - if (cache.isValid()) - fail("PropertyfilesCache does not check its configuration."); - } - - - public void testPropertyfileCache() { - PropertiesfileCache cache = new PropertiesfileCache(); - File cachefile = new File("cache.properties"); - cache.setCachefile(cachefile); - doTest(cache); - assertFalse("Cache file not deleted.", cachefile.exists()); - } - - - /** Checks whether a cache file is created. */ - public void testCreatePropertiesCacheDirect() { - File cachefile = new File(basedir, "cachefile.properties"); - - PropertiesfileCache cache = new PropertiesfileCache(); - cache.setCachefile(cachefile); - - cache.put("key", "value"); - cache.save(); - - assertTrue("Cachefile not created.", cachefile.exists()); - - cache.delete(); - assertFalse("Cachefile not deleted.", cachefile.exists()); - } - - - /** Checks whether a cache file is created. */ - public void testCreatePropertiesCacheViaModifiedSelector() { - File cachefile = new File(basedir, "cachefile.properties"); - try { - - // initialize test environment (called "bed") - makeBed(); - - // Configure the selector - ModifiedSelector s = (ModifiedSelector)getSelector(); - s.setDelayUpdate(false); - s.addParam("cache.cachefile", cachefile); - - ModifiedSelector.CacheName cacheName = new ModifiedSelector.CacheName(); - cacheName.setValue("propertyfile"); - s.setCache(cacheName); - - s.setUpdate(true); - - // does the selection - String results = selectionString(s); - - // evaluate correctness - assertTrue("Cache file is not created.", cachefile.exists()); - } finally { - cleanupBed(); - if (cachefile!=null) cachefile.delete(); - } - } - - - /** - * In earlier implementations there were problems with the order - * of the s. The scenario was
-     *   
-     *       
-     *       
-     *   
-     * 
It was important first to set the cache and then to set - * the cache's configuration parameters. That results in the reorganized - * configure() method of ModifiedSelector. This testcase tests that. - */ - public void testCreatePropertiesCacheViaCustomSelector() { - File cachefile = FILE_UTILS.createTempFile("tmp-cache-", ".properties", null); - try { - // initialize test environment (called "bed") - makeBed(); - - // Configure the selector - - ExtendSelector s = new ExtendSelector(); - s.setClassname("org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector"); - s.addParam(createParam("update", "true")); - s.addParam(createParam("cache.cachefile", cachefile.getAbsolutePath())); - s.addParam(createParam("cache", "propertyfile")); - - // does the selection - String results = selectionString(s); - - // evaluate correctness - assertTrue("Cache file is not created.", cachefile.exists()); - } finally { - cleanupBed(); - if (cachefile!=null) cachefile.delete(); - } - } - - - public void _testCustomCache() { - // same logic as on algorithm, no testcases created - } - - - /** - * Test the interface semantic of Caches. - * This method does some common test for cache implementations. - * A cache must return a stored value and a valid iterator. - * After calling the delete() the cache must be empty. - * - * @param algo configured test object - */ - protected void doTest(Cache cache) { - assertTrue("Cache not proper configured.", cache.isValid()); - - String key1 = "key1"; - String value1 = "value1"; - String key2 = "key2"; - String value2 = "value2"; - - // given cache must be empty - Iterator it1 = cache.iterator(); - assertFalse("Cache is not empty", it1.hasNext()); - - // cache must return a stored value - cache.put(key1, value1); - cache.put(key2, value2); - assertEquals("cache returned wrong value", value1, cache.get(key1)); - assertEquals("cache returned wrong value", value2, cache.get(key2)); - - // test the iterator - Iterator it2 = cache.iterator(); - Object returned = it2.next(); - boolean ok = (key1.equals(returned) || key2.equals(returned)); - String msg = "Iterator returned unexpected value." - + " key1.equals(returned)="+key1.equals(returned) - + " key2.equals(returned)="+key2.equals(returned) - + " returned="+returned - + " ok="+ok; - assertTrue(msg, ok); - - // clear the cache - cache.delete(); - Iterator it3 = cache.iterator(); - assertFalse("Cache is not empty", it1.hasNext()); - } - - - // ============== testcases for the algorithm implementations ============== - - - public void testHashvalueAlgorithm() { - HashvalueAlgorithm algo = new HashvalueAlgorithm(); - doTest(algo); - } - - - public void testDigestAlgorithmMD5() { - DigestAlgorithm algo = new DigestAlgorithm(); - algo.setAlgorithm("MD5"); - doTest(algo); - } - - - public void testDigestAlgorithmSHA() { - DigestAlgorithm algo = new DigestAlgorithm(); - algo.setAlgorithm("SHA"); - doTest(algo); - } - - - public void testChecksumAlgorithm() { - ChecksumAlgorithm algo = new ChecksumAlgorithm(); - doTest(algo); - } - - - public void testChecksumAlgorithmCRC() { - ChecksumAlgorithm algo = new ChecksumAlgorithm(); - algo.setAlgorithm("CRC"); - doTest(algo); - } - - - public void testChecksumAlgorithmAdler() { - ChecksumAlgorithm algo = new ChecksumAlgorithm(); - algo.setAlgorithm("Adler"); - doTest(algo); - } - - - /** - * Test the interface semantic of Algorithms. - * This method does some common test for algorithm implementations. - * An algorithm must return always the same value for the same file and - * it must not return null. - * - * @param algo configured test object - */ - protected void doTest(Algorithm algo) { - assertTrue("Algorithm not proper configured.", algo.isValid()); - try { - makeBed(); - - for (int i=0; i - *
  • try fist time --> should select all
  • - *
  • try second time --> should select no files (only directories)
  • - *
  • modify timestamp of one file and content of a nother one
  • - *
  • try third time --> should select only the file with modified - * content
  • - */ - public void testScenario1() { - BFT bft = null; - ModifiedSelector s = null; - try { - // - // ***** initialize test environment (called "bed") ***** - // - makeBed(); - String results = null; - - // Configure the selector - only defaults are used - s = (ModifiedSelector)getSelector(); - - // - // ***** First Run ***** - // the first call should get all files, because nothing is in - // the cache - // - performTests(s, "TTTTTTTTTTTT"); - - // - // ***** Second Run ***** - // the second call should get no files, because no content - // has changed - // - performTests(s, "TFFFFFFFFFFT"); - - // - // ***** make some files dirty ***** - // - - // these files are made dirty --> 3+4 with different content - String f2name = "tar/bz2/asf-logo-huge.tar.bz2"; - String f3name = "asf-logo.gif.md5"; - String f4name = "copy.filterset.filtered"; - - // AccessObject to the test-Ant-environment - bft = new BFT(); - // give some values (via property file) to that environment - bft.writeProperties("f2name="+f2name); - bft.writeProperties("f3name="+f3name); - bft.writeProperties("f4name="+f4name); - // call the target for making the files dirty - bft.doTarget("modifiedselectortest-makeDirty"); - - // - // ***** Third Run ***** - // third call should get only those files, which CONTENT changed - // (no timestamp changes required!) - results = selectionString(s); - - // - // ***** Check the result ***** - // - - // Mark all files which should be selected as (T)rue and all others - // as (F)alse. Directories are always selected so they always are - // (T)rue. - StringBuffer expected = new StringBuffer(); - for (int i=0; i selector. Used values are:
      - *
    • Cache: Propertyfile, - * cachefile={java.io.tmpdir}/mycache.txt
    • - *
    • Algorithm: Digest - * algorithm=SHA, Provider=null
    • - *
    • Comparator: java.text.RuleBasedCollator - *
    • Update: true
    • - */ - public void _testScenario2() { // RuleBasedCollator not yet supported - see Selector:375 note - ExtendSelector s = new ExtendSelector(); - BFT bft = new BFT(); - String cachefile = System.getProperty("java.io.tmpdir")+"/mycache.txt"; - try { - makeBed(); - - s.setClassname("org.apache.tools.ant.types.selectors.modifiedselector.ModifiedSelector"); - - s.addParam(createParam("cache.cachefile", cachefile)); - //s.addParam(createParam("algorithm.provider","---")); // i don't know any valid - s.addParam(createParam("cache","propertyfile")); - s.addParam(createParam("update","true")); - s.addParam(createParam("comparator","rule")); - s.addParam(createParam("algorithm.name","sha")); - s.addParam(createParam("algorithm","digest")); - - // first and second run - performTests(s, "TTTTTTTTTTTT"); - performTests(s, "TFFFFFFFFFFT"); - // make dirty - String f2name = "tar/bz2/asf-logo-huge.tar.bz2"; - String f3name = "asf-logo.gif.md5"; - String f4name = "copy.filterset.filtered"; - bft.writeProperties("f2name="+f2name); - bft.writeProperties("f3name="+f3name); - bft.writeProperties("f4name="+f4name); - bft.doTarget("modifiedselectortest-makeDirty"); - // third run - String results = selectionString(s); - StringBuffer expected = new StringBuffer(); - for (int i=0; i5); - assertTrue("Too much files copied on second time.", to2.list().length==0); - assertTrue("Too much files copied on third time.", to3.list().length==2); - // don't catch the JUnit exceptions - } finally { - bft.doTarget("modifiedselectortest-scenario-clean"); - bft.deletePropertiesfile(); - bft.tearDown(); - cachefile.delete(); - } - } - - - // ===================== helper methods and classes ==================== - - - /** - * Creates a configured parameter object. - * @param name name of the parameter - * @param value value of the parameter - * @return the parameter object - */ - private Parameter createParam(String name, String value) { - Parameter p = new Parameter(); - p.setName(name); - p.setValue(value); - return p; - } - - - /** - * The BFT class wrapps the selector test-builfile inside an - * ant project (BuildFileTest). It supports target execution - * and property transfer to that project. - */ - private class BFT extends org.apache.tools.ant.BuildFileTest { - String buildfile = "src/etc/testcases/types/selectors.xml"; - - BFT() { super("nothing"); } - BFT(String name) { - super(name); - } - - String propfile = "ModifiedSelectorTest.properties"; - - boolean isConfigured = false; - - public void setUp() { - configureProject(buildfile); - isConfigured = true; - } - - - /** - * This stub teardown is here because the outer class needs to call the - * tearDown method, and in the superclass it is protected. - */ - public void tearDown() { - try { - super.tearDown(); - } catch (Exception e) { - // ignore - } - } - - public void doTarget(String target) { - if (!isConfigured) setUp(); - executeTarget(target); - } - - public String getProperty(String property) { - return project.getProperty(property); - } - - public void writeProperties(String line) { - if (!isConfigured) setUp(); - File dir = getProject().getBaseDir(); - File file = new File(dir, propfile); - try { - java.io.FileWriter out = - new java.io.FileWriter(file.getAbsolutePath(), true); - out.write(line); - out.write(System.getProperty("line.separator")); - out.flush(); - out.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void deletePropertiesfile() { - if (!isConfigured) setUp(); - new File(getProject().getBaseDir(), propfile).delete(); - } - - public void deleteCachefile() { - File basedir = new File(buildfile).getParentFile(); - File cacheFile = new File(basedir, "cache.properties"); - cacheFile.delete(); - } - - public String getBuildfile() { - return buildfile; - } - public void setBuildfile(String buildfile) { - this.buildfile = buildfile; - } - }//class-BFT - - - /** - * MockProject wrappes a very small ant project (one target, one task) - * but provides public methods to fire the build events. - */ - private class MockProject extends Project { - private Task task; - private Target target; - - public MockProject() { - task = new Task(){ - public void execute() { - } - }; - task.setTaskName("testTask"); - target = new Target(); - target.setName("testTarget"); - target.setProject(this); - target.addTask(task); - task.setOwningTarget(target); - } - - public void fireBuildFinished() { - super.fireBuildFinished(null); - } - public void fireSubBuildFinished() { - super.fireSubBuildFinished(null); - } - public void fireTargetStarted() { - super.fireTargetStarted(target); - } - public void fireTargetFinished() { - super.fireTargetFinished(target, null); - } - public void fireTaskStarted() { - super.fireTaskStarted(task); - } - public void fireTaskFinished() { - super.fireTaskFinished(task, null); - } - }//class-MockProject - - -}//class-ModifiedSelectorTest \ No newline at end of file diff --git a/src/testcases/org/apache/tools/ant/types/selectors/PresentSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/PresentSelectorTest.java deleted file mode 100644 index 180faf3c1..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/PresentSelectorTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Mapper; - -import java.io.File; - - -/** - * Tests Present Selectors - * - */ -public class PresentSelectorTest extends BaseSelectorTest { - - private Project project; - - public PresentSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new PresentSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - PresentSelector s = (PresentSelector)getInstance(); - try { - s.createMapper(); - s.createMapper(); - fail("PresentSelector allowed more than one nested mapper."); - } catch (BuildException be1) { - assertEquals("Cannot define more than one mapper", - be1.getMessage()); - } - - s = (PresentSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("PresentSelector did not check for required fields"); - } catch (BuildException be2) { - assertEquals("The targetdir attribute is required.", - be2.getMessage()); - } - - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - PresentSelector s; - String results; - Mapper m; - Mapper.MapperType identity = new Mapper.MapperType(); - identity.setValue("identity"); - Mapper.MapperType glob = new Mapper.MapperType(); - glob.setValue("glob"); - Mapper.MapperType merge = new Mapper.MapperType(); - merge.setValue("merge"); - Mapper.MapperType flatten = new Mapper.MapperType(); - flatten.setValue("flatten"); - - try { - makeBed(); - - s = (PresentSelector)getInstance(); - s.setTargetdir(beddir); - results = selectionString(s); - assertEquals("TTTTTTTTTTTT", results); - - s = (PresentSelector)getInstance(); - s.setTargetdir(beddir); - m = s.createMapper(); - m.setType(identity); - results = selectionString(s); - assertEquals("TTTTTTTTTTTT", results); - - s = (PresentSelector)getInstance(); - File subdir = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/expected"); - s.setTargetdir(subdir); - m = s.createMapper(); - m.setType(flatten); - results = selectionString(s); - assertEquals("TTTTTTTTTTTF", results); - - s = (PresentSelector)getInstance(); - s.setTargetdir(beddir); - m = s.createMapper(); - m.setType(merge); - m.setTo("asf-logo.gif.gz"); - results = selectionString(s); - assertEquals("TTTTTTTTTTTT", results); - - s = (PresentSelector)getInstance(); - subdir = new File(beddir, "tar/bz2"); - s.setTargetdir(subdir); - m = s.createMapper(); - m.setType(glob); - m.setFrom("*.bz2"); - m.setTo("*.tar.bz2"); - results = selectionString(s); - assertEquals("FFTFFFFFFFFF", results); - - try { - makeMirror(); - - s = (PresentSelector)getInstance(); - subdir = getProject().resolveFile("selectortest2"); - s.setTargetdir(subdir); - results = mirrorSelectionString(s); - assertEquals("TTTFFTTTTTTT", results); - results = selectionString(s); - assertEquals("TTTFFTTTTTTT", results); - - - } - finally { - cleanupMirror(); - } - - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/README b/src/testcases/org/apache/tools/ant/types/selectors/README deleted file mode 100755 index eb48f6bbc..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/README +++ /dev/null @@ -1,96 +0,0 @@ -A DESCRIPTION OF THE SELECTOR TEST FRAMEWORK - -When writing tests for selectors, I found that I wanted to have some -standard way of working with a set of files and testing whether one or -another of them was selected. To that end, I created a base class called -BaseSelectorTest that does most of the heavy lifting. Of course, you can -test your selectors any way you want, but if you want to reuse this code, -read on. - -What BaseSelectorTest does is use an ant build file -"src/etc/testcases/types/selector.xml" to copy a tree of files out of -"src/etc/testcases/taskdefs/expected" into a "selectortest" directories. -Then it takes a list of 12 of the files and directories in this tree, and -applies whatever selector you pass in to each one. It passes back to your -test a 12 character long string indicating which of the 12 files and -directories was selected, using 'T' for selected and 'F' for not selected. -In the Test class for your selector, you override the getInstance() method -to create your own type of selector, and set the elements of your selector -a variety of ways to ensure that the string of T's and F's returned when -the selector is applied to those 12 files is correct. - -So, for example, DepthSelectorTest.java extends BaseSelectorTest and has -the following code: - - - public BaseSelector getInstance() { - return new DepthSelector(); - } - - - public void testSelectionBehaviour() { - DepthSelector s; - String results; - - - try { - makeBed(); - - - s = (DepthSelector)getInstance(); - s.setMin(20); - s.setMax(25); - results = selectionString(s); - assertEquals("FFFFFFFFFFFF", results); - - - s = (DepthSelector)getInstance(); - s.setMin(0); - results = selectionString(s); - assertEquals("TTTTTTTTTTTT", results); - - - s = (DepthSelector)getInstance(); - s.setMin(1); - results = selectionString(s); - assertEquals("FFFFFTTTTTTT", results); - - -The first test says that none of the 12 files or directories will match if -the depth range for the selector is between 20 and 25 (that would be one -deep directory tree!). The second says that all files and directories -match if the minimum depth is set to 0 and the maximum isn't specified. The -third test says that if the minumum depth is 1, the first 5 entries in the -list of 12 will not be selected and the rest will. - - -You can find the 12 files and directories that are tested for selection in -the BaseSelectorTest class. I used a fixed list so that if someone added -new files to the src/etc/testcases/types directory it wouldn't break my -tests: - - - protected String[] filenames = {".","asf-logo.gif.md5","asf- - logo.gif.bz2", - "asf-logo.gif.gz","copy.filterset.filtered","zip/asf- - logo.gif.zip", - "tar/asf-logo.gif.tar","tar/asf-logo-huge.tar.gz", - "tar/gz/asf-logo.gif.tar.gz","tar/bz2/asf-logo.gif.tar.bz2", - "tar/bz2/asf-logo-huge.tar.bz2","tar/bz2"}; - - -If you wish to use this set of files and directories to test your selector, -you can reuse the BaseSelectorTest with no change to it. - -You may find you need to alter the build file so that you get some -variation in the files that your selector can work with. Most of the core -selectors have required that kind of modification. If you do that, make -sure that it doesn't alter the output strings on the other selector test, -or if it does that you update their expected return results. - -You may also want to alter the set of files you look at in a particular -selector test. Since the filelist in BaseSelectorTest is protected, you -should be able to override it as you need to. Or you can alter the fileset -in BaseSelectorTest itself, provided you update the test strings in all the -other unit tests. - diff --git a/src/testcases/org/apache/tools/ant/types/selectors/SignedSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/SignedSelectorTest.java deleted file mode 100644 index 8b938b9c0..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/SignedSelectorTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildFileTest; - -/** - * Testcase for the <signedselector> selector. - * - */ -public class SignedSelectorTest extends BuildFileTest { - - public SignedSelectorTest(String name) { - super(name); - } - public void setUp() { - configureProject("src/etc/testcases/types/selectors/signedselector.xml"); - } - - public void testSelectSigned() { - executeTarget("selectsigned"); - } - public void testNotSelected() { - executeTarget("notselected"); - } - public void testName() { - executeTarget("name"); - } -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/SizeSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/SizeSelectorTest.java deleted file mode 100644 index 52fcf4c50..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/SizeSelectorTest.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Parameter; - -/** - * Tests Size Selectors - * - */ -public class SizeSelectorTest extends BaseSelectorTest { - - private Project project; - - public SizeSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new SizeSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - SizeSelector s = (SizeSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("SizeSelector did not check for required fields"); - } catch (BuildException be1) { - assertEquals("The value attribute is required, and must " - + "be positive", be1.getMessage()); - } - - s = (SizeSelector)getInstance(); - s.setValue(-10); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("SizeSelector did not check for value being in the " - + "allowable range"); - } catch (BuildException be2) { - assertEquals("The value attribute is required, and must " - + "be positive", be2.getMessage()); - } - - s = (SizeSelector)getInstance(); - Parameter param = new Parameter(); - param.setName("garbage in"); - param.setValue("garbage out"); - Parameter[] params = {param}; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("SizeSelector did not check for valid parameter element"); - } catch (BuildException be3) { - assertEquals("Invalid parameter garbage in", be3.getMessage()); - } - - s = (SizeSelector)getInstance(); - param = new Parameter(); - param.setName("value"); - param.setValue("garbage out"); - params[0] = param; - s.setParameters(params); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("SizeSelector accepted bad value as parameter"); - } catch (BuildException be4) { - assertEquals("Invalid size setting garbage out", - be4.getMessage()); - } - - s = (SizeSelector)getInstance(); - Parameter param1 = new Parameter(); - Parameter param2 = new Parameter(); - param1.setName("value"); - param1.setValue("5"); - param2.setName("units"); - param2.setValue("garbage out"); - params = new Parameter[2]; - params[0] = param1; - params[1] = param2; - try { - s.setParameters(params); - s.isSelected(basedir,filenames[0],files[0]); - fail("SizeSelector accepted bad units as parameter"); - } catch (BuildException be5) { - assertEquals("garbage out is not a legal value for this attribute", - be5.getMessage()); - } - - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - SizeSelector s; - String results; - - SizeSelector.ByteUnits kilo = new SizeSelector.ByteUnits(); - kilo.setValue("K"); - SizeSelector.ByteUnits kibi = new SizeSelector.ByteUnits(); - kibi.setValue("Ki"); - SizeSelector.ByteUnits tibi = new SizeSelector.ByteUnits(); - tibi.setValue("Ti"); - SizeSelector.SizeComparisons less = new SizeSelector.SizeComparisons(); - less.setValue("less"); - SizeSelector.SizeComparisons equal = new SizeSelector.SizeComparisons(); - equal.setValue("equal"); - SizeSelector.SizeComparisons more = new SizeSelector.SizeComparisons(); - more.setValue("more"); - - - try { - makeBed(); - - s = (SizeSelector)getInstance(); - s.setValue(10); - s.setWhen(less); - results = selectionString(s); - assertEquals("TFFFFFFFFFFT", results); - - s = (SizeSelector)getInstance(); - s.setValue(10); - s.setWhen(more); - results = selectionString(s); - assertEquals("TTTTTTTTTTTT", results); - - s = (SizeSelector)getInstance(); - s.setValue(32); - s.setWhen(equal); - results = selectionString(s); - assertEquals("TFFFTFFFFFFT", results); - - s = (SizeSelector)getInstance(); - s.setValue(7); - s.setWhen(more); - s.setUnits(kilo); - results = selectionString(s); - assertEquals("TFTFFTTTTTTT", results); - - s = (SizeSelector)getInstance(); - s.setValue(7); - s.setWhen(more); - s.setUnits(kibi); - results = selectionString(s); - assertEquals("TFTFFFTTFTTT", results); - - s = (SizeSelector)getInstance(); - s.setValue(99999); - s.setWhen(more); - s.setUnits(tibi); - results = selectionString(s); - assertEquals("TFFFFFFFFFFT", results); - - s = (SizeSelector)getInstance(); - Parameter param1 = new Parameter(); - Parameter param2 = new Parameter(); - Parameter param3 = new Parameter(); - param1.setName("value"); - param1.setValue("20"); - param2.setName("units"); - param2.setValue("Ki"); - param3.setName("when"); - param3.setValue("more"); - Parameter[] params = {param1,param2,param3}; - s.setParameters(params); - results = selectionString(s); - assertEquals("TFFFFFFTFFTT", results); - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/types/selectors/TypeSelectorTest.java b/src/testcases/org/apache/tools/ant/types/selectors/TypeSelectorTest.java deleted file mode 100644 index 1158177f3..000000000 --- a/src/testcases/org/apache/tools/ant/types/selectors/TypeSelectorTest.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.types.selectors; - -import org.apache.tools.ant.BuildException; - -/** - * Tests Type Selectors. - * - */ -public class TypeSelectorTest extends BaseSelectorTest { - - public TypeSelectorTest(String name) { - super(name); - } - - /** - * Factory method from base class. This is overriden in child - * classes to return a specific Selector class. - */ - public BaseSelector getInstance() { - return new TypeSelector(); - } - - /** - * Test the code that validates the selector. - */ - public void testValidate() { - TypeSelector s = (TypeSelector)getInstance(); - try { - s.isSelected(basedir,filenames[0],files[0]); - fail("TypeSelector did not check for required fields"); - } catch (BuildException be1) { - assertEquals("The type attribute is required" - , be1.getMessage()); - } - } - - /** - * Tests to make sure that the selector is selecting files correctly. - */ - public void testSelectionBehaviour() { - TypeSelector s; - String results; - - TypeSelector.FileType directory = new - TypeSelector.FileType(); - directory.setValue("dir"); - TypeSelector.FileType file = new - TypeSelector.FileType(); - file.setValue("file"); - - try { - makeBed(); - - s = (TypeSelector)getInstance(); - s.setType(directory); - results = selectionString(s); - assertEquals("TFFFFFFFFFFT", results); - - s = (TypeSelector)getInstance(); - s.setType(file); - results = selectionString(s); - assertEquals("FTTTTTTTTTTF", results); - - - } - finally { - cleanupBed(); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/util/ClasspathUtilsTest.java b/src/testcases/org/apache/tools/ant/util/ClasspathUtilsTest.java deleted file mode 100644 index b975f6566..000000000 --- a/src/testcases/org/apache/tools/ant/util/ClasspathUtilsTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import java.io.IOException; -import java.util.Enumeration; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; -import org.apache.tools.ant.types.Path; - - -/** - * Test case for ClasspathUtils - * - */ -public class ClasspathUtilsTest extends TestCase { - - private Project p; - - public ClasspathUtilsTest(String name) { - super(name); - } - - public void setUp() { - p = new Project(); - p.init(); - } - - - public void testOnlyOneInstance() { - Enumeration enumeration; - String list = ""; - ClassLoader c = ClasspathUtils.getUniqueClassLoaderForPath(p, (Path) null, false); - try { - enumeration = c.getResources( - "org/apache/tools/ant/taskdefs/defaults.properties"); - } catch (IOException e) { - throw new BuildException( - "Could not get the defaults.properties resource"); - } - int count = 0; - while (enumeration.hasMoreElements()) { - list = list + " " + enumeration.nextElement(); - count++; - } - assertTrue("Should be only one and not " + count + " " + list, count == 1); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/CollectionUtilsTest.java b/src/testcases/org/apache/tools/ant/util/CollectionUtilsTest.java deleted file mode 100644 index 340c357b2..000000000 --- a/src/testcases/org/apache/tools/ant/util/CollectionUtilsTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import java.util.Hashtable; -import java.util.Properties; -import java.util.Stack; -import java.util.Vector; - -import junit.framework.TestCase; - -/** - * Tests for org.apache.tools.ant.util.CollectionUtils. - * - */ -public class CollectionUtilsTest extends TestCase { - - public CollectionUtilsTest(String name) { - super(name); - } - - public void testVectorEquals() { - assertTrue(!CollectionUtils.equals(null, new Vector())); - assertTrue(!CollectionUtils.equals(new Vector(), null)); - assertTrue(CollectionUtils.equals(new Vector(), new Vector())); - Vector v1 = new Vector(); - Stack s2 = new Stack(); - v1.addElement("foo"); - s2.push("foo"); - assertTrue(CollectionUtils.equals(v1, s2)); - assertTrue(CollectionUtils.equals(s2, v1)); - v1.addElement("bar"); - assertTrue(!CollectionUtils.equals(v1, s2)); - assertTrue(!CollectionUtils.equals(s2, v1)); - s2.push("bar"); - assertTrue(CollectionUtils.equals(v1, s2)); - assertTrue(CollectionUtils.equals(s2, v1)); - s2.push("baz"); - assertTrue(!CollectionUtils.equals(v1, s2)); - assertTrue(!CollectionUtils.equals(s2, v1)); - v1.addElement("baz"); - assertTrue(CollectionUtils.equals(v1, s2)); - assertTrue(CollectionUtils.equals(s2, v1)); - v1.addElement("zyzzy"); - s2.push("zyzzy2"); - assertTrue(!CollectionUtils.equals(v1, s2)); - assertTrue(!CollectionUtils.equals(s2, v1)); - } - - public void testDictionaryEquals() { - assertTrue(!CollectionUtils.equals(null, new Hashtable())); - assertTrue(!CollectionUtils.equals(new Hashtable(), null)); - assertTrue(CollectionUtils.equals(new Hashtable(), new Properties())); - Hashtable h1 = new Hashtable(); - Properties p2 = new Properties(); - h1.put("foo", ""); - p2.put("foo", ""); - assertTrue(CollectionUtils.equals(h1, p2)); - assertTrue(CollectionUtils.equals(p2, h1)); - h1.put("bar", ""); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); - p2.put("bar", ""); - assertTrue(CollectionUtils.equals(h1, p2)); - assertTrue(CollectionUtils.equals(p2, h1)); - p2.put("baz", ""); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); - h1.put("baz", ""); - assertTrue(CollectionUtils.equals(h1, p2)); - assertTrue(CollectionUtils.equals(p2, h1)); - h1.put("zyzzy", ""); - p2.put("zyzzy2", ""); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); - p2.put("zyzzy", ""); - h1.put("zyzzy2", ""); - assertTrue(CollectionUtils.equals(h1, p2)); - assertTrue(CollectionUtils.equals(p2, h1)); - h1.put("dada", "1"); - p2.put("dada", "2"); - assertTrue(!CollectionUtils.equals(h1, p2)); - assertTrue(!CollectionUtils.equals(p2, h1)); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/DOMElementWriterTest.java b/src/testcases/org/apache/tools/ant/util/DOMElementWriterTest.java deleted file mode 100644 index 0e6d62996..000000000 --- a/src/testcases/org/apache/tools/ant/util/DOMElementWriterTest.java +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import java.io.IOException; -import java.io.StringWriter; - -import junit.framework.TestCase; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -/** - * Tests for org.apache.tools.ant.util.DOMElementWriter. - * - */ -public class DOMElementWriterTest extends TestCase { - - private DOMElementWriter w = new DOMElementWriter(); - - public DOMElementWriterTest(String name) { - super(name); - } - - public void testIsReference() { - assertTrue("", w.isReference("")); - assertTrue(" ", w.isReference(" ")); - assertTrue(" ", w.isReference(" ")); - assertTrue("&#A0;", !w.isReference("&#A0;")); - assertTrue("20;", !w.isReference("20;")); - assertTrue("", !w.isReference("")); - assertTrue(""", w.isReference(""")); - assertTrue("'", w.isReference("'")); - assertTrue(">", w.isReference(">")); - assertTrue("<", w.isReference("<")); - assertTrue("&", w.isReference("&")); - } - - public void testEncode() { - assertEquals("", w.encode("")); - assertEquals(" ", w.encode(" ")); - assertEquals(" ", w.encode(" ")); - assertEquals("&#A0;", w.encode("&#A0;")); - assertEquals("20;", w.encode("20;")); - assertEquals("&#20", w.encode("")); - assertEquals(""", w.encode(""")); - assertEquals("'", w.encode("'")); - assertEquals(">", w.encode(">")); - assertEquals("<", w.encode("<")); - assertEquals("&", w.encode("&")); - assertEquals(""", w.encode("\"")); - assertEquals("<", w.encode("<")); - assertEquals("&", w.encode("&")); - assertEquals("", w.encode("\u0017")); - assertEquals("\"20;&", w.encodedata("\"20;&")); - assertEquals("", w.encodedata("\u0017")); - } - - public void testIsLegalCharacter() { - assertTrue("0x00", !w.isLegalCharacter('\u0000')); - assertTrue("0x09", w.isLegalCharacter('\t')); - assertTrue("0x0A", w.isLegalCharacter('\n')); - assertTrue("0x0C", w.isLegalCharacter('\r')); - assertTrue("0x1F", !w.isLegalCharacter('\u001F')); - assertTrue("0x20", w.isLegalCharacter('\u0020')); - assertTrue("0xD7FF", w.isLegalCharacter('\uD7FF')); - assertTrue("0xD800", !w.isLegalCharacter('\uD800')); - assertTrue("0xDFFF", !w.isLegalCharacter('\uDFFF')); - assertTrue("0xE000", w.isLegalCharacter('\uE000')); - assertTrue("0xFFFD", w.isLegalCharacter('\uFFFD')); - assertTrue("0xFFFE", !w.isLegalCharacter('\uFFFE')); - } - - public void testCDATAEndEncoding() { - assertEquals("]>", w.encodedata("]>")); - assertEquals("]]", w.encodedata("]]")); - assertEquals("]]>", w.encodedata("]]>")); - assertEquals("]]>A", w.encodedata("]]>A")); - assertEquals("A]]>", w.encodedata("A]]>")); - assertEquals("A]]>A", w.encodedata("A]]>A")); - assertEquals("A]]>B]]>C", - w.encodedata("A]]>B]]>C")); - } - - public void testNoAdditionalWhiteSpaceForText() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElement("root"); - DOMUtils.appendTextElement(root, "textElement", "content"); - - StringWriter sw = new StringWriter(); - DOMElementWriter w = new DOMElementWriter(); - w.write(root, sw, 0, " "); - assertEquals("" + StringUtils.LINE_SEP - + " content" - + StringUtils.LINE_SEP - + "" + StringUtils.LINE_SEP, - sw.toString()); - } - - public void testNoAdditionalWhiteSpaceForCDATA() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElement("root"); - DOMUtils.appendCDATAElement(root, "cdataElement", "content"); - - StringWriter sw = new StringWriter(); - DOMElementWriter w = new DOMElementWriter(); - w.write(root, sw, 0, " "); - assertEquals("" + StringUtils.LINE_SEP - + " " - + StringUtils.LINE_SEP - + "" + StringUtils.LINE_SEP, - sw.toString()); - } - - public void testNoAdditionalWhiteSpaceForEmptyElement() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElement("root"); - DOMUtils.createChildElement(root, "emptyElement"); - - StringWriter sw = new StringWriter(); - DOMElementWriter w = new DOMElementWriter(); - w.write(root, sw, 0, " "); - assertEquals("" + StringUtils.LINE_SEP - // + " " - + " " - + StringUtils.LINE_SEP - + "" + StringUtils.LINE_SEP, - sw.toString()); - } - - public void testNoNSPrefixByDefault() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElementNS("urn:foo", "root"); - root.setAttributeNS("urn:foo2", "bar", "baz"); - - StringWriter sw = new StringWriter(); - DOMElementWriter w = new DOMElementWriter(); - w.write(root, sw, 0, " "); - assertEquals("" - + StringUtils.LINE_SEP, sw.toString()); - } - - public void testNSOnElement() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElementNS("urn:foo", "root"); - root.setAttributeNS("urn:foo2", "bar", "baz"); - - StringWriter sw = new StringWriter(); - DOMElementWriter w = - new DOMElementWriter(false, - DOMElementWriter.XmlNamespacePolicy - .ONLY_QUALIFY_ELEMENTS); - w.write(root, sw, 0, " "); - assertEquals("" - + StringUtils.LINE_SEP, sw.toString()); - } - - public void testNSPrefixOnAttribute() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElementNS("urn:foo", "root"); - root.setAttributeNS("urn:foo2", "bar", "baz"); - - StringWriter sw = new StringWriter(); - DOMElementWriter w = - new DOMElementWriter(false, - DOMElementWriter.XmlNamespacePolicy - .QUALIFY_ALL); - w.write(root, sw, 0, " "); - assertEquals("" - + StringUtils.LINE_SEP, sw.toString()); - } - - public void testNSPrefixOnAttributeEvenWithoutElement() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElementNS("urn:foo", "root"); - root.setAttributeNS("urn:foo2", "bar", "baz"); - - StringWriter sw = new StringWriter(); - DOMElementWriter w = - new DOMElementWriter(false, - new DOMElementWriter.XmlNamespacePolicy(false, - true) - ); - w.write(root, sw, 0, " "); - assertEquals("" - + StringUtils.LINE_SEP, sw.toString()); - } - - public void testNSGetsReused() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElementNS("urn:foo", "root"); - Element child = d.createElementNS("urn:foo", "child"); - root.appendChild(child); - StringWriter sw = new StringWriter(); - DOMElementWriter w = - new DOMElementWriter(false, - DOMElementWriter.XmlNamespacePolicy - .ONLY_QUALIFY_ELEMENTS); - w.write(root, sw, 0, " "); - assertEquals("" - + StringUtils.LINE_SEP - + " " - + StringUtils.LINE_SEP - + "" - + StringUtils.LINE_SEP, sw.toString()); - } - - public void testNSGoesOutOfScope() throws IOException { - Document d = DOMUtils.newDocument(); - Element root = d.createElementNS("urn:foo", "root"); - Element child = d.createElementNS("urn:foo2", "child"); - root.appendChild(child); - Element child2 = d.createElementNS("urn:foo2", "child"); - root.appendChild(child2); - Element grandChild = d.createElementNS("urn:foo2", "grandchild"); - child2.appendChild(grandChild); - Element child3 = d.createElementNS("urn:foo2", "child"); - root.appendChild(child3); - StringWriter sw = new StringWriter(); - DOMElementWriter w = - new DOMElementWriter(false, - DOMElementWriter.XmlNamespacePolicy - .ONLY_QUALIFY_ELEMENTS); - w.write(root, sw, 0, " "); - assertEquals("" - + StringUtils.LINE_SEP - + " " - + StringUtils.LINE_SEP - + " " - + StringUtils.LINE_SEP - + " " - + StringUtils.LINE_SEP - + " " - + StringUtils.LINE_SEP - + " " - + StringUtils.LINE_SEP - + "" - + StringUtils.LINE_SEP, sw.toString()); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/DateUtilsTest.java b/src/testcases/org/apache/tools/ant/util/DateUtilsTest.java deleted file mode 100644 index ede0b4355..000000000 --- a/src/testcases/org/apache/tools/ant/util/DateUtilsTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import java.util.Calendar; -import java.util.TimeZone; - -import junit.framework.TestCase; - -/** - * TestCase for DateUtils. - * - */ -public class DateUtilsTest extends TestCase { - public DateUtilsTest(String s) { - super(s); - } - - public void testElapsedTime(){ - String text = DateUtils.formatElapsedTime(50*1000); - assertEquals("50 seconds", text); - text = DateUtils.formatElapsedTime(65*1000); - assertEquals("1 minute 5 seconds", text); - text = DateUtils.formatElapsedTime(120*1000); - assertEquals("2 minutes 0 seconds", text); - text = DateUtils.formatElapsedTime(121*1000); - assertEquals("2 minutes 1 second", text); - } - - public void testDateTimeISO(){ - TimeZone timeZone = TimeZone.getTimeZone("GMT+1"); - Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23,10,11,12); - String text = DateUtils.format(cal.getTime(), - DateUtils.ISO8601_DATETIME_PATTERN); - assertEquals("2002-02-23T09:11:12", text); - } - - public void testDateISO(){ - TimeZone timeZone = TimeZone.getTimeZone("GMT"); - Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23); - String text = DateUtils.format(cal.getTime(), - DateUtils.ISO8601_DATE_PATTERN); - assertEquals("2002-02-23", text); - } - - public void testTimeISODate(){ - // make sure that elapsed time in set via date works - TimeZone timeZone = TimeZone.getTimeZone("GMT+1"); - Calendar cal = Calendar.getInstance(timeZone); - cal.set(2002,1,23, 21, 11, 12); - String text = DateUtils.format(cal.getTime(), - DateUtils.ISO8601_TIME_PATTERN); - assertEquals("20:11:12", text); - } - - public void testTimeISO(){ - // make sure that elapsed time in ms works - long ms = (20*3600 + 11*60 + 12)*1000; - String text = DateUtils.format(ms, - DateUtils.ISO8601_TIME_PATTERN); - assertEquals("20:11:12", text); - } - - public void testPhaseOfMoon() { - TimeZone timeZone = TimeZone.getTimeZone("GMT"); - Calendar cal = Calendar.getInstance(timeZone); - // should be full moon - cal.set(2002, 2, 27); - assertEquals(4, DateUtils.getPhaseOfMoon(cal)); - // should be new moon - cal.set(2002, 2, 12); - assertEquals(0, DateUtils.getPhaseOfMoon(cal)); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java b/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java deleted file mode 100644 index e1f4092e6..000000000 --- a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java +++ /dev/null @@ -1,574 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; - -import junit.framework.TestCase; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.taskdefs.condition.Os; - -/** - * Tests for org.apache.tools.ant.util.FileUtils. - * - */ -public class FileUtilsTest extends TestCase { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - private File removeThis; - private String root; - - public FileUtilsTest(String name) { - super(name); - } - - public void setUp() { - // Windows adds the drive letter in uppercase, unless you run Cygwin - root = new File(File.separator).getAbsolutePath().toUpperCase(); - } - - public void tearDown() { - if (removeThis != null && removeThis.exists()) { - removeThis.delete(); - } - } - - /** - * test modification. - * Since Ant1.7, the method being tested no longer uses - * reflection to provide backwards support to Java1.1, so this - * test is not so critical. But it does explore file system - * behaviour and will help catch any regression in Java itself, - * so is worth retaining. - * @see FileUtils#setFileLastModified(java.io.File, long) - * @throws IOException - */ - public void testSetLastModified() throws IOException { - removeThis = new File("dummy"); - FileOutputStream fos = new FileOutputStream(removeThis); - fos.write(new byte[0]); - fos.close(); - long modTime = removeThis.lastModified(); - assertTrue(modTime != 0); - - /* - * Sleep for some time to make sure a touched file would get a - * more recent timestamp according to the file system's - * granularity (should be > 2s to account for Windows FAT). - */ - try { - Thread.sleep(5000); - } catch (InterruptedException ie) { - fail(ie.getMessage()); - } - - FILE_UTILS.setFileLastModified(removeThis, -1); - long secondModTime = removeThis.lastModified(); - assertTrue(secondModTime > modTime); - - // number of milliseconds in a day - final int millisperday=24 * 3600 * 1000; - // in a previous version, the date of the file was set to 123456 - // milliseconds since 01.01.1970 - // it did not work on a computer running JDK 1.4.1_02 + Windows 2000 - FILE_UTILS.setFileLastModified(removeThis, secondModTime + millisperday); - long thirdModTime = removeThis.lastModified(); - /* - * I would love to compare this with 123456, but depending on - * the filesystems granularity it can take an arbitrary value. - * - * Just assert the time has changed. - */ - assertTrue(thirdModTime != secondModTime); - } - - public void testResolveFile() { - if (!(Os.isFamily("dos") || Os.isFamily("netware"))) { - /* - * Start with simple absolute file names. - */ - assertEquals(File.separator, - FILE_UTILS.resolveFile(null, "/").getPath()); - assertEquals(File.separator, - FILE_UTILS.resolveFile(null, "\\").getPath()); - } else { - assertEqualsIgnoreDriveCase(localize(File.separator), - FILE_UTILS.resolveFile(null, "/").getPath()); - assertEqualsIgnoreDriveCase(localize(File.separator), - FILE_UTILS.resolveFile(null, "\\").getPath()); - /* - * throw in drive letters - */ - String driveSpec = "C:"; - assertEquals(driveSpec + "\\", - FILE_UTILS.resolveFile(null, driveSpec + "/").getPath()); - assertEquals(driveSpec + "\\", - FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath()); - String driveSpecLower = "c:"; - assertEquals(driveSpec + "\\", - FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath()); - assertEquals(driveSpec + "\\", - FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath()); - /* - * promised to eliminate consecutive slashes after drive letter. - */ - assertEquals(driveSpec + "\\", - FILE_UTILS.resolveFile(null, driveSpec + "/////").getPath()); - assertEquals(driveSpec + "\\", - FILE_UTILS.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); - } - if (Os.isFamily("netware")) { - /* - * throw in NetWare volume names - */ - String driveSpec = "SYS:"; - assertEquals(driveSpec, - FILE_UTILS.resolveFile(null, driveSpec + "/").getPath()); - assertEquals(driveSpec, - FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath()); - String driveSpecLower = "sys:"; - assertEquals(driveSpec, - FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath()); - assertEquals(driveSpec, - FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath()); - /* - * promised to eliminate consecutive slashes after drive letter. - */ - assertEquals(driveSpec, - FILE_UTILS.resolveFile(null, driveSpec + "/////").getPath()); - assertEquals(driveSpec, - FILE_UTILS.resolveFile(null, driveSpec + "\\\\\\\\\\\\").getPath()); - } else if (!(Os.isFamily("dos"))) { - /* - * drive letters must be considered just normal filenames. - */ - String driveSpec = "C:"; - String udir = System.getProperty("user.dir"); - assertEquals(udir + File.separator + driveSpec, - FILE_UTILS.resolveFile(null, driveSpec + "/").getPath()); - assertEquals(udir + File.separator + driveSpec, - FILE_UTILS.resolveFile(null, driveSpec + "\\").getPath()); - String driveSpecLower = "c:"; - assertEquals(udir + File.separator + driveSpecLower, - FILE_UTILS.resolveFile(null, driveSpecLower + "/").getPath()); - assertEquals(udir + File.separator + driveSpecLower, - FILE_UTILS.resolveFile(null, driveSpecLower + "\\").getPath()); - } - - /* - * Now test some relative file name magic. - */ - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "4").getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "./4").getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), ".\\4").getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "./.\\4").getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "../3/4").getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "..\\3\\4").getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "../../5/.././2/./3/6/../4").getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.resolveFile(new File(localize("/1/2/3")), "..\\../5/..\\./2/./3/6\\../4").getPath()); - - assertEquals("meaningless result but no exception", - new File(localize("/1/../../b")), - FILE_UTILS.resolveFile(new File(localize("/1")), "../../b")); - - } - - public void testNormalize() { - if (!(Os.isFamily("dos") || Os.isFamily("netware"))) { - /* - * Start with simple absolute file names. - */ - assertEquals(File.separator, - FILE_UTILS.normalize("/").getPath()); - assertEquals(File.separator, - FILE_UTILS.normalize("\\").getPath()); - } else { - try { - FILE_UTILS.normalize("/").getPath(); - fail("normalized \"/\" on dos or netware"); - } catch (Exception e) { - } - try { - FILE_UTILS.normalize("\\").getPath(); - fail("normalized \"\\\" on dos or netware"); - } catch (Exception e) { - } - } - - if (Os.isFamily("dos")) { - /* - * throw in drive letters - */ - String driveSpec = "C:"; - try { - FILE_UTILS.normalize(driveSpec).getPath(); - fail(driveSpec + " is not an absolute path"); - } catch (Exception e) { - } - assertEquals(driveSpec + "\\", - FILE_UTILS.normalize(driveSpec + "/").getPath()); - assertEquals(driveSpec + "\\", - FILE_UTILS.normalize(driveSpec + "\\").getPath()); - String driveSpecLower = "c:"; - assertEquals(driveSpec + "\\", - FILE_UTILS.normalize(driveSpecLower + "/").getPath()); - assertEquals(driveSpec + "\\", - FILE_UTILS.normalize(driveSpecLower + "\\").getPath()); - /* - * promised to eliminate consecutive slashes after drive letter. - */ - assertEquals(driveSpec + "\\", - FILE_UTILS.normalize(driveSpec + "/////").getPath()); - assertEquals(driveSpec + "\\", - FILE_UTILS.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); - } else if (Os.isFamily("netware")) { - /* - * throw in NetWare volume names - */ - String driveSpec = "SYS:"; - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpec).getPath()); - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpec + "/").getPath()); - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpec + "\\").getPath()); - String driveSpecLower = "sys:"; - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpecLower).getPath()); - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpecLower + "/").getPath()); - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpecLower + "\\").getPath()); - assertEquals(driveSpec + "\\junk", - FILE_UTILS.normalize(driveSpecLower + "\\junk").getPath()); - /* - * promised to eliminate consecutive slashes after drive letter. - */ - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpec + "/////").getPath()); - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpec + "\\\\\\\\\\\\").getPath()); - } else { - try { - String driveSpec = "C:"; - assertEquals(driveSpec, - FILE_UTILS.normalize(driveSpec).getPath()); - fail("Expected failure, C: isn't an absolute path on other os's"); - } catch (BuildException e) { - // Passed test - } - } - - /* - * Now test some relative file name magic. - */ - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/4")).getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/./4")).getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/.\\4")).getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/./.\\4")).getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/../3/4")).getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/..\\3\\4")).getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/../../5/.././2/./3/6/../4")).getPath()); - assertEquals(localize("/1/2/3/4"), - FILE_UTILS.normalize(localize("/1/2/3/..\\../5/..\\./2/./3/6\\../4")).getPath()); - - try { - FILE_UTILS.normalize("foo"); - fail("foo is not an absolute path"); - } catch (BuildException e) { - // Expected exception caught - } - - assertEquals("will not go outside FS root (but will not throw an exception either)", - new File(localize("/1/../../b")), - FILE_UTILS.normalize(localize("/1/../../b"))); - } - - /** - * Test handling of null arguments. - */ - public void testNullArgs() { - try { - FILE_UTILS.normalize(null); - fail("successfully normalized a null-file"); - } catch (NullPointerException npe) { - // Expected exception caught - } - - File f = FILE_UTILS.resolveFile(null, "a"); - assertEquals(f, new File("a").getAbsoluteFile()); - } - - /** - * Test createTempFile - */ - public void testCreateTempFile() { - File parent = new File((new File("/tmp")).getAbsolutePath()); - File tmp1 = FILE_UTILS.createTempFile("pre", ".suf", parent); - assertTrue("new file", !tmp1.exists()); - - String name = tmp1.getName(); - assertTrue("starts with pre", name.startsWith("pre")); - assertTrue("ends with .suf", name.endsWith(".suf")); - assertEquals("is inside parent dir", - parent.getAbsolutePath(), - tmp1.getParent()); - - File tmp2 = FILE_UTILS.createTempFile("pre", ".suf", parent); - assertTrue("files are different", - !tmp1.getAbsolutePath().equals(tmp2.getAbsolutePath())); - - // null parent dir - File tmp3 = FILE_UTILS.createTempFile("pre", ".suf", null); - String tmploc = System.getProperty("java.io.tmpdir"); - assertEquals((new File(tmploc, tmp3.getName())).getAbsolutePath(), - tmp3.getAbsolutePath()); - } - - /** - * Test contentEquals - */ - public void testContentEquals() throws IOException { - assertTrue("Non existing files", FILE_UTILS.contentEquals(new File(System.getProperty("root"), "foo"), - new File(System.getProperty("root"), "bar"))); - assertTrue("One exists, the other one doesn\'t", - !FILE_UTILS.contentEquals(new File(System.getProperty("root"), "foo"), new File(System.getProperty("root"), "build.xml"))); - assertTrue("Don\'t compare directories", - !FILE_UTILS.contentEquals(new File(System.getProperty("root"), "src"), new File(System.getProperty("root"), "src"))); - assertTrue("File equals itself", - FILE_UTILS.contentEquals(new File(System.getProperty("root"), "build.xml"), - new File(System.getProperty("root"), "build.xml"))); - assertTrue("Files are different", - !FILE_UTILS.contentEquals(new File(System.getProperty("root"), "build.xml"), - new File(System.getProperty("root"), "docs.xml"))); - } - - /** - * Test createNewFile - */ - public void testCreateNewFile() throws IOException { - removeThis = new File("dummy"); - assertTrue(!removeThis.exists()); - FILE_UTILS.createNewFile(removeThis); - assertTrue(removeThis.exists()); - } - - /** - * Test removeLeadingPath. - */ - public void testRemoveLeadingPath() { - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("/foo"), - new File("/foo/bar"))); - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("/foo/"), - new File("/foo/bar"))); - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("\\foo"), - new File("\\foo\\bar"))); - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("\\foo\\"), - new File("\\foo\\bar"))); - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:/foo"), - new File("c:/foo/bar"))); - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:/foo/"), - new File("c:/foo/bar"))); - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:\\foo"), - new File("c:\\foo\\bar"))); - assertEquals("bar", FILE_UTILS.removeLeadingPath(new File("c:\\foo\\"), - new File("c:\\foo\\bar"))); - if (!(Os.isFamily("dos") || Os.isFamily("netware"))) { - assertEquals(FILE_UTILS.normalize("/bar").getAbsolutePath(), - FILE_UTILS.removeLeadingPath(new File("/foo"), new File("/bar"))); - assertEquals(FILE_UTILS.normalize("/foobar").getAbsolutePath(), - FILE_UTILS.removeLeadingPath(new File("/foo"), new File("/foobar"))); - } - // bugzilla report 19979 - assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar"), - new File("/foo/bar"))); - assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar"), - new File("/foo/bar/"))); - assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar/"), - new File("/foo/bar/"))); - assertEquals("", FILE_UTILS.removeLeadingPath(new File("/foo/bar/"), - new File("/foo/bar"))); - - String expected = "foo/bar".replace('\\', File.separatorChar) - .replace('/', File.separatorChar); - assertEquals(expected, FILE_UTILS.removeLeadingPath(new File("/"), - new File("/foo/bar"))); - assertEquals(expected, FILE_UTILS.removeLeadingPath(new File("c:/"), - new File("c:/foo/bar"))); - assertEquals(expected, FILE_UTILS.removeLeadingPath(new File("c:\\"), - new File("c:\\foo\\bar"))); - } - - /** - * test toUri - */ - public void testToURI() { - String dosRoot = null; - if (Os.isFamily("dos") || Os.isFamily("netware")) { - dosRoot = System.getProperty("user.dir") - .substring(0, 3).replace(File.separatorChar, '/'); - - //preserve case on Cygwin when using 1.4 toURI: - Class uriClazz = null; - try { - uriClazz = Class.forName("java.net.URI"); - } catch (ClassNotFoundException e) { - // OK, Java 1.3. - dosRoot = dosRoot.toUpperCase(); - } - } - else - { - dosRoot = ""; - } - if (Os.isFamily("dos")) { - assertEquals("file:/c:/foo", removeExtraneousAuthority(FILE_UTILS.toURI("c:\\foo"))); - } - if (Os.isFamily("netware")) { - assertEquals("file:/SYS:/foo", removeExtraneousAuthority(FILE_UTILS.toURI("sys:\\foo"))); - } - if (File.pathSeparatorChar == '/') { - assertEquals("file:/foo", removeExtraneousAuthority(FILE_UTILS.toURI("/foo"))); - assertTrue("file: URIs must name absolute paths", FILE_UTILS.toURI("./foo").startsWith("file:/")); - assertTrue(FILE_UTILS.toURI("./foo").endsWith("/foo")); - assertEquals("file:/" + dosRoot + "foo%20bar", removeExtraneousAuthority(FILE_UTILS.toURI("/foo bar"))); - assertEquals("file:/" + dosRoot + "foo%23bar", removeExtraneousAuthority(FILE_UTILS.toURI("/foo#bar"))); - } else if (File.pathSeparatorChar == '\\') { - assertEquals("file:/" + dosRoot + "foo", removeExtraneousAuthority(FILE_UTILS.toURI("\\foo"))); - assertTrue("file: URIs must name absolute paths", FILE_UTILS.toURI(".\\foo").startsWith("file:/")); - assertTrue(FILE_UTILS.toURI(".\\foo").endsWith("/foo")); - assertEquals("file:/" + dosRoot + "foo%20bar", removeExtraneousAuthority(FILE_UTILS.toURI("\\foo bar"))); - assertEquals("file:/" + dosRoot + "foo%23bar", removeExtraneousAuthority(FILE_UTILS.toURI("\\foo#bar"))); - } - // a test with ant for germans - // the escaped character used for the test is the "a umlaut" - // this is the fix for the bug 37348 - assertEquals("file:/" + dosRoot + "%C3%A4nt", removeExtraneousAuthority(FILE_UTILS.toURI("/\u00E4nt"))); - } - - /** - * Authority field is unnecessary, but harmless, in file: URIs. - * Java 1.4 does not produce it when using File.toURI. - */ - private static String removeExtraneousAuthority(String uri) { - String prefix = "file:///"; - if (uri.startsWith(prefix)) { - return "file:/" + uri.substring(prefix.length()); - } else { - return uri; - } - } - /** - * test fromUri - */ - public void testFromURI() { - String dosRoot = null; - if (Os.isFamily("dos") || Os.isFamily("netware")) { - dosRoot = Character.toUpperCase( - System.getProperty("user.dir").charAt(0)) + ":"; - } - else - { - dosRoot = ""; - } - if (Os.isFamily("netware")) { - assertEqualsIgnoreDriveCase("SYS:\\foo", FILE_UTILS.fromURI("file:///sys:/foo")); - } - if (Os.isFamily("dos")) { - assertEqualsIgnoreDriveCase("C:\\foo", FILE_UTILS.fromURI("file:///c:/foo")); - } - assertEqualsIgnoreDriveCase(dosRoot + File.separator + "foo", FILE_UTILS.fromURI("file:///foo")); - assertEquals("." + File.separator + "foo", - FILE_UTILS.fromURI("file:./foo")); - assertEquals(dosRoot + File.separator + "foo bar", FILE_UTILS.fromURI("file:///foo%20bar")); - assertEquals(dosRoot + File.separator + "foo#bar", FILE_UTILS.fromURI("file:///foo%23bar")); - } - - public void testModificationTests() { - - //get a time - long firstTime=System.currentTimeMillis(); - //add some time. We assume no OS has a granularity this bad - long secondTime=firstTime+60000; -/* - assertTrue("same timestamp is up to date", - fu.isUpToDate(firstTime, firstTime)); - */ - - //check that older is up to date with a newer dest - assertTrue("older source files are up to date", - FILE_UTILS.isUpToDate(firstTime,secondTime)); - //check that older is up to date with a newer dest - assertFalse("newer source files are no up to date", - FILE_UTILS.isUpToDate(secondTime, firstTime)); - - assertTrue("-1 dest timestamp implies nonexistence", - !FILE_UTILS.isUpToDate(firstTime,-1L)); - } - - public void testGetDefaultEncoding() { - // This just tests that the function does not blow up - FILE_UTILS.getDefaultEncoding(); - } - - /** - * adapt file separators to local conventions - */ - private String localize(String path) { - path = root + path.substring(1); - return path.replace('\\', File.separatorChar).replace('/', File.separatorChar); - } - - /** - * convenience method - * normalize brings the drive in uppercase - * the drive letter is in lower case under cygwin - * calling this method allows tests where normalize is called to pass under cygwin - */ - private void assertEqualsIgnoreDriveCase(String s1, String s2) { - if ((Os.isFamily("dos") || Os.isFamily("netware")) - && s1.length() > 0 && s2.length() > 0) { - StringBuffer sb1 = new StringBuffer(s1); - StringBuffer sb2 = new StringBuffer(s2); - sb1.setCharAt(0, Character.toUpperCase(s1.charAt(0))); - sb2.setCharAt(0, Character.toUpperCase(s2.charAt(0))); - assertEquals(sb1.toString(), sb2.toString()); - } else { - assertEquals(s1, s2); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/util/GlobPatternMapperTest.java b/src/testcases/org/apache/tools/ant/util/GlobPatternMapperTest.java deleted file mode 100644 index bca05b2e3..000000000 --- a/src/testcases/org/apache/tools/ant/util/GlobPatternMapperTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import junit.framework.TestCase; - -/** - * Tests for org.apache.tools.ant.util;GlobPatternMapper. - * - */ -public class GlobPatternMapperTest extends TestCase { - - public GlobPatternMapperTest(String name) { - super(name); - } - - public void testNoPatternAtAll() { - GlobPatternMapper m = new GlobPatternMapper(); - m.setFrom("foobar"); - m.setTo("baz"); - assertNull("Shouldn\'t match foobar", m.mapFileName("plonk")); - String[] result = m.mapFileName("foobar"); - assertNotNull("Should match foobar", result); - assertEquals("only one result for foobar", 1, result.length); - assertEquals("baz", result[0]); - } - - public void testPostfixOnly() { - GlobPatternMapper m = new GlobPatternMapper(); - m.setFrom("*foo"); - m.setTo("*plonk"); - assertNull("Shouldn\'t match *foo", m.mapFileName("bar.baz")); - String[] result = m.mapFileName("bar.foo"); - assertNotNull("Should match *.foo", result); - assertEquals("only one result for bar.foo", 1, result.length); - assertEquals("bar.plonk", result[0]); - - // Try a silly case - m.setTo("foo*"); - result = m.mapFileName("bar.foo"); - assertEquals("foobar.", result[0]); - } - - public void testPrefixOnly() { - GlobPatternMapper m = new GlobPatternMapper(); - m.setFrom("foo*"); - m.setTo("plonk*"); - assertNull("Shouldn\'t match foo*", m.mapFileName("bar.baz")); - String[] result = m.mapFileName("foo.bar"); - assertNotNull("Should match foo*", result); - assertEquals("only one result for foo.bar", 1, result.length); - assertEquals("plonk.bar", result[0]); - - // Try a silly case - m.setTo("*foo"); - result = m.mapFileName("foo.bar"); - assertEquals(".barfoo", result[0]); - } - - public void testPreAndPostfix() { - GlobPatternMapper m = new GlobPatternMapper(); - m.setFrom("foo*bar"); - m.setTo("plonk*pling"); - assertNull("Shouldn\'t match foo*bar", m.mapFileName("bar.baz")); - String[] result = m.mapFileName("foo.bar"); - assertNotNull("Should match foo*bar", result); - assertEquals("only one result for foo.bar", 1, result.length); - assertEquals("plonk.pling", result[0]); - - // and a little longer - result = m.mapFileName("foo.baz.bar"); - assertNotNull("Should match foo*bar", result); - assertEquals("only one result for foo.baz.bar", 1, result.length); - assertEquals("plonk.baz.pling", result[0]); - - // and a little shorter - result = m.mapFileName("foobar"); - assertNotNull("Should match foo*bar", result); - assertEquals("only one result for foobar", 1, result.length); - assertEquals("plonkpling", result[0]); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/JAXPUtilsTest.java b/src/testcases/org/apache/tools/ant/util/JAXPUtilsTest.java deleted file mode 100644 index e5a3b7f57..000000000 --- a/src/testcases/org/apache/tools/ant/util/JAXPUtilsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import junit.framework.TestCase; - -import java.io.File; - -/** - * JAXPUtils test case - */ -public class JAXPUtilsTest extends TestCase { - public JAXPUtilsTest(String name){ - super(name); - } - - public void testGetSystemId(){ - File file = null; - if ( File.separatorChar == '\\' ){ - file = new File("d:\\jdk"); - } else { - file = new File("/user/local/bin"); - } - String systemid = JAXPUtils.getSystemId(file); - assertTrue("SystemIDs should start by file:/", systemid.startsWith("file:/")); - assertTrue("SystemIDs should not start with file:////", !systemid.startsWith("file:////")); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/JavaEnvUtilsTest.java b/src/testcases/org/apache/tools/ant/util/JavaEnvUtilsTest.java deleted file mode 100644 index 4ee47ea77..000000000 --- a/src/testcases/org/apache/tools/ant/util/JavaEnvUtilsTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import java.io.File; - -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; - -import org.apache.tools.ant.taskdefs.condition.Os; - -/** - * TestCase for JavaEnvUtils. - * - */ -public class JavaEnvUtilsTest extends TestCase { - - private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); - - public JavaEnvUtilsTest(String s) { - super(s); - } - - public void testGetExecutableNetware() { - if (Os.isName("netware")) { - assertEquals("java", JavaEnvUtils.getJreExecutable("java")); - assertEquals("javac", JavaEnvUtils.getJdkExecutable("javac")); - assertEquals("foo", JavaEnvUtils.getJreExecutable("foo")); - assertEquals("foo", JavaEnvUtils.getJdkExecutable("foo")); - } - } - - public void testGetExecutableWindows() { - if (Os.isFamily("windows")) { - String javaHome = - FILE_UTILS.normalize(System.getProperty("java.home")) - .getAbsolutePath(); - - String j = JavaEnvUtils.getJreExecutable("java"); - assertTrue(j.endsWith(".exe")); - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); - try { - assertTrue(j+" is normalized and in the JRE dir", - j.startsWith(javaHome)); - } catch (AssertionFailedError e) { - // java.home is bogus - assertEquals("java.exe", j); - } - - j = JavaEnvUtils.getJdkExecutable("javac"); - assertTrue(j.endsWith(".exe")); - try { - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); - String javaHomeParent = - FILE_UTILS.normalize(javaHome+"/..").getAbsolutePath(); - assertTrue(j+" is normalized and in the JDK dir", - j.startsWith(javaHomeParent)); - assertTrue(j+" is normalized and not in the JRE dir", - !j.startsWith(javaHome)); - - } catch (AssertionFailedError e) { - // java.home is bogus - assertEquals("javac.exe", j); - } - - assertEquals("foo.exe", JavaEnvUtils.getJreExecutable("foo")); - assertEquals("foo.exe", JavaEnvUtils.getJdkExecutable("foo")); - } - } - - public void testGetExecutableMostPlatforms() { - if (!Os.isName("netware") && !Os.isFamily("windows")) { - String javaHome = - FILE_UTILS.normalize(System.getProperty("java.home")) - .getAbsolutePath(); - - // could still be OS/2 - String extension = Os.isFamily("dos") ? ".exe" : ""; - - String j = JavaEnvUtils.getJreExecutable("java"); - if (!extension.equals("")) { - assertTrue(j.endsWith(extension)); - } - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); - assertTrue(j+" is normalized and in the JRE dir", - j.startsWith(javaHome)); - - j = JavaEnvUtils.getJdkExecutable("javac"); - if (!extension.equals("")) { - assertTrue(j.endsWith(extension)); - } - assertTrue(j+" is absolute", (new File(j)).isAbsolute()); - - String javaHomeParent = - FILE_UTILS.normalize(javaHome+"/..").getAbsolutePath(); - assertTrue(j+" is normalized and in the JDK dir", - j.startsWith(javaHomeParent)); - - if (Os.isFamily("mac")) { - assertTrue(j+" is normalized and in the JRE dir", - j.startsWith(javaHome)); - } else { - assertTrue(j+" is normalized and not in the JRE dir", - !j.startsWith(javaHome)); - } - - assertEquals("foo"+extension, - JavaEnvUtils.getJreExecutable("foo")); - assertEquals("foo"+extension, - JavaEnvUtils.getJdkExecutable("foo")); - } - - } - -} diff --git a/src/testcases/org/apache/tools/ant/util/LazyFileOutputStreamTest.java b/src/testcases/org/apache/tools/ant/util/LazyFileOutputStreamTest.java deleted file mode 100644 index 394669ebe..000000000 --- a/src/testcases/org/apache/tools/ant/util/LazyFileOutputStreamTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import java.io.File; -import java.io.IOException; -import junit.framework.TestCase; - -/** - * @since Ant 1.6 - */ -public class LazyFileOutputStreamTest extends TestCase { - private LazyFileOutputStream los; - private final static File f = new File("test.txt"); - - public LazyFileOutputStreamTest(String s) { - super(s); - } - - public void setUp() { - los = new LazyFileOutputStream(f); - } - - public void tearDown() throws IOException { - try { - los.close(); - } finally { - f.delete(); - } - } - - public void testNoFileWithoutWrite() throws IOException { - los.close(); - assertTrue(f + " has not been written.", !f.exists()); - } - - public void testOpen() throws IOException { - los.open(); - los.close(); - assertTrue(f + " has been written.", f.exists()); - } - - public void testSingleByte() throws IOException { - los.write(0); - los.close(); - assertTrue(f + " has been written.", f.exists()); - } - - public void testByteArray() throws IOException { - los.write(new byte[] {0}); - los.close(); - assertTrue(f + " has been written.", f.exists()); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java b/src/testcases/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java deleted file mode 100644 index 7bcb4dcb1..000000000 --- a/src/testcases/org/apache/tools/ant/util/LineOrientedOutputStreamTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import java.io.IOException; -import junit.framework.TestCase; - -/** - */ - -public class LineOrientedOutputStreamTest extends TestCase { - - private static String LINE = "This is a line"; - private DummyStream stream; - - public LineOrientedOutputStreamTest(String name) { - super(name); - } - - public void setUp() { - stream = new DummyStream(); - } - - public void tearDown() throws IOException { - if (stream != null) { - stream.close(); - } - } - - public void testLineWithLinefeedArray() throws IOException { - writeByteArray(); - writeAsArray('\n'); - stream.assertInvoked(); - } - - public void testLineWithLinefeedSingleBytes() throws IOException { - writeSingleBytes(); - stream.write('\n'); - stream.assertInvoked(); - } - - public void testLineWithCariagereturnArray() throws IOException { - writeByteArray(); - writeAsArray('\r'); - stream.assertInvoked(); - } - - public void testLineWithCariagereturnSingleBytes() throws IOException { - writeSingleBytes(); - stream.write('\r'); - stream.assertInvoked(); - } - - public void testLineWithCariagereturnLinefeedArray() throws IOException { - writeByteArray(); - writeAsArray('\r'); - writeAsArray('\n'); - stream.assertInvoked(); - } - - public void testLineWithCariagereturnLinefeedSingleBytes() throws IOException { - writeSingleBytes(); - stream.write('\r'); - stream.write('\n'); - stream.assertInvoked(); - } - - public void testFlushArray() throws IOException { - writeByteArray(); - stream.flush(); - stream.assertInvoked(); - } - - public void testFlushSingleBytes() throws IOException { - writeSingleBytes(); - stream.flush(); - stream.assertInvoked(); - } - - public void testCloseArray() throws IOException { - writeByteArray(); - stream.close(); - stream.assertInvoked(); - stream = null; - } - - public void testCloseSingleBytes() throws IOException { - writeSingleBytes(); - stream.close(); - stream.assertInvoked(); - stream = null; - } - - private void writeByteArray() throws IOException { - stream.write(LINE.getBytes(), 0, LINE.length()); - } - - private void writeSingleBytes() throws IOException { - byte[] b = LINE.getBytes(); - for (int i = 0; i < b.length; i++) { - stream.write(b[i]); - } - } - - private void writeAsArray(char c) throws IOException { - stream.write(new byte[] {(byte) c}, 0, 1); - } - - private class DummyStream extends LineOrientedOutputStream { - private boolean invoked; - protected void processLine(String line) { - LineOrientedOutputStreamTest.this.assertFalse("Only one line", - invoked); - LineOrientedOutputStreamTest.this.assertEquals(LINE, line); - invoked = true; - } - - private void assertInvoked() { - LineOrientedOutputStreamTest.this.assertTrue("At least one line", - invoked); - } - } -}// LineOrientedOutputStreamTest diff --git a/src/testcases/org/apache/tools/ant/util/LoaderUtilsTest.java b/src/testcases/org/apache/tools/ant/util/LoaderUtilsTest.java deleted file mode 100644 index 49518ea3d..000000000 --- a/src/testcases/org/apache/tools/ant/util/LoaderUtilsTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import java.io.File; -import junit.framework.TestCase; - -/** - * @since Ant 1.6 - */ -public class LoaderUtilsTest extends TestCase { - - public LoaderUtilsTest(String name) { - super(name); - } - - public void testGetXyzSource() { - File f1 = LoaderUtils.getClassSource(LoaderUtils.class); - assertNotNull(f1); - - File f2 = LoaderUtils.getResourceSource(null, - "org/apache/tools/ant/taskdefs/defaults.properties"); - assertNotNull(f2); - - assertEquals(f1.getAbsolutePath(), f2.getAbsolutePath()); - } - -} diff --git a/src/testcases/org/apache/tools/ant/util/PackageNameMapperTest.java b/src/testcases/org/apache/tools/ant/util/PackageNameMapperTest.java deleted file mode 100644 index f6c859f17..000000000 --- a/src/testcases/org/apache/tools/ant/util/PackageNameMapperTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - package org.apache.tools.ant.util; - -import java.io.File; -import junit.framework.TestCase; - -public class PackageNameMapperTest extends TestCase { - public PackageNameMapperTest(String name) { super(name); } - - public void testMapping() { - PackageNameMapper mapper = new PackageNameMapper(); - mapper.setFrom("*.java"); - mapper.setTo("TEST-*.xml"); - String file = fixupPath("org/apache/tools/ant/util/PackageNameMapperTest.java"); - String result = mapper.mapFileName(file)[0]; - - assertEquals("TEST-org.apache.tools.ant.util.PackageNameMapperTest.xml", - result); - } - - private String fixupPath(String file) { - return file.replace('/', File.separatorChar); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java b/src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java deleted file mode 100644 index a7648cbde..000000000 --- a/src/testcases/org/apache/tools/ant/util/ReaderInputStreamTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import java.io.*; - -import junit.framework.TestCase; - -/** - * Test for ReaderInputStream - */ -public class ReaderInputStreamTest extends TestCase { - public ReaderInputStreamTest(String s) { - super(s); - } - - public void testSimple() throws Exception { - compareBytes("abc", "utf-8"); - } - - public void testSimple16() throws Exception { - compareBytes("a", "utf-16"); - } - - public void testSimpleAbc16() throws Exception { - // THIS WILL FAIL. - //compareBytes("abc", "utf-16"); - byte[] bytes = new byte[40]; - int pos = 0; - ReaderInputStream r = new ReaderInputStream( - new StringReader("abc"), "utf-16"); - for (int i = 0; true; ++i) { - int res = r.read(); - if (res == -1) { - break; - } - bytes[pos++] = (byte) res; - } - bytes = "abc".getBytes("utf-16"); - // String n = new String(bytes, 0, pos, "utf-16"); - String n = new String(bytes, 0, bytes.length, "utf-16"); - System.out.println(n); - } - - public void testReadZero() throws Exception { - ReaderInputStream r = new ReaderInputStream( - new StringReader("abc")); - byte[] bytes = new byte[30]; - // First read in zero bytes - r.read(bytes, 0, 0); - // Now read in the string - int readin = r.read(bytes, 0, 10); - // Make sure that the counts are the same - assertEquals("abc".getBytes().length, readin); - } - - public void testPreample() throws Exception { - byte[] bytes = "".getBytes("utf-16"); - System.out.println("Preample len is " + bytes.length); - } - - private void compareBytes(String s, String encoding) throws Exception { - byte[] expected = s.getBytes(encoding); - - ReaderInputStream r = new ReaderInputStream( - new StringReader(s), encoding); - for (int i = 0; i < expected.length; ++i) { - int expect = expected[i] & 0xFF; - int read = r.read(); - if (expect != read) { - fail("Mismatch in ReaderInputStream at index " + i - + " expecting " + expect + " got " + read + " for string " - + s + " with encoding " + encoding); - } - } - if (r.read() != -1) { - fail("Mismatch in ReaderInputStream - EOF not seen for string " - + s + " with encoding " + encoding); - } - } -} diff --git a/src/testcases/org/apache/tools/ant/util/ResourceUtilsTest.java b/src/testcases/org/apache/tools/ant/util/ResourceUtilsTest.java deleted file mode 100644 index 072718c44..000000000 --- a/src/testcases/org/apache/tools/ant/util/ResourceUtilsTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import junit.framework.TestCase; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.taskdefs.Echo; -import org.apache.tools.ant.types.Resource; -import org.apache.tools.ant.types.ResourceFactory; - -/** - * Tests for org.apache.tools.ant.util.ResourceUtils. - */ -public class ResourceUtilsTest extends TestCase - implements ResourceFactory, FileNameMapper { - - private Echo taskINeedForLogging = new Echo(); - - public ResourceUtilsTest(String name) { - super(name); - taskINeedForLogging.setProject(new Project()); - } - - public void testNoDuplicates() { - Resource r = new Resource("samual vimes", true, 1, false); - Resource[] toNew = - ResourceUtils.selectOutOfDateSources(taskINeedForLogging, - new Resource[] {r}, - this, this); - assertEquals(1, toNew.length); - } - - /* ============ ResourceFactory interface ====================== */ - public Resource getResource(String name) { - return new Resource(name); // implies lastModified == 0 - } - - /* ============ FileNameMapper interface ======================= */ - public void setFrom(String s) {} - public void setTo(String s) {} - public String[] mapFileName(String s) { - return new String[] {"fred colon", "carrot ironfoundersson"}; - } -} diff --git a/src/testcases/org/apache/tools/ant/util/StringUtilsTest.java b/src/testcases/org/apache/tools/ant/util/StringUtilsTest.java deleted file mode 100644 index 5f934e590..000000000 --- a/src/testcases/org/apache/tools/ant/util/StringUtilsTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import java.util.Vector; - -import junit.framework.TestCase; - -/** - * Test for StringUtils - */ -public class StringUtilsTest extends TestCase { - public StringUtilsTest(String s) { - super(s); - } - - public void testSplit(){ - final String data = "a,b,,"; - Vector res = StringUtils.split(data, ','); - assertEquals(4, res.size()); - assertEquals("a", res.elementAt(0)); - assertEquals("b", res.elementAt(1)); - assertEquals("", res.elementAt(2)); - assertEquals("", res.elementAt(3)); - } - - public void testSplitLines(){ - final String data = "a\r\nb\nc\nd\ne"; - Vector res = StringUtils.lineSplit(data); - assertEquals(5, res.size()); - assertEquals("a\r", res.elementAt(0)); - assertEquals("b", res.elementAt(1)); - assertEquals("c", res.elementAt(2)); - assertEquals("d", res.elementAt(3)); - assertEquals("e", res.elementAt(4)); - } - - public void testReplace() { - final String data = "abcabcabca"; - String res = StringUtils.replace(data, "a", ""); - assertEquals("bcbcbc", res); - } - - public void testEndsWithBothEmpty() { - assertTrue( StringUtils.endsWith( new StringBuffer(), "") ); - } - - public void testEndsWithEmptyString() { - assertTrue( StringUtils.endsWith( new StringBuffer("12234545"), "") ); - } - - public void testEndsWithShorterString() { - assertTrue( StringUtils.endsWith( new StringBuffer("12345678"), "78")); - } - - public void testEndsWithSameString() { - assertTrue( StringUtils.endsWith( new StringBuffer("123"), "123")); - } - - public void testEndsWithLongerString() { - assertFalse( StringUtils.endsWith( new StringBuffer("12"), "1245")); - } - - public void testEndsWithNoMatch() { - assertFalse( StringUtils.endsWith( new StringBuffer("12345678"), "789")); - } - - public void testEndsWithEmptyBuffer() { - assertFalse( StringUtils.endsWith( new StringBuffer(""), "12345667") ); - } - - public void testEndsWithJDKPerf() { - StringBuffer buf = getFilledBuffer(1024*300, 'a'); - for (int i = 0; i < 1000; i++) { - assertTrue(buf.toString().endsWith("aa")); - } - } - - public void testEndsWithPerf() { - StringBuffer buf = getFilledBuffer(1024*300, 'a'); - for (int i = 0; i < 1000; i++) { - assertTrue(StringUtils.endsWith(buf, "aa")); - } - } - - private StringBuffer getFilledBuffer(int size, char ch) { - StringBuffer buf = new StringBuffer(size); - for (int i = 0; i < size; i++) { buf.append(ch); }; - return buf; - } -} diff --git a/src/testcases/org/apache/tools/ant/util/UnPackageNameMapperTest.java b/src/testcases/org/apache/tools/ant/util/UnPackageNameMapperTest.java deleted file mode 100644 index c78e1d351..000000000 --- a/src/testcases/org/apache/tools/ant/util/UnPackageNameMapperTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.ant.util; - -import java.io.File; -import junit.framework.TestCase; - -public class UnPackageNameMapperTest extends TestCase { - public UnPackageNameMapperTest(String name) { super(name); } - - public void testMapping() { - UnPackageNameMapper mapper = new UnPackageNameMapper(); - mapper.setFrom("TEST-*.xml"); - mapper.setTo("*.java"); - String file ="TEST-org.apache.tools.ant.util.UnPackageNameMapperTest.xml"; - String result = mapper.mapFileName(file)[0]; - String expected = fixupPath("org/apache/tools/ant/util/UnPackageNameMapperTest.java"); - - assertEquals(expected, result); - } - - private String fixupPath(String file) { - return file.replace('/', File.separatorChar); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/XMLFragmentTest.java b/src/testcases/org/apache/tools/ant/util/XMLFragmentTest.java deleted file mode 100644 index f139d605a..000000000 --- a/src/testcases/org/apache/tools/ant/util/XMLFragmentTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util; - -import org.apache.tools.ant.BuildFileTest; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class XMLFragmentTest extends BuildFileTest { - - public XMLFragmentTest(String name) { - super(name); - } - - public void setUp() { - configureProject("src/etc/testcases/types/xmlfragment.xml"); - } - - public void testNestedText() { - XMLFragment x = (XMLFragment) getProject().getReference("nested-text"); - assertNotNull(x); - Node n = x.getFragment(); - assertTrue("No attributes", !n.hasAttributes()); - NodeList nl = n.getChildNodes(); - assertEquals(1, nl.getLength()); - assertEquals(Node.TEXT_NODE, nl.item(0).getNodeType()); - assertEquals("foo", nl.item(0).getNodeValue()); - } - - public void testNestedChildren() { - XMLFragment x = - (XMLFragment) getProject().getReference("with-children"); - assertNotNull(x); - Node n = x.getFragment(); - assertTrue("No attributes", !n.hasAttributes()); - NodeList nl = n.getChildNodes(); - assertEquals(3, nl.getLength()); - - assertEquals(Node.ELEMENT_NODE, nl.item(0).getNodeType()); - Element child1 = (Element) nl.item(0); - assertEquals("child1", child1.getTagName()); - assertTrue(!child1.hasAttributes()); - NodeList nl2 = child1.getChildNodes(); - assertEquals(1, nl2.getLength()); - assertEquals(Node.TEXT_NODE, nl2.item(0).getNodeType()); - assertEquals("foo", nl2.item(0).getNodeValue()); - - assertEquals(Node.ELEMENT_NODE, nl.item(1).getNodeType()); - Element child2 = (Element) nl.item(1); - assertEquals("child2", child2.getTagName()); - assertTrue(child2.hasAttributes()); - nl2 = child2.getChildNodes(); - assertEquals(0, nl2.getLength()); - assertEquals("bar", child2.getAttribute("foo")); - - assertEquals(Node.ELEMENT_NODE, nl.item(2).getNodeType()); - Element child3 = (Element) nl.item(2); - assertEquals("child3", child3.getTagName()); - assertTrue(!child3.hasAttributes()); - nl2 = child3.getChildNodes(); - assertEquals(1, nl2.getLength()); - assertEquals(Node.ELEMENT_NODE, nl2.item(0).getNodeType()); - assertEquals("child4", ((Element) nl2.item(0)).getTagName()); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java b/src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java deleted file mode 100644 index f80b4d9af..000000000 --- a/src/testcases/org/apache/tools/ant/util/facade/FacadeTaskHelperTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.facade; - -import junit.framework.TestCase; - -/** - * @since Ant 1.5 - */ -public class FacadeTaskHelperTest extends TestCase { - - public FacadeTaskHelperTest(String name) { - super(name); - } - - public void testPrecedenceRules() { - FacadeTaskHelper fth = new FacadeTaskHelper("foo"); - assertEquals("foo", fth.getImplementation()); - - fth.setMagicValue("bar"); - assertEquals("bar", fth.getImplementation()); - - fth = new FacadeTaskHelper("foo", "bar"); - assertEquals("bar", fth.getImplementation()); - - fth = new FacadeTaskHelper("foo", null); - assertEquals("foo", fth.getImplementation()); - - fth = new FacadeTaskHelper("foo"); - fth.setMagicValue("bar"); - fth.setImplementation("baz"); - assertEquals("baz", fth.getImplementation()); - } - - public void testHasBeenSet() { - FacadeTaskHelper fth = new FacadeTaskHelper("foo"); - assertTrue("nothing set", !fth.hasBeenSet()); - fth.setMagicValue(null); - assertTrue("magic has not been set", !fth.hasBeenSet()); - fth.setMagicValue("foo"); - assertTrue("magic has been set", fth.hasBeenSet()); - fth.setMagicValue(null); - assertTrue(!fth.hasBeenSet()); - fth.setImplementation("baz"); - assertTrue("set explicitly", fth.hasBeenSet()); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java b/src/testcases/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java deleted file mode 100644 index e4e7a2ae5..000000000 --- a/src/testcases/org/apache/tools/ant/util/facade/ImplementationSpecificArgumentTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.facade; - -import junit.framework.TestCase; - -/** - * @since Ant 1.5 - */ -public class ImplementationSpecificArgumentTest extends TestCase { - - public ImplementationSpecificArgumentTest(String name) { - super(name); - } - - public void testDependsOnImplementation() { - ImplementationSpecificArgument ia = - new ImplementationSpecificArgument(); - ia.setLine("A B"); - String[] parts = ia.getParts(); - assertNotNull(parts); - assertEquals(2, parts.length); - assertEquals("A", parts[0]); - assertEquals("B", parts[1]); - - parts = ia.getParts(null); - assertNotNull(parts); - assertEquals(2, parts.length); - assertEquals("A", parts[0]); - assertEquals("B", parts[1]); - - ia.setImplementation("foo"); - parts = ia.getParts(null); - assertNotNull(parts); - assertEquals(0, parts.length); - - parts = ia.getParts("foo"); - assertNotNull(parts); - assertEquals(2, parts.length); - assertEquals("A", parts[0]); - assertEquals("B", parts[1]); - } -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java b/src/testcases/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java deleted file mode 100644 index d1405f4ad..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/JakartaOroMatcherTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -/** - * Tests for the jakarta-oro implementation of the RegexpMatcher interface. - * - */ -public class JakartaOroMatcherTest extends RegexpMatcherTest { - - public RegexpMatcher getImplementation() { - return new JakartaOroMatcher(); - } - - public JakartaOroMatcherTest(String name) { - super(name); - } - -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java b/src/testcases/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java deleted file mode 100644 index e869c62e1..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/JakartaOroRegexpTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -/** - * Tests for the jakarta-oro implementation of the Regexp interface. - * - */ -public class JakartaOroRegexpTest extends RegexpTest { - - public Regexp getRegexpImplementation() { - return new JakartaOroRegexp(); - } - - public JakartaOroRegexpTest(String name) { - super(name); - } - -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java b/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java deleted file mode 100644 index 3340b59cf..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpMatcherTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the jakarta-regexp implementation of the RegexpMatcher interface. - * - */ -public class JakartaRegexpMatcherTest extends RegexpMatcherTest { - - public RegexpMatcher getImplementation() { - return new JakartaRegexpMatcher(); - } - - public JakartaRegexpMatcherTest(String name) { - super(name); - } - - public void testWindowsLineSeparator2() throws IOException { - try { - super.testWindowsLineSeparator2(); - fail("Should trigger when this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e) { - } - } - - /** - * Fails for the same reason as "default" mode in doEndTest2. - */ - public void testUnixLineSeparator() throws IOException { - try { - super.testUnixLineSeparator(); - fail("Should trigger once this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e) { - } - } - - - /** - * Fails for "default" mode. - */ - protected void doEndTest2(String text) {} -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java b/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java deleted file mode 100644 index 078fbb1bd..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/JakartaRegexpRegexpTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the jakarta-regexp implementation of the Regexp interface. - * - */ -public class JakartaRegexpRegexpTest extends RegexpTest { - - public Regexp getRegexpImplementation() { - return new JakartaRegexpRegexp(); - } - - public JakartaRegexpRegexpTest(String name) { - super(name); - } - - public void testWindowsLineSeparator2() throws IOException { - try { - super.testWindowsLineSeparator2(); - fail("Should trigger when this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e){ - } - } - - /** - * Fails for the same reason as "default" mode in doEndTest2. - */ - public void testUnixLineSeparator() throws IOException { - try { - super.testUnixLineSeparator(); - fail("Should trigger once this bug is fixed. {@since 1.2}"); - } catch (AssertionFailedError e){ - } - } - - /** - * Fails for "default" mode. - */ - protected void doEndTest2(String text) {} -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java b/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java deleted file mode 100644 index c042e7157..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpMatcherTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the JDK 1.4 implementation of the RegexpMatcher interface. - * - */ -public class Jdk14RegexpMatcherTest extends RegexpMatcherTest { - - public RegexpMatcher getImplementation() { - return new Jdk14RegexpMatcher(); - } - - public Jdk14RegexpMatcherTest(String name) { - super(name); - } - - public void testParagraphCharacter() throws IOException { - try { - super.testParagraphCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testLineSeparatorCharacter() throws IOException { - try { - super.testLineSeparatorCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testStandaloneCR() throws IOException { - try { - super.testStandaloneCR(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testWindowsLineSeparator() throws IOException { - try { - super.testWindowsLineSeparator(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java b/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java deleted file mode 100644 index 2b60406a3..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/Jdk14RegexpRegexpTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -import java.io.IOException; - -import junit.framework.AssertionFailedError; - -/** - * Tests for the JDK 1.4 implementation of the Regexp interface. - * - */ -public class Jdk14RegexpRegexpTest extends RegexpTest { - - public Regexp getRegexpImplementation() { - return new Jdk14RegexpRegexp(); - } - - public Jdk14RegexpRegexpTest(String name) { - super(name); - } - - public void testParagraphCharacter() throws IOException { - try { - super.testParagraphCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testLineSeparatorCharacter() throws IOException { - try { - super.testLineSeparatorCharacter(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testStandaloneCR() throws IOException { - try { - super.testStandaloneCR(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - - public void testWindowsLineSeparator() throws IOException { - try { - super.testWindowsLineSeparator(); - fail("Should trigger once fixed. {@since JDK 1.4RC1}"); - } catch (AssertionFailedError e){ - } - } - -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java b/src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java deleted file mode 100644 index 095082740..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/RegexpMatcherTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -import java.io.IOException; -import java.util.Vector; - -import junit.framework.TestCase; - -/** - * Tests for all implementations of the RegexpMatcher interface. - * - */ -public abstract class RegexpMatcherTest extends TestCase { - - public final static String UNIX_LINE = "\n"; - - private RegexpMatcher reg; - - public abstract RegexpMatcher getImplementation(); - - protected final RegexpMatcher getReg() {return reg;} - - public RegexpMatcherTest(String name) { - super(name); - } - - public void setUp() { - reg = getImplementation(); - } - - public void testMatches() { - reg.setPattern("aaaa"); - assertTrue("aaaa should match itself", reg.matches("aaaa")); - assertTrue("aaaa should match xaaaa", reg.matches("xaaaa")); - assertTrue("aaaa shouldn\'t match xaaa", !reg.matches("xaaa")); - reg.setPattern("^aaaa"); - assertTrue("^aaaa shouldn\'t match xaaaa", !reg.matches("xaaaa")); - assertTrue("^aaaa should match aaaax", reg.matches("aaaax")); - reg.setPattern("aaaa$"); - assertTrue("aaaa$ shouldn\'t match aaaax", !reg.matches("aaaax")); - assertTrue("aaaa$ should match xaaaa", reg.matches("xaaaa")); - reg.setPattern("[0-9]+"); - assertTrue("[0-9]+ should match 123", reg.matches("123")); - assertTrue("[0-9]+ should match 1", reg.matches("1")); - assertTrue("[0-9]+ shouldn\'t match \'\'", !reg.matches("")); - assertTrue("[0-9]+ shouldn\'t match a", !reg.matches("a")); - reg.setPattern("[0-9]*"); - assertTrue("[0-9]* should match 123", reg.matches("123")); - assertTrue("[0-9]* should match 1", reg.matches("1")); - assertTrue("[0-9]* should match \'\'", reg.matches("")); - assertTrue("[0-9]* should match a", reg.matches("a")); - reg.setPattern("([0-9]+)=\\1"); - assertTrue("([0-9]+)=\\1 should match 1=1", reg.matches("1=1")); - assertTrue("([0-9]+)=\\1 shouldn\'t match 1=2", !reg.matches("1=2")); - } - - public void testGroups() { - reg.setPattern("aaaa"); - Vector v = reg.getGroups("xaaaa"); - assertEquals("No parens -> no extra groups", 1, v.size()); - assertEquals("Trivial match with no parens", "aaaa", - (String) v.elementAt(0)); - - reg.setPattern("(aaaa)"); - v = reg.getGroups("xaaaa"); - assertEquals("Trivial match with single paren", 2, v.size()); - assertEquals("Trivial match with single paren, full match", "aaaa", - (String) v.elementAt(0)); - assertEquals("Trivial match with single paren, matched paren", "aaaa", - (String) v.elementAt(0)); - - reg.setPattern("(a+)b(b+)"); - v = reg.getGroups("xaabb"); - assertEquals(3, v.size()); - assertEquals("aabb", (String) v.elementAt(0)); - assertEquals("aa", (String) v.elementAt(1)); - assertEquals("b", (String) v.elementAt(2)); - } - - public void testBugzillaReport14619() { - reg.setPattern("^(.*)/src/((.*/)*)([a-zA-Z0-9_\\.]+)\\.java$"); - Vector v = reg.getGroups("de/tom/src/Google.java"); - assertEquals(5, v.size()); - assertEquals("de/tom", v.elementAt(1)); - assertEquals("", v.elementAt(2)); - assertEquals("", v.elementAt(3)); - assertEquals("Google", v.elementAt(4)); - } - - public void testCaseInsensitiveMatch() { - reg.setPattern("aaaa"); - assertTrue("aaaa doesn't match AAaa", !reg.matches("AAaa")); - assertTrue("aaaa matches AAaa ignoring case", - reg.matches("AAaa", RegexpMatcher.MATCH_CASE_INSENSITIVE)); - } - - -// make sure there are no issues concerning line separator interpretation -// a line separator for regex (perl) is always a unix line (ie \n) - - public void testParagraphCharacter() throws IOException { - reg.setPattern("end of text$"); - assertTrue("paragraph character", !reg.matches("end of text\u2029")); - } - - public void testLineSeparatorCharacter() throws IOException { - reg.setPattern("end of text$"); - assertTrue("line-separator character", !reg.matches("end of text\u2028")); - } - - public void testNextLineCharacter() throws IOException { - reg.setPattern("end of text$"); - assertTrue("next-line character", !reg.matches("end of text\u0085")); - } - - public void testStandaloneCR() throws IOException { - reg.setPattern("end of text$"); - assertTrue("standalone CR", !reg.matches("end of text\r")); - } - - public void testWindowsLineSeparator() throws IOException { - reg.setPattern("end of text$"); - assertTrue("Windows line separator", !reg.matches("end of text\r\n")); - } - - public void testWindowsLineSeparator2() throws IOException { - reg.setPattern("end of text\r$"); - assertTrue("Windows line separator", reg.matches("end of text\r\n")); - } - - public void testUnixLineSeparator() throws IOException { - reg.setPattern("end of text$"); - assertTrue("Unix line separator", reg.matches("end of text\n")); - } - - - public void testMultiVersusSingleLine() throws IOException { - StringBuffer buf = new StringBuffer(); - buf.append("Line1").append(UNIX_LINE); - buf.append("starttest Line2").append(UNIX_LINE); - buf.append("Line3 endtest").append(UNIX_LINE); - buf.append("Line4").append(UNIX_LINE); - String text = buf.toString(); - - doStartTest1(text); - doStartTest2(text); - doEndTest1(text); - doEndTest2(text); - } - - protected void doStartTest1(String text) { - reg.setPattern("^starttest"); - assertTrue("^starttest in default mode", !reg.matches(text)); - assertTrue("^starttest in single line mode", - !reg.matches(text, RegexpMatcher.MATCH_SINGLELINE)); - assertTrue("^starttest in multi line mode", - reg.matches(text, RegexpMatcher.MATCH_MULTILINE)); - } - - protected void doStartTest2(String text) { - reg.setPattern("^Line1"); - assertTrue("^Line1 in default mode", reg.matches(text)); - assertTrue("^Line1 in single line mode", - reg.matches(text, RegexpMatcher.MATCH_SINGLELINE)); - assertTrue("^Line1 in multi line mode", - reg.matches(text, RegexpMatcher.MATCH_MULTILINE)); - } - - protected void doEndTest1(String text) { - reg.setPattern("endtest$"); - assertTrue("endtest$ in default mode", !reg.matches(text)); - assertTrue("endtest$ in single line mode", - !reg.matches(text, RegexpMatcher.MATCH_SINGLELINE)); - assertTrue("endtest$ in multi line mode", - reg.matches(text, RegexpMatcher.MATCH_MULTILINE)); - } - - protected void doEndTest2(String text) { - reg.setPattern("Line4$"); - assertTrue("Line4$ in default mode", reg.matches(text)); - assertTrue("Line4$ in single line mode", - reg.matches(text, RegexpMatcher.MATCH_SINGLELINE)); - assertTrue("Line4$ in multi line mode", - reg.matches(text, RegexpMatcher.MATCH_MULTILINE)); - } - -} diff --git a/src/testcases/org/apache/tools/ant/util/regexp/RegexpTest.java b/src/testcases/org/apache/tools/ant/util/regexp/RegexpTest.java deleted file mode 100644 index 5cfe8c976..000000000 --- a/src/testcases/org/apache/tools/ant/util/regexp/RegexpTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.ant.util.regexp; - -/** - * Tests for all implementations of the Regexp interface. - * - */ -public abstract class RegexpTest extends RegexpMatcherTest { - - private static final String test = "abcdefg-abcdefg"; - private static final String pattern = "ab([^d]*)d([^f]*)f"; - - public RegexpTest(String name) { - super(name); - } - - public final RegexpMatcher getImplementation() { - return getRegexpImplementation(); - } - - public abstract Regexp getRegexpImplementation(); - - public void testSubstitution() { - Regexp reg = (Regexp) getReg(); - reg.setPattern(pattern); - assertTrue(reg.matches(test)); - assertEquals("abedcfg-abcdefg", reg.substitute(test, "ab\\2d\\1f", - Regexp.MATCH_DEFAULT)); - } - - public void testReplaceFirstSubstitution() { - Regexp reg = (Regexp) getReg(); - reg.setPattern(pattern); - assertTrue(reg.matches(test)); - assertEquals("abedcfg-abcdefg", reg.substitute(test, "ab\\2d\\1f", - Regexp.REPLACE_FIRST)); - } - - public void testReplaceAllSubstitution() { - Regexp reg = (Regexp) getReg(); - reg.setPattern(pattern); - assertTrue(reg.matches(test)); - assertEquals("abedcfg-abedcfg", reg.substitute(test, "ab\\2d\\1f", - Regexp.REPLACE_ALL)); - } -} diff --git a/src/testcases/org/apache/tools/mail/MailMessageTest.java b/src/testcases/org/apache/tools/mail/MailMessageTest.java deleted file mode 100644 index a8e75308f..000000000 --- a/src/testcases/org/apache/tools/mail/MailMessageTest.java +++ /dev/null @@ -1,734 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.mail; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.net.InetAddress; -import java.net.Socket; -import java.net.ServerSocket; -import java.util.Enumeration; -import java.util.Vector; - -import org.apache.tools.mail.MailMessage; - -import junit.framework.TestCase; - -/** - * JUnit 3 testcases for org.apache.tools.mail.MailMessage. - * - * @since Ant 1.6 - */ -public class MailMessageTest extends TestCase { - - // 27224 = magic (a random port which is unlikely to be in use) - private static int TEST_PORT = 27224; - - private String local = null; - - public MailMessageTest(String name) { - super(name); - } - - public void setUp() { - try { - local = InetAddress.getLocalHost().getHostName(); - } catch (java.net.UnknownHostException uhe) { - // ignore - } - } - - /** - * Test an example that is similar to the one given in the API - * If this testcase takes >90s to complete, it is very likely that - * the two threads are blocked waiting for each other and Thread.join() - * timed out. - */ - public void testAPIExample() { - - ServerThread testMailServer = new ServerThread(); - Thread server = new Thread(testMailServer); - server.start(); - - ClientThread testMailClient = new ClientThread(); - - testMailClient.from("Mail Message "); - testMailClient.to("to@you.com"); - testMailClient.cc("cc1@you.com"); - testMailClient.cc("cc2@you.com"); - testMailClient.bcc("bcc@you.com"); - testMailClient.setSubject("Test subject"); - testMailClient.setMessage( "test line 1\n" + - "test line 2" ); - - Thread client = new Thread(testMailClient); - client.start(); - - try { - server.join(60 * 1000); // 60s - client.join(30 * 1000); // a further 30s - } catch (InterruptedException ie ) { - fail( "InterruptedException: " + ie ); - } - - String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "Cc: cc1@you.com, cc2@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; - for (int icounter = 0; icounterresult.length()) { - System.out.println("excedent of expected result " - + expectedResult.substring(result.length())); - } - if (expectedResult.length()"); - testMailClient.to("to@you.com"); - testMailClient.setSubject("Test subject"); - testMailClient.setMessage( "test line 1\n" + - "test line 2" ); - - Thread client = new Thread(testMailClient); - client.start(); - - try { - server.join(60 * 1000); // 60s - client.join(30 * 1000); // a further 30s - } catch (InterruptedException ie ) { - fail("InterruptedException: " + ie); - } - - String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; - assertEquals(expectedResult.length(), result.length()); - assertEquals(expectedResult, result); // order of headers cannot be guaranteed - if (testMailClient.isFailed()) { - fail(testMailClient.getFailMessage()); - } - } - - - /** - * Test a MailMessage with no to or bcc lines - */ - public void testCcOnly() { - ServerThread testMailServer = new ServerThread(); - Thread server = new Thread(testMailServer); - server.start(); - - ClientThread testMailClient = new ClientThread(); - - testMailClient.from("Mail Message "); - testMailClient.cc("cc@you.com"); - testMailClient.setSubject("Test subject"); - testMailClient.setMessage( "test line 1\n" + - "test line 2" ); - - Thread client = new Thread(testMailClient); - client.start(); - - try { - server.join(60 * 1000); // 60s - client.join(30 * 1000); // a further 30s - } catch (InterruptedException ie ) { - fail( "InterruptedException: " + ie ); - } - - String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "Cc: cc@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; - assertEquals(expectedResult.length(), result.length()); - assertEquals(expectedResult, result); - if (testMailClient.isFailed()) { - fail(testMailClient.getFailMessage()); - } - } - - - /** - * Test a MailMessage with no to or cc lines - */ - public void testBccOnly() { - ServerThread testMailServer = new ServerThread(); - Thread server = new Thread(testMailServer); - server.start(); - - ClientThread testMailClient = new ClientThread(); - - testMailClient.from("Mail Message "); - testMailClient.bcc("bcc@you.com"); - testMailClient.setSubject("Test subject"); - testMailClient.setMessage( "test line 1\n" + - "test line 2" ); - - Thread client = new Thread(testMailClient); - client.start(); - - try { - server.join(60 * 1000); // 60s - client.join(30 * 1000); // a further 30s - } catch (InterruptedException ie ) { - fail( "InterruptedException: " + ie ); - } - - String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; - assertEquals( expectedResult.length(), result.length() ); - assertEquals( expectedResult, result ); - if ( testMailClient.isFailed() ) { - fail( testMailClient.getFailMessage() ); - } - } - - - /** - * Test a MailMessage with no subject line - * Subject is an optional field (RFC 822 s4.1) - */ - public void testNoSubject() { - ServerThread testMailServer = new ServerThread(); - Thread server = new Thread(testMailServer); - server.start(); - - ClientThread testMailClient = new ClientThread(); - - testMailClient.from("Mail Message "); - testMailClient.to("to@you.com"); - testMailClient.setMessage( "test line 1\n" + - "test line 2" ); - - Thread client = new Thread(testMailClient); - client.start(); - - try { - server.join(60 * 1000); // 60s - client.join(30 * 1000); // a further 30s - } catch (InterruptedException ie ) { - fail( "InterruptedException: " + ie ); - } - - String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "test line 1\r\n" + - "test line 2\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; - assertEquals( expectedResult.length(), result.length() ); - assertEquals( expectedResult, result ); - if ( testMailClient.isFailed() ) { - fail( testMailClient.getFailMessage() ); - } - } - - - /** - * Test a MailMessage with empty body message - */ - public void testEmptyBody() { - ServerThread testMailServer = new ServerThread(); - Thread server = new Thread(testMailServer); - server.start(); - - ClientThread testMailClient = new ClientThread(); - - testMailClient.from("Mail Message "); - testMailClient.to("to@you.com"); - testMailClient.setSubject("Test subject"); - testMailClient.setMessage(""); - - Thread client = new Thread(testMailClient); - client.start(); - - try { - server.join(60 * 1000); // 60s - client.join(30 * 1000); // a further 30s - } catch (InterruptedException ie ) { - fail( "InterruptedException: " + ie ); - } - - String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: to@you.com\r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; - assertEquals(expectedResult.length(), result.length()); - assertEquals(expectedResult, result); - if (testMailClient.isFailed()) { - fail(testMailClient.getFailMessage()); - } - } - - - /** - * Test a MailMessage with US-ASCII character set - * The next four testcase can be kinda hard to debug as Ant will often - * print the junit failure in US-ASCII. - */ - public void testAsciiCharset() { - - ServerThread testMailServer = new ServerThread(); - Thread server = new Thread(testMailServer); - server.start(); - - ClientThread testMailClient = new ClientThread(); - - testMailClient.from("Mail Message "); - testMailClient.to("Ceki G\u00fclc\u00fc "); - testMailClient.setSubject("Test subject"); - testMailClient.setMessage(""); - - Thread client = new Thread(testMailClient); - client.start(); - - try { - server.join(60 * 1000); // 60s - client.join(30 * 1000); // a further 30s - } catch (InterruptedException ie ) { - fail("InterruptedException: " + ie); - } - - String result = testMailServer.getResult(); - String expectedResult = "220 test SMTP EmailTaskTest\r\n" + - "HELO " + local + "\r\n" + - "250 " + local + " Hello " + local + " [127.0.0.1], pleased to meet you\r\n" + - "MAIL FROM: \r\n" + - "250\r\n" + - "RCPT TO: \r\n" + - "250\r\n" + - "DATA\r\n" + - "354\r\n" + - "Subject: Test subject\r\n" + - "From: Mail Message \r\n" + - "To: Ceki G\u00fclc\u00fc \r\n" + - "X-Mailer: org.apache.tools.mail.MailMessage (ant.apache.org)\r\n" + - "\r\n" + - "\r\n" + - "\r\n" + - ".\r\n" + - "250\r\n" + - "QUIT\r\n" + - "221\r\n"; - ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - PrintStream bos1 = new PrintStream(baos1, true); - PrintStream bos2 = new PrintStream(baos2, true); - - bos1.print(expectedResult); - bos2.print(result); - - assertEquals( "expected message length != actual message length " - + "in testAsciiCharset()", expectedResult.length(), result.length() ); - assertEquals( "baos1 and baos2 should be the same in testAsciiCharset()", - baos1.toString(), baos2.toString() ); // order of headers cannot be guaranteed - if (testMailClient.isFailed()) { - fail(testMailClient.getFailMessage()); - } - } - - - - - /** - * A private test class that pretends to be a mail transfer agent - */ - private class ServerThread implements Runnable { - - private StringBuffer sb = null; - private boolean loop = false; - ServerSocket ssock = null; - Socket sock = null; - BufferedWriter out = null; - BufferedReader in = null; - private boolean data = false; // state engine: false=envelope, true=message - - public void run() { - - try { - ssock = new ServerSocket(TEST_PORT); - sock = ssock.accept(); // wait for connection - in = new BufferedReader( new InputStreamReader( - sock.getInputStream()) ); - out = new BufferedWriter( new OutputStreamWriter( - sock.getOutputStream() ) ); - sb = new StringBuffer(); - send( "220 test SMTP EmailTaskTest\r\n" ); - loop = true; - while ( loop ) { - String response = in.readLine(); - if ( response == null ) { - loop = false; - break; - } - sb.append( response + "\r\n" ); - - if ( !data && response.startsWith( "HELO" ) ) { - send( "250 " + local + " Hello " + local + " " + - "[127.0.0.1], pleased to meet you\r\n" ); - } else if ( !data && response.startsWith("MAIL") ) { - send( "250\r\n" ); - } else if ( !data && response.startsWith("RCPT")) { - send( "250\r\n" ); - } else if (!data && response.startsWith("DATA")) { - send( "354\r\n" ); - data = true; - } else if (data && response.equals(".") ) { - send( "250\r\n" ); - data = false; - } else if (!data && response.startsWith("QUIT")) { - send( "221\r\n" ); - loop = false; - } else if (!data) { - //throw new IllegalStateException("Command unrecognized: " - // + response); - send( "500 5.5.1 Command unrecognized: \"" + - response + "\"\r\n" ); - loop = false; - } else { - // sb.append( response + "\r\n" ); - } - - } // while - } catch (IOException ioe) { - fail(); - } finally { - disconnect(); - } - } - - private void send(String retmsg) throws IOException { - out.write( retmsg ); - out.flush(); - sb.append( retmsg ); - } - - private void disconnect() { - if (out != null) { - try { - out.flush(); - out.close(); - out = null; - } catch (IOException e) { - // ignore - } - } - if (in != null) { - try { - in.close(); - in = null; - } catch (IOException e) { - // ignore - } - } - if (sock != null) { - try { - sock.close(); - sock = null; - } catch (IOException e) { - // ignore - } - } - if (ssock != null) { - try { - ssock.close(); - ssock = null; - } catch (IOException e) { - // ignore - } - } - } - - public synchronized String getResult() { - loop = false; - return sb.toString(); - } - - } - - /** - * A private test class that wraps MailMessage - */ - private class ClientThread implements Runnable { - - private MailMessage msg; - private boolean fail = false; - private String failMessage = null; - - protected String from = null; - protected String subject = null; - protected String message = null; - - protected Vector replyToList = new Vector(); - protected Vector toList = new Vector(); - protected Vector ccList = new Vector(); - protected Vector bccList = new Vector(); - - - public void run() { - for (int i = 9; i > 0; i--) { - try { - msg = new MailMessage("localhost", TEST_PORT); - } catch (java.net.ConnectException ce) { - try { - Thread.sleep(10 * 1000); - } catch (InterruptedException ie) { - // ignore - } - } catch (IOException ioe) { - fail = true; - failMessage = "IOException: " + ioe; - return; - } - if (msg != null) { - break; - } - } - - if (msg == null) { - fail = true; - failMessage = "java.net.ConnectException: Connection refused"; - return; - } - - try { - msg.from(from); - - Enumeration e; - - e = replyToList.elements(); - while (e.hasMoreElements()) { - msg.replyto(e.nextElement().toString()); - } - - e = toList.elements(); - while (e.hasMoreElements()) { - msg.to(e.nextElement().toString()); - } - - e = ccList.elements(); - while (e.hasMoreElements()) { - msg.cc(e.nextElement().toString()); - } - - e = bccList.elements(); - while (e.hasMoreElements()) { - msg.bcc(e.nextElement().toString()); - } - - if (subject != null) { - msg.setSubject(subject); - } - - if (message != null ) { - PrintStream out = msg.getPrintStream(); - out.println( message ); - } - - msg.sendAndClose(); - } catch (IOException ioe) { - fail = true; - failMessage = "IOException: " + ioe; - return; - } - } - - public boolean isFailed() { - return fail; - } - - public String getFailMessage() { - return failMessage; - } - - public void replyTo(String replyTo) { - replyToList.add(replyTo); - } - - public void to(String to) { - toList.add(to); - } - - public void cc(String cc) { - ccList.add(cc); - } - - public void bcc(String bcc) { - bccList.add(bcc); - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public void from(String from) { - this.from = from; - } - - public void setMessage(String message) { - this.message = message; - } - - } - -} diff --git a/src/testcases/org/apache/tools/tar/TarEntryTest.java b/src/testcases/org/apache/tools/tar/TarEntryTest.java deleted file mode 100644 index 23f4185ec..000000000 --- a/src/testcases/org/apache/tools/tar/TarEntryTest.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.tar; - -import junit.framework.TestCase; - -/** - * @since Ant 1.6 - */ -public class TarEntryTest extends TestCase { - - public TarEntryTest(String name) { - super(name); - } - - /** - * demonstrates bug 18105 on OSes with os.name shorter than 7. - */ - public void testFileConstructor() { - new TarEntry(new java.io.File("/foo")); - } -} diff --git a/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java b/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java deleted file mode 100644 index be5311af8..000000000 --- a/src/testcases/org/apache/tools/tar/TarOutputStreamTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.tar; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import junit.framework.TestCase; - -public class TarOutputStreamTest extends TestCase { - - public void testClose() throws IOException { - ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); - TarOutputStream stream = new TarOutputStream(byteStream); - stream.close(); - stream.close(); - } -} diff --git a/src/testcases/org/apache/tools/tar/TarRoundTripTest.java b/src/testcases/org/apache/tools/tar/TarRoundTripTest.java deleted file mode 100644 index 6df0de845..000000000 --- a/src/testcases/org/apache/tools/tar/TarRoundTripTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.apache.tools.tar; - -import java.io.IOException; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import junit.framework.TestCase; - -public class TarRoundTripTest extends TestCase { - - private static final String LONG_NAME - = "this/path/name/contains/more/than/one/hundred/characters/in/order/" - + "to/test/the/GNU/long/file/name/capability/round/tripped"; - - public TarRoundTripTest(String name) { - super(name); - } - - /** - * test round-tripping long (GNU) entries - */ - public void testLongRoundTripping() throws IOException { - TarEntry original = new TarEntry(LONG_NAME); - assertEquals("over 100 chars", true, LONG_NAME.length() > 100); - assertEquals("original name", LONG_NAME, original.getName()); - - - ByteArrayOutputStream buff = new ByteArrayOutputStream(); - TarOutputStream tos = new TarOutputStream(buff); - tos.setLongFileMode(TarOutputStream.LONGFILE_GNU); - tos.putNextEntry(original); - tos.closeEntry(); - tos.close(); - - TarInputStream tis - = new TarInputStream(new ByteArrayInputStream(buff.toByteArray())); - TarEntry tripped = tis.getNextEntry(); - assertEquals("round-tripped name", LONG_NAME, tripped.getName()); - assertNull("no more entries", tis.getNextEntry()); - tis.close(); - } -} - - diff --git a/src/testcases/org/apache/tools/zip/AsiExtraFieldTest.java b/src/testcases/org/apache/tools/zip/AsiExtraFieldTest.java deleted file mode 100644 index c8e4fe418..000000000 --- a/src/testcases/org/apache/tools/zip/AsiExtraFieldTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.zip; - -import junit.framework.TestCase; - -/** - * JUnit 3 testcases for org.apache.tools.zip.AsiExtraField. - * - */ -public class AsiExtraFieldTest extends TestCase implements UnixStat { - public AsiExtraFieldTest(String name) { - super(name); - } - - /** - * Test file mode magic. - */ - public void testModes() { - AsiExtraField a = new AsiExtraField(); - a.setMode(0123); - assertEquals("plain file", 0100123, a.getMode()); - a.setDirectory(true); - assertEquals("directory", 040123, a.getMode()); - a.setLinkedFile("test"); - assertEquals("symbolic link", 0120123, a.getMode()); - } - - /** - * Test content. - */ - public void testContent() { - AsiExtraField a = new AsiExtraField(); - a.setMode(0123); - a.setUserId(5); - a.setGroupId(6); - byte[] b = a.getLocalFileDataData(); - - // CRC manually calculated, sorry - byte[] expect = {(byte)0xC6, 0x02, 0x78, (byte)0xB6, // CRC - 0123, (byte)0x80, // mode - 0, 0, 0, 0, // link length - 5, 0, 6, 0}; // uid, gid - assertEquals("no link", expect.length, b.length); - for (int i=0; i> 16) & 0xFFFF); - assertEquals(0, ze.getExternalAttributes() & 0xFFFF); - - ze.setUnixMode(0444); - assertEquals(3, ze.getPlatform()); - assertEquals(0444, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(1, ze.getExternalAttributes() & 0xFFFF); - - ze = new ZipEntry("foo/"); - assertEquals(0, ze.getPlatform()); - ze.setUnixMode(0777); - assertEquals(3, ze.getPlatform()); - assertEquals(0777, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0x10, ze.getExternalAttributes() & 0xFFFF); - - ze.setUnixMode(0577); - assertEquals(3, ze.getPlatform()); - assertEquals(0577, - (ze.getExternalAttributes() >> 16) & 0xFFFF); - assertEquals(0x11, ze.getExternalAttributes() & 0xFFFF); - } - -} diff --git a/src/testcases/org/apache/tools/zip/ZipLongTest.java b/src/testcases/org/apache/tools/zip/ZipLongTest.java deleted file mode 100644 index e72aaaaef..000000000 --- a/src/testcases/org/apache/tools/zip/ZipLongTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.zip; - -import junit.framework.TestCase; - -/** - * JUnit 3 testcases for org.apache.tools.zip.ZipLong. - * - */ -public class ZipLongTest extends TestCase { - - public ZipLongTest(String name) { - super(name); - } - - /** - * Test conversion to bytes. - */ - public void testToBytes() { - ZipLong zl = new ZipLong(0x12345678); - byte[] result = zl.getBytes(); - assertEquals("length getBytes", 4, result.length); - assertEquals("first byte getBytes", 0x78, result[0]); - assertEquals("second byte getBytes", 0x56, result[1]); - assertEquals("third byte getBytes", 0x34, result[2]); - assertEquals("fourth byte getBytes", 0x12, result[3]); - } - - /** - * Test conversion from bytes. - */ - public void testFromBytes() { - byte[] val = new byte[] {0x78, 0x56, 0x34, 0x12}; - ZipLong zl = new ZipLong(val); - assertEquals("value from bytes", 0x12345678, zl.getValue()); - } - - /** - * Test the contract of the equals method. - */ - public void testEquals() { - ZipLong zl = new ZipLong(0x12345678); - ZipLong zl2 = new ZipLong(0x12345678); - ZipLong zl3 = new ZipLong(0x87654321); - - assertTrue("reflexive", zl.equals(zl)); - - assertTrue("works", zl.equals(zl2)); - assertTrue("works, part two", !zl.equals(zl3)); - - assertTrue("symmetric", zl2.equals(zl)); - - assertTrue("null handling", !zl.equals(null)); - assertTrue("non ZipLong handling", !zl.equals(new Integer(0x1234))); - } - - /** - * Test sign handling. - */ - public void testSign() { - ZipLong zl = new ZipLong(new byte[] {(byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}); - assertEquals(0x00000000FFFFFFFFl, zl.getValue()); - } - -} diff --git a/src/testcases/org/apache/tools/zip/ZipOutputStreamTest.java b/src/testcases/org/apache/tools/zip/ZipOutputStreamTest.java deleted file mode 100644 index 19b7c0591..000000000 --- a/src/testcases/org/apache/tools/zip/ZipOutputStreamTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.zip; - -import java.util.Calendar; -import java.util.Date; - -import junit.framework.TestCase; - -public class ZipOutputStreamTest extends TestCase { - - private Date time; - private ZipLong zl; - - /** - * Constructor - */ - public ZipOutputStreamTest(String name) { - super(name); - } - - protected void setUp() throws Exception { - time = new Date(); - Calendar cal = Calendar.getInstance(); - cal.setTime(time); - int year = cal.get(Calendar.YEAR); - int month = cal.get(Calendar.MONTH) + 1; - long value = ((year - 1980) << 25) - | (month << 21) - | (cal.get(Calendar.DAY_OF_MONTH) << 16) - | (cal.get(Calendar.HOUR_OF_DAY) << 11) - | (cal.get(Calendar.MINUTE) << 5) - | (cal.get(Calendar.SECOND) >> 1); - - byte[] result = new byte[4]; - result[0] = (byte) ((value & 0xFF)); - result[1] = (byte) ((value & 0xFF00) >> 8); - result[2] = (byte) ((value & 0xFF0000) >> 16); - result[3] = (byte) ((value & 0xFF000000L) >> 24); - zl = new ZipLong(result); - } - - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testZipLong() throws Exception { - ZipLong test = ZipOutputStream.toDosTime(time); - assertEquals(test.getValue(), zl.getValue()); - } - - public void testAdjustToLong() { - assertEquals((long) Integer.MAX_VALUE, - ZipOutputStream.adjustToLong(Integer.MAX_VALUE)); - assertEquals(((long) Integer.MAX_VALUE) + 1, - ZipOutputStream.adjustToLong(Integer.MAX_VALUE + 1)); - assertEquals(2 * ((long) Integer.MAX_VALUE), - ZipOutputStream.adjustToLong(2 * Integer.MAX_VALUE)); - } - -} diff --git a/src/testcases/org/apache/tools/zip/ZipShortTest.java b/src/testcases/org/apache/tools/zip/ZipShortTest.java deleted file mode 100644 index 3fb604f7d..000000000 --- a/src/testcases/org/apache/tools/zip/ZipShortTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.apache.tools.zip; - -import junit.framework.TestCase; - -/** - * JUnit 3 testcases for org.apache.tools.zip.ZipShort. - * - */ -public class ZipShortTest extends TestCase { - - public ZipShortTest(String name) { - super(name); - } - - /** - * Test conversion to bytes. - */ - public void testToBytes() { - ZipShort zs = new ZipShort(0x1234); - byte[] result = zs.getBytes(); - assertEquals("length getBytes", 2, result.length); - assertEquals("first byte getBytes", 0x34, result[0]); - assertEquals("second byte getBytes", 0x12, result[1]); - } - - /** - * Test conversion from bytes. - */ - public void testFromBytes() { - byte[] val = new byte[] {0x34, 0x12}; - ZipShort zs = new ZipShort(val); - assertEquals("value from bytes", 0x1234, zs.getValue()); - } - - /** - * Test the contract of the equals method. - */ - public void testEquals() { - ZipShort zs = new ZipShort(0x1234); - ZipShort zs2 = new ZipShort(0x1234); - ZipShort zs3 = new ZipShort(0x5678); - - assertTrue("reflexive", zs.equals(zs)); - - assertTrue("works", zs.equals(zs2)); - assertTrue("works, part two", !zs.equals(zs3)); - - assertTrue("symmetric", zs2.equals(zs)); - - assertTrue("null handling", !zs.equals(null)); - assertTrue("non ZipShort handling", !zs.equals(new Integer(0x1234))); - } - - /** - * Test sign handling. - */ - public void testSign() { - ZipShort zs = new ZipShort(new byte[] {(byte)0xFF, (byte)0xFF}); - assertEquals(0x0000FFFF, zs.getValue()); - } - -} diff --git a/src/testcases/org/example/junit/Output.java b/src/testcases/org/example/junit/Output.java deleted file mode 100644 index a7135f7b3..000000000 --- a/src/testcases/org/example/junit/Output.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.example.junit; - -import junit.framework.TestCase; - -/** - * Not really a test of Ant but a test that is run by the test of the - * junit task. Confused? - * - * @since Ant 1.5 - */ -public class Output extends TestCase { - - public Output(String s) { - super(s); - } - - public void testOutput() { - System.out.println("foo"); - } -} diff --git a/src/testcases/org/example/junit/ThreadedOutput.java b/src/testcases/org/example/junit/ThreadedOutput.java deleted file mode 100644 index 91f462a21..000000000 --- a/src/testcases/org/example/junit/ThreadedOutput.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.example.junit; - -import junit.framework.TestCase; - -/** - * Not really a test of Ant but a test that is run by the test of the - * junit task. Confused? - * - * @since Ant 1.5 - */ -public class ThreadedOutput extends TestCase { - - public ThreadedOutput(String s) { - super(s); - } - - public void testOutput() throws InterruptedException { - Thread t = new Thread(new Runnable() { - public void run() { - System.out.println("foo"); - } - }); - t.start(); - t.join(); - } -} diff --git a/src/testcases/org/example/junit/XmlParserTest.java b/src/testcases/org/example/junit/XmlParserTest.java deleted file mode 100644 index ddc766dd1..000000000 --- a/src/testcases/org/example/junit/XmlParserTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ -package org.example.junit; - -import junit.framework.TestCase; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -/** - * created Aug 12, 2004 1:39:59 PM - */ - -public class XmlParserTest extends TestCase { - - public XmlParserTest(String s) { - super(s); - } - - public void testXercesIsPresent() throws SAXException { - XMLReader xerces; - xerces = XMLReaderFactory.createXMLReader( - "org.apache.xerces.parsers.SAXParser"); - assertNotNull(xerces); - } - - public void testXercesHandlesSchema() throws SAXException { - XMLReader xerces; - xerces = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser"); - xerces.setFeature("http://apache.org/xml/features/validation/schema", - true); - } - - public void testParserHandlesSchema() throws SAXException { - XMLReader xerces; - xerces = XMLReaderFactory.createXMLReader(); - xerces.setFeature("http://apache.org/xml/features/validation/schema", - true); - } - -} diff --git a/src/testcases/org/example/tasks/TaskdefTestContainerTask.java b/src/testcases/org/example/tasks/TaskdefTestContainerTask.java deleted file mode 100644 index a566d5c1f..000000000 --- a/src/testcases/org/example/tasks/TaskdefTestContainerTask.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.example.tasks; - -import org.apache.tools.ant.taskdefs.Sequential; - -public class TaskdefTestContainerTask extends Sequential { - public TaskdefTestContainerTask() {} -} diff --git a/src/testcases/org/example/tasks/TaskdefTestSimpleTask.java b/src/testcases/org/example/tasks/TaskdefTestSimpleTask.java deleted file mode 100644 index bce8cd503..000000000 --- a/src/testcases/org/example/tasks/TaskdefTestSimpleTask.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.example.tasks; - -import org.apache.tools.ant.Project; -import org.apache.tools.ant.Task; - -public class TaskdefTestSimpleTask extends Task { - - public class Echo { - Echo() {} - private String message = null; - public void setMessage(String s) {message = s;} - } - - public TaskdefTestSimpleTask() {} - - private Echo echo; - public Echo createEcho() { - echo = new Echo(); - return echo; - } - - public void execute() { - log("simpletask: "+echo.message, Project.MSG_INFO); - } - -} - diff --git a/src/testcases/org/example/tasks/antlib.xml b/src/testcases/org/example/tasks/antlib.xml deleted file mode 100644 index 593ed604c..000000000 --- a/src/testcases/org/example/tasks/antlib.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/testcases/org/example/tasks/antlib2.xml b/src/testcases/org/example/tasks/antlib2.xml deleted file mode 100644 index 593ed604c..000000000 --- a/src/testcases/org/example/tasks/antlib2.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/testcases/org/example/types/TypedefTestType.java b/src/testcases/org/example/types/TypedefTestType.java deleted file mode 100644 index 235b76f61..000000000 --- a/src/testcases/org/example/types/TypedefTestType.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package org.example.types; - -import org.apache.tools.ant.ProjectComponent; - -public class TypedefTestType extends ProjectComponent { -} -