Source Code Cross Referenced for TestPushUpFieldRefactoring.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.summary.SummaryTraversal;
006:        import org.acm.seguin.junit.FileCompare;
007:        import org.acm.seguin.junit.DirSourceTestCase;
008:        import org.acm.seguin.refactor.RefactoringException;
009:
010:        /**
011:         *  Unit tests for the pullup field refactoring.
012:         *
013:         *@author    Chris Seguin
014:         */
015:        public class TestPushUpFieldRefactoring extends DirSourceTestCase {
016:            private File impDest;
017:            private File dest;
018:
019:            /**
020:             *  Constructor for the TestPullUpFieldRefactoring object
021:             *
022:             *@param  name  the name of the unit test to run
023:             */
024:            public TestPushUpFieldRefactoring(String name) {
025:                super (name);
026:            }
027:
028:            /**
029:             *  A unit test for JUnit
030:             */
031:            public void test1() {
032:                PushUpFieldRefactoring puff = new PushUpFieldRefactoring();
033:                puff.setClass("field.pullup", "Child");
034:                puff.setField("panel1");
035:
036:                boolean exceptionThrown = false;
037:                try {
038:                    puff.run();
039:                } catch (RefactoringException re) {
040:                    exceptionThrown = true;
041:                    assertEquals(
042:                            "Incorrect message",
043:                            "Field named panel1 already exists in parent class",
044:                            re.getMessage());
045:                }
046:
047:                assertTrue("No exception thrown", exceptionThrown);
048:            }
049:
050:            /**
051:             *  A unit test for JUnit
052:             */
053:            public void test2() {
054:                PushUpFieldRefactoring puff = new PushUpFieldRefactoring();
055:                puff.setClass("field.pullup", "Child");
056:                puff.setField("panel2");
057:
058:                boolean exceptionThrown = false;
059:                try {
060:                    puff.run();
061:                } catch (RefactoringException re) {
062:                    exceptionThrown = true;
063:                    assertEquals(
064:                            "Incorrect message",
065:                            "Field named panel2 already exists in an ancestor class",
066:                            re.getMessage());
067:                }
068:
069:                assertTrue("No exception thrown", exceptionThrown);
070:            }
071:
072:            /**
073:             *  A unit test for JUnit
074:             *
075:             *@exception  RefactoringException  Description of Exception
076:             */
077:            public void test3() throws RefactoringException {
078:                PushUpFieldRefactoring puff = new PushUpFieldRefactoring();
079:                puff.setClass("field.pullup", "Child");
080:                puff.setField("panel3");
081:
082:                puff.run();
083:
084:                //  Check things out
085:                File check = new File(this .check + "\\ut2\\step1");
086:
087:                FileCompare.assertEquals("Child is incorrect", new File(check,
088:                        "Child.java"), new File(dest, "Child.java"));
089:                FileCompare.assertEquals("Child2 is incorrect", new File(check,
090:                        "Child2.java"), new File(dest, "Child2.java"));
091:                FileCompare.assertEquals("Parent is incorrect", new File(check,
092:                        "Parent.java"), new File(dest, "Parent.java"));
093:            }
094:
095:            /**
096:             *  A unit test for JUnit
097:             *
098:             *@exception  RefactoringException  Description of Exception
099:             */
100:            public void test4() throws RefactoringException {
101:                PushUpFieldRefactoring puff = new PushUpFieldRefactoring();
102:                puff.setClass("field.pullup", "Child");
103:                puff.setField("panel4");
104:
105:                puff.run();
106:
107:                //  Check things out
108:                File check = new File(this .check + "\\ut2\\step2");
109:
110:                FileCompare.assertEquals("Child is incorrect", new File(check,
111:                        "Child.java"), new File(dest, "Child.java"));
112:                FileCompare.assertEquals("Child2 is incorrect", new File(check,
113:                        "Child2.java"), new File(dest, "Child2.java"));
114:                FileCompare.assertEquals("Parent is incorrect", new File(check,
115:                        "Parent.java"), new File(dest, "Parent.java"));
116:            }
117:
118:            /**
119:             *  A unit test for JUnit
120:             *
121:             *@exception  RefactoringException  Description of Exception
122:             */
123:            public void test5() throws RefactoringException {
124:                PushUpFieldRefactoring puff = new PushUpFieldRefactoring();
125:                puff.setClass("field.pullup", "Child");
126:                puff.setField("panel5");
127:
128:                puff.run();
129:
130:                //  Check things out
131:                File check = new File(this .check + "\\ut2\\step3");
132:
133:                FileCompare.assertEquals("Child is incorrect", new File(check,
134:                        "Child.java"), new File(dest, "Child.java"));
135:                FileCompare.assertEquals("Child2 is incorrect", new File(check,
136:                        "Child2.java"), new File(dest, "Child2.java"));
137:                FileCompare.assertEquals("Parent is incorrect", new File(check,
138:                        "Parent.java"), new File(dest, "Parent.java"));
139:            }
140:
141:            /**
142:             *  A unit test for JUnit
143:             */
144:            public void test6() {
145:                PushUpFieldRefactoring puff = new PushUpFieldRefactoring();
146:                puff.setClass("field.pullup", "Child");
147:                puff.setField("panel7");
148:
149:                boolean exceptionThrown = false;
150:                try {
151:                    puff.run();
152:                } catch (RefactoringException re) {
153:                    exceptionThrown = true;
154:                    assertEquals("Incorrect message",
155:                            "Field named panel7 does not exist in Child", re
156:                                    .getMessage());
157:                }
158:
159:                assertTrue("No exception thrown", exceptionThrown);
160:            }
161:
162:            /**
163:             *  The JUnit setup method
164:             */
165:            protected void setUp() {
166:                File cleanDir = new File(this .clean);
167:                dest = new File(root + "\\field\\pullup");
168:                if (!dest.exists()) {
169:                    dest.mkdirs();
170:                }
171:
172:                (new FileCopy(new File(cleanDir, "field_pullup_Child.java"),
173:                        new File(dest, "Child.java"), false)).run();
174:                (new FileCopy(new File(cleanDir, "field_pullup_Child2.java"),
175:                        new File(dest, "Child2.java"), false)).run();
176:
177:                (new FileCopy(new File(cleanDir, "field_pullup_Parent.java"),
178:                        new File(dest, "Parent.java"), false)).run();
179:
180:                (new FileCopy(new File(cleanDir,
181:                        "field_pullup_Grandparent.java"), new File(dest,
182:                        "Grandparent.java"), false)).run();
183:
184:                (new SummaryTraversal(root)).run();
185:            }
186:
187:            /**
188:             *  The teardown method for JUnit
189:             */
190:            protected void tearDown() {
191:                (new File(dest, "Child.java")).delete();
192:                (new File(dest, "Child2.java")).delete();
193:                (new File(dest, "Parent.java")).delete();
194:                (new File(dest, "Grandparent.java")).delete();
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.