KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > MoveTest


1 /*
2  * Copyright 2000-2004 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
18 package org.apache.tools.ant.taskdefs;
19
20 import org.apache.tools.ant.BuildFileTest;
21 import org.apache.tools.ant.Project;
22 import org.apache.tools.ant.util.FileUtils;
23 import java.io.File JavaDoc;
24 import java.io.IOException JavaDoc;
25
26 /**
27  * Tests the Move task.
28  *
29  */

30 public class MoveTest extends BuildFileTest {
31
32     public MoveTest(String JavaDoc name) {
33         super(name);
34     }
35
36     public void setUp() {
37         configureProject("src/etc/testcases/taskdefs/move.xml");
38     }
39
40     public void tearDown() {
41         executeTarget("cleanup");
42     }
43
44     public void testFilterSet() throws IOException JavaDoc {
45         executeTarget("testFilterSet");
46         FileUtils fileUtils = FileUtils.newFileUtils();
47         File JavaDoc tmp = new File JavaDoc(getProjectDir(), "move.filterset.tmp");
48         File JavaDoc check = new File JavaDoc(getProjectDir(), "expected/copy.filterset.filtered");
49         assertTrue(tmp.exists());
50         assertTrue(fileUtils.contentEquals(tmp, check));
51     }
52
53     public void testFilterChain() throws IOException JavaDoc {
54         executeTarget("testFilterChain");
55         FileUtils fileUtils = FileUtils.newFileUtils();
56         File JavaDoc tmp = new File JavaDoc(getProjectDir(), "move.filterchain.tmp");
57         File JavaDoc check = new File JavaDoc(getProjectDir(), "expected/copy.filterset.filtered");
58         assertTrue(tmp.exists());
59         assertTrue(fileUtils.contentEquals(tmp, check));
60     }
61
62     /** Bugzilla Report 11732 */
63     public void testDirectoryRemoval() throws IOException JavaDoc {
64         executeTarget("testDirectoryRemoval");
65         assertTrue(!getProject().resolveFile("E/B/1").exists());
66         assertTrue(getProject().resolveFile("E/C/2").exists());
67         assertTrue(getProject().resolveFile("E/D/3").exists());
68         assertTrue(getProject().resolveFile("A/B/1").exists());
69         assertTrue(!getProject().resolveFile("A/C/2").exists());
70         assertTrue(!getProject().resolveFile("A/D/3").exists());
71         assertTrue(!getProject().resolveFile("A/C").exists());
72         assertTrue(!getProject().resolveFile("A/D").exists());
73     }
74
75     /** Bugzilla Report 18886 */
76     public void testDirectoryRetaining() throws IOException JavaDoc {
77         executeTarget("testDirectoryRetaining");
78         assertTrue(getProject().resolveFile("E").exists());
79         assertTrue(getProject().resolveFile("E/1").exists());
80         assertTrue(!getProject().resolveFile("A/1").exists());
81         assertTrue(getProject().resolveFile("A").exists());
82     }
83
84     public void testCompleteDirectoryMove() throws IOException JavaDoc {
85         executeTarget("testCompleteDirectoryMove");
86         assertTrue(getProject().resolveFile("E").exists());
87         assertTrue(getProject().resolveFile("E/1").exists());
88         assertTrue(!getProject().resolveFile("A/1").exists());
89         assertTrue(!getProject().resolveFile("A").exists());
90     }
91
92     public void testMoveFileAndFileset() {
93         executeTarget("testMoveFileAndFileset");
94     }
95
96     public void testCompleteDirectoryMoveToExistingDir() {
97         executeTarget("testCompleteDirectoryMoveToExistingDir");
98     }
99
100     public void testCompleteDirectoryMoveFileToFile() {
101         executeTarget("testCompleteDirectoryMoveFileToFile");
102     }
103
104     public void testCompleteDirectoryMoveFileToDir() {
105         executeTarget("testCompleteDirectoryMoveFileToDir");
106     }
107
108     public void testCompleteDirectoryMoveFileAndFileset() {
109         executeTarget("testCompleteDirectoryMoveFileAndFileset");
110     }
111
112     public void testCompleteDirectoryMoveFileToExistingFile() {
113         executeTarget("testCompleteDirectoryMoveFileToExistingFile");
114     }
115
116     public void testCompleteDirectoryMoveFileToExistingDir() {
117         executeTarget("testCompleteDirectoryMoveFileToExistingDir");
118     }
119
120     public void testCompleteDirectoryMoveFileToDirWithExistingFile() {
121         executeTarget("testCompleteDirectoryMoveFileToDirWithExistingFile");
122     }
123
124     public void testCompleteDirectoryMoveFileToDirWithExistingDir() {
125         executeTarget("testCompleteDirectoryMoveFileToDirWithExistingDir");
126     }
127
128 }
129
Popular Tags