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.method;
010:
011: import java.io.File;
012: import org.acm.seguin.io.FileCopy;
013: import org.acm.seguin.junit.DirSourceTestCase;
014: import org.acm.seguin.junit.FileCompare;
015: import org.acm.seguin.refactor.RefactoringException;
016: import org.acm.seguin.summary.MethodSummary;
017: import org.acm.seguin.summary.PackageSummary;
018: import org.acm.seguin.summary.ParameterSummary;
019: import org.acm.seguin.summary.SummaryTraversal;
020: import org.acm.seguin.summary.TypeSummary;
021: import org.acm.seguin.summary.query.GetTypeSummary;
022: import org.acm.seguin.summary.query.MethodQuery;
023: import org.acm.seguin.summary.query.ParameterQuery;
024:
025: /**
026: * Description of the Class
027: *
028: *@author Chris Seguin
029: */
030: public class TestRenameParameterRefactoring extends DirSourceTestCase {
031: /**
032: * Constructor for the TestRenameParameterRefactoring object
033: *
034: *@param name Description of Parameter
035: */
036: public TestRenameParameterRefactoring(String name) {
037: super (name);
038: }
039:
040: /**
041: * A unit test for JUnit
042: *
043: *@exception RefactoringException Description of Exception
044: */
045: public void test01() throws RefactoringException {
046: RenameParameterRefactoring rpr = new RenameParameterRefactoring();
047: PackageSummary packageSummary = PackageSummary
048: .getPackageSummary("method.param");
049: TypeSummary typeSummary = GetTypeSummary.query(packageSummary,
050: "TestRenameParamSample");
051: MethodSummary methodSummary = MethodQuery.find(typeSummary,
052: "function");
053: ParameterSummary paramSummary = ParameterQuery.query(
054: methodSummary, "paramName");
055: rpr.setMethodSummary(methodSummary);
056: rpr.setParameterSummary(paramSummary);
057: rpr.setNewName("height");
058:
059: rpr.run();
060:
061: // Check things out
062: File check = new File(this .check + "\\ut3\\step40");
063: File dest = new File(root + "\\method\\param");
064:
065: FileCompare.assertEquals("TestRenameParamSample is incorrect",
066: new File(check, "TestRenameParamSample.java"),
067: new File(dest, "TestRenameParamSample.java"));
068: }
069:
070: /**
071: * A unit test for JUnit
072: *
073: *@exception RefactoringException Description of Exception
074: */
075: public void test02() throws RefactoringException {
076: RenameParameterRefactoring rpr = new RenameParameterRefactoring();
077: PackageSummary packageSummary = PackageSummary
078: .getPackageSummary("method.param");
079: TypeSummary typeSummary = GetTypeSummary.query(packageSummary,
080: "TestRenameParamSample");
081: MethodSummary methodSummary = MethodQuery.find(typeSummary,
082: "TestRenameParamSample");
083: ParameterSummary paramSummary = ParameterQuery.query(
084: methodSummary, "paramName");
085: rpr.setMethodSummary(methodSummary);
086: rpr.setParameterSummary(paramSummary);
087: rpr.setNewName("height");
088:
089: rpr.run();
090:
091: // Check things out
092: File check = new File(this .check + "\\ut3\\step41");
093: File dest = new File(root + "\\method\\param");
094:
095: FileCompare.assertEquals("TestRenameParamSample is incorrect",
096: new File(check, "TestRenameParamSample.java"),
097: new File(dest, "TestRenameParamSample.java"));
098: }
099:
100: public void test03() throws RefactoringException {
101: RenameParameterRefactoring rpr = new RenameParameterRefactoring();
102: PackageSummary packageSummary = PackageSummary
103: .getPackageSummary("method.param");
104: TypeSummary typeSummary = GetTypeSummary.query(packageSummary,
105: "TestRenameParamSample");
106: MethodSummary methodSummary = MethodQuery.find(typeSummary,
107: "useParam");
108: ParameterSummary paramSummary = ParameterQuery.query(
109: methodSummary, "paramName");
110: rpr.setMethodSummary(methodSummary);
111: rpr.setParameterSummary(paramSummary);
112: rpr.setNewName("height");
113:
114: rpr.run();
115:
116: // Check things out
117: File check = new File(this .check + "\\ut3\\step42");
118: File dest = new File(root + "\\method\\param");
119:
120: FileCompare.assertEquals("TestRenameParamSample is incorrect",
121: new File(check, "TestRenameParamSample.java"),
122: new File(dest, "TestRenameParamSample.java"));
123: }
124:
125: /**
126: * The JUnit setup method
127: */
128: protected void setUp() {
129: File cleanDir = new File(clean);
130: File destDir = new File(root + "\\method\\param");
131:
132: (new FileCopy(new File(cleanDir,
133: "method_param_TestRenameParamSample.java"), new File(
134: destDir, "TestRenameParamSample.java"), false)).run();
135:
136: (new SummaryTraversal(root)).run();
137: }
138:
139: /**
140: * The teardown method for JUnit
141: */
142: protected void tearDown() {
143: File destDir = new File(root + "\\method\\param");
144: (new File(destDir, "TestRenameParamSample.java")).delete();
145: }
146: }
|