KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > types > DirSetTest


1 /*
2  * Copyright 2002,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.types;
19
20 import org.apache.tools.ant.BuildException;
21
22 /**
23  * JUnit 3 testcases for org.apache.tools.ant.types.DirSet.
24  *
25  */

26 public class DirSetTest extends AbstractFileSetTest {
27
28     public DirSetTest(String JavaDoc name) {
29         super(name);
30     }
31
32     protected AbstractFileSet getInstance() {
33         return new DirSet();
34     }
35
36     public void testFileSetIsNoDirSet() {
37         DirSet ds = (DirSet) getInstance();
38         ds.setProject(getProject());
39         FileSet fs = new FileSet();
40         fs.setProject(getProject());
41         getProject().addReference("dummy", fs);
42         ds.setRefid(new Reference("dummy"));
43         try {
44             ds.getDir(getProject());
45             fail("DirSet created from FileSet reference");
46         } catch (BuildException e) {
47             assertEquals("dummy doesn\'t denote a DirSet", e.getMessage());
48         }
49
50         ds = (DirSet) getInstance();
51         ds.setProject(getProject());
52         getProject().addReference("dummy2", ds);
53         fs.setRefid(new Reference("dummy2"));
54         try {
55             fs.getDir(getProject());
56             fail("FileSet created from DirSet reference");
57         } catch (BuildException e) {
58             assertEquals("dummy2 doesn\'t denote a FileSet", e.getMessage());
59         }
60     }
61
62 }
63
Popular Tags