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.

TarTest.java 4.5 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * Copyright 2000-2002,2004-2005 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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. */
  17. package org.apache.tools.ant.taskdefs;
  18. import java.io.IOException;
  19. import java.io.File;
  20. import org.apache.tools.ant.BuildFileTest;
  21. import org.apache.tools.ant.util.FileUtils;
  22. /**
  23. */
  24. public class TarTest extends BuildFileTest {
  25. public TarTest(String name) {
  26. super(name);
  27. }
  28. public void setUp() {
  29. configureProject("src/etc/testcases/taskdefs/tar.xml");
  30. }
  31. public void test1() {
  32. expectBuildException("test1", "required argument not specified");
  33. }
  34. public void test2() {
  35. expectBuildException("test2", "required argument not specified");
  36. }
  37. public void test3() {
  38. expectBuildException("test3", "required argument not specified");
  39. }
  40. public void test4() {
  41. expectBuildException("test4", "tar cannot include itself");
  42. }
  43. public void test5() {
  44. executeTarget("test5");
  45. File f
  46. = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test5.tar");
  47. if (!f.exists()) {
  48. fail("Tarring a directory failed");
  49. }
  50. }
  51. public void test6() {
  52. expectBuildException("test6", "Invalid value specified for longfile attribute.");
  53. }
  54. public void test7() {
  55. test7("test7");
  56. }
  57. public void test7UsingPlainFileSet() {
  58. test7("test7UsingPlainFileSet");
  59. }
  60. public void test7UsingFileList() {
  61. test7("test7UsingFileList");
  62. }
  63. private void test7(String target) {
  64. executeTarget(target);
  65. File f1
  66. = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test7-prefix");
  67. if (!(f1.exists() && f1.isDirectory())) {
  68. fail("The prefix attribute is not working properly.");
  69. }
  70. File f2
  71. = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test7dir");
  72. if (!(f2.exists() && f2.isDirectory())) {
  73. fail("The prefix attribute is not working properly.");
  74. }
  75. }
  76. public void test8() {
  77. test8("test8");
  78. }
  79. public void test8UsingZipFileset() {
  80. test8("test8UsingZipFileset");
  81. }
  82. public void test8UsingZipFilesetSrc() {
  83. test8("test8UsingZipFilesetSrc");
  84. }
  85. public void test8UsingTarFilesetSrc() {
  86. test8("test8UsingTarFilesetSrc");
  87. }
  88. public void test8UsingZipEntry() {
  89. test8("test8UsingZipEntry");
  90. }
  91. private void test8(String target) {
  92. executeTarget(target);
  93. File f1
  94. = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test8.xml");
  95. if (! f1.exists()) {
  96. fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
  97. }
  98. }
  99. public void test9() {
  100. expectBuildException("test9", "Invalid value specified for compression attribute.");
  101. }
  102. public void test10() {
  103. executeTarget("test10");
  104. File f1
  105. = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test10.xml");
  106. if (! f1.exists()) {
  107. fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
  108. }
  109. }
  110. public void test11() {
  111. executeTarget("test11");
  112. File f1
  113. = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/test11.xml");
  114. if (! f1.exists()) {
  115. fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
  116. }
  117. }
  118. public void testGZipResource() throws IOException {
  119. executeTarget("testGZipResource");
  120. assertTrue(FileUtils.getFileUtils()
  121. .contentEquals(getProject().resolveFile("../asf-logo.gif"),
  122. getProject().resolveFile("testout/asf-logo.gif.gz")));
  123. }
  124. public void tearDown() {
  125. executeTarget("cleanup");
  126. }
  127. }