01: /*
02: * Author: Chris Seguin
03: *
04: * This software has been developed under the copyleft
05: * rules of the GNU General Public License. Please
06: * consult the GNU General Public License for more
07: * details about use and distribution of this software.
08: */
09: package org.acm.seguin.summary.query;
10:
11: import java.io.File;
12: import java.util.Iterator;
13: import org.acm.seguin.summary.SummaryTraversal;
14: import org.acm.seguin.io.FileCopy;
15: import org.acm.seguin.summary.TypeSummary;
16: import org.acm.seguin.summary.PackageSummary;
17: import org.acm.seguin.junit.DirSourceTestCase;
18:
19: /**
20: * Test cases for the ChildClassSearcher object
21: *
22: *@author Chris Seguin
23: */
24: public class TestChildClassSearcher extends DirSourceTestCase {
25: /**
26: * Constructor for the TestChildClassSearcher object
27: *
28: *@param name Description of Parameter
29: */
30: public TestChildClassSearcher(String name) {
31: super (name);
32: }
33:
34: /**
35: * A unit test for JUnit
36: */
37: public void test1() {
38: PackageSummary packageSummary = PackageSummary
39: .getPackageSummary("imp.inh");
40: TypeSummary baseClass = GetTypeSummary.query(packageSummary,
41: "BaseClass");
42:
43: Iterator iter = ChildClassSearcher.query(baseClass);
44: if (iter == null) {
45: fail("Should have two classes");
46: }
47:
48: int count = 0;
49: while (iter.hasNext()) {
50: count++;
51: iter.next();
52: }
53:
54: assertEquals("Wrong number of child classes", 2, count);
55: }
56:
57: /**
58: * The JUnit setup method
59: */
60: protected void setUp() {
61: File cleanDir = new File(clean);
62: File destDir = new File(root + "\\imp\\inh");
63:
64: (new FileCopy(new File(cleanDir, "imp_inh_BaseClass.java"),
65: new File(destDir, "BaseClass.java"), false)).run();
66: (new FileCopy(new File(cleanDir, "imp_inh_ChildOneClass.java"),
67: new File(destDir, "ChildOneClass.java"), false)).run();
68: (new FileCopy(new File(cleanDir, "imp_inh_ChildTwoClass.java"),
69: new File(destDir, "ChildTwoClass.java"), false)).run();
70:
71: (new SummaryTraversal(root)).run();
72: }
73:
74: /**
75: * The teardown method for JUnit
76: */
77: protected void tearDown() {
78: File destDir = new File(root + "\\imp\\inh");
79: (new File(destDir, "BaseClass.java")).delete();
80: (new File(destDir, "ChildOneClass.java")).delete();
81: (new File(destDir, "ChildTwoClass.java")).delete();
82: }
83: }
|