Source Code Cross Referenced for TestRenameFieldRefactoring.java in  » UML » jrefactory » org » acm » seguin » refactor » field » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » UML » jrefactory » org.acm.seguin.refactor.field 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.acm.seguin.refactor.field;
002:
003:        import java.io.File;
004:        import org.acm.seguin.io.FileCopy;
005:        import org.acm.seguin.junit.DirSourceTestCase;
006:        import org.acm.seguin.junit.FileCompare;
007:        import org.acm.seguin.refactor.RefactoringException;
008:        import org.acm.seguin.summary.SummaryTraversal;
009:
010:        /**
011:         *  Unit tests for the rename field refactoring.
012:         *
013:         * @author    Chris Seguin
014:         */
015:        public class TestRenameFieldRefactoring extends DirSourceTestCase {
016:            private File impDest;
017:            private File dest;
018:
019:            /**
020:             *  Constructor for the TestRenameFieldRefactoring object
021:             *
022:             * @param  name  the name of the unit test to run
023:             */
024:            public TestRenameFieldRefactoring(String name) {
025:                super (name);
026:            }
027:
028:            /**
029:             *  A unit test for JUnit
030:             *
031:             * @exception  RefactoringException  Description of Exception
032:             */
033:            public void test01() throws RefactoringException {
034:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
035:                rfr.setClass("field", "RenameFieldTest");
036:                rfr.setField("simple");
037:                rfr.setNewName("changed");
038:
039:                rfr.run();
040:
041:                //  Check things out
042:                File check = new File(this .check + "\\ut2\\step11");
043:
044:                FileCompare.assertEquals("RenameFieldTest is incorrect",
045:                        new File(check, "RenameFieldTest.java"), new File(dest,
046:                                "RenameFieldTest.java"));
047:                FileCompare.assertEquals("UsesFieldTest is incorrect",
048:                        new File(check, "UsesFieldTest.java"), new File(dest,
049:                                "UsesFieldTest.java"));
050:                FileCompare.assertEquals("InheritFieldTest is incorrect",
051:                        new File(check, "InheritFieldTest.java"), new File(
052:                                dest, "InheritFieldTest.java"));
053:            }
054:
055:            /**
056:             *  A unit test for JUnit
057:             *
058:             * @exception  RefactoringException  Description of Exception
059:             */
060:            public void test02() throws RefactoringException {
061:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
062:                rfr.setClass("field", "RenameFieldTest");
063:                rfr.setField("code");
064:                rfr.setNewName("changed");
065:
066:                rfr.run();
067:
068:                //  Check things out
069:                File check = new File(this .check + "\\ut2\\step12");
070:
071:                FileCompare.assertEquals("RenameFieldTest is incorrect",
072:                        new File(check, "RenameFieldTest.java"), new File(dest,
073:                                "RenameFieldTest.java"));
074:                FileCompare.assertEquals("UsesFieldTest is incorrect",
075:                        new File(check, "UsesFieldTest.java"), new File(dest,
076:                                "UsesFieldTest.java"));
077:                FileCompare.assertEquals("InheritFieldTest is incorrect",
078:                        new File(check, "InheritFieldTest.java"), new File(
079:                                dest, "InheritFieldTest.java"));
080:            }
081:
082:            /**
083:             *  A unit test for JUnit
084:             *
085:             * @exception  RefactoringException  Description of Exception
086:             */
087:            public void test03() throws RefactoringException {
088:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
089:                rfr.setClass("field", "RenameFieldTest");
090:                rfr.setField("height");
091:                rfr.setNewName("changed");
092:
093:                rfr.run();
094:
095:                //  Check things out
096:                File check = new File(this .check + "\\ut2\\step13");
097:
098:                FileCompare.assertEquals("RenameFieldTest is incorrect",
099:                        new File(check, "RenameFieldTest.java"), new File(dest,
100:                                "RenameFieldTest.java"));
101:                FileCompare.assertEquals("UsesFieldTest is incorrect",
102:                        new File(check, "UsesFieldTest.java"), new File(dest,
103:                                "UsesFieldTest.java"));
104:                FileCompare.assertEquals("InheritFieldTest is incorrect",
105:                        new File(check, "InheritFieldTest.java"), new File(
106:                                dest, "InheritFieldTest.java"));
107:            }
108:
109:            /**
110:             *  A unit test for JUnit
111:             *
112:             * @exception  RefactoringException  Description of Exception
113:             */
114:            public void test04() throws RefactoringException {
115:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
116:                rfr.setClass("field", "RenameFieldTest");
117:                rfr.setField("CODE_ON");
118:                rfr.setNewName("changed");
119:
120:                rfr.run();
121:
122:                //  Check things out
123:                File check = new File(this .check + "\\ut2\\step14");
124:
125:                FileCompare.assertEquals("RenameFieldTest is incorrect",
126:                        new File(check, "RenameFieldTest.java"), new File(dest,
127:                                "RenameFieldTest.java"));
128:                FileCompare.assertEquals("UsesFieldTest is incorrect",
129:                        new File(check, "UsesFieldTest.java"), new File(dest,
130:                                "UsesFieldTest.java"));
131:                FileCompare.assertEquals("InheritFieldTest is incorrect",
132:                        new File(check, "InheritFieldTest.java"), new File(
133:                                dest, "InheritFieldTest.java"));
134:            }
135:
136:            /**
137:             *  A unit test for JUnit
138:             *
139:             */
140:            public void test05() {
141:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
142:                rfr.setClass("field", "RenameFieldTest");
143:                rfr.setField("crazy");
144:                rfr.setNewName("changed");
145:
146:                boolean exceptionThrown = false;
147:
148:                try {
149:                    rfr.run();
150:                } catch (RefactoringException re) {
151:                    exceptionThrown = true;
152:                    assertEquals(
153:                            "Incorrect exception",
154:                            "No field named crazy is contained in RenameFieldTest",
155:                            re.getMessage());
156:                }
157:
158:                assertTrue("No exception thrown", exceptionThrown);
159:            }
160:
161:            /**
162:             *  A unit test for JUnit
163:             *
164:             */
165:            public void test06() {
166:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
167:                rfr.setClass("field", "RenameFieldTest");
168:                rfr.setField("simple");
169:                rfr.setNewName("code");
170:
171:                boolean exceptionThrown = false;
172:
173:                try {
174:                    rfr.run();
175:                } catch (RefactoringException re) {
176:                    exceptionThrown = true;
177:                    assertEquals(
178:                            "Incorrect exception",
179:                            "A field named code already exists in class RenameFieldTest",
180:                            re.getMessage());
181:                }
182:
183:                assertTrue("No exception thrown", exceptionThrown);
184:            }
185:
186:            /**
187:             *  A unit test for JUnit
188:             *
189:             * @exception  RefactoringException  Description of Exception
190:             */
191:            public void test07() throws RefactoringException {
192:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
193:                rfr.setClass("", "XDateChooser");
194:                rfr.setField("_maxDate");
195:                rfr.setNewName("_maximumDate");
196:
197:                rfr.run();
198:
199:                //  Check things out
200:                File check = new File(this .check + "\\ut2\\step15");
201:
202:                FileCompare.assertEquals("XDateChooser is incorrect", new File(
203:                        check, "XDateChooser.java"), new File(root
204:                        + "\\XDateChooser.java"));
205:            }
206:
207:            /**
208:             *  A unit test for JUnit
209:             *
210:             * @exception  RefactoringException  Description of Exception
211:             */
212:            public void test08() throws RefactoringException {
213:                RenameFieldRefactoring rfr = new RenameFieldRefactoring();
214:                rfr.setClass("field", "RenameFieldTest");
215:                rfr.setField("childObject");
216:                rfr.setNewName("myChild");
217:
218:                rfr.run();
219:
220:                //  Check things out
221:                File check = new File(this .check + "\\ut2\\step16");
222:
223:                FileCompare.assertEquals("RenameFieldTest is incorrect",
224:                        new File(check, "RenameFieldTest.java"), new File(dest,
225:                                "RenameFieldTest.java"));
226:                FileCompare.assertEquals("UsesFieldTest is incorrect",
227:                        new File(check, "UsesFieldTest.java"), new File(dest,
228:                                "UsesFieldTest.java"));
229:                FileCompare.assertEquals("InheritFieldTest is incorrect",
230:                        new File(check, "InheritFieldTest.java"), new File(
231:                                dest, "InheritFieldTest.java"));
232:            }
233:
234:            /**
235:             *  The JUnit setup method
236:             *
237:             */
238:            protected void setUp() {
239:                File cleanDir = new File(this .clean);
240:                dest = new File(root + "\\field");
241:                if (!dest.exists()) {
242:                    dest.mkdirs();
243:                }
244:
245:                (new FileCopy(new File(cleanDir, "field_RenameFieldTest.java"),
246:                        new File(dest, "RenameFieldTest.java"), false)).run();
247:                (new FileCopy(new File(cleanDir, "field_UsesFieldTest.java"),
248:                        new File(dest, "UsesFieldTest.java"), false)).run();
249:                (new FileCopy(
250:                        new File(cleanDir, "field_InheritFieldTest.java"),
251:                        new File(dest, "InheritFieldTest.java"), false)).run();
252:                (new FileCopy(new File(cleanDir, "XDateChooser.java"),
253:                        new File(root + "\\XDateChooser.java"), false)).run();
254:
255:                (new SummaryTraversal(root)).run();
256:            }
257:
258:            /**
259:             *  The teardown method for JUnit
260:             *
261:             */
262:            protected void tearDown() {
263:                (new File(dest, "RenameFieldTest.java")).delete();
264:                (new File(dest, "UsesFieldTest.java")).delete();
265:                (new File(dest, "InheritFieldTest.java")).delete();
266:                (new File(root + "\\XDateChooser.java")).delete();
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.