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.refactor.undo;
10:
11: import java.io.File;
12: import java.io.IOException;
13: import org.acm.seguin.refactor.RefactoringException;
14: import org.acm.seguin.refactor.RefactoringFactory;
15: import org.acm.seguin.summary.SummaryTraversal;
16: import org.acm.seguin.io.FileCopy;
17: import net.sourceforge.jrefactory.ast.ASTName;
18: import net.sourceforge.jrefactory.ast.ASTUnmodifiedClassDeclaration;
19: import net.sourceforge.jrefactory.ast.ASTClassDeclaration;
20: import net.sourceforge.jrefactory.ast.ASTTypeDeclaration;
21: import net.sourceforge.jrefactory.ast.ASTPackageDeclaration;
22: import net.sourceforge.jrefactory.ast.ASTCompilationUnit;
23: import org.acm.seguin.summary.TypeSummary;
24: import org.acm.seguin.summary.PackageSummary;
25: import org.acm.seguin.summary.query.GetTypeSummary;
26: import org.acm.seguin.junit.FileCompare;
27: import org.acm.seguin.junit.DirSourceTestCase;
28: import org.acm.seguin.refactor.type.RenameClassRefactoring;
29:
30: /**
31: * JUnit tests for Undo operation
32: *
33: *@author Chris Seguin
34: */
35: public class TestUndo extends DirSourceTestCase {
36: /**
37: * Constructor for the TestUndo object
38: *
39: *@param name Description of Parameter
40: */
41: public TestUndo(String name) {
42: super (name);
43: }
44:
45: /**
46: * A unit test for JUnit
47: *
48: *@exception RefactoringException Description of Exception
49: *@exception IOException Description of Exception
50: */
51: public void test02() throws RefactoringException, IOException {
52: File cleanDir = new File(clean);
53: File destDir = new File(root + "\\ren");
54: File checkDir = new File(check + "\\ut1\\step30");
55:
56: (new FileCopy(new File(cleanDir, "ChildExtensionClass.java"),
57: new File(destDir, "ChildExtensionClass.java"), false))
58: .run();
59:
60: (new FileCopy(new File(cleanDir, "BaseClass.java"), new File(
61: destDir, "BaseClass.java"), false)).run();
62:
63: (new SummaryTraversal(root)).run();
64: RenameClassRefactoring rcf = RefactoringFactory.get()
65: .renameClass();
66: rcf.setDirectory(destDir.getCanonicalPath());
67: rcf.setOldClassName("BaseClass");
68: rcf.setNewClassName("RenamedClass");
69:
70: rcf.run();
71:
72: FileCompare.assertEquals("RenamedClass class in error",
73: new File(checkDir, "RenamedClass.java"), new File(
74: destDir, "RenamedClass.java"));
75:
76: FileCompare.assertEquals("ChildExtensionClass class in error",
77: new File(checkDir, "ChildExtensionClass.java"),
78: new File(destDir, "ChildExtensionClass.java"));
79:
80: UndoStack.get().undo();
81:
82: FileCompare.assertEquals("BaseClass class in error", new File(
83: checkDir, "BaseClass.java"), new File(destDir,
84: "BaseClass.java"));
85:
86: FileCompare.assertEquals("ChildExtensionClass class in error",
87: new File(checkDir, "undone_ChildExtensionClass.java"),
88: new File(destDir, "ChildExtensionClass.java"));
89:
90: (new File(destDir, "BaseClass.java")).delete();
91: (new File(destDir, "ChildExtensionClass.java")).delete();
92: }
93: }
|