001: /*
002: * Author: Chris Seguin
003: *
004: * This software has been developed under the copyleft
005: * rules of the GNU General Public License. Please
006: * consult the GNU General Public License for more
007: * details about use and distribution of this software.
008: */
009: package org.acm.seguin.refactor.type;
010:
011: import java.io.File;
012: import java.util.LinkedList;
013: import org.acm.seguin.io.FileCopy;
014: import org.acm.seguin.junit.DirSourceTestCase;
015: import org.acm.seguin.junit.FileCompare;
016: import org.acm.seguin.refactor.RefactoringException;
017: import org.acm.seguin.summary.SummaryTraversal;
018: import org.acm.seguin.summary.TypeSummary;
019: import org.acm.seguin.summary.query.GetTypeSummary;
020:
021: /**
022: * Additional unit test for adding a child
023: *
024: *@author Chris Seguin
025: */
026: public class TestAddChildTwo extends DirSourceTestCase {
027: /**
028: * Constructor for the TestAddChildTwo object
029: *
030: *@param name Description of Parameter
031: */
032: public TestAddChildTwo(String name) {
033: super (name);
034: }
035:
036: /**
037: * A unit test for JUnit
038: *
039: *@exception RefactoringException Description of Exception
040: */
041: public void test01() throws RefactoringException {
042: AddChildRefactoring aap = new AddChildRefactoring();
043: aap.setParentClass("abstracter", "ClassThree");
044: aap.setChildName("ClassFour");
045:
046: aap.run();
047:
048: File destDir = new File(root + "\\abstracter");
049: File checkDir = new File(check + "\\ut1\\step23");
050:
051: FileCompare.assertEquals("ClassFour class in error", new File(
052: checkDir, "ClassFour.java"), new File(destDir,
053: "ClassFour.java"));
054:
055: (new File(destDir, "ClassFour.java")).delete();
056: }
057:
058: /**
059: * A unit test for JUnit
060: *
061: *@exception RefactoringException Description of Exception
062: */
063: public void test02() throws RefactoringException {
064: TypeSummary type = GetTypeSummary.query("abstracter",
065: "ClassThree");
066: AbstractMethodFinder finder = new AbstractMethodFinder(type,
067: true);
068: finder.loadInterfaceMethods();
069: LinkedList list = finder.getList();
070:
071: assertEquals("List length is correct", 6, list.size());
072:
073: finder.filter(type);
074: assertEquals("List length is correct", 5, list.size());
075: }
076:
077: /**
078: * A unit test for JUnit
079: *
080: *@exception RefactoringException Description of Exception
081: */
082: public void test03() throws RefactoringException {
083: AddChildRefactoring aap = new AddChildRefactoring();
084: aap.setParentClass("javax.swing.text", "AbstractDocument");
085: aap.setChildName("XMLDocument");
086: aap.setPackageName("abstracter");
087:
088: aap.run();
089:
090: File destDir = new File(root + "\\abstracter");
091: File checkDir = new File(check + "\\ut1\\step24");
092:
093: FileCompare.assertEquals("XMLDocument class in error",
094: new File(checkDir, "XMLDocument.java"), new File(
095: destDir, "XMLDocument.java"));
096:
097: (new File(destDir, "XMLDocument.java")).delete();
098: }
099:
100: /**
101: * A unit test for JUnit
102: *
103: *@exception RefactoringException Description of Exception
104: */
105: public void test04() throws RefactoringException {
106: AddChildRefactoring aap = new AddChildRefactoring();
107: aap.setParentClass("javax.swing.text", "AbstractDocument");
108: aap.setChildName("XMLDocument");
109: aap.setPackageName("");
110:
111: aap.run();
112:
113: File destDir = new File(root);
114: File checkDir = new File(check + "\\ut1\\step26");
115:
116: FileCompare.assertEquals("XMLDocument class in error",
117: new File(checkDir, "XMLDocument.java"), new File(
118: destDir, "XMLDocument.java"));
119:
120: (new File(destDir, "XMLDocument.java")).delete();
121: }
122:
123: /**
124: * The JUnit setup method
125: */
126: protected void setUp() {
127: File cleanDir = new File(clean);
128: File destDir = new File(root + "\\abstracter");
129:
130: (new FileCopy(new File(cleanDir, "child_InterfaceOne.java"),
131: new File(destDir, "InterfaceOne.java"), false)).run();
132:
133: (new FileCopy(new File(cleanDir, "child_InterfaceTwo.java"),
134: new File(destDir, "InterfaceTwo.java"), false)).run();
135:
136: (new FileCopy(new File(cleanDir, "child_InterfaceThree.java"),
137: new File(destDir, "InterfaceThree.java"), false)).run();
138:
139: (new FileCopy(new File(cleanDir, "child_ClassOne.java"),
140: new File(destDir, "ClassOne.java"), false)).run();
141:
142: (new FileCopy(new File(cleanDir, "child_ClassTwo.java"),
143: new File(destDir, "ClassTwo.java"), false)).run();
144:
145: (new FileCopy(new File(cleanDir, "child_ClassThree.java"),
146: new File(destDir, "ClassThree.java"), false)).run();
147:
148: (new SummaryTraversal(root)).run();
149: }
150:
151: /**
152: * The teardown method for JUnit
153: */
154: protected void tearDown() {
155: File destDir = new File(root + "\\abstracter");
156:
157: (new File(destDir, "InterfaceOne.java")).delete();
158: (new File(destDir, "InterfaceTwo.java")).delete();
159: (new File(destDir, "InterfaceThree.java")).delete();
160: (new File(destDir, "ClassOne.java")).delete();
161: (new File(destDir, "ClassTwo.java")).delete();
162: (new File(destDir, "ClassThree.java")).delete();
163: (new File(destDir, "ClassFour.java")).delete();
164:
165: }
166: }
|