001: package org.acm.seguin.refactor.method;
002:
003: import java.io.File;
004: import org.acm.seguin.summary.SummaryTraversal;
005: import org.acm.seguin.io.FileCopy;
006: import org.acm.seguin.summary.TypeSummary;
007: import org.acm.seguin.summary.MethodSummary;
008: import org.acm.seguin.summary.query.GetTypeSummary;
009: import org.acm.seguin.summary.query.GetMethodSummary;
010: import org.acm.seguin.refactor.RefactoringException;
011: import org.acm.seguin.junit.FileCompare;
012: import org.acm.seguin.junit.DirSourceTestCase;
013:
014: /**
015: * Functional tests for Push up method
016: *
017: *@author unknown
018: *@created April 5, 2000
019: */
020: public class TestPushUpAbstractMethod extends DirSourceTestCase {
021: /**
022: * Constructor for the TestPushUpAbstractMethod object
023: *
024: *@param name Description of Parameter
025: */
026: public TestPushUpAbstractMethod(String name) {
027: super (name);
028: }
029:
030: /**
031: * A unit test for JUnit
032: *
033: *@exception RefactoringException Description of Exception
034: */
035: public void test01() throws RefactoringException {
036: TypeSummary type = GetTypeSummary.query("method", "Child");
037: MethodSummary method = GetMethodSummary.query(type, "getPanel");
038:
039: PushUpAbstractMethodRefactoring pum = new PushUpAbstractMethodRefactoring();
040: pum.setMethod(method);
041:
042: pum.run();
043:
044: // Check things out
045: File check = new File(this .check + "\\ut3\\step6");
046: File dest = new File(root + "\\method");
047:
048: FileCompare.assertEquals("Child is incorrect", new File(check,
049: "Child.java"), new File(dest, "Child.java"));
050: FileCompare.assertEquals("Parent is incorrect", new File(check,
051: "Parent.java"), new File(dest, "Parent.java"));
052: }
053:
054: /*
055: * A unit test for JUnit
056: *
057: * @exception RefactoringException Description of Exception
058: */
059: /**
060: * A unit test for JUnit
061: *
062: *@exception RefactoringException Description of Exception
063: */
064: public void test02() throws RefactoringException {
065: TypeSummary type = GetTypeSummary.query("method", "Child");
066: MethodSummary method = GetMethodSummary.query(type, "init");
067:
068: PushUpAbstractMethodRefactoring pum = new PushUpAbstractMethodRefactoring();
069: pum.setMethod(method);
070:
071: pum.run();
072:
073: // Check things out
074: File checkDir = new File(check + "\\ut3\\step7");
075: File dest = new File(root + "\\method");
076:
077: FileCompare.assertEquals("Child is incorrect", new File(
078: checkDir, "Child.java"), new File(dest, "Child.java"));
079: FileCompare
080: .assertEquals("Parent is incorrect", new File(checkDir,
081: "Parent.java"), new File(dest, "Parent.java"));
082: }
083:
084: /**
085: * The JUnit setup method
086: */
087: protected void setUp() {
088: File cleanDir = new File(clean);
089: File destDir = new File(root + "\\method");
090: destDir.mkdir();
091:
092: (new FileCopy(new File(cleanDir, "method_Parent.java"),
093: new File(destDir, "Parent.java"), false)).run();
094: (new FileCopy(new File(cleanDir, "method_Child.java"),
095: new File(destDir, "Child.java"), false)).run();
096:
097: (new SummaryTraversal(root)).run();
098: }
099:
100: /**
101: * The teardown method for JUnit
102: */
103: protected void tearDown() {
104: File destDir = new File(root + "\\method");
105: (new File(destDir, "Parent.java")).delete();
106: (new File(destDir, "Child.java")).delete();
107: }
108: }
|