01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.tools.ant.taskdefs;
19:
20: import org.apache.tools.ant.BuildFileTest;
21: import org.apache.tools.ant.util.FileUtils;
22:
23: /**
24: */
25: public class UntarTest extends BuildFileTest {
26:
27: /** Utilities used for file operations */
28: private static final FileUtils FILE_UTILS = FileUtils
29: .getFileUtils();
30:
31: public UntarTest(String name) {
32: super (name);
33: }
34:
35: public void setUp() {
36: configureProject("src/etc/testcases/taskdefs/untar.xml");
37: }
38:
39: public void tearDown() {
40: executeTarget("cleanup");
41: }
42:
43: public void testRealTest() throws java.io.IOException {
44: testLogoExtraction("realTest");
45: }
46:
47: public void testRealGzipTest() throws java.io.IOException {
48: testLogoExtraction("realGzipTest");
49: }
50:
51: public void testRealBzip2Test() throws java.io.IOException {
52: testLogoExtraction("realBzip2Test");
53: }
54:
55: public void testTestTarTask() throws java.io.IOException {
56: testLogoExtraction("testTarTask");
57: }
58:
59: public void testTestGzipTarTask() throws java.io.IOException {
60: testLogoExtraction("testGzipTarTask");
61: }
62:
63: public void testTestBzip2TarTask() throws java.io.IOException {
64: testLogoExtraction("testBzip2TarTask");
65: }
66:
67: public void testSrcDirTest() {
68: expectBuildException("srcDirTest", "Src cannot be a directory.");
69: }
70:
71: public void testEncoding() {
72: expectSpecificBuildException("encoding",
73: "<untar> overrides setEncoding.",
74: "The untar task doesn't support the "
75: + "encoding attribute");
76: }
77:
78: public void testResourceCollection() throws java.io.IOException {
79: testLogoExtraction("resourceCollection");
80: }
81:
82: private void testLogoExtraction(String target)
83: throws java.io.IOException {
84: executeTarget(target);
85: assertTrue(FILE_UTILS.contentEquals(project
86: .resolveFile("../asf-logo.gif"), project
87: .resolveFile("asf-logo.gif")));
88: }
89:
90: public void testDocumentationClaimsOnCopy() {
91: executeTarget("testDocumentationClaimsOnCopy");
92: assertFalse(getProject().resolveFile("untartestout/1/foo")
93: .exists());
94: assertTrue(getProject().resolveFile("untartestout/2/bar")
95: .exists());
96: }
97: }
|