Author: jjankovi
Date: 2011-11-14 11:25:13 -0500 (Mon, 14 Nov 2011)
New Revision: 36325
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/EventBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/ObserverBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MainBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean2.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean3.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean4.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean5.java.cdi
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
Log:
JBDS50_0010 Classes indication for Open Injected Class works - test implemented
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/EventBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/EventBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/EventBean.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -0,0 +1,16 @@
+package cdi;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+public class EventBean {
+
+ public EventBean() {
+
+ }
+
+ @Inject
+ @Q1
+ Event<ObserverBean> event;
+
+}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi 2011-11-14
15:29:00 UTC (rev 36324)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -1,16 +0,0 @@
-package cdi;
-
-import javax.enterprise.event.Event;
-import javax.inject.Inject;
-
-public class MyBean3 {
-
- public MyBean3() {
-
- }
-
- @Inject
- @Q1
- Event<MyBean4> event;
-
-}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi 2011-11-14
15:29:00 UTC (rev 36324)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -1,15 +0,0 @@
-package cdi;
-
-import javax.enterprise.event.Observes;
-
-public class MyBean4 {
-
- public MyBean4() {
-
- }
-
- public void observerMethod(@Observes MyBean4 bean) {
-
- }
-
-}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/ObserverBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/ObserverBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/ObserverBean.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -0,0 +1,15 @@
+package cdi;
+
+import javax.enterprise.event.Observes;
+
+public class ObserverBean {
+
+ public ObserverBean() {
+
+ }
+
+ public void observerMethod(@Observes ObserverBean bean) {
+
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MainBean.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MainBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MainBean.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -0,0 +1,29 @@
+package cdi;
+
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+public class MainBean {
+
+ @Inject private MyBean1 myBean1;
+
+ @Inject private MyBean2 myBean2;
+
+ @Inject @Q1 private MyBean1 myBean3;
+
+ @Inject @Q1 private MyBean2 myBean4;
+
+ @Inject @Q2 private MyBean1 myBean5;
+
+ @Inject @Q2 private MyBean2 myBean6;
+
+ @Inject @Any private MyBean1 myBean7;
+
+ @Inject @Any private MyBean2 myBean8;
+
+ @Inject @Q1 @Q2 private MyBean1 myBean9;
+
+ @Inject @Q1 @Q2 private MyBean2 myBean10;
+
+ @Inject @Q1 @Q2 private MyBean4 myBean11;
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean2.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean2.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean2.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -0,0 +1,9 @@
+package cdi;
+
+public class MyBean2 extends MyBean1{
+
+ public MyBean2() {
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean3.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean3.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean3.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -0,0 +1,67 @@
+package cdi;
+
+import javax.enterprise.inject.Produces;
+
+public class MyBean3 {
+
+ public MyBean3() {
+
+ }
+
+ @Produces
+ public MyBean1 getMyBean1() {
+ return new MyBean1();
+ }
+
+ @Produces
+ public MyBean2 getMyBean2() {
+ return new MyBean2();
+ }
+
+ @Produces
+ public MyBean1 getMyBean1WithIMB2() {
+ return new MyBean2();
+ }
+
+
+
+ @Produces
+ @Q1
+ public MyBean1 getMyBean1WithQ1() {
+ return new MyBean1();
+ }
+
+ @Produces
+ @Q2
+ public MyBean1 getMyBean1WithQ2() {
+ return new MyBean1();
+ }
+
+
+
+ @Produces
+ @Q1
+ public MyBean2 getMyBean2WithQ1() {
+ return new MyBean2();
+ }
+
+ @Produces
+ @Q2
+ public MyBean2 getMyBean2WithQ2() {
+ return new MyBean2();
+ }
+
+
+ @Produces
+ @Q1
+ public MyBean1 getMyBean1WithIMB2Q1() {
+ return new MyBean2();
+ }
+
+ @Produces
+ @Q2
+ public MyBean1 getMyBean1WithIMB2Q2() {
+ return new MyBean2();
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean4.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean4.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean4.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -0,0 +1,10 @@
+package cdi;
+@Q1
+@Q2
+public class MyBean4 extends MyBean2{
+
+ public MyBean4() {
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean5.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean5.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/MyBean5.java.cdi 2011-11-14
16:25:13 UTC (rev 36325)
@@ -0,0 +1,6 @@
+package cdi;
+
+@Q2
+public class MyBean5 extends MyBean2 {
+
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-11-14
15:29:00 UTC (rev 36324)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-11-14
16:25:13 UTC (rev 36325)
@@ -12,11 +12,13 @@
import java.util.logging.Logger;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.quickfix.CDIQuickFixTest;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
@@ -29,12 +31,6 @@
*
* @author Jaroslav Jankovic
*
- *
- * TO DO
- *
- * - Classes indication for Open Injected Class works
- *
- *
*/
@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
@@ -42,7 +38,7 @@
@SuiteClasses({ CDIAllBotTests.class })
public class CDIOpenOnTest extends CDIBase {
- private static final Logger LOGGER = Logger.getLogger(CDIQuickFixTest.class.getName());
+ private static final Logger LOGGER =
Logger.getLogger(CDIQuickFixTest.class.getName());
@Override
public String getProjectName() {
@@ -52,22 +48,15 @@
@Test
public void testBeanInjectOpenOn() {
- createComponent(CDICOMPONENT.BEAN, "Animal", getPackageName(), null);
-
- createComponent(CDICOMPONENT.BEAN, "BrokenFarm", getPackageName(), null);
-
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
- false);
- LOGGER.info("Content of \"BrokenFarm.java.cdi\" copied to
BrokenFarm");
- openOn("@Inject", "BrokenFarm.java", "@Inject");
- assertTrue("ERROR: redirected to " + getEd().getTitle(), getEd()
- .getTitle().equals("Animal.java"));
+ prepareInjectedPointsComponents();
+
+ testInjectedPoints();
+
}
-
+
/*
*
https://issues.jboss.org/browse/JBIDE-7025
- */
+ */
@Test
public void testBeansXMLClassesOpenOn() {
@@ -113,8 +102,7 @@
/*
*
https://issues.jboss.org/browse/JBIDE-6251
- */
-
+ */
@Test
public void testDisposerProducerOpenOn() {
@@ -132,27 +120,199 @@
}
@Test
- public void testObserverOpenOn() {
- createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, "MyBean3", getPackageName(), null);
+ public void testObserverOpenOn() {
+ createComponent(CDICOMPONENT.BEAN, "EventBean", getPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/MyBean3.java.cdi"),
+ .getResourceAsStream("/resources/cdi/EventBean.java.cdi"),
false);
- createComponent(CDICOMPONENT.BEAN, "MyBean4", getPackageName(), null);
+ createComponent(CDICOMPONENT.BEAN, "ObserverBean", getPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/MyBean4.java.cdi"),
+ .getResourceAsStream("/resources/cdi/ObserverBean.java.cdi"),
false);
- bot.editorByTitle("MyBean3.java").show();
+ bot.editorByTitle("EventBean.java").show();
setEd(bot.activeEditor().toTextEditor());
CDIUtil.replaceInEditor(getEd(), bot, " event", " event");
- openOn("observerMethod", "MyBean4.java", "Open CDI
Event");
+ openOn("observerMethod", "ObserverBean.java", "Open CDI
Event");
assertTrue(getEd().toTextEditor().getSelection().equals("event"));
- openOn("Event<MyBean4> event", "MyBean3.java", "Open CDI
Observer Method");
+ openOn("Event<ObserverBean> event", "EventBean.java",
"Open CDI Observer Method");
assertTrue(getEd().toTextEditor().getSelection().equals("observerMethod"));
}
+ private void prepareInjectedPointsComponents() {
+ createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
+
+ createComponent(CDICOMPONENT.QUALIFIER, "Q2", getPackageName(), null);
+
+ createComponent(CDICOMPONENT.BEAN, "MyBean1", getPackageName(), null);
+
+ createComponent(CDICOMPONENT.BEAN, "MyBean2", getPackageName(), null);
+ CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
+ .getResourceAsStream("/resources/injectedPoints/MyBean2.java.cdi"),
+ false);
+
+ createComponent(CDICOMPONENT.BEAN, "MyBean3", getPackageName(), null);
+ CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
+ .getResourceAsStream("/resources/injectedPoints/MyBean3.java.cdi"),
+ false);
+
+ createComponent(CDICOMPONENT.BEAN, "MyBean4", getPackageName(), null);
+ CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
+ .getResourceAsStream("/resources/injectedPoints/MyBean4.java.cdi"),
+ false);
+
+ createComponent(CDICOMPONENT.BEAN, "MyBean5", getPackageName(), null);
+ CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
+ .getResourceAsStream("/resources/injectedPoints/MyBean5.java.cdi"),
+ false);
+
+ createComponent(CDICOMPONENT.BEAN, "MainBean", getPackageName(), null);
+ CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
+ .getResourceAsStream("/resources/injectedPoints/MainBean.java.cdi"),
+ false);
+ }
+ private void testInjectedPoints() {
+ String injectOption = null;
+ for (int i = 1; i < 12; i++) {
+ injectOption = "Show All Assignable Beans...";
+ String injectPoint = "myBean" + i;
+ if (i > 8) injectOption = "Open @Inject Bean";
+ checkInjectedPoint(injectPoint, injectOption);
+ }
+
+ }
+
+ private void checkInjectedPoint(String injectedPoint, String option) {
+ openOn(injectedPoint, "MainBean.java", option);
+ bot.sleep(Timing.time1S());
+ if (option.equals("Open @Inject Bean")) {
+ LOGGER.info("Testing injected point: \"" + injectedPoint +
"\" started");
+ assertTrue(getEd().getTitle().equals("MyBean4.java"));
+ assertTrue(getEd().toTextEditor().getSelection().equals("MyBean4"));
+ LOGGER.info("Testing injected point: \"" + injectedPoint +
"\" ended");
+ } else {
+ SWTBotTable assignBeans = bot.table(0);
+ assertTrue(checkAllAssignBeans(injectedPoint, assignBeans));
+ }
+ }
+
+ private boolean checkAllAssignBeans(String injectedPoint,
+ SWTBotTable assignBeans) {
+ String packageProjectPath = getPackageName() + " - /" + getProjectName() +
"/src";
+ String paramAssignBean = "XXX - " + packageProjectPath;
+ String prodInjPoint = "@Produces MyBean3.getMyBeanXXX()";
+ boolean allassignBeans = false;
+ String indexOfInjPoint = injectedPoint.split("myBean")[1];
+ int intIndexOfInjPoint = Integer.parseInt(indexOfInjPoint);
+ LOGGER.info("Testing injected point: \"" + injectedPoint + "\"
started");
+ switch (intIndexOfInjPoint) {
+ case 1:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean1")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX",
"1WithIMB2")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 2:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 3:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX",
"1WithQ1")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX",
"1WithIMB2Q1")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 4:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 5:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithQ2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q2"))))
{
+ allassignBeans = true;
+ }
+ break;
+ case 6:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 7:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean1")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1"))) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithQ1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithQ2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2"))) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 8:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2"))) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 9:
+ case 10:
+ case 11:
+ throw new IllegalStateException("Injection Point \"" + injectedPoint +
"\" should " +
+ "have been tested earlier!!");
+ }
+ LOGGER.info("Testing injected point: \"" + injectedPoint + "\"
ended");
+ return allassignBeans;
+ }
+
}
\ No newline at end of file