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.types.selectors;
20:
21: import java.io.File;
22:
23: import junit.framework.TestCase;
24:
25: import org.apache.tools.ant.BuildFileTest;
26: import org.apache.tools.ant.Project;
27:
28: public class ContainsRegexpTest extends TestCase {
29:
30: private Project project;
31:
32: public ContainsRegexpTest(String name) {
33: super (name);
34: }
35:
36: public void setUp() {
37: project = new Project();
38: project.setBasedir(".");
39: }
40:
41: public void testContainsRegexp() {
42: TaskdefForRegexpTest MyTask = new TaskdefForRegexpTest(
43: "containsregexp");
44: try {
45: MyTask.setUp();
46: MyTask.test();
47: } finally {
48: MyTask.tearDown();
49: }
50: }
51:
52: private class TaskdefForRegexpTest extends BuildFileTest {
53: TaskdefForRegexpTest(String name) {
54: super (name);
55: }
56:
57: public void setUp() {
58: configureProject("src/etc/testcases/types/selectors.xml");
59: }
60:
61: public void tearDown() {
62: executeTarget("cleanupregexp");
63: }
64:
65: public void test() {
66: File dir = null;
67: File[] files = null;
68: int filecount;
69:
70: executeTarget("containsregexp");
71:
72: dir = new File(getProjectDir() + "/regexpseltestdest/");
73: files = dir.listFiles();
74: filecount = files.length;
75:
76: if (filecount != 1)
77: assertEquals(
78: "ContainsRegexp test should have copied 1 file",
79: 1, files.length);
80:
81: }
82: }
83: }
|