You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

zip-test.xml 4.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?xml version="1.0"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing, software
  11. distributed under the License is distributed on an "AS IS" BASIS,
  12. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. See the License for the specific language governing permissions and
  14. limitations under the License.
  15. -->
  16. <project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
  17. <import file="../antunit-base.xml" />
  18. <target name="testEmptyDirs">
  19. <mkdir dir="${input}/foo"/>
  20. <mkdir dir="${output}/bar"/>
  21. <zip destfile="${output}/test.zip">
  22. <fileset dir="${input}"/>
  23. </zip>
  24. <unzip src="${output}/test.zip" dest="${output}/bar"/>
  25. <au:assertFileExists file="${output}/bar/foo"/>
  26. </target>
  27. <target name="testMappedResources">
  28. <mkdir dir="${input}"/>
  29. <mkdir dir="${output}/out"/>
  30. <echo file="${input}/foo.txt">Hello, world!</echo>
  31. <zip destfile="${output}/test.zip">
  32. <mappedresources>
  33. <fileset dir="${input}"/>
  34. <globmapper from="foo.*" to="bar.*"/>
  35. </mappedresources>
  36. </zip>
  37. <unzip src="${output}/test.zip" dest="${output}/out"/>
  38. <au:assertFileDoesntExist file="${output}/out/foo.txt"/>
  39. <au:assertFileExists file="${output}/out/bar.txt"/>
  40. <au:assertFilesMatch expected="${input}/foo.txt"
  41. actual="${output}/out/bar.txt"/>
  42. </target>
  43. <target name="testMappedClasspath">
  44. <mkdir dir="${input}"/>
  45. <mkdir dir="${output}/out"/>
  46. <zip destfile="${output}/test.zip">
  47. <mappedresources>
  48. <path path="${java.class.path}"/>
  49. <chainedmapper>
  50. <flattenmapper/>
  51. <globmapper from="*" to="WEB-INF/lib/*"/>
  52. </chainedmapper>
  53. </mappedresources>
  54. </zip>
  55. <unzip src="${output}/test.zip" dest="${output}/out"/>
  56. <au:assertFileExists file="${output}/out/WEB-INF/lib/ant.jar"/>
  57. </target>
  58. <target name="testIssue45902"
  59. description="https://issues.apache.org/bugzilla/show_bug.cgi?id=45902">
  60. <mkdir dir="${input}/src/p"/>
  61. <mkdir dir="${output}"/>
  62. <touch file="${input}/src/p/X.java"/>
  63. <touch file="${input}/src/p/x.properties"/>
  64. <mkdir dir="${input}/build"/>
  65. <copy todir="${input}/build">
  66. <fileset dir="${input}/src" includes="**/*.java"/>
  67. </copy>
  68. <jar jarfile="${output}/jar.jar">
  69. <fileset dir="${input}/build"/>
  70. <fileset dir="${input}/src" excludes="**/*.java"/>
  71. </jar>
  72. <copy file="${output}/jar.jar" tofile="${output}/reference.jar"/>
  73. <sleep seconds="1"/>
  74. <touch file="${input}/src/p/y.properties"/>
  75. <sleep seconds="1"/>
  76. <delete file="${input}/src/p/y.properties"/>
  77. <jar jarfile="${output}/jar.jar">
  78. <fileset dir="${input}/build"/>
  79. <fileset dir="${input}/src" excludes="**/*.java"/>
  80. </jar>
  81. <au:assertDestIsUptodate src="${output}/jar.jar"
  82. dest="${output}/reference.jar"/>
  83. <sleep seconds="1"/>
  84. <jar jarfile="${output}/jar.jar">
  85. <fileset dir="${input}/build"/>
  86. <fileset dir="${input}/src" excludes="**/*.java"/>
  87. </jar>
  88. <au:assertDestIsUptodate src="${output}/jar.jar"
  89. dest="${output}/reference.jar"/>
  90. <jar jarfile="${output}/jar.jar">
  91. <fileset dir="${input}/build"/>
  92. <fileset dir="${input}/src" excludes="**/*.java"/>
  93. </jar>
  94. <au:assertDestIsUptodate src="${output}/jar.jar"
  95. dest="${output}/reference.jar"/>
  96. </target>
  97. <target name="testNewEmptyDirUpdatesArchive">
  98. <mkdir dir="${input}"/>
  99. <touch file="${input}/x"/>
  100. <mkdir dir="${output}"/>
  101. <jar jarfile="${output}/jar.jar">
  102. <fileset dir="${input}"/>
  103. </jar>
  104. <copy file="${output}/jar.jar" tofile="${output}/reference.jar"/>
  105. <mkdir dir="${input}/y"/>
  106. <sleep seconds="2"/>
  107. <jar jarfile="${output}/jar.jar">
  108. <fileset dir="${input}"/>
  109. </jar>
  110. <au:assertDestIsOutofdate src="${output}/jar.jar"
  111. dest="${output}/reference.jar"/>
  112. </target>
  113. </project>