Source Code Cross Referenced for TestExtractMethod.java in  » UML » jrefactory » org » acm » seguin » refactor » method » 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.method 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.*;
012:        import org.acm.seguin.junit.DirSourceTestCase;
013:        import org.acm.seguin.junit.FileCompare;
014:        import org.acm.seguin.refactor.RefactoringException;
015:        import org.acm.seguin.summary.LocalVariableSummary;
016:        import org.acm.seguin.summary.TypeDeclSummary;
017:
018:        /**
019:         *  Unit tests for the extract method refactoring
020:         *
021:         *@author    Chris Seguin
022:         */
023:        public class TestExtractMethod extends DirSourceTestCase {
024:            /**
025:             *  Constructor for the TestExtractMethod object
026:             *
027:             *@param  init  Description of Parameter
028:             */
029:            public TestExtractMethod(String init) {
030:                super (init);
031:            }
032:
033:            /**
034:             *  A unit test for JUnit
035:             *
036:             *@exception  IOException           Description of Exception
037:             *@exception  RefactoringException  Description of Exception
038:             */
039:            public void test01() throws IOException, RefactoringException {
040:                check("method_ExtractMethod.java", 8, 14, 20);
041:            }
042:
043:            /**
044:             *  A unit test for JUnit
045:             *
046:             *@exception  IOException           Description of Exception
047:             *@exception  RefactoringException  Description of Exception
048:             */
049:            public void test02() throws IOException, RefactoringException {
050:                check("method_ExtractMethod.java", 21, 22, 21);
051:            }
052:
053:            /**
054:             *  A unit test for JUnit
055:             *
056:             *@exception  IOException           Description of Exception
057:             *@exception  RefactoringException  Description of Exception
058:             */
059:            public void test03() throws IOException, RefactoringException {
060:                check("method_ExtractMethod.java", 34, 37, 22);
061:            }
062:
063:            /**
064:             *  A unit test for JUnit
065:             *
066:             *@exception  IOException           Description of Exception
067:             *@exception  RefactoringException  Description of Exception
068:             */
069:            public void test04() throws IOException, RefactoringException {
070:                check("method_ExtractMethodTestTwo.java", 16, 18, 23);
071:            }
072:
073:            /**
074:             *  A unit test for JUnit
075:             *
076:             *@exception  IOException           Description of Exception
077:             *@exception  RefactoringException  Description of Exception
078:             */
079:            public void test05() throws IOException, RefactoringException {
080:                check("method_ExtractMethodTestTwo.java", 17, 18, 24);
081:            }
082:
083:            /**
084:             *  A unit test for JUnit
085:             *
086:             *@exception  IOException           Description of Exception
087:             *@exception  RefactoringException  Description of Exception
088:             */
089:            public void test06() throws IOException, RefactoringException {
090:                check("method_ExtractMethodTestTwo.java", 17, 17, 25);
091:            }
092:
093:            /**
094:             *  A unit test for JUnit
095:             *
096:             *@exception  IOException           Description of Exception
097:             *@exception  RefactoringException  Description of Exception
098:             */
099:            public void test07() throws IOException, RefactoringException {
100:                check("method_ExtractMethodTestTwo.java", 22, 22, 26);
101:            }
102:
103:            /**
104:             *  A unit test for JUnit
105:             *
106:             *@exception  IOException           Description of Exception
107:             *@exception  RefactoringException  Description of Exception
108:             */
109:            public void test08() throws IOException, RefactoringException {
110:                check("method_ExtractMethodTestTwo.java", 34, 34, 27);
111:            }
112:
113:            /**
114:             *  A unit test for JUnit
115:             *
116:             *@exception  IOException           Description of Exception
117:             *@exception  RefactoringException  Description of Exception
118:             */
119:            public void test09() throws IOException, RefactoringException {
120:                check("method_ExtractMethodTestTwo.java", 32, 36, 28);
121:            }
122:
123:            /**
124:             *  A unit test for JUnit
125:             *
126:             *@exception  IOException           Description of Exception
127:             *@exception  RefactoringException  Description of Exception
128:             */
129:            public void test10() throws IOException, RefactoringException {
130:                check("method_ExtractMethodTestTwo.java", 32, 35, 29);
131:            }
132:
133:            /**
134:             *  A unit test for JUnit
135:             *
136:             *@exception  IOException           Description of Exception
137:             *@exception  RefactoringException  Description of Exception
138:             */
139:            public void test11() throws IOException, RefactoringException {
140:                check("method_ExtractMethodTestTwo.java", 33, 36, 30);
141:            }
142:
143:            /**
144:             *  A unit test for JUnit
145:             *
146:             *@exception  IOException           Description of Exception
147:             *@exception  RefactoringException  Description of Exception
148:             */
149:            public void test12() throws IOException, RefactoringException {
150:                check("method_ExtractMethodTestTwo.java", 36, 36, 31);
151:            }
152:
153:            /**
154:             *  A unit test for JUnit
155:             *
156:             *@exception  IOException           Description of Exception
157:             *@exception  RefactoringException  Description of Exception
158:             */
159:            public void test13() throws IOException, RefactoringException {
160:                check("method_ExtractMethodTestTwo.java", 30, 30, 32);
161:            }
162:
163:            /**
164:             *  A unit test for JUnit
165:             *
166:             *@exception  IOException           Description of Exception
167:             *@exception  RefactoringException  Description of Exception
168:             */
169:            public void test14() throws IOException, RefactoringException {
170:                check("method_ExtractMethodTestTwo.java", 43, 45, 33);
171:            }
172:
173:            /**
174:             *  A unit test for JUnit
175:             *
176:             *@exception  IOException           Description of Exception
177:             *@exception  RefactoringException  Description of Exception
178:             */
179:            public void test15() throws IOException, RefactoringException {
180:                check("method_ExtractMethodTestThree.java", 14, 15, 34);
181:            }
182:
183:            /**
184:             *  A unit test for JUnit
185:             *
186:             *@exception  IOException           Description of Exception
187:             *@exception  RefactoringException  Description of Exception
188:             */
189:            public void test17() throws IOException, RefactoringException {
190:                check("ExtendedExtractMethodTester.java", 21, 26, 46);
191:            }
192:
193:            /**
194:             *  A unit test for JUnit
195:             *
196:             *@exception  IOException           Description of Exception
197:             *@exception  RefactoringException  Description of Exception
198:             */
199:            public void test18() throws IOException, RefactoringException {
200:                check("ExtendedExtractMethodTester.java", 42, 42, 47);
201:            }
202:
203:            /**
204:             *  A unit test for JUnit
205:             *
206:             *@exception  IOException           Description of Exception
207:             *@exception  RefactoringException  Description of Exception
208:             */
209:            public void test19() throws IOException, RefactoringException {
210:                check("method_ExtractMethodTestFour.java", 8, 11, 38);
211:            }
212:
213:            /**
214:             *  A unit test for JUnit
215:             *
216:             *@exception  IOException           Description of Exception
217:             *@exception  RefactoringException  Description of Exception
218:             */
219:            public void test20() throws IOException, RefactoringException {
220:                check("method_ExtractMethodTestFour.java", 8, 10, 39);
221:            }
222:
223:            /**
224:             *  A unit test for JUnit
225:             *
226:             *@exception  IOException           Description of Exception
227:             *@exception  RefactoringException  Description of Exception
228:             */
229:            public void test21() throws IOException, RefactoringException {
230:                check("method_ExtractMethodTestFour.java", 20, 22, 50);
231:            }
232:
233:            /**
234:             *  A unit test for JUnit
235:             *
236:             *@exception  IOException           Description of Exception
237:             *@exception  RefactoringException  Description of Exception
238:             */
239:            public void test22() throws IOException, RefactoringException {
240:                check("method_ExtractMethodTestFour.java", 33, 35, 51);
241:            }
242:
243:            /**
244:             *  A unit test for JUnit
245:             *
246:             *@exception  IOException           Description of Exception
247:             *@exception  RefactoringException  Description of Exception
248:             */
249:            public void test23() throws IOException, RefactoringException {
250:                check("method_ExtractMethodTestFour.java", 45, 46, 52);
251:            }
252:
253:            /**
254:             *  A unit test for JUnit
255:             *
256:             *@exception  IOException           Description of Exception
257:             *@exception  RefactoringException  Description of Exception
258:             */
259:            public void test24() throws IOException, RefactoringException {
260:                check("method_ExtractMethodTestFive.java", 10, 17, 53);
261:            }
262:
263:            /**
264:             *  A unit test for JUnit
265:             *
266:             *@exception  IOException           Description of Exception
267:             *@exception  RefactoringException  Description of Exception
268:             */
269:            public void test25() throws IOException, RefactoringException {
270:                check("method_ExtractMethodTestFive.java", 30, 33, 54);
271:            }
272:
273:            /**
274:             *  A unit test for JUnit
275:             *
276:             *@exception  IOException           Description of Exception
277:             *@exception  RefactoringException  Description of Exception
278:             */
279:            public void test26() throws IOException, RefactoringException {
280:                check("method_ExtractMethodTestSix.java", 7, 8, 55);
281:            }
282:
283:            /**
284:             *  A unit test for JUnit
285:             *
286:             *@exception  IOException           Description of Exception
287:             *@exception  RefactoringException  Description of Exception
288:             */
289:            public void test27() throws IOException, RefactoringException {
290:                check("method_ExtractMethodTestSix.java", 25, 26, 56);
291:            }
292:
293:            /**
294:             *  A unit test for JUnit
295:             *
296:             *@exception  IOException           Description of Exception
297:             *@exception  RefactoringException  Description of Exception
298:             */
299:            public void test28() throws IOException, RefactoringException {
300:                check("method_ExtractMethodTestSeven.java", 8, 17, 57);
301:            }
302:
303:            /**
304:             *  A unit test for JUnit
305:             *
306:             *@exception  IOException           Description of Exception
307:             *@exception  RefactoringException  Description of Exception
308:             */
309:            public void test16() throws IOException, RefactoringException {
310:                TypeDeclSummary tds = new TypeDeclSummary(null, null, "String");
311:                LocalVariableSummary lvs = new LocalVariableSummary(null, tds,
312:                        "keyword");
313:                check("ExtendedExtractMethodTester.java", 6, 12, 45, lvs);
314:            }
315:
316:            /**
317:             *  Description of the Method
318:             *
319:             *@param  filename                  Description of Parameter
320:             *@param  startLine                 Description of Parameter
321:             *@param  endLine                   Description of Parameter
322:             *@param  code                      Description of Parameter
323:             *@exception  IOException           Description of Exception
324:             *@exception  RefactoringException  Description of Exception
325:             */
326:            protected void check(String filename, int startLine, int endLine,
327:                    int code) throws IOException, RefactoringException {
328:                check(filename, startLine, endLine, code, null);
329:            }
330:
331:            /**
332:             *  A unit test for JUnit
333:             *
334:             *@param  filename                  Description of Parameter
335:             *@param  startLine                 Description of Parameter
336:             *@param  endLine                   Description of Parameter
337:             *@param  code                      Description of Parameter
338:             *@param  returnType                Description of Parameter
339:             *@exception  IOException           Description of Exception
340:             *@exception  RefactoringException  Description of Exception
341:             */
342:            protected void check(String filename, int startLine, int endLine,
343:                    int code, Object returnType) throws IOException,
344:                    RefactoringException {
345:                FileReader fileReader = new FileReader(clean + File.separator
346:                        + filename);
347:                BufferedReader input = new BufferedReader(fileReader);
348:
349:                StringBuffer fullFile = new StringBuffer();
350:                StringBuffer selection = new StringBuffer();
351:
352:                String line = input.readLine();
353:                int count = 1;
354:                while (line != null) {
355:                    fullFile.append(line);
356:                    fullFile.append("\n");
357:                    if ((count >= startLine) && (count <= endLine)) {
358:                        selection.append(line);
359:                        selection.append("\n");
360:                    }
361:                    line = input.readLine();
362:                    count++;
363:                }
364:
365:                input.close();
366:
367:                ExtractMethodRefactoring em = new ExtractMethodRefactoring();
368:                em.setFullFile(fullFile.toString());
369:                em.setSelection(selection.toString());
370:                em.setMethodName("extractedMethod");
371:                if (returnType != null) {
372:                    em.setReturnType(returnType);
373:                }
374:
375:                em.run();
376:
377:                String revised = em.getFullFile();
378:
379:                File dest = new File(root + File.separator
380:                        + "ExtractMethod.java");
381:                FileWriter fileWriter = new FileWriter(dest);
382:                PrintWriter output = new PrintWriter(fileWriter);
383:                output.print(revised);
384:                output.flush();
385:                output.close();
386:                fileWriter.close();
387:
388:                File checkCode = new File(check + "/ut3/step" + code
389:                        + "/ExtractMethod.java");
390:                FileCompare.assertEquals("ExtractMethod is incorrect",
391:                        checkCode, dest);
392:            }
393:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.