Source Code Cross Referenced for RenamePrivateMethodTests.java in  » IDE-Eclipse » jdt » org » eclipse » jdt » ui » tests » refactoring » 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 » IDE Eclipse » jdt » org.eclipse.jdt.ui.tests.refactoring 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.jdt.ui.tests.refactoring;
011:
012:        import junit.framework.Test;
013:        import junit.framework.TestSuite;
014:
015:        import org.eclipse.core.runtime.NullProgressMonitor;
016:
017:        import org.eclipse.jdt.core.ICompilationUnit;
018:        import org.eclipse.jdt.core.IMethod;
019:        import org.eclipse.jdt.core.IType;
020:
021:        import org.eclipse.jdt.internal.corext.refactoring.rename.RenameMethodProcessor;
022:        import org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor;
023:        import org.eclipse.ltk.core.refactoring.RefactoringCore;
024:        import org.eclipse.ltk.core.refactoring.RefactoringStatus;
025:        import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
026:        import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring;
027:
028:        public class RenamePrivateMethodTests extends RefactoringTest {
029:
030:            private static final Class clazz = RenamePrivateMethodTests.class;
031:            private static final String REFACTORING_PATH = "RenamePrivateMethod/";
032:
033:            public RenamePrivateMethodTests(String name) {
034:                super (name);
035:            }
036:
037:            public static Test suite() {
038:                return new RefactoringTestSetup(new TestSuite(clazz));
039:            }
040:
041:            public static Test setUpTest(Test test) {
042:                return new RefactoringTestSetup(test);
043:            }
044:
045:            protected String getRefactoringPath() {
046:                return REFACTORING_PATH;
047:            }
048:
049:            private void helper1_0(String methodName, String newMethodName,
050:                    String[] signatures) throws Exception {
051:                IType classA = getType(
052:                        createCUfromTestFile(getPackageP(), "A"), "A");
053:                RenameMethodProcessor processor = new RenameNonVirtualMethodProcessor(
054:                        classA.getMethod(methodName, signatures));
055:                RenameRefactoring refactoring = new RenameRefactoring(processor);
056:                processor.setNewElementName(newMethodName);
057:                RefactoringStatus result = performRefactoring(refactoring);
058:                assertNotNull("precondition was supposed to fail", result);
059:            }
060:
061:            private void helper1() throws Exception {
062:                helper1_0("m", "k", new String[0]);
063:            }
064:
065:            private void helper2_0(String methodName, String newMethodName,
066:                    String[] signatures, boolean updateReferences,
067:                    boolean createDelegate) throws Exception {
068:                ParticipantTesting.reset();
069:                ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
070:                IType classA = getType(cu, "A");
071:                IMethod method = classA.getMethod(methodName, signatures);
072:                String[] handles = ParticipantTesting.createHandles(method);
073:                RenameMethodProcessor processor = new RenameNonVirtualMethodProcessor(
074:                        method);
075:                RenameRefactoring refactoring = new RenameRefactoring(processor);
076:                processor.setUpdateReferences(updateReferences);
077:                processor.setNewElementName(newMethodName);
078:                processor.setDelegateUpdating(createDelegate);
079:                assertEquals("was supposed to pass", null,
080:                        performRefactoring(refactoring));
081:                assertEqualLines("invalid renaming",
082:                        getFileContents(getOutputTestFileName("A")), cu
083:                                .getSource());
084:
085:                ParticipantTesting.testRename(handles,
086:                        new RenameArguments[] { new RenameArguments(
087:                                newMethodName, updateReferences) });
088:
089:                assertTrue("anythingToUndo", RefactoringCore.getUndoManager()
090:                        .anythingToUndo());
091:                assertTrue("! anythingToRedo", !RefactoringCore
092:                        .getUndoManager().anythingToRedo());
093:                //assertEquals("1 to undo", 1, Refactoring.getUndoManager().getRefactoringLog().size());
094:
095:                RefactoringCore.getUndoManager().performUndo(null,
096:                        new NullProgressMonitor());
097:                assertEqualLines("invalid undo",
098:                        getFileContents(getInputTestFileName("A")), cu
099:                                .getSource());
100:
101:                assertTrue("! anythingToUndo", !RefactoringCore
102:                        .getUndoManager().anythingToUndo());
103:                assertTrue("anythingToRedo", RefactoringCore.getUndoManager()
104:                        .anythingToRedo());
105:                //assertEquals("1 to redo", 1, Refactoring.getUndoManager().getRedoStack().size());
106:
107:                RefactoringCore.getUndoManager().performRedo(null,
108:                        new NullProgressMonitor());
109:                assertEqualLines("invalid redo",
110:                        getFileContents(getOutputTestFileName("A")), cu
111:                                .getSource());
112:            }
113:
114:            private void helper2_0(String methodName, String newMethodName,
115:                    String[] signatures) throws Exception {
116:                helper2_0(methodName, newMethodName, signatures, true, false);
117:            }
118:
119:            private void helper2(boolean updateReferences) throws Exception {
120:                helper2_0("m", "k", new String[0], updateReferences, false);
121:            }
122:
123:            private void helper2() throws Exception {
124:                helper2(true);
125:            }
126:
127:            private void helperDelegate() throws Exception {
128:                helper2_0("m", "k", new String[0], true, true);
129:            }
130:
131:            public void testFail0() throws Exception {
132:                helper1();
133:            }
134:
135:            public void testFail1() throws Exception {
136:                helper1();
137:            }
138:
139:            public void testFail2() throws Exception {
140:                helper1();
141:            }
142:
143:            public void testFail5() throws Exception {
144:                helper1();
145:            }
146:
147:            public void test0() throws Exception {
148:                helper2();
149:            }
150:
151:            public void test10() throws Exception {
152:                helper2();
153:            }
154:
155:            public void test11() throws Exception {
156:                helper2();
157:            }
158:
159:            public void test12() throws Exception {
160:                helper2();
161:            }
162:
163:            public void test13() throws Exception {
164:                helper2();
165:            }
166:
167:            public void test14() throws Exception {
168:                helper2();
169:            }
170:
171:            public void test15() throws Exception {
172:                helper2_0("m", "k", new String[] { "I" });
173:            }
174:
175:            public void test16() throws Exception {
176:                helper2_0("m", "fred", new String[] { "I" });
177:            }
178:
179:            public void test17() throws Exception {
180:                helper2_0("m", "kk", new String[] { "I" });
181:            }
182:
183:            public void test18() throws Exception {
184:                ICompilationUnit cu = createCUfromTestFile(getPackageP(), "A");
185:                ICompilationUnit cuC = createCUfromTestFile(getPackageP(), "C");
186:
187:                IType classB = getType(cu, "B");
188:                RenameMethodProcessor processor = new RenameNonVirtualMethodProcessor(
189:                        classB.getMethod("m", new String[] { "I" }));
190:                RenameRefactoring refactoring = new RenameRefactoring(processor);
191:                processor.setNewElementName("kk");
192:
193:                assertEquals("was supposed to pass", null,
194:                        performRefactoring(refactoring));
195:                assertEqualLines("invalid renaming A",
196:                        getFileContents(getOutputTestFileName("A")), cu
197:                                .getSource());
198:                assertEqualLines("invalid renaming C",
199:                        getFileContents(getOutputTestFileName("C")), cuC
200:                                .getSource());
201:
202:            }
203:
204:            public void test2() throws Exception {
205:                helper2_0("m", "fred", new String[0]);
206:            }
207:
208:            public void test20() throws Exception {
209:                helper2_0("m", "fred", new String[] { "I" });
210:            }
211:
212:            public void test23() throws Exception {
213:                helper2_0("m", "k", new String[0]);
214:            }
215:
216:            public void test24() throws Exception {
217:                helper2_0("m", "k", new String[] { "QString;" });
218:            }
219:
220:            public void test25() throws Exception {
221:                helper2_0("m", "k", new String[] { "[QString;" });
222:            }
223:
224:            public void test26() throws Exception {
225:                helper2_0("m", "k", new String[0]);
226:            }
227:
228:            public void test27() throws Exception {
229:                helper2_0("m", "k", new String[0], false, false);
230:            }
231:
232:            public void testAnon0() throws Exception {
233:                helper2();
234:            }
235:
236:            public void testDelegate01() throws Exception {
237:                // simple static delegate
238:                helperDelegate();
239:            }
240:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.