001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018:
019: package org.apache.tools.ant.taskdefs;
020:
021: import java.io.IOException;
022: import java.io.File;
023: import org.apache.tools.ant.BuildFileTest;
024: import org.apache.tools.ant.util.FileUtils;
025:
026: /**
027: */
028: public class TarTest extends BuildFileTest {
029:
030: public TarTest(String name) {
031: super (name);
032: }
033:
034: public void setUp() {
035: configureProject("src/etc/testcases/taskdefs/tar.xml");
036: }
037:
038: public void test1() {
039: expectBuildException("test1", "required argument not specified");
040: }
041:
042: public void test2() {
043: expectBuildException("test2", "required argument not specified");
044: }
045:
046: public void test3() {
047: expectBuildException("test3", "required argument not specified");
048: }
049:
050: public void test4() {
051: expectBuildException("test4", "tar cannot include itself");
052: }
053:
054: public void test5() {
055: executeTarget("test5");
056: File f = new File(System.getProperty("root"),
057: "src/etc/testcases/taskdefs/test5.tar");
058:
059: if (!f.exists()) {
060: fail("Tarring a directory failed");
061: }
062: }
063:
064: public void test6() {
065: expectBuildException("test6",
066: "Invalid value specified for longfile attribute.");
067: }
068:
069: public void test7() {
070: test7("test7");
071: }
072:
073: public void test7UsingPlainFileSet() {
074: test7("test7UsingPlainFileSet");
075: }
076:
077: public void test7UsingFileList() {
078: test7("test7UsingFileList");
079: }
080:
081: private void test7(String target) {
082: executeTarget(target);
083: File f1 = new File(System.getProperty("root"),
084: "src/etc/testcases/taskdefs/test7-prefix");
085:
086: if (!(f1.exists() && f1.isDirectory())) {
087: fail("The prefix attribute is not working properly.");
088: }
089:
090: File f2 = new File(System.getProperty("root"),
091: "src/etc/testcases/taskdefs/test7dir");
092:
093: if (!(f2.exists() && f2.isDirectory())) {
094: fail("The prefix attribute is not working properly.");
095: }
096: }
097:
098: public void test8() {
099: test8("test8");
100: }
101:
102: public void test8UsingZipFileset() {
103: test8("test8UsingZipFileset");
104: }
105:
106: public void test8UsingZipFilesetSrc() {
107: test8("test8UsingZipFilesetSrc");
108: }
109:
110: public void test8UsingTarFilesetSrc() {
111: test8("test8UsingTarFilesetSrc");
112: }
113:
114: public void test8UsingZipEntry() {
115: test8("test8UsingZipEntry");
116: }
117:
118: private void test8(String target) {
119: executeTarget(target);
120: File f1 = new File(System.getProperty("root"),
121: "src/etc/testcases/taskdefs/test8.xml");
122: if (!f1.exists()) {
123: fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
124: }
125: }
126:
127: public void test9() {
128: expectBuildException("test9",
129: "Invalid value specified for compression attribute.");
130: }
131:
132: public void test10() {
133: executeTarget("test10");
134: File f1 = new File(System.getProperty("root"),
135: "src/etc/testcases/taskdefs/test10.xml");
136: if (!f1.exists()) {
137: fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
138: }
139: }
140:
141: public void test11() {
142: executeTarget("test11");
143: File f1 = new File(System.getProperty("root"),
144: "src/etc/testcases/taskdefs/test11.xml");
145: if (!f1.exists()) {
146: fail("The fullpath attribute or the preserveLeadingSlashes attribute does not work propertly");
147: }
148: }
149:
150: public void testGZipResource() throws IOException {
151: executeTarget("testGZipResource");
152: assertTrue(FileUtils.getFileUtils().contentEquals(
153: getProject().resolveFile("../asf-logo.gif"),
154: getProject().resolveFile("testout/asf-logo.gif.gz")));
155: }
156:
157: public void tearDown() {
158: executeTarget("cleanup");
159: }
160: }
|