Author: dazarov
Date: 2010-04-08 12:30:42 -0400 (Thu, 08 Apr 2010)
New Revision: 21358
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Game.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Generator.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/HomePage.xhtml
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/MaxNumber.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Random.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/index.jsp
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NamedBeanRefactoringTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5927
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF 2010-04-08 16:28:17
UTC (rev 21357)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/META-INF/MANIFEST.MF 2010-04-08 16:30:42
UTC (rev 21358)
@@ -14,7 +14,8 @@
org.eclipse.ui,
org.eclipse.jdt.core,
org.jboss.tools.common.el.core,
- org.jboss.tools.common.model.ui
+ org.jboss.tools.common.model.ui,
+ org.eclipse.ltk.core.refactoring;bundle-version="3.5.0"
Export-Package: org.jboss.tools.cdi.core.test,
org.jboss.tools.cdi.core.test.tck
Bundle-ClassPath: cdi-core-test.jar
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Game.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Game.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Game.java 2010-04-08
16:30:42 UTC (rev 21358)
@@ -0,0 +1,97 @@
+package org.jboss.jsr299.tck.tests.refactoring;
+
+import java.io.Serializable;
+
+//import javax.annotation.PostConstruct;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Instance;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.naming.NamingException;
+
+@SessionScoped
+@Named
+public class Game implements Serializable
+{
+ private static final long serialVersionUID = 12L;
+
+ @Named("myInner")
+ public static class MyInner {
+
+ }
+ private int number;
+ private int guess;
+ private int smallest;
+ private int biggest;
+ private int remainingGuesses;
+
+ @Inject @MaxNumber private int maxNumber;
+
+ @Inject private int[] maxNumber2;
+
+ @Inject Generator[] generator;
+
+ @Inject @Random Instance<Integer> randomNumber;
+
+ public Game() throws NamingException {}
+
+ public int getNumber()
+ {
+ return number + 9;
+ }
+
+ public int getGuess()
+ {
+ return guess;
+ }
+
+ public void setGuess(int guess)
+ {
+ String s = "#{another.kkk}";
+ this.guess = guess;
+ }
+
+ public int getSmallest()
+ {
+ return smallest;
+ }
+
+ public int getBiggest()
+ {
+ return biggest;
+ }
+
+ public int getRemainingGuesses()
+ {
+ return remainingGuesses;
+ }
+
+ public boolean check()
+ {
+ if (guess>number)
+ {
+ biggest = guess - 1;
+ }
+ if (guess<number)
+ {
+ smallest = guess + 1;
+ }
+ remainingGuesses--;
+ return (guess == number);
+ }
+
+// @PostConstruct
+ public void reset()
+ {
+ this.smallest = 0;
+ this.guess = 0;
+ this.remainingGuesses = 10;
+ this.biggest = maxNumber;
+ this.number = randomNumber.get();
+ }
+}
+
+@Named("myLocal")
+class MyLocal {
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Game.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Generator.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Generator.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Generator.java 2010-04-08
16:30:42 UTC (rev 21358)
@@ -0,0 +1,38 @@
+package org.jboss.jsr299.tck.tests.refactoring;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+
+@ApplicationScoped
+public class Generator implements Serializable
+{
+ private static final long serialVersionUID = -7213673465118041882L;
+
+ private java.util.Random random = new java.util.Random(System.currentTimeMillis());
+
+ private int maxNumber = 100;
+
+ java.util.Random getRandom()
+ {
+ String s = "#{game}";
+ return random;
+ }
+
+ @Produces @Random int next()
+ {
+ return getRandom().nextInt(maxNumber);
+ }
+
+ @Produces @MaxNumber int getMaxNumber()
+ {
+ return maxNumber;
+ }
+}
+
+@Named("another")
+class AnotherOne {
+
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Generator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/HomePage.xhtml
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/HomePage.xhtml
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/HomePage.xhtml 2010-04-08
16:30:42 UTC (rev 21358)
@@ -0,0 +1,28 @@
+<html
xmlns:h="http://java.sun.com/jsf/html">
+ <head>
+ <title>Wicket Weld example</title>
+ </head>
+ <body>
+ <h1>Guess a number...</h1>
+ <form wicket:id="NumberGuessMain">
+ <div style="color: red">
+ <span wicket:id="messages#{myInner}"/>
+ </div>
+
+ <div wicket:id="prompt">
+ I'm thinking of a number between 0 and 100. You have 10 guesses.
+ </div>
+
+ <div>
+ <span wicket:id="guessLabel">Your guess:</span>
+ <input wicket:id="inputGuess" type="text"
size="3"/>
+ <input wicket:id="GuessButton" type="submit"
value="Guess"/>
+ <input wicket:id="RestartButton" type="submit"
value="Reset"/>
+ <h:commandButton id="GuessButton" value="Guess"
action="#{game.check}" disabled="false"/>
+ </div>
+ <div>
+ <h:commandButton id="RestartButton" value="Reset"
action="#{game.reset}" immediate="true"/>
+ </div>
+ </form>
+ </body>
+</html>
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/HomePage.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/MaxNumber.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/MaxNumber.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/MaxNumber.java 2010-04-08
16:30:42 UTC (rev 21358)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.refactoring;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface MaxNumber
+{
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/MaxNumber.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Random.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Random.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Random.java 2010-04-08
16:30:42 UTC (rev 21358)
@@ -0,0 +1,21 @@
+package org.jboss.jsr299.tck.tests.refactoring;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+public @interface Random
+{
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/Random.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/index.jsp
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/index.jsp
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/index.jsp 2010-04-08
16:30:42 UTC (rev 21358)
@@ -0,0 +1,19 @@
+<%@ taglib
uri="http://java.sun.com/jsf/core" prefix="f"%>
+<%@ taglib
uri="http://java.sun.com/jsf/html" prefix="h"%>
+
+<f:loadBundle var="Message" basename="demo.Messages" />
+
+<html>
+ <head>
+ <title>Hello!</title>
+ </head>
+
+ <body>
+ <f:view>
+ <h3>
+ <h:outputText value="#{game.biggest}" />!
+ </h3>
+ </f:view>
+ </body>
+
+</html>
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/resources/tck/tests/refactoring/index.jsp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-04-08
16:28:17 UTC (rev 21357)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2010-04-08
16:30:42 UTC (rev 21358)
@@ -13,6 +13,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.jboss.tools.cdi.core.test.tck.NamedBeanRefactoringTest;
import org.jboss.tools.tests.AbstractPluginsLoadTest;
/**
@@ -23,6 +24,7 @@
public static Test suite() {
TestSuite suite = new TestSuite("CDI Core Tests");
suite.addTest(new CDICoreTestSetup(CDICoreTestSuite.suite()));
+ suite.addTest(new NamedBeanRefactoringTest().suite());
return suite;
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NamedBeanRefactoringTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NamedBeanRefactoringTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NamedBeanRefactoringTest.java 2010-04-08
16:30:42 UTC (rev 21358)
@@ -0,0 +1,98 @@
+package org.jboss.tools.cdi.core.test.tck;
+
+import java.util.ArrayList;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.ICDIProject;
+import org.jboss.tools.cdi.internal.core.refactoring.RenameNamedBeanProcessor;
+import org.jboss.tools.tests.AbstractRefactorTest;
+
+public class NamedBeanRefactoringTest extends AbstractRefactorTest {
+ private static final String PROJECT_NAME = "/tests/refactoring";
+ private static final String FILE_NAME1 =
"JavaSource/org/jboss/jsr299/tck/tests/refactoring/Game.java";
+ private static final String FILE_NAME2 =
"JavaSource/org/jboss/jsr299/tck/tests/refactoring/Generator.java";
+ private static final String FILE_NAME3 = "WebContent/HomePage.xhtml";
+ private static final String FILE_NAME4 = "WebContent/index.jsp";
+ static IProject project;
+
+ public NamedBeanRefactoringTest(){
+ super("Named Bean Refactoring Test");
+ }
+
+ public static Test suite() {
+ return new TestSuite(NamedBeanRefactoringTest.class);
+ }
+
+ public void testNamedBeanRename() throws Exception {
+ IProject project = TCKTest.importPreparedProject(PROJECT_NAME);
+ doTest(project);
+ TCKTest.cleanProject(PROJECT_NAME);
+ }
+
+ public void doTest(IProject project) throws CoreException {
+ final String newName = "abcd";
+ ArrayList<TestChangeStructure> list = new
ArrayList<TestChangeStructure>();
+
+ TestChangeStructure structure = new TestChangeStructure(project.getProject(),
FILE_NAME1);
+ TestTextChange change = new TestTextChange(324, 4, newName);
+ structure.addTextChange(change);
+ list.add(structure);
+
+ structure = new TestChangeStructure(project, FILE_NAME2);
+ change = new TestTextChange(522, 4, newName);
+ structure.addTextChange(change);
+ list.add(structure);
+
+ structure = new TestChangeStructure(project, FILE_NAME3);
+ change = new TestTextChange(789, 4, newName);
+ structure.addTextChange(change);
+ change = new TestTextChange(923, 4, newName);
+ structure.addTextChange(change);
+ list.add(structure);
+
+ structure = new TestChangeStructure(project, FILE_NAME4);
+ change = new TestTextChange(293, 4, newName);
+ structure.addTextChange(change);
+ list.add(structure);
+
+ IFile sourceFile = project.getProject().getFile(FILE_NAME1);
+
+ IBean bean = getBean(sourceFile, "game");
+
+ RenameNamedBeanProcessor processor = new RenameNamedBeanProcessor(bean);
+ processor.setNewName(newName);
+
+ checkRename(processor, list);
+ }
+
+ private IBean getBean(IFile file, String name){
+ CDICoreNature cdiNature = CDICorePlugin.getCDI(file.getProject(), true);
+ if(cdiNature == null)
+ return null;
+
+ ICDIProject cdiProject = cdiNature.getDelegate();
+
+ if(cdiProject == null)
+ return null;
+
+ Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+
+ for(IBean bean : beans){
+ if(bean.getName() != null && name.equals(bean.getName()))
+ return bean;
+
+ }
+ return null;
+ }
+
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/NamedBeanRefactoringTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-04-08
16:28:17 UTC (rev 21357)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-04-08
16:30:42 UTC (rev 21358)
@@ -184,7 +184,7 @@
static class PageFileFilter implements FileFilter {
public boolean accept(File pathname) {
String name = pathname.getName();
- return (pathname.isDirectory() && !name.endsWith(".svn")) &&
!name.endsWith(".xml");
+ return (pathname.isDirectory() && !name.endsWith(".svn")) ||
name.endsWith(".jsp") || name.endsWith(".xhtml");
}
}