001: package org.acm.seguin.refactor.type;
002:
003: import java.io.File;
004: import org.acm.seguin.summary.SummaryTraversal;
005: import org.acm.seguin.io.FileCopy;
006: import net.sourceforge.jrefactory.ast.ASTName;
007: import net.sourceforge.jrefactory.ast.ASTUnmodifiedClassDeclaration;
008: import net.sourceforge.jrefactory.ast.ASTClassDeclaration;
009: import net.sourceforge.jrefactory.ast.ASTTypeDeclaration;
010: import net.sourceforge.jrefactory.ast.ASTPackageDeclaration;
011: import net.sourceforge.jrefactory.ast.ASTCompilationUnit;
012: import org.acm.seguin.summary.TypeSummary;
013: import org.acm.seguin.summary.PackageSummary;
014: import org.acm.seguin.summary.query.GetTypeSummary;
015: import org.acm.seguin.junit.FileCompare;
016: import org.acm.seguin.junit.DirSourceTestCase;
017: import org.acm.seguin.refactor.RefactoringException;
018:
019: /**
020: * Unit test for adding a child
021: *
022: *@author Chris Seguin
023: */
024: public class TestAddChildRefactoring extends DirSourceTestCase {
025: /**
026: * Constructor for the TestAddChildRefactoring object
027: *
028: *@param name Description of Parameter
029: */
030: public TestAddChildRefactoring(String name) {
031: super (name);
032: }
033:
034: /**
035: * A unit test for JUnit
036: */
037: public void test01() {
038: AddChildRefactoring aap = new AddChildRefactoring();
039: aap.setParentClass("abstracter", "NameConflict");
040: aap.setChildName("Associate");
041:
042: boolean exceptionThrown = false;
043: try {
044: aap.run();
045: } catch (RefactoringException re) {
046: exceptionThrown = true;
047: }
048:
049: assertTrue("Did not complain about the name conflicts",
050: exceptionThrown);
051: }
052:
053: /**
054: * A unit test for JUnit
055: *
056: *@exception RefactoringException Description of Exception
057: */
058: public void test02() throws RefactoringException {
059: AddChildRefactoring aap = new AddChildRefactoring();
060: aap.setParentClass("abstracter", "NormalClass");
061: aap.setChildName("ChildOneClass");
062:
063: aap.run();
064:
065: File destDir = new File(root + "\\abstracter");
066: File checkDir = new File(check + "\\ut1\\step20");
067: File impDir = new File(root + "\\imp");
068:
069: FileCompare.assertEquals("NormalClass class in error",
070: new File(checkDir, "NormalClass.java"), new File(
071: destDir, "NormalClass.java"));
072:
073: FileCompare.assertEquals("ChildOneClass class in error",
074: new File(checkDir, "ChildOneClass.java"), new File(
075: destDir, "ChildOneClass.java"));
076:
077: FileCompare.assertEquals("TypeChecker class in error",
078: new File(checkDir, "TypeChecker.java"), new File(
079: impDir, "TypeChecker.java"));
080:
081: (new File(destDir, "ChildOneClass.java")).delete();
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 + "\\abstracter");
090: File impDir = new File(root + "\\imp");
091:
092: (new FileCopy(new File(cleanDir, "NormalClass.java"), new File(
093: destDir, "NormalClass.java"), false)).run();
094:
095: (new FileCopy(new File(cleanDir, "TypeChecker.java"), new File(
096: impDir, "TypeChecker.java"), false)).run();
097:
098: (new FileCopy(new File(cleanDir, "NameConflict.java"),
099: new File(destDir, "NameConflict.java"), false)).run();
100:
101: (new SummaryTraversal(root)).run();
102: }
103:
104: /**
105: * The teardown method for JUnit
106: */
107: protected void tearDown() {
108: File destDir = new File(root + "\\abstracter");
109: File impDir = new File(root + "\\imp");
110:
111: (new File(destDir, "NormalClass.java")).delete();
112: (new File(impDir, "TypeChecker.java")).delete();
113: (new File(destDir, "NameConflict.java")).delete();
114: }
115: }
|