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:
19: package org.apache.tools.ant.taskdefs;
20:
21: import org.apache.tools.ant.BuildFileTest;
22: import org.apache.tools.ant.DirectoryScanner;
23:
24: /**
25: */
26: public class DefaultExcludesTest extends BuildFileTest {
27:
28: public DefaultExcludesTest(String name) {
29: super (name);
30: }
31:
32: public void setUp() {
33: configureProject("src/etc/testcases/taskdefs/defaultexcludes.xml");
34: }
35:
36: public void tearDown() {
37: project.executeTarget("cleanup");
38: }
39:
40: // Output the default excludes
41: public void test1() {
42: String[] expected = { "**/*~", "**/#*#", "**/.#*", "**/%*%",
43: "**/._*", "**/CVS", "**/CVS/**", "**/.cvsignore",
44: "**/SCCS", "**/SCCS/**", "**/vssver.scc", "**/.svn",
45: "**/.svn/**", "**/.DS_Store" };
46: project.executeTarget("test1");
47: assertEquals("current default excludes", expected,
48: DirectoryScanner.getDefaultExcludes());
49: }
50:
51: // adding something to the excludes'
52: public void test2() {
53: String[] expected = { "**/*~", "**/#*#", "**/.#*", "**/%*%",
54: "**/._*", "**/CVS", "**/CVS/**", "**/.cvsignore",
55: "**/SCCS", "**/SCCS/**", "**/vssver.scc", "**/.svn",
56: "**/.svn/**", "**/.DS_Store", "foo" };
57: project.executeTarget("test2");
58: assertEquals("current default excludes", expected,
59: DirectoryScanner.getDefaultExcludes());
60: }
61:
62: // removing something from the defaults
63: public void test3() {
64: String[] expected = { "**/*~", "**/#*#", "**/.#*",
65: "**/%*%",
66: "**/._*",
67: //CVS missing
68: "**/CVS/**", "**/.cvsignore", "**/SCCS", "**/SCCS/**",
69: "**/vssver.scc", "**/.svn", "**/.svn/**",
70: "**/.DS_Store" };
71: project.executeTarget("test3");
72: assertEquals("current default excludes", expected,
73: DirectoryScanner.getDefaultExcludes());
74: }
75:
76: private void assertEquals(String message, String[] expected,
77: String[] actual) {
78: // check that both arrays have the same size
79: assertEquals(message + " : string array length match",
80: expected.length, actual.length);
81: for (int counter = 0; counter < expected.length; counter++) {
82: assertEquals(message + " : " + counter
83: + "th element in array match", expected[counter],
84: actual[counter]);
85: }
86:
87: }
88: }
|