KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 2003-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.DirectoryScanner;
22
23 /**
24  */

25 public class DefaultExcludesTest extends BuildFileTest {
26
27     public DefaultExcludesTest(String JavaDoc name) {
28         super(name);
29     }
30
31     public void setUp() {
32         configureProject("src/etc/testcases/taskdefs/defaultexcludes.xml");
33     }
34
35     public void tearDown() {
36         project.executeTarget("cleanup");
37     }
38
39     // Output the default excludes
40
public void test1() {
41         String JavaDoc[] expected = {
42                           "**/*~",
43                           "**/#*#",
44                           "**/.#*",
45                           "**/%*%",
46                           "**/._*",
47                           "**/CVS",
48                           "**/CVS/**",
49                           "**/.cvsignore",
50                           "**/SCCS",
51                           "**/SCCS/**",
52                           "**/vssver.scc",
53                           "**/.svn",
54                           "**/.svn/**",
55                           "**/.DS_Store"};
56         project.executeTarget("test1");
57         assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
58     }
59
60     // adding something to the excludes'
61
public void test2() {
62         String JavaDoc[] expected = {
63                           "**/*~",
64                           "**/#*#",
65                           "**/.#*",
66                           "**/%*%",
67                           "**/._*",
68                           "**/CVS",
69                           "**/CVS/**",
70                           "**/.cvsignore",
71                           "**/SCCS",
72                           "**/SCCS/**",
73                           "**/vssver.scc",
74                           "**/.svn",
75                           "**/.svn/**",
76                           "**/.DS_Store",
77                           "foo"};
78         project.executeTarget("test2");
79         assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
80     }
81
82     // removing something from the defaults
83
public void test3() {
84         String JavaDoc[] expected = {
85                           "**/*~",
86                           "**/#*#",
87                           "**/.#*",
88                           "**/%*%",
89                           "**/._*",
90                           //CVS missing
91
"**/CVS/**",
92                           "**/.cvsignore",
93                           "**/SCCS",
94                           "**/SCCS/**",
95                           "**/vssver.scc",
96                           "**/.svn",
97                           "**/.svn/**",
98                           "**/.DS_Store"};
99         project.executeTarget("test3");
100         assertEquals("current default excludes", expected, DirectoryScanner.getDefaultExcludes());
101     }
102     private void assertEquals(String JavaDoc message, String JavaDoc[] expected, String JavaDoc[] actual) {
103         // check that both arrays have the same size
104
assertEquals(message + " : string array length match", expected.length, actual.length);
105         for (int counter=0; counter <expected.length; counter++) {
106             assertEquals(message + " : " + counter + "th element in array match", expected[counter], actual[counter]);
107         }
108
109     }
110 }
111
Popular Tags