Author: scabanovich
Date: 2011-02-14 11:17:24 -0500 (Mon, 14 Feb 2011)
New Revision: 29141
Added:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MethodRefactoringTest.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/META-INF/MANIFEST.MF
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/JavaSource/demo/User.java
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.original
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.xml
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java
Log:
JBIDE-8392
https://issues.jboss.org/browse/JBIDE-8392
Modified: trunk/jsf/tests/org.jboss.tools.jsf.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/jsf/tests/org.jboss.tools.jsf.test/META-INF/MANIFEST.MF 2011-02-14 16:02:23 UTC
(rev 29140)
+++ trunk/jsf/tests/org.jboss.tools.jsf.test/META-INF/MANIFEST.MF 2011-02-14 16:17:24 UTC
(rev 29141)
@@ -19,6 +19,9 @@
org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.jface.text,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.core.manipulation,
+ org.eclipse.jdt.ui,
org.jboss.tools.tests,
org.jboss.tools.common.test,
org.jboss.tools.jst.jsp.test,
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/JavaSource/demo/User.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/JavaSource/demo/User.java 2011-02-14
16:02:23 UTC (rev 29140)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/JavaSource/demo/User.java 2011-02-14
16:17:24 UTC (rev 29141)
@@ -42,4 +42,8 @@
public void setX3(int i, int j) {
}
+
+ public String getAge() {
+ return "";
+ }
}
\ No newline at end of file
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.original
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.original 2011-02-14
16:02:23 UTC (rev 29140)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.original 2011-02-14
16:17:24 UTC (rev 29141)
@@ -66,6 +66,16 @@
</list-entries>
</managed-property>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>second</managed-bean-name>
+ <managed-bean-class>demo.User</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>age</property-name>
+ <property-class>java.lang.String</property-class>
+ <value/>
+ </managed-property>
+ </managed-bean>
<navigation-rule>
<from-view-id>/pages/inputname.jsp</from-view-id>
<navigation-case>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.xml
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.xml 2011-02-14
16:02:23 UTC (rev 29140)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/projects/JSFKickStartOldFormat/WebContent/WEB-INF/faces-config.xml 2011-02-14
16:17:24 UTC (rev 29141)
@@ -66,6 +66,16 @@
</list-entries>
</managed-property>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>second</managed-bean-name>
+ <managed-bean-class>demo.User</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ <managed-property>
+ <property-name>age</property-name>
+ <property-class>java.lang.String</property-class>
+ <value/>
+ </managed-property>
+ </managed-bean>
<navigation-rule>
<from-view-id>/pages/inputname.jsp</from-view-id>
<navigation-case>
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java 2011-02-14
16:02:23 UTC (rev 29140)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/JsfAllTests.java 2011-02-14
16:17:24 UTC (rev 29141)
@@ -28,6 +28,7 @@
import org.jboss.tools.jsf.test.refactoring.ELVariableRefactoringTest;
import org.jboss.tools.jsf.test.refactoring.JSF2RefactoringTest;
import org.jboss.tools.jsf.test.refactoring.MessagePropertyRefactoringTest;
+import org.jboss.tools.jsf.test.refactoring.MethodRefactoringTest;
import org.jboss.tools.jsf.test.validation.ELValidatorTest;
import org.jboss.tools.jsf.test.validation.JSF2ComponentsValidatorTest;
import org.jboss.tools.test.util.JobUtils;
@@ -63,6 +64,10 @@
new String[] { "projects/JSFKickStartOldFormat" }, //$NON-NLS-1$
new String[] { "JSFKickStartOldFormat" })); //$NON-NLS-1$
suite.addTest(new ProjectImportTestSetup(new TestSuite(
+ MethodRefactoringTest.class), "org.jboss.tools.jsf.test", //$NON-NLS-1$
+ new String[] { "projects/JSFKickStartOldFormat" }, //$NON-NLS-1$
+ new String[] { "JSFKickStartOldFormat" })); //$NON-NLS-1$
+ suite.addTest(new ProjectImportTestSetup(new TestSuite(
MessagePropertyRefactoringTest.class), "org.jboss.tools.jsf.test",
//$NON-NLS-1$
new String[] { "projects/JSFKickStartOldFormat" }, //$NON-NLS-1$
new String[] { "JSFKickStartOldFormat" })); //$NON-NLS-1$
Added:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MethodRefactoringTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MethodRefactoringTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MethodRefactoringTest.java 2011-02-14
16:17:24 UTC (rev 29141)
@@ -0,0 +1,67 @@
+package org.jboss.tools.jsf.test.refactoring;
+
+import java.lang.reflect.InvocationTargetException;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import
org.eclipse.jdt.internal.corext.refactoring.rename.RenameNonVirtualMethodProcessor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.ltk.core.refactoring.participants.RenameArguments;
+import org.eclipse.text.edits.MultiTextEdit;
+import org.eclipse.text.edits.ReplaceEdit;
+import org.eclipse.text.edits.TextEdit;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.jsf.model.handlers.bean.JSFRenameFieldParticipant;
+import org.jboss.tools.test.util.ProjectImportTestSetup;
+
+public class MethodRefactoringTest extends TestCase {
+ static String projectName = "JSFKickStartOldFormat";
+ static IProject project;
+
+ public MethodRefactoringTest() {
+ super("");
+ }
+
+ protected void setUp() throws Exception {
+ project = ProjectImportTestSetup.loadProject(projectName);
+ project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
+ }
+
+ public void testMethodRename() throws CoreException, InvocationTargetException,
InterruptedException {
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(project);
+ IType t = jp.findType("demo.User");
+ assertNotNull(t);
+ IMethod m = t.getMethod("getAge", new String[0]);
+ assertNotNull(m);
+
+ RenameNonVirtualMethodProcessor processor = new RenameNonVirtualMethodProcessor(m);
+ processor.setNewElementName("getAge2");
+
+ JSFRenameFieldParticipant participant = new JSFRenameFieldParticipant();
+ participant.initialize(processor, m, new RenameArguments("getAge2", true));
+
+ Change change = participant.createChange(new NullProgressMonitor());
+ assertTrue(change instanceof TextFileChange);
+ TextFileChange tc = (TextFileChange)change;
+ TextEdit e = tc.getEdit();
+ if(e instanceof MultiTextEdit) {
+ TextEdit[] cs = ((MultiTextEdit)e).getChildren();
+ assertEquals(1, cs.length);
+ e = cs[0];
+ }
+ assertTrue(e instanceof ReplaceEdit);
+ ReplaceEdit re = (ReplaceEdit)e;
+ String text = re.getText();
+ assertEquals("age2", text);
+ }
+
+
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.test/src/org/jboss/tools/jsf/test/refactoring/MethodRefactoringTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain