JBoss Tools SVN: r36469 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test: resources/openon/InjectedPoints and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-11-21 05:06:20 -0500 (Mon, 21 Nov 2011)
New Revision: 36469
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MainBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean2.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean3.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean4.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean5.java.cdi
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java
Log:
New resource for OpenOn test + JavaDoc for some classes
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MainBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MainBean.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MainBean.java.cdi 2011-11-21 10:06:20 UTC (rev 36469)
@@ -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/openon/InjectedPoints/MyBean2.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean2.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean2.java.cdi 2011-11-21 10:06:20 UTC (rev 36469)
@@ -0,0 +1,9 @@
+package cdi;
+
+public class MyBean2 extends MyBean1{
+
+ public MyBean2() {
+
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean3.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean3.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean3.java.cdi 2011-11-21 10:06:20 UTC (rev 36469)
@@ -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/openon/InjectedPoints/MyBean4.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean4.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean4.java.cdi 2011-11-21 10:06:20 UTC (rev 36469)
@@ -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/openon/InjectedPoints/MyBean5.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean5.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/InjectedPoints/MyBean5.java.cdi 2011-11-21 10:06:20 UTC (rev 36469)
@@ -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/CDIAllBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -48,7 +48,7 @@
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 25min
+ * Suite duration: aprox. 23min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -33,7 +33,7 @@
*
* Sample swtbot.properties file:
*
- * SERVER=JBOSS_AS,6.0,default,/home/lukas/latest/jboss-6.0.0.Final
+ * SERVER=JBOSS_AS,6.0,default,/home/jjankovi/Dokumenty/Red_Hat_Stuff/Runtimes/jboss-6.0.0.Final
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -153,27 +153,27 @@
wizard.createComponent(CDIWizardType.BEAN, "MyBean2", getPackageName(), null);
editResourceUtil.replaceClassContentByResource(OpenOnTest.class
- .getResourceAsStream("/resources/openon/injectedPoints/MyBean2.java.cdi"),
+ .getResourceAsStream("/resources/openon/InjectedPoints/MyBean2.java.cdi"),
false);
wizard.createComponent(CDIWizardType.BEAN, "MyBean3", getPackageName(), null);
editResourceUtil.replaceClassContentByResource(OpenOnTest.class
- .getResourceAsStream("/resources/openon/injectedPoints/MyBean3.java.cdi"),
+ .getResourceAsStream("/resources/openon/InjectedPoints/MyBean3.java.cdi"),
false);
wizard.createComponent(CDIWizardType.BEAN, "MyBean4", getPackageName(), null);
editResourceUtil.replaceClassContentByResource(OpenOnTest.class
- .getResourceAsStream("/resources/openon/injectedPoints/MyBean4.java.cdi"),
+ .getResourceAsStream("/resources/openon/InjectedPoints/MyBean4.java.cdi"),
false);
wizard.createComponent(CDIWizardType.BEAN, "MyBean5", getPackageName(), null);
editResourceUtil.replaceClassContentByResource(OpenOnTest.class
- .getResourceAsStream("/resources/openon/injectedPoints/MyBean5.java.cdi"),
+ .getResourceAsStream("/resources/openon/InjectedPoints/MyBean5.java.cdi"),
false);
wizard.createComponent(CDIWizardType.BEAN, "MainBean", getPackageName(), null);
editResourceUtil.replaceClassContentByResource(OpenOnTest.class
- .getResourceAsStream("/resources/openon/injectedPoints/MainBean.java.cdi"),
+ .getResourceAsStream("/resources/openon/InjectedPoints/MainBean.java.cdi"),
false);
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -88,7 +88,7 @@
checkMultipleBean();
}
- @Ignore
+
// https://issues.jboss.org/browse/JBIDE-7664
@Test
public void testConstructor() {
@@ -113,7 +113,7 @@
checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
}
- @Ignore
+
// https://issues.jboss.org/browse/JBIDE-7665
@Test
public void testProducer() {
@@ -139,7 +139,7 @@
checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
}
- @Ignore
+
// https://issues.jboss.org/browse/JBIDE-7667
@Test
public void testInjectDisposer() {
@@ -155,7 +155,7 @@
checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
}
- @Ignore
+
// https://issues.jboss.org/browse/JBIDE-7667
@Test
public void testInjectObserver() {
@@ -174,7 +174,7 @@
checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
}
- @Ignore
+
// https://issues.jboss.org/browse/JBIDE-7667
@Test
public void testInjectProducer() {
@@ -191,7 +191,7 @@
checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.BEAN);
}
- @Ignore
+
// https://issues.jboss.org/browse/JBIDE-7668
@Test
public void testObserverWithDisposer() {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -133,7 +133,11 @@
util.waitForNonIgnoredJobs();
}
-
+ /**
+ * Method resolves one validation problem in one test case in
+ * BeanValidationQuickFixTest - it is too specific method, not usable
+ * in general, only in this case
+ */
public void resolveMultipleBeans() {
SWTBotTreeItem validationProblem = getProblem(CDIAnnotationsType.INJECT,
@@ -158,6 +162,10 @@
util.waitForNonIgnoredJobs();
}
+ /**
+ * Method checks if specific validation problem was resolved by
+ * quick fix - not usable in general, only in this case
+ */
public void checkMultipleBean() {
String code = getEd().toTextEditor().getText();
assertTrue(code.contains("@Inject @Q1 private Animal animal;"));
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -21,12 +21,19 @@
public class CDIProjectHelper extends CDIBase{
-
+ /**
+ * Method creates new CDI Project - Dynamic Web Project + CDI Support
+ * @param projectName
+ */
public void createCDIProject(String projectName) {
createDynamicWebProject(projectName);
addCDISupport(projectName);
}
+ /**
+ * Method creates new Dynamic Web Project with CDI Preset checked
+ * @param projectName
+ */
public void createDynamicWebProjectWithCDIPreset(String projectName) {
new NewFileWizardAction().run()
.selectTemplate("Web", "Dynamic Web Project").next();
@@ -34,6 +41,10 @@
util.waitForNonIgnoredJobs();
}
+ /**
+ * Method creates new Dynamic Web Project with CDI Facets checked
+ * @param projectName
+ */
public void createDynamicWebProjectWithCDIFacets(String projectName) {
new NewFileWizardAction().run()
.selectTemplate("Web", "Dynamic Web Project").next();
@@ -42,6 +53,11 @@
util.waitForNonIgnoredJobs();
}
+ /**
+ * Methods checks if project with entered name exists in actual workspace
+ * @param projectName
+ * @return
+ */
public boolean projectExists(String projectName) {
SWTBotTree tree = projectExplorer.bot().tree();
boolean projectExists = false;
@@ -53,6 +69,10 @@
return projectExists;
}
+ /**
+ * Method creates new Dynamic Web Project
+ * @param projectName
+ */
private void createDynamicWebProject(String projectName) {
new NewFileWizardAction().run()
.selectTemplate("Web", "Dynamic Web Project").next();
@@ -60,6 +80,10 @@
util.waitForNonIgnoredJobs();
}
+ /**
+ * Method adds CDI support to project with entered name
+ * @param projectName
+ */
private void addCDISupport(String projectName) {
projectExplorer.selectProject(projectName);
SWTBotTree tree = projectExplorer.bot().tree();
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -21,6 +21,15 @@
public class OpenOnHelper extends CDIBase{
+ /**
+ * Method simulates "OpenOn" - press Ctrl, move mouse over selected string and
+ * context menu appears. Method selects "openOnString", open context menu, select
+ * "chosenOption" and simulates click - after OpenOn, it sets active editor to
+ * one, opened by OpenOn
+ * @param openOnString
+ * @param titleName
+ * @param chosenOption
+ */
public void openOnByOption(String openOnString, String titleName, String chosenOption) {
selectTextForOpenOn(openOnString, titleName);
SWTBotMenu navigateMenu = bot.menu("Navigate");
@@ -38,6 +47,13 @@
setEd(bot.activeEditor().toTextEditor());
}
+ /**
+ * Method simulates direct "OpenOn" - press F3 when selecting some string.
+ * Method selects "openOnString" and simulates F3 - after OpenOn, it sets
+ * active editor to one, opened by OpenOn
+ * @param openOnString
+ * @param titleName
+ */
public void openOnDirect(String openOnString, String titleName) {
selectTextForOpenOn(openOnString, titleName);
bot.sleep(Timing.time3S());
@@ -45,6 +61,12 @@
setEd(bot.activeEditor().toTextEditor());
}
+ /**
+ * Methods select text in editor. It has some workaround when "openOnString"
+ * contains @, these string cannot be opened by openon, so offset is set to 1
+ * @param openOnString
+ * @param titleName
+ */
private void selectTextForOpenOn(String openOnString, String titleName) {
SWTBotEditor ed = bot.editorByTitle(titleName);
ed.show();
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -10,8 +10,6 @@
protected AbstractValidationProvider validationErrorsProvider;
- public static SWTBotTreeItem[] problemsTrees;
-
/**
* Method open context menu for given tree item and opens Quick Fix option
* @param item
@@ -37,6 +35,10 @@
return problemsTree;
}
+ /**
+ * Method gets allProblems in problemsView as array of SWTBotTreeItem
+ * @return
+ */
public SWTBotTreeItem[] getAllProblems() {
SWTBotTreeItem[] warningProblemsTree = getProblems(ProblemsType.WARNINGS);
@@ -46,6 +48,12 @@
return joinTwoArrays(warningProblemsTree, errorProblemsTree);
}
+ /**
+ * Method joins two arrays and returns them as one joined array
+ * @param aArray
+ * @param bArray
+ * @return
+ */
private SWTBotTreeItem[] joinTwoArrays(SWTBotTreeItem[] aArray, SWTBotTreeItem[] bArray) {
SWTBotTreeItem[] bigArray = new SWTBotTreeItem[aArray.length + bArray.length];
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java 2011-11-21 09:33:15 UTC (rev 36468)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java 2011-11-21 10:06:20 UTC (rev 36469)
@@ -13,15 +13,25 @@
throw new AssertionError();
}
+ /**
+ * Method disables folding used in editor in eclipse
+ * @param bot
+ * @param util
+ */
public static void disableFolding(SWTBotExt bot, SWTUtilExt util) {
editFolding(bot, util, false);
}
+ /**
+ * Method enable folding used in editor in eclipse
+ * @param bot
+ * @param util
+ */
public static void enableFolding(SWTBotExt bot, SWTUtilExt util) {
editFolding(bot, util, true);
}
- public static void editFolding(SWTBotExt bot, SWTUtilExt util,
+ private static void editFolding(SWTBotExt bot, SWTUtilExt util,
boolean select) {
bot.menu("Window").menu("Preferences").click();
bot.shell("Preferences").activate();
13 years, 1 month
JBoss Tools SVN: r36468 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test: resources and 23 other directories.
by jbosstools-commits@lists.jboss.org
Author: jjankovi
Date: 2011-11-21 04:33:15 -0500 (Mon, 21 Nov 2011)
New Revision: 36468
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/BeanWithDisposerAndProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/BrokenFarm.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/FindObserverForEventTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/Seam3Test.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java
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/quickfix/CDIQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/editor/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIATWizardTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt
Log:
BeansXMLValidationTest + OpenOn test on assignable beans + huge refactoring of all tests
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<beans xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+</beans>
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/BeanWithDisposerAndProducer.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/BeanWithDisposerAndProducer.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/BeanWithDisposerAndProducer.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,21 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ int value;
+
+ public void disposeMethod(@Disposes int value) {
+
+ }
+
+ @Produces
+ public int produceMethod() {
+ return 0;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -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;
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -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/quickfix/BrokenFarm.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/BrokenFarm.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/BrokenFarm.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,9 @@
+package cdi;
+
+import javax.inject.Inject;
+
+public class BrokenFarm {
+ @SuppressWarnings("unused")
+ @Inject private Animal animal;
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,9 @@
+package cdi;
+
+public class Dog extends Animal {
+
+ public Dog() {
+
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,14 @@
+package cdi;
+
+import javax.enterprise.context.SessionScoped;
+
+@SessionScoped
+public class BeanComponent {
+
+ private static final long serialVersionUID = 1L;
+
+ public BeanComponent() {
+
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ public void method(@Disposes int value) {
+
+ }
+
+ @Produces
+ public int getInt() {
+ return 0;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,14 @@
+package cdi;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ @Produces
+ public int getInt() {
+ return 0;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ public BeanComponent(@Disposes String value) {
+
+ }
+
+ @Produces
+ public String getValue() {
+ return null;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,16 @@
+package cdi;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+public class BeanComponent {
+ @Produces
+ public long produce(){
+ return 0;
+ }
+
+ public void method(@Observes long param1, @Disposes long param2){
+
+ }
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+public class BeanComponent {
+
+ @Produces
+ public String getValue(@Disposes String value) {
+ return null;
+ }
+
+ @Produces
+ public String getValue2() {
+ return null;
+ }
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,23 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Disposes;
+import javax.inject.Inject;
+
+@Decorator
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+ public void method(@Disposes String value) {
+
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Decorator
+@Named
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,24 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+@Decorator
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+ @Produces
+ public int getValue() {
+ return 0;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,22 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Specializes;
+import javax.inject.Inject;
+
+@Decorator
+@Specializes
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+@Decorator
+@Stateless
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+ public void method(@Disposes String value) {
+
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.inject.Named;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@Named
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,21 @@
+package cdi;
+
+import javax.enterprise.inject.Produces;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+ @Produces
+ public int getValue() {
+ return 0;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.enterprise.inject.Specializes;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@Specializes
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@Stateless
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,23 @@
+package cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Inherited
+@Target({ TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+public @interface IBindingComponent {
+
+ AAnnotation value();
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,23 @@
+package cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+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;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface QualifierComponent {
+
+ AAnnotation value();
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,22 @@
+package cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.context.NormalScope;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@NormalScope
+@Inherited
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface ScopeComponent {
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,18 @@
+package cdi;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+@Retention(RUNTIME)
+@Stereotype
+@Target({ TYPE, METHOD, FIELD })
+@Documented
+public @interface StereotypeComponent {
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+import javax.inject.Named;
+
+@Retention(RUNTIME)
+@Stereotype
+@Target({FIELD})
+@Named("name")
+@Documented
+public @interface StereotypeComponent {
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+import javax.enterprise.inject.Typed;
+
+@Retention(RUNTIME)
+@Stereotype
+@Target({FIELD})
+@Typed
+@Documented
+public @interface StereotypeComponent {
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package cdi;
+
+import java.net.URL;
+
+import javax.inject.Inject;
+
+import org.jboss.seam.solder.resourceLoader.Resource;
+
+public class BeanComponent {
+
+ @Inject
+ @Resource("WEB-INF/beans.xml")
+ URL beansXml;
+
+ public ResourceBean() {
+ // TODO Auto-generated constructor stub
+ }
+
+}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -10,16 +10,22 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test;
-import org.jboss.tools.cdi.bot.test.editor.CDIBeansEditorTest;
-import org.jboss.tools.cdi.bot.test.openon.CDIFindObserverForEventTest;
-import org.jboss.tools.cdi.bot.test.openon.CDIOpenOnTest;
-import org.jboss.tools.cdi.bot.test.quickfix.CDIQuickFixTest;
-import org.jboss.tools.cdi.bot.test.seam3.CDISeam3Test;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.wizard.CDIATWizardTest;
-import org.jboss.tools.cdi.bot.test.wizard.CDIConfigurationPresetTest;
-import org.jboss.tools.cdi.bot.test.wizard.CDIFacetTest;
+import org.jboss.tools.cdi.bot.test.beansxml.BeansXMLValidationTest;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
+import org.jboss.tools.cdi.bot.test.openon.FindObserverForEventTest;
+import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
+import org.jboss.tools.cdi.bot.test.quickfix.BeanValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.DecoratorValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.IBindingValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.InterceptorValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.QualifierValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.ScopeValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.StereotypeValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.seam3.Seam3Test;
+import org.jboss.tools.cdi.bot.test.uiutils.SWTEclipseCDIExtUtil;
+import org.jboss.tools.cdi.bot.test.wizard.ConfigurationPresetTest;
+import org.jboss.tools.cdi.bot.test.wizard.FacetTest;
+import org.jboss.tools.cdi.bot.test.wizard.WizardTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -38,37 +44,45 @@
*
* Sample swtbot.properties file:
*
- * SERVER=JBOSS_AS,6.0,default,/home/lukas/latest/jboss-6.0.0.Final
+ * SERVER=JBOSS_AS,6.0,default,/home/jjankovi/Dokumenty/Red_Hat_Stuff/Runtimes/jboss-6.0.0.Final
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 19min
+ * Suite duration: aprox. 25min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
*/
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
- //CDIPerspectiveTest.class,
- CDIConfigurationPresetTest.class,
- CDIFacetTest.class,
- CDIATWizardTest.class,
- CDIBeansEditorTest.class,
- CDIQuickFixTest.class,
- CDIOpenOnTest.class,
- CDIFindObserverForEventTest.class,
- CDISeam3Test.class
+// PerspectiveTest.class,
+ ConfigurationPresetTest.class,
+ FacetTest.class,
+ WizardTest.class,
+ BeansEditorTest.class,
+ BeansXMLValidationTest.class,
+// BeansXMLCompletionTest.class,
+ StereotypeValidationQuickFixTest.class,
+ QualifierValidationQuickFixTest.class,
+ ScopeValidationQuickFixTest.class,
+ BeanValidationQuickFixTest.class,
+ InterceptorValidationQuickFixTest.class,
+ DecoratorValidationQuickFixTest.class,
+ IBindingValidationQuickFixTest.class,
+ OpenOnTest.class,
+ FindObserverForEventTest.class,
+ Seam3Test.class
})
-public class CDIAllBotTests extends CDIBase {
+public class CDIAllBotTests extends CDITestBase {
/*
* init method "setup()" shows a project explorer view as default,
- * disable folding ( to easier source code editing)
+ * disable folding (to easier source code editing)
*/
@BeforeClass
public static void setUpSuite() {
eclipse.showView(ViewType.PROJECT_EXPLORER);
- CDIUtil.disableFolding(bot, util);
+ SWTEclipseCDIExtUtil.disableFolding(bot, util);
}
}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+
+public class CDIBase extends SWTTestExt{
+
+ private static SWTBotEclipseEditor ed;
+
+ public SWTBotEclipseEditor getEd() {
+ return ed;
+ }
+
+ public void setEd(SWTBotEclipseEditor ed) {
+ CDIBase.ed = ed;
+ }
+}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -10,12 +10,11 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test;
-import org.jboss.tools.cdi.bot.test.editor.CDIBeansEditorTest;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.wizard.CDIATWizardTest;
-import org.jboss.tools.cdi.bot.test.wizard.CDIConfigurationPresetTest;
-import org.jboss.tools.cdi.bot.test.wizard.CDIFacetTest;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
+import org.jboss.tools.cdi.bot.test.uiutils.SWTEclipseCDIExtUtil;
+import org.jboss.tools.cdi.bot.test.wizard.WizardTest;
+import org.jboss.tools.cdi.bot.test.wizard.ConfigurationPresetTest;
+import org.jboss.tools.cdi.bot.test.wizard.FacetTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -44,13 +43,13 @@
*/
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
- //CDIPerspectiveTest.class,
- CDIConfigurationPresetTest.class,
- CDIFacetTest.class,
- CDIATWizardTest.class,
- CDIBeansEditorTest.class,
+ //PerspectiveTest.class,
+ ConfigurationPresetTest.class,
+ FacetTest.class,
+ WizardTest.class,
+ BeansEditorTest.class,
})
-public class CDISmokeBotTests extends CDIBase {
+public class CDISmokeBotTests extends CDITestBase {
/*
* init method "setup()" shows a project explorer view as default,
@@ -59,6 +58,6 @@
@BeforeClass
public static void setUpSuite() {
eclipse.showView(ViewType.PROJECT_EXPLORER);
- CDIUtil.disableFolding(bot, util);
+ SWTEclipseCDIExtUtil.disableFolding(bot, util);
}
}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test;
+
+import org.jboss.tools.cdi.bot.test.uiutils.CDIProjectHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.EditorResourceHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.LibraryHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.OpenOnHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
+import org.junit.After;
+import org.junit.Before;
+
+public class CDITestBase extends CDIBase {
+
+ private String projectName = "CDIProject";
+ private String packageName = "cdi";
+ public final String LINE_SEPARATOR = System.getProperty("line.separator");
+
+ public static CDIProjectHelper projectHelper = new CDIProjectHelper();
+ public static CDIWizard wizard = new CDIWizard();
+ public static OpenOnHelper openOnUtil = new OpenOnHelper();
+ public static LibraryHelper libraryUtil = new LibraryHelper();
+ public static EditorResourceHelper editResourceUtil = new EditorResourceHelper();
+
+ @Before
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ }
+ }
+
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.annotations;
+
+public enum CDIAnnotationsType {
+
+ SERIALIZABLE, TARGET, RETENTION, NAMED, TYPED, DISPOSES, OBSERVES, INTERCEPTOR,
+ SPECIALIZES, DECORATOR, PRODUCES, NONBINDING, STATELESS, INJECT;
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.annotations;
+
+public enum CDIWizardType {
+
+ INTERCEPTOR_BINDING, QUALIFIER, SCOPE, STEREOTYPE,
+ DECORATOR, INTERCEPTOR, BEAN, ANNOTATION_LITERAL,
+ BEANS_XML;
+
+ String getName() {
+ switch (this) {
+ case INTERCEPTOR_BINDING:
+ return "Interceptor Binding";
+ case QUALIFIER:
+ return "Qualifier";
+ case SCOPE:
+ return "Scope";
+ case STEREOTYPE:
+ return "Stereotype";
+ case DECORATOR:
+ return "Decorator";
+ case INTERCEPTOR:
+ return "Interceptor";
+ case BEAN:
+ return "Bean";
+ case ANNOTATION_LITERAL:
+ return "Annotation Literal";
+ case BEANS_XML:
+ return "File beans.xml";
+ default:
+ throw new AssertionError("Unknown type");
+ }
+ }
+
+ public String getAnnotationType() {
+ return isAnnotation() ? getName() + " Annotation" : getName();
+ }
+
+ private boolean isAnnotation() {
+ return this.ordinal() < DECORATOR.ordinal();
+ }
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.annotations;
+
+public enum ProblemsType {
+ WARNINGS, ERRORS
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.beansxml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+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;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on code completion in beans.xml
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class BeansXMLCompletionTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger
+ .getLogger(BeansXMLCompletionTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIBeansCodeCompletion";
+ }
+
+ @Test
+ public void testPossibleCompletionInBeansXML() {
+ wizard.createClearBeansXML(getPackageName());
+ LOGGER.info("Clear beans.xml was created");
+
+ List<String> autoCompletion = getAutoCompletion(3, 0, "<");
+
+ assertTrue("Error: Size of auto completion proposals should be 3 " +
+ "instead of " + autoCompletion.size(), autoCompletion.size() == 3);
+ }
+ @Ignore
+ @Test
+ public void testInterceptorsCompletion() {
+
+ prepareInterceptors();
+
+ wizard.createClearBeansXML(getPackageName());
+ LOGGER.info("Clear beans.xml was created");
+
+ }
+ @Ignore
+ @Test
+ public void testDecoratorsCompletion() {
+
+ prepareDecorators();
+
+ wizard.createClearBeansXML(getPackageName());
+ LOGGER.info("Clear beans.xml was created");
+
+ }
+ @Ignore
+ @Test
+ public void testAlternativesCompletion() {
+
+ prepareAlternatives();
+
+ wizard.createClearBeansXML(getPackageName());
+ LOGGER.info("Clear beans.xml was created");
+
+ }
+
+ private void prepareInterceptors() {
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor1",
+ getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor2",
+ getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor3",
+ getPackageName(), null);
+
+ }
+
+ private void prepareDecorators() {
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "Decorator1",
+ getPackageName(), "java.util.Set");
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "Decorator2",
+ getPackageName(), "java.util.Set");
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "Decorator3",
+ getPackageName(), "java.util.Set");
+
+ }
+
+ private void prepareAlternatives() {
+
+ wizard.createComponent(CDIWizardType.BEAN, "Alternative1",
+ getPackageName(), "alternative");
+
+ wizard.createComponent(CDIWizardType.BEAN, "Alternative2",
+ getPackageName(), "alternative");
+
+ wizard.createComponent(CDIWizardType.BEAN, "Alternative3",
+ getPackageName(), "alternative");
+
+ }
+
+ //not complete yet
+ private List<String> getAutoCompletion(int row, int column, String text) {
+ List<String> listOfCompletion = new ArrayList<String>();
+ getEd().navigateTo(row, column);
+ bot.sleep(Timing.time500MS());
+ getEd().typeText(text);
+ bot.sleep(Timing.time500MS());
+ getEd().pressShortcut(Keystrokes.CTRL, Keystrokes.SPACE);
+ bot.sleep(Timing.time1S());
+ for (int i = 0; i < bot.table().rowCount(); i++) {
+ listOfCompletion.add(bot.table().getTableItem(i).getText());
+ }
+ return listOfCompletion;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.beansxml;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on code completion in beans.xml
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class BeansXMLValidationTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger
+ .getLogger(BeansXMLValidationTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIBeansValidation";
+ }
+
+ @Test
+ public void testClearBeansXMLValidation() {
+
+ wizard.createClearBeansXML(getProjectName());
+ LOGGER.info("Clear beans.xml was created");
+
+ SWTBotTreeItem[] validationErrors = getBeansXMLValidationErrors();
+
+ assertTrue(validationErrors.length == 0);
+
+ }
+
+ @Test
+ public void testInterceptorsValidation() {
+
+ String firstPackage = getPackageName() + ".test1";
+ String secondPackage = getPackageName() + ".test2";
+ String nonExistingPackage = getPackageName() + ".test3";
+
+ prepareTwoInterceptors(firstPackage, secondPackage);
+
+ wizard.createClearBeansXML(getProjectName());
+ LOGGER.info("Clear beans.xml was created");
+
+ String interceptorTag = "<interceptors>" + LINE_SEPARATOR +
+ "</interceptors>" + LINE_SEPARATOR;
+ String firstInterceptor = "<class>" + firstPackage + ".I1</class>" + LINE_SEPARATOR;
+
+ editResourceUtil.insertInEditor(3, 0, interceptorTag);
+ editResourceUtil.insertInEditor(4, 0, firstInterceptor);
+ assertTrue(getBeansXMLValidationErrors().length == 0);
+
+ String secondDecorator = "<class>" + secondPackage + ".I2</class>" + LINE_SEPARATOR;
+ editResourceUtil.insertInEditor(5, 0, secondDecorator);
+ assertTrue(getBeansXMLValidationErrors().length == 0);
+
+
+ editResourceUtil.replaceInEditor(firstPackage, nonExistingPackage);
+
+ SWTBotTreeItem[] validationErrors = getBeansXMLValidationErrors();
+ assertTrue(validationErrors.length == 1);
+ assertTrue(validationErrors[0].getText().contains("There is no class with the specified name"));
+
+ wizard.createComponent(CDIWizardType.BEAN, "Bean1", firstPackage, null);
+ bot.editorByTitle("beans.xml").show();
+ bot.editorByTitle("beans.xml").setFocus();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceInEditor(nonExistingPackage + ".I1", firstPackage + ".Bean1");
+
+ validationErrors = getBeansXMLValidationErrors();
+ assertTrue(validationErrors.length == 1);
+ assertTrue(validationErrors[0].getText().contains("must specify the name of an interceptor class"));
+ }
+
+ @Test
+ public void testDecoratorsValidation() {
+
+ }
+
+ @Test
+ public void testAlternativesValidation() {
+
+ }
+
+ @Test
+ public void testNotSupportedCDIComponentsValidation() {
+
+ }
+
+ private SWTBotTreeItem[] getBeansXMLValidationErrors() {
+ return ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
+ + getProjectName() + "/WebContent/WEB-INF", "beans.xml", "CDI Problem");
+ }
+
+ private void prepareTwoInterceptors(String firstPackage, String secondPackage) {
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "I1", firstPackage, null);
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "I2", secondPackage, null);
+
+ }
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.editor;
+
+import org.apache.log4j.Level;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.IEditorReference;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.widgets.SWTBotMultiPageEditor;
+
+/**
+ * @author Lukas Jungmann
+ */
+public class BeansEditor extends SWTBotMultiPageEditor {
+
+ public enum Item {
+ INTERCEPTOR("Interceptors"), DECORATOR("Decorators"),
+ CLASS("Alternatives"), STEREOTYPE("Alternatives");
+
+ private final String node;
+
+ private Item(String node) {
+ this.node = node;
+ }
+
+ private String getNode() {
+ return node;
+ }
+
+ public String getElementName() {
+ switch (this) {
+ case STEREOTYPE:
+ return "stereotype";
+ default:
+ return "class";
+ }
+ }
+ }
+
+ private SWTBotExt bot = new SWTBotExt();
+ private static final String ROOT_NODE = "beans.xml";
+
+ public BeansEditor(IEditorReference editorReference, SWTWorkbenchBot bot) {
+ super(editorReference, bot);
+ }
+
+ public BeansEditor add(Item item, String name) {
+ return modify(item, name, "Add...", new AddDialogHandler(item, name));
+ }
+
+ public BeansEditor remove(Item item, String name) {
+ return modify(item, name, "Remove...", new DeleteDialogHandler());
+ }
+
+ public String getSelectedItem() {
+ return bot().tree().selection().get(0, 0);
+ }
+
+ private BeansEditor modify(Item item, String name, String actionLabel, DialogHandler h) {
+ SWTBotTree tree = bot.tree(1);
+ for (SWTBotTreeItem ti:tree.getAllItems()) {
+ log.setLevel(Level.FATAL);
+ log.fatal(ti.getText());
+ }
+ tree.expandNode(ROOT_NODE, item.getNode()).select().click();
+ selectItem(item, name);
+ getItemButton(item, actionLabel).click();
+ h.handle(bot.activeShell());
+ bot.sleep(500);
+ this.setFocus();
+ return this;
+ }
+
+ private void selectItem(Item item, String name) {
+ SWTBotTable t = item == Item.STEREOTYPE ? bot.table(1) : bot.table(0);
+ if (t.containsItem(name)) {
+ t.select(name);
+ }
+ }
+
+ private SWTBotButton getItemButton(Item i, String label) {
+ return i == Item.STEREOTYPE ? bot.button(label, 1) : bot.button(label, 0);
+ }
+
+ private interface DialogHandler {
+ void handle(SWTBotShell dialog);
+ }
+
+ private class AddDialogHandler implements DialogHandler {
+
+ private final Item type;
+ private final String name;
+
+ public AddDialogHandler(Item type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ public void handle(SWTBotShell dialog) {
+ SWTBot sh = dialog.bot();
+ SWTBotText t = type == Item.STEREOTYPE
+ ? sh.textWithLabel("Stereotype:*")
+ : sh.textWithLabel("Class:*");
+ t.setText(name);
+ sh.button("Finish").click();
+ }
+ }
+
+ private class DeleteDialogHandler implements DialogHandler {
+
+ public void handle(SWTBotShell dialog) {
+ dialog.bot().button("OK").click();
+ }
+
+ }
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.editor;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditor.Item;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * prerequisite - CDIAtWizardTest!!!
+ *
+ *
+ * @author Lukas Jungmann
+ * @author jjankovi
+ */
+@Require(clearProjects = false, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class BeansEditorTest extends CDITestBase {
+
+ private static final String descPath = "WebContent/WEB-INF/beans.xml";
+ private static final Logger LOGGER = Logger.getLogger(BeansEditorTest.class.getName());
+
+ @BeforeClass
+ public static void setup() {
+ editResourceUtil.copyResource("resources/beans.xml", descPath);
+ editResourceUtil.copyResource("resources/Foo.jav_", "src/cdi/Foo.java");
+ editResourceUtil.copyResource("resources/Bar.jav_", "src/cdi/Bar.java");
+ }
+
+ @Override
+ public void checkAndCreateProject() {
+ new ProjectExplorer().openFile(getProjectName(), descPath.split("/"));
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIWizardTest";
+ }
+
+ @Test
+ public void testClasses() {
+ addItem(Item.CLASS, getPackageName() + ".Foo");
+ addItem(Item.CLASS, getPackageName() + ".Bar");
+ removeItem(Item.CLASS, getPackageName() + ".Foo");
+ }
+
+ @Test
+ public void testInterceptors() {
+ addItem(Item.INTERCEPTOR, getPackageName() + ".I1");
+ removeItem(Item.INTERCEPTOR, getPackageName() + ".I1");
+ addItem(Item.INTERCEPTOR, getPackageName() + ".I2");
+ }
+
+
+ @Test
+ public void testDecorators() {
+ addItem(Item.DECORATOR, getPackageName() + ".MapDecorator");
+ addItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
+ removeItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
+ }
+
+
+ @Test
+ public void testStereotypes() {
+ addItem(Item.STEREOTYPE, getPackageName() + ".S2");
+ addItem(Item.STEREOTYPE, getPackageName() + ".S3");
+ removeItem(Item.STEREOTYPE, getPackageName() + ".S3");
+ addItem(Item.STEREOTYPE, getPackageName() + ".S1");
+ removeItem(Item.STEREOTYPE, getPackageName() + ".S2");
+ }
+
+ @Test
+ public void testResult() {
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Source");
+ String text = be.toTextEditor().getText();
+ List<Node> nl = getItems(text, Item.INTERCEPTOR);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".I2"));
+
+ nl = getItems(text, Item.DECORATOR);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".MapDecorator"));
+
+ nl = getItems(text, Item.CLASS);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".Bar"));
+
+ nl = getItems(text, Item.STEREOTYPE);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".S1"));
+ }
+
+ private void addItem(Item item, String name) {
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Tree");
+ try {
+ be.add(item, name);
+ Assert.assertTrue(be.isDirty());
+ Assert.assertEquals(name, be.getSelectedItem());
+ be.activatePage("Source");
+ String text = be.toTextEditor().getText();
+ List<Node> nl = getItems(text, item);
+ assertTrue(containsItem(nl, name));
+ } finally {
+ if (be.isDirty()) {
+ be.save();
+ }
+ }
+ }
+
+ private void removeItem(Item item, String name) {
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Tree");
+ try {
+ be.remove(item, name);
+ Assert.assertTrue(be.isDirty());
+ be.activatePage("Source");
+ String text = be.toTextEditor().getText();
+ List<Node> nl = getItems(text, item);
+ assertFalse(containsItem(nl, name));
+ } finally {
+ if (be.isDirty()) {
+ be.save();
+ }
+ }
+ }
+
+ private Document getDocument(String text) {
+ Document d = null;
+ try {
+ d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(text.getBytes()));
+ } catch (SAXException e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ } catch (IOException e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ } catch (ParserConfigurationException e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ }
+ return d;
+ }
+
+ private List<Node> getItems(String doc, Item i) {
+ Document d = getDocument(doc);
+ NodeList nl = null;
+ switch (i) {
+ case DECORATOR:
+ nl = d.getElementsByTagName("decorators");
+ break;
+ case INTERCEPTOR:
+ nl = d.getElementsByTagName("interceptors");
+ break;
+ case STEREOTYPE:
+ return getNodes(d.getElementsByTagName("stereotype"), i);
+ case CLASS:
+ nl = d.getElementsByTagName("alternatives");
+ break;
+ }
+ return nl.getLength() > 0 ? getNodes(nl.item(0).getChildNodes(), i) : new ArrayList<Node>();
+ }
+
+ private List<Node> getNodes(NodeList nl, Item item) {
+ List<Node> list = new ArrayList<Node>();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+ if (item.getElementName().equals(n.getNodeName())) {
+ list.add(n);
+ }
+ }
+ return list;
+ }
+
+ private boolean containsItem(List<Node> nl, String name) {
+ if (nl == null) {
+ return false;
+ }
+ for (int i = 0; i < nl.size(); i++) {
+ if (name.equals(nl.get(i).getTextContent())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,225 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.editor;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.uiutils.editor.BeansEditor;
-import org.jboss.tools.cdi.bot.test.uiutils.editor.BeansEditor.Item;
-import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-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;
-import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * prerequisite - CDIAtWizardTest!!!
- *
- *
- * @author Lukas Jungmann
- * @author jjankovi
- */
-@Require(clearProjects = false, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDIBeansEditorTest extends CDIBase {
-
- private static final String descPath = "WebContent/WEB-INF/beans.xml";
- private static final Logger LOGGER = Logger.getLogger(CDIBeansEditorTest.class.getName());
-
- @BeforeClass
- public static void setup() {
- CDIUtil.copyResource("resources/beans.xml", descPath);
- CDIUtil.copyResource("resources/Foo.jav_", "src/cdi/Foo.java");
- CDIUtil.copyResource("resources/Bar.jav_", "src/cdi/Bar.java");
- }
-
- @Override
- public void checkAndCreateProject() {
- new ProjectExplorer().openFile(getProjectName(), descPath.split("/"));
- }
-
- @Override
- public String getProjectName() {
- return "CDIWizardTest";
- }
-
- @Test
- public void testClasses() {
- addItem(Item.CLASS, getPackageName() + ".Foo");
- addItem(Item.CLASS, getPackageName() + ".Bar");
- removeItem(Item.CLASS, getPackageName() + ".Foo");
- }
-
- @Test
- public void testInterceptors() {
- addItem(Item.INTERCEPTOR, getPackageName() + ".I1");
- removeItem(Item.INTERCEPTOR, getPackageName() + ".I1");
- addItem(Item.INTERCEPTOR, getPackageName() + ".I2");
- }
-
-
- @Test
- public void testDecorators() {
- addItem(Item.DECORATOR, getPackageName() + ".MapDecorator");
- addItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
- removeItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
- }
-
-
- @Test
- public void testStereotypes() {
- addItem(Item.STEREOTYPE, getPackageName() + ".S2");
- addItem(Item.STEREOTYPE, getPackageName() + ".S3");
- removeItem(Item.STEREOTYPE, getPackageName() + ".S3");
- addItem(Item.STEREOTYPE, getPackageName() + ".S1");
- removeItem(Item.STEREOTYPE, getPackageName() + ".S2");
- }
-
- @Test
- public void testResult() {
- SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
- BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
- be.activatePage("Source");
- String text = be.toTextEditor().getText();
- List<Node> nl = getItems(text, Item.INTERCEPTOR);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".I2"));
-
- nl = getItems(text, Item.DECORATOR);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".MapDecorator"));
-
- nl = getItems(text, Item.CLASS);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".Bar"));
-
- nl = getItems(text, Item.STEREOTYPE);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".S1"));
- }
-
- private void addItem(Item item, String name) {
- SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
- BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
- be.activatePage("Tree");
- try {
- be.add(item, name);
- Assert.assertTrue(be.isDirty());
- Assert.assertEquals(name, be.getSelectedItem());
- be.activatePage("Source");
- String text = be.toTextEditor().getText();
- List<Node> nl = getItems(text, item);
- assertTrue(containsItem(nl, name));
- } finally {
- if (be.isDirty()) {
- be.save();
- }
- }
- }
-
- private void removeItem(Item item, String name) {
- SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
- BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
- be.activatePage("Tree");
- try {
- be.remove(item, name);
- Assert.assertTrue(be.isDirty());
- be.activatePage("Source");
- String text = be.toTextEditor().getText();
- List<Node> nl = getItems(text, item);
- assertFalse(containsItem(nl, name));
- } finally {
- if (be.isDirty()) {
- be.save();
- }
- }
- }
-
- private Document getDocument(String text) {
- Document d = null;
- try {
- d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ByteArrayInputStream(text.getBytes()));
- } catch (SAXException e) {
- LOGGER.log(Level.SEVERE, e.getMessage(), e);
- } catch (IOException e) {
- LOGGER.log(Level.SEVERE, e.getMessage(), e);
- } catch (ParserConfigurationException e) {
- LOGGER.log(Level.SEVERE, e.getMessage(), e);
- }
- return d;
- }
-
- private List<Node> getItems(String doc, Item i) {
- Document d = getDocument(doc);
- NodeList nl = null;
- switch (i) {
- case DECORATOR:
- nl = d.getElementsByTagName("decorators");
- break;
- case INTERCEPTOR:
- nl = d.getElementsByTagName("interceptors");
- break;
- case STEREOTYPE:
- return getNodes(d.getElementsByTagName("stereotype"), i);
- case CLASS:
- nl = d.getElementsByTagName("alternatives");
- break;
- }
- return nl.getLength() > 0 ? getNodes(nl.item(0).getChildNodes(), i) : new ArrayList<Node>();
- }
-
- private List<Node> getNodes(NodeList nl, Item item) {
- List<Node> list = new ArrayList<Node>();
- for (int i = 0; i < nl.getLength(); i++) {
- Node n = nl.item(i);
- if (item.getElementName().equals(n.getNodeName())) {
- list.add(n);
- }
- }
- return list;
- }
-
- private boolean containsItem(List<Node> nl, String name) {
- if (nl == null) {
- return false;
- }
- for (int i = 0; i < nl.size(); i++) {
- if (name.equals(nl.get(i).getTextContent())) {
- return true;
- }
- }
- return false;
- }
-
-}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,336 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.openon;
-
-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.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;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on CDI perspective
- *
- * @author Jaroslav Jankovic
- */
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDIFindObserverForEventTest extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDIFindObserverForEventTest.class.getName());
- private final String[] events = { "myBean1Q1Event", "myBean1AnyEvent",
- "myBean2Q1Event", "myBean2AnyEvent", "myBean1Q2Event",
- "myBean2Q2Event", "myBean1Q1Event.fire(new MyBean1());",
- "myBean1AnyEvent.fire(new MyBean1())",
- "myBean2Q1Event.fire(new MyBean2())",
- "myBean2AnyEvent.fire(new MyBean2())",
- "myBean1Q2Event.fire(new MyBean1())",
- "myBean2Q2Event.fire(new MyBean2())",
- "myBean1AnyEvent.fire(new MyBean2())" };
- private final String[] observers = { "observeNoQualifierMyBean1",
- "observeAnyMyBean1", "observeQ1MyBean1",
- "observeNoQualifierMyBean2", "observeAnyMyBean2",
- "observeQ1MyBean2", "observeQ2MyBean1", "observeQ2MyBean2" };
-
- @Override
- public String getProjectName() {
- return "CDIObserverTest";
- }
-
- @Test
- public void testSimpleCaseObserverFinding() {
-
- prepareSimpleObserverFinding();
-
- testSimpleObserverFinding();
-
- }
-
- // not implemented yet
- @Test
- public void testComplexCaseObserverFinding() {
-
- prepareComplexObserverFinding();
-
- testComplexObserverFinding();
- }
-
- private void prepareSimpleObserverFinding() {
-
- createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
-
- createComponent(CDICOMPONENT.QUALIFIER, "Q2", getPackageName(), null);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean1", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/MyBean1.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean2", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/MyBean2.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "EventsProducer", getPackageName(), null);
- CDIUtil.copyResourceToClass(
- getEd(),
- CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/EventsProducer.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "ObserverBean", getPackageName(), null);
- CDIUtil.copyResourceToClass(
- getEd(),
- CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/ObserverBean.java.cdi"),
- false);
- util.waitForNonIgnoredJobs();
- }
-
- private void testSimpleObserverFinding() {
-
-
- for (int i = 0; i < events.length; i++) {
- checkObserverMethodsForEvent(events[i]);
- }
-
-
- for (int i = 0; i < observers.length; i++) {
- checkEventsForObserverMethods(observers[i]);
- }
- }
-
- private void checkObserverMethodsForEvent(String eventName) {
-
- String eventsClass = "EventsProducer.java";
-
- String showObserverOption = "Show CDI Observer Methods...";
-
- checkEventsAndObserver(eventName, eventsClass, showObserverOption);
-
- }
-
- private void checkEventsForObserverMethods(String observerName) {
-
- String observerClass = "ObserverBean.java";
-
- /**
- * there are two observer methods for which there is only one
- * event, so there will be no "Show CDI Events" option, instead
- * of that, there will be "Open CDI Event" option
- */
- String showObserverOption = ((observerName.equals("observeQ1MyBean2")) ||
- (observerName.equals("observeQ2MyBean2"))) ? "Open CDI Event" : "Show CDI Events...";
-
- checkEventsAndObserver(observerName, observerClass, showObserverOption);
- }
-
- private void checkEventsAndObserver(String name, String className,
- String option) {
- openOn(name, className, option);
- bot.sleep(Timing.time1S());
- if (option.equals("Open CDI Event")) {
- if (name.equals("observeQ1MyBean2")) {
- LOGGER.info("Testing observer: observeQ1MyBean2 started");
- assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q1Event"));
- LOGGER.info("Testing observer: observeQ1MyBean2 ended");
- }else {
- //observeQ1MyBean2
- LOGGER.info("Testing observer: observeQ1MyBean2 started");
- assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q2Event"));
- LOGGER.info("Testing observer: observeQ1MyBean2 ended");
- }
- } else {
- SWTBotTable observerTable = bot.table(0);
- if (className.equals("EventsProducer.java")) {
- assertTrue(checkAllObserverMethodsForEvent(name, observerTable));
- }
- if (className.equals("ObserverBean.java")) {
- assertTrue(checkAllEventsForObserverMethod(name, observerTable));
- }
- }
- }
-
- private boolean checkAllObserverMethodsForEvent(String eventName,
- SWTBotTable observerTable) {
- String observerClass = "ObserverBean";
- String packageProjectPath = getPackageName() + " - /" + getProjectName() + "/src";
- String parametrizedEventItem = observerClass + ".observeXXX() - " + packageProjectPath;
- boolean allObserversFound = false;
- for (int i = 0; i < events.length; i++) {
- if (eventName.equals(events[i])) {
- LOGGER.info("Testing event: " + events[i] + " started");
- switch (i) {
- //myBean1Q1Event
- //myBean1Q1Event.fire(new MyBean1())
- case 0:
- case 6:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q1MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1"))) {
- allObserversFound = true;
- }
- break;
- //myBean1AnyEvent
- //myBean1AnyEvent.fire(new MyBean1())
- //myBean1AnyEvent.fire(new MyBean2())
- case 1:
- case 7:
- case 12:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1"))) {
- allObserversFound = true;
- }
- break;
- //myBean2Q1Event
- //myBean2Q1Event.fire(new MyBean2())
- case 2:
- case 8:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q1MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q1MyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean2"))) {
- allObserversFound = true;
- }
- break;
- //myBean2AnyEvent
- //myBean2AnyEvent.fire(new MyBean2())
- case 3:
- case 9:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean2"))) {
- allObserversFound = true;
- }
- break;
- //myBean1Q2Event
- //myBean1Q2Event.fire(new MyBean1())
- case 4:
- case 10:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q2MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1"))) {
- allObserversFound = true;
- }
- break;
- //myBean2Q2Event
- //myBean2Q2Event.fire(new MyBean2())
- case 5:
- case 11:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q2MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q2MyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean2"))) {
- allObserversFound = true;
- }
- break;
- }
- LOGGER.info("Testing event: " + events[i] + " ended");
- break;
- }
- }
- return allObserversFound;
- }
-
- private boolean checkAllEventsForObserverMethod(String observerName,
- SWTBotTable eventsTable) {
- String eventsClass = "EventsProducer";
- String packageProjectPath = getPackageName() + " - /" + getProjectName() + "/src";
- String parametrizedEventItem = eventsClass + ".myBeanXXX - " + packageProjectPath;
- boolean allEventsFound = false;
- for (int i = 0; i < observers.length; i++) {
- if (observerName.equals(observers[i])) {
- LOGGER.info("Testing observer: " + observers[i] + " started");
- switch (i) {
- //observeNoQualifierMyBean1
- //observeAnyMyBean1
- case 0:
- case 1:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1AnyEvent")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2AnyEvent")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q2Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q2Event"))) {
- allEventsFound = true;
- }
- //observeQ1MyBean1
- case 2:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q1Event"))) {
- allEventsFound = true;
- }
- break;
- //observeNoQualifierMyBean2
- //observeAnyMyBean2
- case 3:
- case 4:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2AnyEvent")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q2Event"))) {
- allEventsFound = true;
- }
- break;
- //observeQ1MyBean2
- case 5:
- throw new IllegalStateException("Observer method \"observeQ1MyBean2\" should " +
- "have been tested earlier!!");
- //observeQ2MyBean1
- case 6:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q2Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q2Event"))) {
- allEventsFound = true;
- }
- break;
- //observeQ2MyBean2
- case 7:
- throw new IllegalStateException("Observer method \"observeQ2MyBean2\" should " +
- "have been tested earlier!!");
- }
- LOGGER.info("Testing observer: " + observers[i] + " ended");
- break;
- }
- }
- return allEventsFound;
- }
-
- // not implemented yet
- private void prepareComplexObserverFinding() {
-
- }
-
- // not implemented yet
- private void testComplexObserverFinding() {
- /**
- * main idea - check events which have multiple qualifiers defined
- * (http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
- * 11.6) - check events with qualifiers which has members
- * (http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
- * 11.5)
- */
- }
-}
Deleted: 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-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,318 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.openon;
-
-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;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on hyperlinks-openons using CDI tools
- *
- * @author Jaroslav Jankovic
- *
- */
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDIOpenOnTest extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDIQuickFixTest.class.getName());
-
- @Override
- public String getProjectName() {
- return "CDIOpenOnTest";
- }
-
- @Test
- public void testBeanInjectOpenOn() {
-
- prepareInjectedPointsComponents();
-
- testInjectedPoints();
-
- }
-
- /*
- * https://issues.jboss.org/browse/JBIDE-7025
- */
- @Test
- public void testBeansXMLClassesOpenOn() {
-
- /*
- * check if beans.xml was not created in previous tests. If so, I cannot create
- * beans.xml into getProjectName()/WebContent/WEB-INF/beans.xml.
- */
- if (!projectExplorer.isFilePresent(getProjectName(), "WebContent/META-INF/beans.xml") &&
- !projectExplorer.isFilePresent(getProjectName(), "WebContent/WEB-INF/beans.xml")) {
- createComponent(CDICOMPONENT.BEANSXML, null, getProjectName() + "/WebContent/WEB-INF", null);
- }
-
- createComponent(CDICOMPONENT.DECORATOR, "D1", getPackageName(),
- "java.util.Set");
- bot.editorByTitle("beans.xml").show();
- bot.cTabItem("Source").activate();
- openOn(getPackageName() + ".D1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd().getTitle(),
- getEd().getTitle().equals("D1.java"));
-
- createComponent(CDICOMPONENT.INTERCEPTOR, "Interceptor1", getPackageName(),
- null);
- bot.editorByTitle("beans.xml").show();
- openOn(getPackageName() + ".Interceptor1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd(),
- getEd().getTitle().equals("Interceptor1.java"));
-
- createComponent(CDICOMPONENT.BEAN, "B1", getPackageName(),
- "alternative+beansxml");
- bot.editorByTitle("beans.xml").show();
- openOn(getPackageName() + ".B1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd(),
- getEd().getTitle().equals("B1.java"));
-
- createComponent(CDICOMPONENT.STEREOSCOPE, "S1", getPackageName(),
- "alternative+beansxml");
- bot.editorByTitle("beans.xml").show();
- openOn(getPackageName() + ".S1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd(),
- getEd().getTitle().equals("S1.java"));
-
- }
-
- /*
- * https://issues.jboss.org/browse/JBIDE-6251
- */
- @Test
- public void testDisposerProducerOpenOn() {
-
- String testedBean = "DisposerProducerBean";
- createComponent(CDICOMPONENT.BEAN, "MyBean", getPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, testedBean, getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/" + testedBean + ".java.cdi"),
- false);
- openOn("disposeMethod", testedBean + ".java", "Open Bound Producer");
- assertTrue(getEd().toTextEditor().getSelection().equals("produceMethod"));
-
- openOn("produceMethod", testedBean + ".java", "Open Bound Disposer");
- assertTrue(getEd().toTextEditor().getSelection().equals("disposeMethod"));
- }
-
- @Test
- public void testObserverOpenOn() {
- createComponent(CDICOMPONENT.BEAN, "EventBean", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/EventBean.java.cdi"),
- false);
- createComponent(CDICOMPONENT.BEAN, "ObserverBean", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/ObserverBean.java.cdi"),
- false);
-
- bot.editorByTitle("EventBean.java").show();
- setEd(bot.activeEditor().toTextEditor());
- CDIUtil.replaceInEditor(getEd(), bot, " event", " event");
-
- openOn("observerMethod", "ObserverBean.java", "Open CDI Event");
- assertTrue(getEd().toTextEditor().getSelection().equals("event"));
-
- 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
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/FindObserverForEventTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/FindObserverForEventTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/FindObserverForEventTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.openon;
+
+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.annotations.CDIWizardType;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on CDI perspective
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class FindObserverForEventTest extends OpenOnBase {
+
+ private static final Logger LOGGER = Logger.getLogger(FindObserverForEventTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIObserverTest";
+ }
+
+ @Test
+ public void testSimpleCaseObserverFinding() {
+
+ prepareSimpleObserverFinding();
+
+ testSimpleObserverFinding();
+
+ }
+
+ // not implemented yet
+ @Test
+ public void testComplexCaseObserverFinding() {
+
+ prepareComplexObserverFinding();
+
+ testComplexObserverFinding();
+ }
+
+ private void prepareSimpleObserverFinding() {
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q1", getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q2", getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean1", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/MyBean1.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean2", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/MyBean2.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "EventsProducer", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/EventsProducer.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "ObserverBean", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/ObserverBean.java.cdi"),
+ false);
+ util.waitForNonIgnoredJobs();
+ }
+
+ private void testSimpleObserverFinding() {
+
+
+ for (int i = 0; i < events.length; i++) {
+ checkObserverMethodsForEvent(events[i]);
+ }
+
+
+ for (int i = 0; i < observers.length; i++) {
+ checkEventsForObserverMethods(observers[i]);
+ }
+ }
+
+ private void checkObserverMethodsForEvent(String eventName) {
+
+ String eventsClass = "EventsProducer.java";
+
+ String showObserverOption = "Show CDI Observer Methods...";
+
+ checkEventsAndObserver(eventName, eventsClass, showObserverOption);
+
+ }
+
+ private void checkEventsForObserverMethods(String observerName) {
+
+ String observerClass = "ObserverBean.java";
+
+ /**
+ * there are two observer methods for which there is only one
+ * event, so there will be no "Show CDI Events" option, instead
+ * of that, there will be "Open CDI Event" option
+ */
+ String showObserverOption = ((observerName.equals("observeQ1MyBean2")) ||
+ (observerName.equals("observeQ2MyBean2"))) ? "Open CDI Event" : "Show CDI Events...";
+
+ checkEventsAndObserver(observerName, observerClass, showObserverOption);
+ }
+
+ private void checkEventsAndObserver(String name, String className,
+ String option) {
+ openOnUtil.openOnByOption(name, className, option);
+ bot.sleep(Timing.time1S());
+ if (option.equals("Open CDI Event")) {
+ if (name.equals("observeQ1MyBean2")) {
+ LOGGER.info("Testing observer: observeQ1MyBean2 started");
+ assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q1Event"));
+ LOGGER.info("Testing observer: observeQ1MyBean2 ended");
+ }else {
+ //observeQ1MyBean2
+ LOGGER.info("Testing observer: observeQ1MyBean2 started");
+ assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q2Event"));
+ LOGGER.info("Testing observer: observeQ1MyBean2 ended");
+ }
+ } else {
+ SWTBotTable observerTable = bot.table(0);
+ if (className.equals("EventsProducer.java")) {
+ assertTrue(checkAllObserverMethodsForEvent(name, observerTable));
+ }
+ if (className.equals("ObserverBean.java")) {
+ assertTrue(checkAllEventsForObserverMethod(name, observerTable));
+ }
+ }
+ }
+
+ private boolean checkAllObserverMethodsForEvent(String eventName,
+ SWTBotTable observerTable) {
+ String observerClass = "ObserverBean";
+ String packageProjectPath = getPackageName() + " - /" + getProjectName() + "/src";
+ String parametrizedEventItem = observerClass + ".observeXXX() - " + packageProjectPath;
+ boolean allObserversFound = false;
+ for (int i = 0; i < events.length; i++) {
+ if (eventName.equals(events[i])) {
+ LOGGER.info("Testing event: " + events[i] + " started");
+ switch (i) {
+ //myBean1Q1Event
+ //myBean1Q1Event.fire(new MyBean1())
+ case 0:
+ case 6:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q1MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean1AnyEvent
+ //myBean1AnyEvent.fire(new MyBean1())
+ //myBean1AnyEvent.fire(new MyBean2())
+ case 1:
+ case 7:
+ case 12:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean2Q1Event
+ //myBean2Q1Event.fire(new MyBean2())
+ case 2:
+ case 8:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q1MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q1MyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean2"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean2AnyEvent
+ //myBean2AnyEvent.fire(new MyBean2())
+ case 3:
+ case 9:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean2"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean1Q2Event
+ //myBean1Q2Event.fire(new MyBean1())
+ case 4:
+ case 10:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q2MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean2Q2Event
+ //myBean2Q2Event.fire(new MyBean2())
+ case 5:
+ case 11:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q2MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "Q2MyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "AnyMyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX", "NoQualifierMyBean2"))) {
+ allObserversFound = true;
+ }
+ break;
+ }
+ LOGGER.info("Testing event: " + events[i] + " ended");
+ break;
+ }
+ }
+ return allObserversFound;
+ }
+
+ private boolean checkAllEventsForObserverMethod(String observerName,
+ SWTBotTable eventsTable) {
+ String eventsClass = "EventsProducer";
+ String packageProjectPath = getPackageName() + " - /" + getProjectName() + "/src";
+ String parametrizedEventItem = eventsClass + ".myBeanXXX - " + packageProjectPath;
+ boolean allEventsFound = false;
+ for (int i = 0; i < observers.length; i++) {
+ if (observerName.equals(observers[i])) {
+ LOGGER.info("Testing observer: " + observers[i] + " started");
+ switch (i) {
+ //observeNoQualifierMyBean1
+ //observeAnyMyBean1
+ case 0:
+ case 1:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1AnyEvent")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2AnyEvent")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q2Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q2Event"))) {
+ allEventsFound = true;
+ }
+ //observeQ1MyBean1
+ case 2:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q1Event"))) {
+ allEventsFound = true;
+ }
+ break;
+ //observeNoQualifierMyBean2
+ //observeAnyMyBean2
+ case 3:
+ case 4:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2AnyEvent")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q2Event"))) {
+ allEventsFound = true;
+ }
+ break;
+ //observeQ1MyBean2
+ case 5:
+ throw new IllegalStateException("Observer method \"observeQ1MyBean2\" should " +
+ "have been tested earlier!!");
+ //observeQ2MyBean1
+ case 6:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX", "1Q2Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX", "2Q2Event"))) {
+ allEventsFound = true;
+ }
+ break;
+ //observeQ2MyBean2
+ case 7:
+ throw new IllegalStateException("Observer method \"observeQ2MyBean2\" should " +
+ "have been tested earlier!!");
+ }
+ LOGGER.info("Testing observer: " + observers[i] + " ended");
+ break;
+ }
+ }
+ return allEventsFound;
+ }
+
+ // not implemented yet
+ private void prepareComplexObserverFinding() {
+
+ }
+
+ // not implemented yet
+ private void testComplexObserverFinding() {
+ /**
+ * main idea - check events which have multiple qualifiers defined
+ * (http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
+ * 11.6) - check events with qualifiers which has members
+ * (http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
+ * 11.5)
+ */
+ }
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.openon;
+
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+
+public class OpenOnBase extends CDITestBase{
+
+ public static final String[] events = { "myBean1Q1Event", "myBean1AnyEvent",
+ "myBean2Q1Event", "myBean2AnyEvent", "myBean1Q2Event",
+ "myBean2Q2Event", "myBean1Q1Event.fire(new MyBean1());",
+ "myBean1AnyEvent.fire(new MyBean1())",
+ "myBean2Q1Event.fire(new MyBean2())",
+ "myBean2AnyEvent.fire(new MyBean2())",
+ "myBean1Q2Event.fire(new MyBean1())",
+ "myBean2Q2Event.fire(new MyBean2())",
+ "myBean1AnyEvent.fire(new MyBean2())" };
+ public static final String[] observers = { "observeNoQualifierMyBean1",
+ "observeAnyMyBean1", "observeQ1MyBean1",
+ "observeNoQualifierMyBean2", "observeAnyMyBean2",
+ "observeQ1MyBean2", "observeQ2MyBean1", "observeQ2MyBean2" };
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.openon;
+
+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.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on hyperlinks-openons using CDI tools
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class OpenOnTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(OpenOnTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIOpenOnTest";
+ }
+
+ @Test
+ public void testBeanInjectOpenOn() {
+
+ prepareInjectedPointsComponents();
+
+ testInjectedPoints();
+
+ }
+
+ /**
+ * https://issues.jboss.org/browse/JBIDE-7025
+ */
+ @Test
+ public void testBeansXMLClassesOpenOn() {
+
+ /**
+ * check if beans.xml was not wizard.created in previous tests. If so, I cannot wizard.create
+ * beans.xml into getProjectName()/WebContent/WEB-INF/beans.xml.
+ */
+ if (!projectExplorer.isFilePresent(getProjectName(),
+ "WebContent/META-INF/beans.xml".split("/")) &&
+ !projectExplorer.isFilePresent(getProjectName(),
+ "WebContent/WEB-INF/beans.xml".split("/"))) {
+ wizard.createComponent(CDIWizardType.BEANS_XML, null, getProjectName() + "/WebContent/WEB-INF", null);
+ }
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "D1", getPackageName(),
+ "java.util.Set");
+ bot.editorByTitle("beans.xml").show();
+ bot.cTabItem("Source").activate();
+ openOnUtil.openOnDirect(getPackageName() + ".D1", "beans.xml");
+ assertTrue("ERROR: redirected to " + getEd().getTitle(),
+ getEd().getTitle().equals("D1.java"));
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor1", getPackageName(),
+ null);
+ bot.editorByTitle("beans.xml").show();
+ openOnUtil.openOnDirect(getPackageName() + ".Interceptor1", "beans.xml");
+ assertTrue("ERROR: redirected to " + getEd(),
+ getEd().getTitle().equals("Interceptor1.java"));
+
+ wizard.createComponent(CDIWizardType.BEAN, "B1", getPackageName(),
+ "alternative+beansxml");
+ bot.editorByTitle("beans.xml").show();
+ openOnUtil.openOnDirect(getPackageName() + ".B1", "beans.xml");
+ assertTrue("ERROR: redirected to " + getEd(),
+ getEd().getTitle().equals("B1.java"));
+
+ wizard.createComponent(CDIWizardType.STEREOTYPE, "S1", getPackageName(),
+ "alternative+beansxml");
+ bot.editorByTitle("beans.xml").show();
+ openOnUtil.openOnDirect(getPackageName() + ".S1", "beans.xml");
+ assertTrue("ERROR: redirected to " + getEd(),
+ getEd().getTitle().equals("S1.java"));
+
+ }
+
+ /**
+ * https://issues.jboss.org/browse/JBIDE-6251
+ */
+ @Test
+ public void testDisposerProducerOpenOn() {
+
+ String className = "Bean1";
+
+ wizard.createComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/BeanWithDisposerAndProducer.java.cdi"),
+ false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+ openOnUtil.openOnByOption("disposeMethod", className + ".java", "Open Bound Producer");
+ assertTrue(getEd().toTextEditor().getSelection().equals("produceMethod"));
+
+ openOnUtil.openOnByOption("produceMethod", className + ".java", "Open Bound Disposer");
+ assertTrue(getEd().toTextEditor().getSelection().equals("disposeMethod"));
+ }
+
+ @Test
+ public void testObserverOpenOn() {
+ wizard.createComponent(CDIWizardType.BEAN, "EventBean", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/EventBean.java.cdi"),
+ false);
+ wizard.createComponent(CDIWizardType.BEAN, "ObserverBean", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/ObserverBean.java.cdi"),
+ false);
+
+ bot.editorByTitle("EventBean.java").show();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceInEditor(" event", " event");
+
+ openOnUtil.openOnByOption("observerMethod", "ObserverBean.java", "Open CDI Event");
+ assertTrue(getEd().toTextEditor().getSelection().equals("event"));
+
+ openOnUtil.openOnByOption("Event<ObserverBean> event", "EventBean.java", "Open CDI Observer Method");
+ assertTrue(getEd().toTextEditor().getSelection().equals("observerMethod"));
+ }
+
+ private void prepareInjectedPointsComponents() {
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q1", getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q2", getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean1", getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean2", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean2.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean3", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean3.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean4", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean4.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean5", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean5.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MainBean", getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MainBean.java.cdi"),
+ false);
+ }
+
+ private void testInjectedPoints() {
+ String injectOption = null;
+ for (int i = 1; i < 12; i++) {
+ String injectPoint = "myBean" + i;
+ injectOption = "Show All Assignable Beans...";
+ if (i > 8) injectOption = "Open @Inject Bean";
+ checkInjectedPoint(injectPoint, injectOption);
+ }
+
+ }
+
+ private void checkInjectedPoint(String injectedPoint, String option) {
+ openOnUtil.openOnByOption(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
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class BeanValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixBeanTest";
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-8550
+ @Test
+ public void testSerializableManagedBean() {
+
+ String className = "ManagedBean";
+
+ wizard.createComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource( BeanValidationQuickFixTest.class
+ .getResourceAsStream("/resources/quickfix/SerializableBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.SERIALIZABLE, CDIWizardType.BEAN);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7635
+ @Test
+ public void testMultipleBeansQF() {
+ String animalClassName = "Animal";
+ String dogClassName = "Dog";
+ String brokenFarmClassName = "BrokenFarm";
+
+
+ wizard.createComponent(CDIWizardType.BEAN, brokenFarmClassName, getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q1", getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, animalClassName, getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, dogClassName, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(BeanValidationQuickFixTest.class
+ .getResourceAsStream("/resources/quickfix/Dog.java.cdi"), false);
+
+ bot.editorByTitle(brokenFarmClassName + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceClassContentByResource(BeanValidationQuickFixTest.class
+ .getResourceAsStream("/resources/quickfix/BrokenFarm.java.cdi"),
+ false);
+
+ bot.sleep(TIME_1S);
+ util.waitForNonIgnoredJobs();
+
+ resolveMultipleBeans();
+
+ checkMultipleBean();
+ }
+
+ @Ignore
+ // https://issues.jboss.org/browse/JBIDE-7664
+ @Test
+ public void testConstructor() {
+
+ String className = "Bean1";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ConstructorWithParam.java.cdi"), false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ConstructorWithParam.java.cdi"), false);
+
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+ }
+ @Ignore
+ // https://issues.jboss.org/browse/JBIDE-7665
+ @Test
+ public void testProducer() {
+
+ String className = "Bean2";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ProducerWithParam.java.cdi"), false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ProducerWithParam.java.cdi"), false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ // https://issues.jboss.org/browse/JBIDE-7667
+ @Test
+ public void testInjectDisposer() {
+
+ String className = "Bean3";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/BeanInjectDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ // https://issues.jboss.org/browse/JBIDE-7667
+ @Test
+ public void testInjectObserver() {
+
+ String className = "Bean4";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/BeanInjectDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ // https://issues.jboss.org/browse/JBIDE-7667
+ @Test
+ public void testInjectProducer() {
+
+ String className = "Bean5";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/BeanInjectProducer.java.cdi"), false);
+
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ // https://issues.jboss.org/browse/JBIDE-7668
+ @Test
+ public void testObserverWithDisposer() {
+
+ String className = "Bean6";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ObserverWithDisposer.java.cdi"),
+ false);
+
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+
+ }
+
+}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,799 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.quickfix;
-
-
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-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;
-import org.jboss.tools.ui.bot.ext.view.ProblemsView;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on quick fixes of CDI components validation
- *
- * @author Jaroslav Jankovic
- */
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDIQuickFixTest extends CDIBase {
-
- private static SWTBotTreeItem[] problemsTrees;
- private static final String LINE_SEPARATOR = System.getProperty("line.separator");
-
- @Override
- public String getProjectName() {
- return "CDIQuickFixTest";
- }
-
- /*
- * check problems (warnings and errors in Problems View)
- */
- @Override
- public void waitForJobs() {
- checkProjectAllProblems();
- util.waitForNonIgnoredJobs();
- /**
- * needed for creating non-dependant components
- */
- projectExplorer.selectProject(getProjectName());
- }
-
-
- @Test
- public void testSerializableQF() {
-
-
- String className = "B1";
- createComponent(CDICOMPONENT.BEAN, className, getPackageName(), null);
-
- // https://issues.jboss.org/browse/JBIDE-8550
- checkSerializableAnnotation(CDICOMPONENT.BEAN, className);
- }
-
- @Test
- public void testMultipleBeansQF() {
- String className = "BrokenFarm";
- createComponent(CDICOMPONENT.BEAN, className, getPackageName(), null);
-
- // https://issues.jboss.org/browse/JBIDE-7635
- checkMultipleBeans(CDICOMPONENT.BEAN, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Stereoscope component
- */
-
- @Test
- public void testStereoscopeQF() {
- String className = "S1";
- prepareCdiComponent(CDICOMPONENT.STEREOSCOPE, className);
-
- // 1.QF - https://issues.jboss.org/browse/JBIDE-7630
- checkTargetAnnotation(CDICOMPONENT.STEREOSCOPE, className);
-
- // 2.QF - https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.STEREOSCOPE, className);
-
- // 3.QF - https://issues.jboss.org/browse/JBIDE-7634
- checkNamedAnnotation(CDICOMPONENT.STEREOSCOPE, className);
-
- // 4.QF - https://issues.jboss.org/browse/JBIDE-7640
- checkTypedAnnotation(CDICOMPONENT.STEREOSCOPE, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Qualifier component
- */
-
- @Test
- public void testQualifiersQF() {
- String className = "Q2";
- prepareCdiComponent(CDICOMPONENT.QUALIFIER, className);
-
- // 1.QF - https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.QUALIFIER, className);
-
- // 2.QF - https://issues.jboss.org/browse/JBIDE-7632
- checkTargetAnnotation(CDICOMPONENT.QUALIFIER, className);
-
- // 3.QF - https://issues.jboss.org/browse/JBIDE-7641
- checkNonBindingAnnotation(CDICOMPONENT.QUALIFIER, className);
-
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Scope component
- */
-
- @Test
- public void testScopeQF() {
- String className = "Scope1";
- prepareCdiComponent(CDICOMPONENT.SCOPE, className);
-
- // 1.QF - https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.SCOPE, className);
-
- // 2.QF - https://issues.jboss.org/browse/JBIDE-7633
- checkTargetAnnotation(CDICOMPONENT.SCOPE, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about general Bean component
- */
-
- @Test
- public void testBeanQF() {
- String className = "MyBean";
- prepareCdiComponent(CDICOMPONENT.BEAN, className);
-
- // 1.QF - https://issues.jboss.org/browse/JBIDE-7664
- checkConstructor(CDICOMPONENT.BEAN, className);
-
- // 2.QF - https://issues.jboss.org/browse/JBIDE-7665
- checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.DISPOSES, className);
-
- // 3.QF - https://issues.jboss.org/browse/JBIDE-7667
- checkObserverDisposerMethod(CDICOMPONENT.BEAN, className);
-
- // 4.QF - https://issues.jboss.org/browse/JBIDE-7668
- checkObserWithDisposParamMethod(CDICOMPONENT.BEAN, className);
-
- // 5.QF - https://issues.jboss.org/browse/JBIDE-7680
- checkSessionBean(CDICOMPONENT.BEAN, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Interceptors/Interceptor Binding/Decorator component
- */
-
- @Test
- public void testInterDecorQF() {
- String className = "InterDecor";
- prepareCdiComponent(CDICOMPONENT.BEAN, className);
-
- // 1.QF - https://issues.jboss.org/browse/JBIDE-7636
- checkNamedAnnotation(CDICOMPONENT.BEAN, className);
-
- // 2.QF - https://issues.jboss.org/browse/JBIDE-7683
- checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.INTERCEPTOR, className);
-
- // 3.QF - https://issues.jboss.org/browse/JBIDE-7684
- checkDisposesAnnotation(CDICOMPONENT.BEAN, className);
-
- // 4.QF - https://issues.jboss.org/browse/JBIDE-7685
- checkObserveAnnotation(CDICOMPONENT.BEAN, className);
-
- // 5.QF - https://issues.jboss.org/browse/JBIDE-7686
- checkSpecializeAnnotation(CDICOMPONENT.BEAN, "TestBean");
-
- // 6.QF - https://issues.jboss.org/browse/JBIDE-7641
- checkNonBindingAnnotation(CDICOMPONENT.INTERBINDING, "Interceptor");
- }
-
-
- /*
- * method edits default Target form because of "one space inconsistency"
- */
- private void prepareCdiComponent(CDICOMPONENT component, String name) {
- createComponent(component, name, getPackageName(), null);
- switch (component) {
- case QUALIFIER:
- CDIUtil.replaceInEditor(getEd(), bot, "@Target({ TYPE, METHOD, PARAMETER, FIELD })",
- "@Target({TYPE, METHOD, PARAMETER, FIELD})");
- break;
- case STEREOSCOPE:
- case SCOPE:
- CDIUtil.replaceInEditor(getEd(), bot, "@Target({ TYPE, METHOD, FIELD })",
- "@Target({TYPE, METHOD, FIELD})");
- break;
- }
- }
-
- /*
- ****************************************************************
- *
- * "prepare" like methods which prepare structure of project
- * before testing itself
- *
- ****************************************************************
- */
-
- private void prepareSerializableAnnotation() {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/B1.java.cdi"), false);
- }
-
- private void prepareMultipleBeans(String className) {
- createComponent(CDICOMPONENT.BEAN, "Animal", getPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, "Dog", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/Dog.java.cdi"), false);
- createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
- bot.editorByTitle(className + ".java").show();
- setEd(bot.activeEditor().toTextEditor());
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
- false);
-
- }
-
- private void prepareNamedAnnotation(CDICOMPONENT comp,
- String className, boolean add) {
- if (comp == CDICOMPONENT.BEAN) {
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, "import javax.inject.Named;" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, "@Named" + LINE_SEPARATOR);
- if (add) {
- CDIUtil.insertInEditor(getEd(), bot, 2, 0, "import javax.decorator.Decorator;" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 4, 0, "@Decorator" + LINE_SEPARATOR);
- } else {
- CDIUtil.replaceInEditor(getEd(), bot, "import javax.decorator.Decorator;",
- "import javax.interceptor.Interceptor;");
- CDIUtil.replaceInEditor(getEd(), bot, "@Decorator", "@Interceptor");
- }
- } else {
- if (add) {
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-4, 0, "@Named(\"Name\")" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6 , 0, "import javax.inject.Named;" + LINE_SEPARATOR);
- } else {
- CDIUtil.replaceInEditor(getEd(), bot, "@Named", "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import javax.inject.Named;", "");
- }
- }
- }
-
- private void prepareTypedAnnotation() {
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-4 , 0, "@Typed" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6 , 0, "import javax.enterprise.inject.Typed;" + LINE_SEPARATOR);
- }
-
- private void prepareInjectAnnot() {
- CDIUtil.insertInEditor(getEd(), bot, 3 , 1, "@Inject" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1 , 0, "import javax.inject.Inject;" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6 , 15, "String aaa");
- }
-
- private void prepareProducer() {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/MyBean.java.cdi"), false);
- }
-
- private void prepareObserverDisposer() {
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "@Produces", "@Inject");
- CDIUtil.replaceInEditor(getEd(), bot, "import javax.enterprise.inject.Produces;", "");
- CDIUtil.replaceInEditor(getEd(), bot, "String produceString", "void method");
- CDIUtil.replaceInEditor(getEd(), bot, "return \"test\";", "");
- }
-
- private void prepareObserWithDisposParam() {
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "import javax.inject.Inject;", "import javax.enterprise.event.Observes;" +
- LINE_SEPARATOR + "import javax.enterprise.inject.Disposes;" + LINE_SEPARATOR);
- CDIUtil.replaceInEditor(getEd(), bot, "@Inject", "");
- CDIUtil.replaceInEditor(getEd(), bot, "MyBean(String aaa)",
- "void method(@Observes String param1, @Disposes String param2)");
- }
-
- private void prepareCheckSessionBean(String replacement) {
- if (replacement.equals("@Decorator")) {
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, "import javax.decorator.Decorator;" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 4, 0, "import javax.ejb.Stateless;" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 5, 0, "@Decorator" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6, 0, "@Stateless" + LINE_SEPARATOR);
- } else {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/MyBean2.java.cdi"), false);
- }
- }
-
- private void prepareDisposesAnnot() {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/InterDecor.java.cdi"), false);
- }
-
- private void prepareComponentsForSpecializeAnnotation(String testBeanName) {
- createComponent(CDICOMPONENT.BEAN, "AnyBean", getPackageName(), null);
- createComponent(CDICOMPONENT.INTERBINDING, "AnyBinding", getPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, testBeanName, getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/TestBean.java.cdi"), false);
- }
-
-
- /*
- ****************************************************************
- *
- * "check" like methods which are the most general method to test
- * CDI components with various annotations, replacements and so on
- *
- ****************************************************************
- */
-
-
- private void checkSerializableAnnotation(CDICOMPONENT comp, String className) {
- prepareSerializableAnnotation();
- checkQuickFix(ANNOTATIONS.SERIALIZABLE, comp, className, "Serializable");
- cleanWarnings(className);
- }
-
- private void checkMultipleBeans(CDICOMPONENT comp, String className) {
- prepareMultipleBeans(className);
- checkQuickFix(ANNOTATIONS.NAMED, comp, className, "MultipleBeans");
- }
-
- private void checkTargetAnnotation(CDICOMPONENT comp, String className) {
- checkTargetAnnotWithAddon(comp, className, "@Target({TYPE, FIELD})");
- checkTargetAnnotWithAddon(comp, className, "");
- }
-
- private void checkTargetAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- switch (comp) {
- case STEREOSCOPE:
- case SCOPE:
- CDIUtil.replaceInEditor(getEd(), bot,
- "@Target({TYPE, METHOD, FIELD})", replacement);
- break;
- case QUALIFIER:
- if (replacement.equals("")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "@Target({TYPE, METHOD, FIELD, PARAMETER})", replacement);
- } else {
- CDIUtil.replaceInEditor(getEd(), bot,
- "@Target({TYPE, METHOD, PARAMETER, FIELD})", replacement);
- }
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.PARAMETER;", "");
- break;
- }
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.METHOD;", "");
- if (replacement.equals("")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import java.lang.annotation.Target;", "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.TYPE;", "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.FIELD;", "");
- }
- checkQuickFix(ANNOTATIONS.TARGET, comp, className, replacement);
- }
-
- private void checkRetentionAnnotation(CDICOMPONENT comp, String className) {
- checkRetentionAnnotWithAddon(comp, className, "@Retention(CLASS)");
- checkRetentionAnnotWithAddon(comp, className, "");
- }
-
- private void checkRetentionAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- CDIUtil.replaceInEditor(getEd(), bot, "@Retention(RUNTIME)", replacement);
- if (replacement.equals("@Retention(CLASS)")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.RetentionPolicy.RUNTIME;",
- "import static java.lang.annotation.RetentionPolicy.CLASS;");
- } else {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.RetentionPolicy.RUNTIME;",
- "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import java.lang.annotation.Retention;", "");
- }
- checkQuickFix(ANNOTATIONS.RETENTION, comp, className, replacement);
- if (replacement.equals("@Retention(CLASS)")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.RetentionPolicy.CLASS;","");
- }
- }
-
- private void checkNamedAnnotation(CDICOMPONENT comp, String className) {
- if (className.equals("InterDecor")) {
- prepareNamedAnnotation(comp, className, true);
- checkNamedAnnotWithAddon(comp, className, "@Named");
- prepareNamedAnnotation(comp, className, false);
- checkNamedAnnotWithAddon(comp, className, "@Named");
- } else {
- prepareNamedAnnotation(comp, className, true);
- checkNamedAnnotWithAddon(comp, className, "@Named");
- prepareNamedAnnotation(comp, className, false);
- prepareNamedAnnotation(comp, className, true);
- checkNamedAnnotWithAddon(comp, className, "");
- }
- }
-
- private void checkNamedAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- checkQuickFix(ANNOTATIONS.NAMED, comp, className, replacement);
- }
-
- private void checkTypedAnnotation(CDICOMPONENT comp, String className) {
- prepareTypedAnnotation();
- checkTypedAnnotWithAddon(comp, className, "");
- }
-
- private void checkTypedAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- checkQuickFix(ANNOTATIONS.TYPED, comp, className, replacement);
- }
-
- private void checkConstructor(CDICOMPONENT comp, String className) {
- prepareInjectAnnot();
- checkConstructorWithAddon(comp, className, "@Disposes");
- checkConstructorWithAddon(comp, className, "@Observes");
- }
-
- private void checkConstructorWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- CDIUtil.insertInEditor(getEd(), bot, 6, 15, replacement + " ");
- dispObserCompletion(comp, className, replacement);
- }
-
- private void checkProducerMethod(CDICOMPONENT comp, ANNOTATIONS annonType, String className) {
- if (className.equals("InterDecor")) {
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "MyBean", "InterDecor");
- checkProducerWithAddon(comp, annonType, className, "@Interceptor");
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "MyBean", "InterDecor");
- checkProducerWithAddon(comp, annonType, className, "@Decorator");
- } else {
- prepareProducer();
- checkProducerWithAddon(comp, annonType, className, "@Disposes");
- checkProducerWithAddon(comp, annonType, className, "@Observes");
- }
- }
-
- private void checkProducerWithAddon(CDICOMPONENT comp, ANNOTATIONS annonType,
- String className, String replacement) {
- if (className.equals("InterDecor")) {
- String annot = replacement.equals("@Interceptor")?"@Interceptor":"@Decorator";
- String importAnnot = replacement.equals("@Interceptor")?
- "import javax.interceptor.Interceptor;":
- "import javax.decorator.Decorator;";
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(replacement.equals("@Interceptor")?ANNOTATIONS.INTERCEPTOR:
- ANNOTATIONS.DECORATOR, comp, className, replacement);
- } else {
- CDIUtil.insertInEditor(getEd(), bot, 11, 29, replacement + " ");
- dispObserCompletion(comp, className, replacement);
- }
- }
-
- private void checkObserverDisposerMethod(CDICOMPONENT comp, String className) {
- prepareObserverDisposer();
- checkObserverDisposerWithAddon(comp, className, "@Disposes");
- checkObserverDisposerWithAddon(comp, className, "@Observes");
- }
-
- private void checkObserverDisposerWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- CDIUtil.insertInEditor(getEd(), bot, 10, 20, replacement + " ");
- dispObserCompletion(comp, className, replacement);
- }
-
- private void checkObserWithDisposParamMethod(CDICOMPONENT comp, String className) {
- prepareObserWithDisposParam();
- checkObserWithDisposParamWithAddon(comp, className, "@Disposes");
- checkObserWithDisposParamWithAddon(comp, className, "@Observes");
- }
-
- private void checkObserWithDisposParamWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- if (replacement.equals("@Observes")) {
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, "import javax.enterprise.inject.Disposes;");
- CDIUtil.insertInEditor(getEd(), bot, 6, 46, "@Disposes ");
- }
- checkQuickFix(replacement.equals("@Disposes")?ANNOTATIONS.DISPOSES:ANNOTATIONS.OBSERVES,
- CDICOMPONENT.BEAN, className, "");
- }
-
- private void checkSessionBean(CDICOMPONENT comp, String className) {
- checkSessionBeanWithAddon(comp, className, "@Decorator");
- checkSessionBeanWithAddon(comp, className, "@Interceptor");
- }
-
- private void checkSessionBeanWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- prepareCheckSessionBean(replacement);
- checkQuickFix(replacement.equals("@Decorator")?ANNOTATIONS.DECORATOR:ANNOTATIONS.INTERCEPTOR,
- comp, className, replacement);
- }
-
- private void dispObserCompletion(CDICOMPONENT comp, String className, String replacement) {
- CDIUtil.insertInEditor(getEd(), bot, 2 , 0, "import javax.enterprise." +
- (replacement.contains("Disposes")?"inject.":"event.") +
- (replacement.substring(1) + ";" + LINE_SEPARATOR));
- ANNOTATIONS annonType = (replacement.equals("@Disposes")?ANNOTATIONS.DISPOSES:ANNOTATIONS.OBSERVES);
- checkQuickFix(annonType, comp, className, replacement);
- }
-
- private void checkDisposesAnnotation(CDICOMPONENT comp, String className) {
- checkDisposesAnnotWithAddon(comp, className, "@Decorator");
- checkDisposesAnnotWithAddon(comp, className, "@Interceptor");
- }
-
- private void checkDisposesAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- prepareDisposesAnnot();
- String annot = replacement;
- String importAnnot = "import javax." + replacement.substring(1).toLowerCase()
- + "." + replacement.substring(1) + ";";
- CDIUtil.insertInEditor(getEd(), bot, 2, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement);
- }
-
- private void checkObserveAnnotation(CDICOMPONENT comp, String className) {
- checkObserveAnnotWithAddon(comp, className, "@Decorator");
- checkObserveAnnotWithAddon(comp, className, "@Interceptor");
- CDIUtil.replaceInEditor(getEd(), bot, "@Interceptor", "");
- CDIUtil.replaceInEditor(getEd(), bot, "import javax.interceptor.Interceptor;", "");
- }
-
- private void checkObserveAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- prepareDisposesAnnot();
- CDIUtil.replaceInEditor(getEd(), bot, "@Disposes", "@Observes");
- CDIUtil.replaceInEditor(getEd(), bot, "import javax.enterprise.inject.Disposes;",
- "import javax.enterprise.event.Observes;");
- CDIUtil.replaceInEditor(getEd(), bot, "dispose", "observe");
- String annot = replacement;
- String importAnnot = "import javax." + replacement.substring(1).toLowerCase()
- + "." + replacement.substring(1) + ";";
- CDIUtil.insertInEditor(getEd(), bot, 2, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement);
- }
-
- private void checkSpecializeAnnotation(CDICOMPONENT comp, String className) {
- prepareComponentsForSpecializeAnnotation(className);
- checkSpecializeAnnotWithAddon(comp, className, "@Interceptor");
- checkSpecializeAnnotWithAddon(comp, className, "@Decorator");
- CDIUtil.copyResourceToClass(getEd(),
- CDIQuickFixTest.class.getResourceAsStream("/resources/cdi/TestBean3.java.cdi"), false);
- }
-
- private void checkSpecializeAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- if (replacement.equals("@Decorator")) {
- CDIUtil.copyResourceToClass(getEd(),
- CDIQuickFixTest.class.getResourceAsStream("/resources/cdi/TestBean2.java.cdi"), false);
- }
- checkQuickFix(ANNOTATIONS.SPECIALIZES, comp, className, replacement);
- }
-
- private void checkNonBindingAnnotation(CDICOMPONENT comp, String className) {
- checkNonBindingAnnotationWithAddon(comp, className, "Annotation");
- checkNonBindingAnnotationWithAddon(comp, className, "Array");
-
- }
-
- private void checkNonBindingAnnotationWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- if (comp == CDICOMPONENT.INTERBINDING) {
- boolean interceptorCreated = projectExplorer.isFilePresent(getProjectName(),
- "Java Resources", "src", getPackageName(), className + ".java");
- if (!interceptorCreated) {
- createComponent(CDICOMPONENT.INTERBINDING, className, getPackageName(), null);
- }
- }
-
- if (replacement.equals("Annotation")) {
- boolean annotationCreated = projectExplorer.isFilePresent(getProjectName(),
- "Java Resources", "src", getPackageName(), "AAnnotation.java");
- if (!annotationCreated) {
- createComponent(null, "AAnnotation", getPackageName(), null);
- }
- bot.editorByTitle(className + ".java").show();
- setEd(bot.activeEditor().toTextEditor());
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-3, 1, "AAnnotation annotValue();" + LINE_SEPARATOR);
- }else {
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-3, 1, "String[] array();" + LINE_SEPARATOR);
- }
- checkQuickFix(ANNOTATIONS.NONBINDING, comp, className, replacement);
- }
-
- /*
- ****************************************************************
- *
- * checkQuickFix is the most important method in this class. It
- * gets validation error prior to component type, annotation and
- * class name, then it resolve validation error through quick fix
- * wizard and finally check if validation errors was fixed through
- * this wizard
- *
- ****************************************************************
- */
-
- private void checkQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp,
- String className, String replacement) {
- problemsTrees = getProblems(annonType, comp, className + ".java");
- assertTrue(problemsTrees.length != 0);
- resolveQuickFix(annonType, comp, replacement);
- problemsTrees = getProblems(annonType, comp, className + ".java");
- assertTrue(problemsTrees.length == 0);
- }
-
- private SWTBotTreeItem[] getProblems(ANNOTATIONS annonType, CDICOMPONENT comp, String className) {
- SWTBotTreeItem[] problemsTree;
- boolean warningType = true;
- switch (annonType) {
- case NAMED:
- case SPECIALIZES:
- case SERIALIZABLE:
- warningType = ((comp == CDICOMPONENT.BEAN)?true:false);
- break;
- case DISPOSES:
- case OBSERVES:
- case DECORATOR:
- case INTERCEPTOR:
- warningType = false;
- break;
- }
- String problemsContains = null;
- if (warningType) {
- switch (annonType) {
- case SPECIALIZES:
- problemsContains = "@Specializes";
- break;
- case NONBINDING:
- problemsContains = "@Nonbinding";
- break;
- case SERIALIZABLE:
- problemsContains = "declares a passivating scope SessionScoped";
- break;
- case NAMED:
- problemsContains = "should not have a name";
- }
-
- if (className.equals("BrokenFarm.java")) {
- problemsContains = "Multiple beans are eligible";
- }
- problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, problemsContains, "/"
- + getProjectName(), className, "CDI Problem");
- } else {
- if (className.equals("InterDecor.java")) {
- if (getEd().toTextEditor().getText().contains("produceString")) {
- problemsContains = "Producer cannot be declared in";
- }
- if (getEd().toTextEditor().getText().contains("disposeMethod")) {
- problemsContains = "has a method annotated @Disposes";
- }
- if (getEd().toTextEditor().getText().contains("observeMethod")) {
- problemsContains = "have a method with a parameter annotated @Observes";
- }
- }
- problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, problemsContains, "/"
- + getProjectName(), className, "CDI Problem");
- }
- return problemsTree;
- }
-
- private void resolveQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp, String replacement) {
- if (replacement.equals("MultipleBeans")) {
- resolveMultipleBeans();
- }else {
- int index = indexDetermine(annonType, comp, replacement);
- resolve(annonType, replacement, index);
- }
- }
-
- private int indexDetermine(ANNOTATIONS annonType, CDICOMPONENT comp, String replacement) {
- boolean chooseFirstOption = true;
- if (annonType == ANNOTATIONS.NAMED && replacement.equals("")) {
- chooseFirstOption = false;
- }
- if ((comp == CDICOMPONENT.BEAN && annonType == ANNOTATIONS.DISPOSES) ||
- (comp == CDICOMPONENT.BEAN && annonType == ANNOTATIONS.OBSERVES)) {
- if ((problemsTrees[0].getText().contains("Producer method has a parameter annotated "
- + replacement)) ||
- (problemsTrees[0].getText().contains("method cannot be annotated @Inject")) ||
- (annonType == ANNOTATIONS.OBSERVES &&
- problemsTrees[0].getText().contains("Observer method has a parameter annotated @Disposes"))) {
- chooseFirstOption = false;
- }
- }
- return chooseFirstOption?0:1;
- }
-
- private void resolve(ANNOTATIONS annonType, String replacement, int index) {
- CDIUtil.openQuickFix(problemsTrees[0], bot);
- bot.table(0).click(index, 0);
- assertFalse(bot.button("Finish").isEnabled());
- bot.table(1).getTableItem(0).check();
- assertTrue(bot.button("Finish").isEnabled());
- bot.clickButton("Finish");
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
- }
-
- private void resolveMultipleBeans() {
- CDIUtil.openQuickFix(problemsTrees[0], bot);
- String qualifBean = null;
- if (bot.table(0).cell(0, 0).contains("Animal")) {
- qualifBean = "Animal";
- } else {
- qualifBean = "Dog";
- }
- bot.activeShell().bot().button("Finish").click();
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
- assertFalse(bot.button("Add >").isEnabled());
- assertFalse(bot.button("Finish").isEnabled());
- bot.table(0).click(bot.table(0).indexOf("Q1 - " + getPackageName()), 0);
- assertTrue(bot.button("Add >").isEnabled());
- assertFalse(bot.button("Finish").isEnabled());
- bot.clickButton("Add >");
- assertTrue(bot.button("Finish").isEnabled());
- bot.clickButton("Finish");
-
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
- String code = getEd().toTextEditor().getText();
- assertTrue(code.contains("@Inject @Q1 private Animal animal;"));
- code = bot.editorByTitle(qualifBean + ".java").toTextEditor().getText();
- assertTrue(code.contains("@Q1"));
- }
-
- /*
- * method gets all the problems by all classes in the project.
- * Type of problems (warning, error) is chosen by proper value in parameter
- */
-
- private void checkProjectAllProblems() {
- problemsTrees = getAllProblems(PROBLEM_TYPE.WARNINGS);
- assertTrue(problemsTrees.length == 0);
- problemsTrees = getAllProblems(PROBLEM_TYPE.ERRORS);
- assertTrue(problemsTrees.length == 0);
- }
-
- private SWTBotTreeItem[] getAllProblems(PROBLEM_TYPE problemType) {
- SWTBotTreeItem[] problemsTree = null;
- if (problemType == PROBLEM_TYPE.WARNINGS) {
- problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + getProjectName(), null, null);
- }else if (problemType == PROBLEM_TYPE.ERRORS) {
- problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
- + getProjectName(), null, null);
- }
- return problemsTree;
- }
-
- private void cleanWarnings(String className) {
- problemsTrees = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + getProjectName(), className + ".java", null);
- assertTrue(problemsTrees.length != 0);
- CDIUtil.openQuickFix(problemsTrees[0], bot);
- bot.clickButton("Finish");
- bot.sleep(Timing.time1S());
- bot.activeEditor().save();
- problemsTrees = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + getProjectName(), className, "CDI Problem");
- assertTrue(problemsTrees.length == 0);
- }
-}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class DecoratorValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixDecoratorTest";
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7680
+ @Test
+ public void testSessionAnnotation() {
+
+ String className = "Decorator1";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithStateless.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.STATELESS, CDIWizardType.DECORATOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7636
+ @Test
+ public void testNamedAnnotation() {
+
+ String className = "Decorator2";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithNamed.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.DECORATOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7683
+ @Test
+ public void testProducer() {
+
+ String className = "Decorator3";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithProducer.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.DECORATOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7684
+ @Test
+ public void testDisposesAnnotation() {
+
+ String className = "Decorator4";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.DECORATOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7685
+ @Test
+ public void testObservesAnnotation() {
+
+ String className = "Decorator5";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.DECORATOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7686
+ @Test
+ public void testSpecializesAnnotation() {
+
+ String className = "Decorator6";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithSpecializes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.SPECIALIZES, CDIWizardType.DECORATOR);
+
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class IBindingValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixIBindingTest";
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7641
+ @Test
+ public void testNonbindingAnnotation() {
+
+ String className = "IBinding1";
+
+ wizard.createAnnotation("AAnnotation", getPackageName());
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR_BINDING,
+ className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptorBinding/" +
+ "IBindingWithAnnotation.java.cdi"), false);
+ editResourceUtil.replaceInEditor("IBindingComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.INTERCEPTOR_BINDING);
+
+ editResourceUtil.replaceInEditor("@Nonbinding AAnnotation", "String[]");
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.INTERCEPTOR_BINDING);
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class InterceptorValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixInterceptorTest";
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7680
+ @Test
+ public void testSessionAnnotation() {
+
+ String className = "Interceptor1";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(), null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithStateless.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.STATELESS, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7636
+ @Test
+ public void testNamedAnnotation() {
+
+ String className = "Interceptor2";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(), null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithNamed.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7683
+ @Test
+ public void testProducer() {
+
+ String className = "Interceptor3";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(), null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithProducer.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7684
+ @Test
+ public void testDisposesAnnotation() {
+
+ String className = "Interceptor4";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(), null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7685
+ @Test
+ public void testObservesAnnotation() {
+
+ String className = "Interceptor5";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(), null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7686
+ @Test
+ public void testSpecializesAnnotation() {
+
+ String className = "Interceptor6";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(), null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithSpecializes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.SPECIALIZES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class QualifierValidationQuickFixTest extends QuickFixTestBase {
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixQualifierTest";
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7630
+ @Test
+ public void testTargetAnnotation() {
+
+ String className = "Qualifier1";
+
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, PARAMETER, FIELD })",
+ "@Target({ TYPE, FIELD })");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.QUALIFIER);
+
+ editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD, PARAMETER})", "");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.QUALIFIER);
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7631
+ @Test
+ public void testRetentionAnnotation() {
+
+ String className = "Qualifier2";
+
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "@Retention(CLASS)");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.QUALIFIER);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.QUALIFIER);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7641
+ @Test
+ public void testNonbindingAnnotation() {
+
+ String className = "Qualifier3";
+
+ wizard.createAnnotation("AAnnotation", getPackageName());
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi"), false);
+ editResourceUtil.replaceInEditor("QualifierComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.QUALIFIER);
+
+ editResourceUtil.replaceInEditor("@Nonbinding AAnnotation", "String[]");
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.QUALIFIER);
+ }
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import java.util.ArrayList;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.BeanValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.DecoratorValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.InterceptorBindingValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.InterceptorValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.QualifierValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.ScopeValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.StereotypeValidationProvider;
+import org.jboss.tools.cdi.bot.test.uiutils.QuickFixHelper;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.junit.BeforeClass;
+
+/**
+ * Test base for all QuickFix-like tests
+ *
+ * @author Jaroslav Jankovic
+ */
+
+public class QuickFixTestBase extends QuickFixHelper {
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ }
+ }
+
+ @BeforeClass
+ public static void setup() {
+ problems.show();
+ }
+
+
+ /**
+ * checkQuickFix is the most important method in this class. It
+ * gets validation error prior to component type and annotation type,
+ * then it resolve validation error through quick fix
+ * wizard and finally check if validation errors was fixed through
+ * this wizard
+ * @param annonType
+ * @param compType
+ */
+ public void checkQuickFix(CDIAnnotationsType annonType, CDIWizardType compType) {
+ SWTBotTreeItem validationProblem = getProblem(annonType, compType);
+ assertNotNull(validationProblem);
+ resolveQuickFix(validationProblem);
+ validationProblem = getProblem(annonType, compType);
+ assertNull(validationProblem);
+ }
+
+ /**
+ * Methods gets the particular validation problem located in Problems View by
+ * using specific ValidationErrorsProvider
+ * @param annonType
+ * @param compType
+ * @return
+ */
+ private SWTBotTreeItem getProblem(CDIAnnotationsType annonType, CDIWizardType compType) {
+ switch (compType) {
+ case STEREOTYPE:
+ validationErrorsProvider = new StereotypeValidationProvider();
+ break;
+ case QUALIFIER:
+ validationErrorsProvider = new QualifierValidationProvider();
+ break;
+ case SCOPE:
+ validationErrorsProvider = new ScopeValidationProvider();
+ break;
+ case BEAN:
+ validationErrorsProvider = new BeanValidationProvider();
+ break;
+ case INTERCEPTOR:
+ validationErrorsProvider = new InterceptorValidationProvider();
+ break;
+ case DECORATOR:
+ validationErrorsProvider = new DecoratorValidationProvider();
+ break;
+ case INTERCEPTOR_BINDING:
+ validationErrorsProvider = new InterceptorBindingValidationProvider();
+ break;
+ }
+ ArrayList<String> validationProblems = null;
+ SWTBotTreeItem[] problemsInProblemsView = null;
+ if (validationErrorsProvider.getAllWarningsAnnotation().contains(annonType)) {
+ validationProblems = validationErrorsProvider.getAllWarningForAnnotationType(annonType);
+ problemsInProblemsView = getProblems(ProblemsType.WARNINGS);
+ } else {
+ validationProblems = validationErrorsProvider.getAllErrorsForAnnotationType(annonType);
+ problemsInProblemsView = getProblems(ProblemsType.ERRORS);
+ }
+ for (SWTBotTreeItem ti: problemsInProblemsView) {
+ for (String validationProblem: validationProblems) {
+ if (ti.getText().contains(validationProblem)) {
+ return ti;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method resolves particular validation problem (parameter ti).
+ * It simply open context menu for param "ti", open menu "Quick Fix" and
+ * chooses first option and confirms it
+ *
+ * @param ti
+ */
+ private void resolveQuickFix(SWTBotTreeItem ti) {
+ openQuickFix(ti);
+ bot.table(0).click(0, 0);
+ bot.table(1).getTableItem(0).check();
+ bot.clickButton("Finish");
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ }
+
+
+ public void resolveMultipleBeans() {
+
+ SWTBotTreeItem validationProblem = getProblem(CDIAnnotationsType.INJECT,
+ CDIWizardType.BEAN);
+
+ openQuickFix(validationProblem);
+ int indexOfAnimalBean = 0;
+ if (!bot.table(0).cell(0, 0).contains("Animal")) {
+ indexOfAnimalBean++;
+ }
+
+ bot.table(0).click(indexOfAnimalBean, 0);
+ bot.table(1).getTableItem(0).check();
+ bot.activeShell().bot().button("Finish").click();
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+
+ bot.table(0).click(bot.table(0).indexOf("Q1 - " + getPackageName()), 0);
+ bot.clickButton("Add >");
+ bot.clickButton("Finish");
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ }
+
+ public void checkMultipleBean() {
+ String code = getEd().toTextEditor().getText();
+ assertTrue(code.contains("@Inject @Q1 private Animal animal;"));
+ code = bot.editorByTitle("Animal.java").toTextEditor().getText();
+ assertTrue(code.contains("@Q1"));
+ }
+
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class ScopeValidationQuickFixTest extends QuickFixTestBase {
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixScopeTest";
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7633
+ @Test
+ public void testTargetAnnotation() {
+
+ String className = "Scope1";
+
+ wizard.createCDIComponent(CDIWizardType.SCOPE, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, FIELD })",
+ "@Target({ TYPE, FIELD })");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.SCOPE);
+
+ editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD})", "");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.SCOPE);
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7631
+ @Test
+ public void testRetentionAnnotation() {
+
+ String className = "Scope2";
+
+ wizard.createCDIComponent(CDIWizardType.SCOPE, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "@Retention(CLASS)");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.SCOPE);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.SCOPE);
+
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI stereotype component validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class StereotypeValidationQuickFixTest extends QuickFixTestBase {
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixStereotypeTest";
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7630
+ @Test
+ public void testTargetAnnotation() {
+
+ String className = "Stereotype1";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, FIELD })",
+ "@Target({ TYPE, FIELD })");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.STEREOTYPE);
+
+ editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD})", "");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.STEREOTYPE);
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7631
+ @Test
+ public void testRetentionAnnotation() {
+
+ String className = "Stereotype2";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "@Retention(CLASS)");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.STEREOTYPE);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.STEREOTYPE);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7634
+ @Test
+ public void testNamedAnnotation() {
+
+ String className = "Stereotype3";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi"), false);
+ editResourceUtil.replaceInEditor("StereotypeComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.STEREOTYPE);
+
+ }
+
+ // https://issues.jboss.org/browse/JBIDE-7640
+ @Test
+ public void testTypedAnnotation() {
+
+ String className = "Stereotype4";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi"), false);
+ editResourceUtil.replaceInEditor("StereotypeComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.TYPED, CDIWizardType.STEREOTYPE);
+
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,54 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public abstract class AbstractValidationProvider implements ValidationErrorProvider {
+
+ protected Map<String, ArrayList<String>> validationErrors = null;
+ protected ArrayList<String> warningsForAnnotationType = null;
+ protected ArrayList<String> errorsForAnnotationType = null;
+ protected ArrayList<CDIAnnotationsType> warningsAnnotation = null;
+ protected ArrayList<CDIAnnotationsType> errorsAnnotation = null;
+
+ public AbstractValidationProvider() {
+ validationErrors = new LinkedHashMap<String, ArrayList<String>>();
+ warningsForAnnotationType = new ArrayList<String>();
+ errorsForAnnotationType = new ArrayList<String>();
+ warningsAnnotation = new ArrayList<CDIAnnotationsType>();
+ errorsAnnotation = new ArrayList<CDIAnnotationsType>();
+
+ validationErrors.put("Warnings", new ArrayList<String>());
+ validationErrors.put("Errors", new ArrayList<String>());
+
+ init();
+ }
+
+ abstract void init();
+
+ public Map<String, ArrayList<String>> getAllValidationErrors() {
+ return validationErrors;
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ return warningsForAnnotationType;
+ }
+
+ public ArrayList<CDIAnnotationsType> getAllWarningsAnnotation() {
+ return warningsAnnotation;
+ }
+
+ public ArrayList<CDIAnnotationsType> getAllErrorsAnnotation() {
+ return errorsAnnotation;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,81 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class BeanValidationProvider extends AbstractValidationProvider {
+
+ public BeanValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("which declares a passivating scope SessionScoped " +
+ "must be passivation capable");
+ validationErrors.get("Warnings").add("Multiple beans are eligible for injection to " +
+ "the injection point");
+ validationErrors.get("Errors").add("Bean constructor cannot have a parameter annotated " +
+ "@Disposes");
+ validationErrors.get("Errors").add("Bean constructor cannot have a parameter annotated " +
+ "@Observes");
+ validationErrors.get("Errors").add("Producer method has a parameter annotated @Disposes");
+ validationErrors.get("Errors").add("Producer method has a parameter annotated @Observes");
+ validationErrors.get("Errors").add("Disposer method cannot be annotated @Inject");
+ validationErrors.get("Errors").add("Observer method cannot be annotated @Inject");
+ validationErrors.get("Errors").add("Observer method has a parameter annotated @Disposes");
+ validationErrors.get("Errors").add("Producer method or field cannot be annotated @Inject");
+
+ warningsAnnotation.add(CDIAnnotationsType.SERIALIZABLE);
+ warningsAnnotation.add(CDIAnnotationsType.INJECT);
+
+ errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
+ errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
+ errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch(annotationType) {
+ case DISPOSES:
+ errorIndex = 0;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 2;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 4;
+ break;
+ case OBSERVES:
+ errorIndex = 1;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 3;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 5;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 6;
+ break;
+ case PRODUCES:
+ errorIndex = 7;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case SERIALIZABLE:
+ warningIndex = 0;
+ break;
+ case INJECT:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,72 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class DecoratorValidationProvider extends AbstractValidationProvider {
+
+ public DecoratorValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Decorator should not have a name");
+ validationErrors.get("Warnings").add("Decorator should not be annotated " +
+ "@Specializes");
+ validationErrors.get("Errors").add("Producer cannot be declared in a " +
+ "decorator");
+ validationErrors.get("Errors").add("Decorator has a method annotated " +
+ "@Disposes");
+ validationErrors.get("Errors").add("Decorator cannot have a method with a " +
+ "parameter annotated @Observes");
+ validationErrors.get("Errors").add("Bean class of a session bean cannot be annotated " +
+ "@Decorator");
+
+ warningsAnnotation.add(CDIAnnotationsType.NAMED);
+ warningsAnnotation.add(CDIAnnotationsType.SPECIALIZES);
+
+ errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
+ errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
+ errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
+ errorsAnnotation.add(CDIAnnotationsType.STATELESS);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch(annotationType) {
+ case PRODUCES:
+ errorIndex = 0;
+ break;
+ case DISPOSES:
+ errorIndex = 1;
+ break;
+ case OBSERVES:
+ errorIndex = 2;
+ break;
+ case STATELESS:
+ errorIndex = 3;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case NAMED:
+ warningIndex = 0;
+ break;
+ case SPECIALIZES:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,37 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class InterceptorBindingValidationProvider extends AbstractValidationProvider {
+
+ public InterceptorBindingValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Annotation-valued member of an interceptor " +
+ "binding type should be annotated @Nonbinding");
+ validationErrors.get("Warnings").add("Array-valued member of an interceptor " +
+ "binding type must be annotated @Nonbinding");
+
+ warningsAnnotation.add(CDIAnnotationsType.NONBINDING);
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case NONBINDING:
+ warningIndex = 0;
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,73 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class InterceptorValidationProvider extends AbstractValidationProvider {
+
+ public InterceptorValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Interceptor should not have a name");
+ validationErrors.get("Warnings").add("Interceptor should not be annotated " +
+ "@Specializes");
+ validationErrors.get("Errors").add("Producer cannot be declared in an " +
+ "interceptor");
+ validationErrors.get("Errors").add("Interceptor has a method annotated " +
+ "@Disposes");
+ validationErrors.get("Errors").add("Interceptor cannot have a method with a " +
+ "parameter annotated @Observes");
+ validationErrors.get("Errors").add("Bean class of a session bean cannot be annotated " +
+ "@Interceptor");
+
+ warningsAnnotation.add(CDIAnnotationsType.NAMED);
+ warningsAnnotation.add(CDIAnnotationsType.SPECIALIZES);
+
+ errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
+ errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
+ errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
+ errorsAnnotation.add(CDIAnnotationsType.STATELESS);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch(annotationType) {
+ case PRODUCES:
+ errorIndex = 0;
+ break;
+ case DISPOSES:
+ errorIndex = 1;
+ break;
+ case OBSERVES:
+ errorIndex = 2;
+ break;
+ case STATELESS:
+ errorIndex = 3;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case NAMED:
+ warningIndex = 0;
+ break;
+ case SPECIALIZES:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
+
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,49 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class QualifierValidationProvider extends AbstractValidationProvider {
+
+ public QualifierValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Qualifier annotation type must be annotated " +
+ "with @Retention(RUNTIME)");
+ validationErrors.get("Warnings").add("Qualifier annotation type must be annotated with " +
+ "@Target");
+ validationErrors.get("Warnings").add("Annotation-valued member of a qualifier type " +
+ "should be annotated @Nonbinding");
+ validationErrors.get("Warnings").add("Array-valued member of a qualifier type " +
+ "should be annotated @Nonbinding");
+
+ warningsAnnotation.add(CDIAnnotationsType.RETENTION);
+ warningsAnnotation.add(CDIAnnotationsType.TARGET);
+ warningsAnnotation.add(CDIAnnotationsType.NONBINDING);
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case RETENTION:
+ warningIndex = 0;
+ break;
+ case TARGET:
+ warningIndex = 1;
+ break;
+ case NONBINDING:
+ warningIndex = 2;
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ warningIndex = 3;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,39 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class ScopeValidationProvider extends AbstractValidationProvider {
+
+ public ScopeValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Scope annotation type must be annotated " +
+ "with @Retention(RUNTIME)");
+ validationErrors.get("Warnings").add("Scope annotation type must be annotated with " +
+ "@Target");
+
+ warningsAnnotation.add(CDIAnnotationsType.RETENTION);
+ warningsAnnotation.add(CDIAnnotationsType.TARGET);
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case RETENTION:
+ warningIndex = 0;
+ break;
+ case TARGET:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,58 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class StereotypeValidationProvider extends AbstractValidationProvider {
+
+ public StereotypeValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Stereotype annotation type must be annotated with one of");
+ validationErrors.get("Warnings").add("Stereotype annotation type must be annotated " +
+ "with @Retention(RUNTIME)");
+ validationErrors.get("Warnings").add("A stereotype should not be annotated @Typed");
+ validationErrors.get("Errors").add("Stereotype declares a non-empty @Named annotation");
+
+ warningsAnnotation.add(CDIAnnotationsType.TARGET);
+ warningsAnnotation.add(CDIAnnotationsType.RETENTION);
+ warningsAnnotation.add(CDIAnnotationsType.TYPED);
+
+ errorsAnnotation.add(CDIAnnotationsType.NAMED);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch (annotationType) {
+ case NAMED:
+ errorIndex = 0;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case TARGET:
+ warningIndex = 0;
+ break;
+ case RETENTION:
+ warningIndex = 1;
+ break;
+ case TYPED:
+ warningIndex = 2;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+public interface ValidationErrorProvider {
+
+ Map<String, ArrayList<String>> getAllValidationErrors();
+
+ ArrayList<String> getAllWarningForAnnotationType(CDIAnnotationsType annotationType);
+
+ ArrayList<String> getAllErrorsForAnnotationType(CDIAnnotationsType annotationType);
+
+ ArrayList<CDIAnnotationsType> getAllWarningsAnnotation();
+
+ ArrayList<CDIAnnotationsType> getAllErrorsAnnotation();
+}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.seam3;
-
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
-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;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on seam3 features using CDI tools
- *
- * @author Jaroslav Jankovic
- */
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDISeam3Test extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDISeam3Test.class.getName());
- private final String genericPoint1 = "MyExtendedConfiguration ";
- private final String genericPoint2 = "MyConfigurationProducer.getOneConfig()";
- private final String genericPoint3 = "MyConfigurationProducer.getSecondConfig()";
-
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createAndCheckCDIProject(bot, util, projectExplorer,getProjectName());
- addLibrary("seam-solder.jar");
- checkLibrary("seam-solder.jar");
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDISeam3Test";
- }
-
- private String getGenericPackageName() {
- return "org.cdi.generic";
- }
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
- /*
- * https://issues.jboss.org/browse/JBIDE-8202
- */
- @Test
- public void testResourceOpenOn() {
-
- createComponent(CDICOMPONENT.BEANSXML, "beans.xml", getProjectName() + "/WebContent/WEB-INF", null);
-
- createComponent(CDICOMPONENT.BEAN, "B2", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/B2.java.cdi"), false);
- LOGGER.info("Content of \"B2.java.cdi\" copied to B2");
- openOn("beansXml", "B2.java", "Open Resource");
- String destinationFile = getEd().getTitle();
- assertTrue("ERROR: redirected to " + destinationFile,
- destinationFile.equals("beans.xml"));
-
- moveFileInProjectExplorer("beans.xml", getProjectName() + "/WebContent/WEB-INF",
- getProjectName() + "/WebContent/META-INF");
- LOGGER.info("bean.xml was moved to META-INF");
-
- setEd(bot.swtBotEditorExtByTitle("B2.java"));
- CDIUtil.replaceInEditor(getEd(), bot, "WEB", "META");
- openOn("beansXml", "B2.java", "Open Resource");
-
- destinationFile = getEd().getTitle();
- assertTrue("ERROR: redirected to " + destinationFile,
- destinationFile.equals("beans.xml"));
-
- }
-
- /*
- * https://issues.jboss.org/browse/JBIDE-8692
- */
- @Test
- public void testGenericOpenOn() {
-
- prepareGenericOpenOn();
-
- checkMyBeanInjections();
-
- checkMyGenericBean();
-
- checkMyGenericBean2();
- }
-
- private void addLibrary(String libraryName) {
- try {
- addLibraryIntoProject(getProjectName(), libraryName);
- LOGGER.info("Library: \"" + libraryName + "\" copied");
- util.waitForNonIgnoredJobs();
- addLibraryToProjectsClassPath(getProjectName(), libraryName);
- LOGGER.info("Library: \"" + libraryName + "\" on class path of project\"" + getProjectName() + "\"");
- } catch (IOException exc) {
- LOGGER.log(Level.SEVERE, "Error while adding seam solder library into project");
- }
- }
-
- private void checkLibrary(String libraryName) {
- isLibraryInProjectClassPath(getProjectName(), libraryName);
- }
-
- /**
- * create all necessary components for this test
- */
- private void prepareGenericOpenOn() {
- /*
- * injectable beans + qualifiers + generic configuration components
- */
- createComponent(CDICOMPONENT.BEAN, "MyBean", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean");
-
- createComponent(CDICOMPONENT.BEAN, "MyBean2", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean2");
-
- createComponent(CDICOMPONENT.BEAN, "MyBean3", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean3");
-
- createComponent(CDICOMPONENT.BEAN, "MyConfiguration", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyConfiguration");
-
- createComponent(CDICOMPONENT.BEAN, "MyGenericType", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyGenericType.java.cdi"), false);
-
- createComponent(CDICOMPONENT.QUALIFIER, "Qualifier1", getGenericPackageName(), null);
- createComponent(CDICOMPONENT.QUALIFIER, "Qualifier2", getGenericPackageName(), null);
-
- createComponent(CDICOMPONENT.BEAN, "MyExtendedConfiguration", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyExtendConfig.java.cdi"), false);
-
- createComponent(CDICOMPONENT.BEAN, "MyConfigurationProducer", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyConfigProd.java.cdi"), false);
-
- /*
- * beans which include atributes suggesting opening all the available
- * generic configurations
- */
-
- createComponent(CDICOMPONENT.BEAN, "MyBeanInjections", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBeanInjections.java.cdi"), false);
-
- createComponent(CDICOMPONENT.BEAN, "MyGenericBean", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyGenericBean.java.cdi"), false);
-
- createComponent(CDICOMPONENT.BEAN, "MyGenericBean2", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyGenericBean2.java.cdi"), false);
- }
-
- private void checkMyBeanInjections() {
- checkFirstOpenOnAndGeneric();
- checkSecondOpenOnAndGeneric();
- checkThirdOpenOnAndGeneric();
- }
-
- private void checkMyGenericBean() {
- String parameter = "MyConfiguration config";
- String classTitle = "MyGenericBean.java";
- checkAllGenericPointsForAtribute(parameter, classTitle);
- }
-
- private void checkMyGenericBean2() {
- String classTitle = "MyGenericBean2.java";
-
- checkAllGenericPointsForAtribute("MyConfiguration config", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean c", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean2 c2", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean3 c3", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean parameter1", classTitle);
-
- }
- private void checkFirstOpenOnAndGeneric() {
- checkOpenOnAndGeneric("first1", "MyBeanInjections.java", "Generic Configuration Point",
- "MyConfigurationProducer.java", "getOneConfig");
- checkOpenOnAndGeneric("first1", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean.java", "createMyFirstBean");
-
- checkOpenOnAndGeneric("first2", "MyBeanInjections.java", "Generic Configuration Point",
- "MyConfigurationProducer.java", "getSecondConfig");
- checkOpenOnAndGeneric("first2", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean.java", "createMyFirstBean");
-
- checkOpenOnAndGeneric("first3", "MyBeanInjections.java", "Generic Configuration Point",
- "MyExtendedConfiguration.java", "MyExtendedConfiguration");
- checkOpenOnAndGeneric("first3", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean.java", "createMyFirstBean");
- }
-
- private void checkSecondOpenOnAndGeneric() {
- checkOpenOnAndGeneric("second1", "MyBeanInjections.java", "Generic Configuration Point",
- "MyConfigurationProducer.java", "getOneConfig");
- checkOpenOnAndGeneric("second1", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean2.java", "createMySecondBean");
-
- checkOpenOnAndGeneric("second2", "MyBeanInjections.java", "Generic Configuration Point",
- "MyConfigurationProducer.java", "getSecondConfig");
- checkOpenOnAndGeneric("second2", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean2.java", "createMySecondBean");
-
- checkOpenOnAndGeneric("second3", "MyBeanInjections.java", "Generic Configuration Point",
- "MyExtendedConfiguration.java", "MyExtendedConfiguration");
- checkOpenOnAndGeneric("second3", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean2.java", "createMySecondBean");
- }
-
- private void checkThirdOpenOnAndGeneric() {
- checkOpenOnAndGeneric("third1", "MyBeanInjections.java", "Generic Configuration Point",
- "MyConfigurationProducer.java", "getOneConfig");
- checkOpenOnAndGeneric("third1", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean.java", "myThirdBean");
-
- checkOpenOnAndGeneric("third2", "MyBeanInjections.java", "Generic Configuration Point",
- "MyConfigurationProducer.java", "getSecondConfig");
- checkOpenOnAndGeneric("third2", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean.java", "myThirdBean");
-
- checkOpenOnAndGeneric("third3", "MyBeanInjections.java", "Generic Configuration Point",
- "MyExtendedConfiguration.java", "MyExtendedConfiguration");
- checkOpenOnAndGeneric("third3", "MyBeanInjections.java", "@Inject Bean",
- "MyGenericBean.java", "myThirdBean");
- }
-
- private void checkOpenOnAndGeneric(String openOnString, String titleName, String chosenOption,
- String afterOpenOnTitleName, String injectSelectionAtribute) {
- openOn(openOnString, titleName, chosenOption);
- String activeEditor = bot.activeEditor().getTitle();
- String selectedString = bot.activeEditor().toTextEditor().getSelection();
- assertTrue(activeEditor, activeEditor.equals(afterOpenOnTitleName));
- assertTrue(selectedString, selectedString.equals(injectSelectionAtribute));
- }
-
- private void checkAllGenericPointsForAtribute(String parameter, String classTitle) {
- openOn(parameter, classTitle, "Show All Generic Configuration Points...");
- bot.sleep(Timing.time1S());
- SWTBotTable genericPointTable = bot.table(0);
- assertTrue(checkAllGenericConfPoints(genericPointTable));
- getEd().pressShortcut(Keystrokes.ESC);
- bot.sleep(Timing.time2S());
- }
-
- private boolean checkAllGenericConfPoints(SWTBotTable genericPointTable) {
- boolean isGenericPoint1Present = false;
- boolean isGenericPoint2Present = false;
- boolean isGenericPoint3Present = false;
- for (int rowIterator = 0; rowIterator < genericPointTable.rowCount(); rowIterator++) {
- String itemInTable = genericPointTable.getTableItem(rowIterator).getText();
- if (itemInTable.contains(genericPoint1)) {
- isGenericPoint1Present = true;
- continue;
- }
- if (itemInTable.contains(genericPoint2)) {
- isGenericPoint2Present = true;
- continue;
- }
- if (itemInTable.contains(genericPoint3)) {
- isGenericPoint3Present = true;
- continue;
- }
- }
- return isGenericPoint1Present && isGenericPoint2Present && isGenericPoint3Present;
- }
-
-}
-
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/Seam3Test.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/Seam3Test.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/Seam3Test.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.seam3;
+
+
+import java.io.IOException;
+import java.util.logging.Level;
+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.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on seam3 features using CDI tools
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class Seam3Test extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(Seam3Test.class.getName());
+ private final String genericPoint1 = "MyExtendedConfiguration ";
+ private final String genericPoint2 = "MyConfigurationProducer.getOneConfig()";
+ private final String genericPoint3 = "MyConfigurationProducer.getSecondConfig()";
+
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ addLibrary("seam-solder.jar");
+ checkLibrary("seam-solder.jar");
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDISeam3Test";
+ }
+
+ private String getGenericPackageName() {
+ return "org.cdi.generic";
+ }
+
+
+ /**
+ * https://issues.jboss.org/browse/JBIDE-8202
+ */
+ @Test
+ public void testResourceOpenOn() {
+
+ String className = "Bean1";
+
+ wizard.createComponent(CDIWizardType.BEANS_XML, "beans.xml", getProjectName() + "/WebContent/WEB-INF", null);
+
+ wizard.createComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/seam3/Bean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ openOnUtil.openOnByOption("beansXml", className + ".java", "Open Resource");
+
+ String destinationFile = getEd().getTitle();
+ assertTrue("ERROR: redirected to " + destinationFile,
+ destinationFile.equals("beans.xml"));
+
+ editResourceUtil.moveFileInProjectExplorer("beans.xml", getProjectName() + "/WebContent/WEB-INF",
+ getProjectName() + "/WebContent/META-INF");
+ LOGGER.info("bean.xml was moved to META-INF");
+
+ setEd(bot.swtBotEditorExtByTitle(className + ".java"));
+ editResourceUtil.replaceInEditor("WEB", "META");
+ openOnUtil.openOnByOption("beansXml", className + ".java", "Open Resource");
+
+ destinationFile = getEd().getTitle();
+ assertTrue("ERROR: redirected to " + destinationFile,
+ destinationFile.equals("beans.xml"));
+
+ }
+
+ /**
+ * https://issues.jboss.org/browse/JBIDE-8692
+ */
+ @Test
+ public void testGenericOpenOn() {
+
+ prepareGenericOpenOn();
+
+ checkMyBeanInjections();
+
+ checkMyGenericBean();
+
+ checkMyGenericBean2();
+ }
+
+ private void addLibrary(String libraryName) {
+ try {
+ libraryUtil.addLibraryIntoProject(getProjectName(), libraryName);
+ LOGGER.info("Library: \"" + libraryName + "\" copied");
+ util.waitForNonIgnoredJobs();
+ libraryUtil.addLibraryToProjectsClassPath(getProjectName(), libraryName);
+ LOGGER.info("Library: \"" + libraryName + "\" on class path of project\"" + getProjectName() + "\"");
+ } catch (IOException exc) {
+ LOGGER.log(Level.SEVERE, "Error while adding seam solder library into project");
+ }
+ }
+
+ private void checkLibrary(String libraryName) {
+ assertTrue(libraryUtil.isLibraryInProjectClassPath(getProjectName(), libraryName));
+ }
+
+ /**
+ * wizard.create all necessary components for this test
+ */
+ private void prepareGenericOpenOn() {
+ /**
+ * injectable beans + qualifiers + generic configuration components
+ */
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX", "MyBean");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean2", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX", "MyBean2");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean3", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX", "MyBean3");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyConfiguration", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX", "MyConfiguration");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyGenericType", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericType.java.cdi"), false);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Qualifier1", getGenericPackageName(), null);
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Qualifier2", getGenericPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyExtendedConfiguration", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyExtendConfig.java.cdi"), false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyConfigurationProducer", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyConfigProd.java.cdi"), false);
+
+ /**
+ * beans which include atributes suggesting opening all the available
+ * generic configurations
+ */
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBeanInjections", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBeanInjections.java.cdi"), false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyGenericBean", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericBean.java.cdi"), false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyGenericBean2", getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericBean2.java.cdi"), false);
+ }
+
+ private void checkMyBeanInjections() {
+ checkFirstOpenOnAndGeneric();
+ checkSecondOpenOnAndGeneric();
+ checkThirdOpenOnAndGeneric();
+ }
+
+ private void checkMyGenericBean() {
+ String parameter = "MyConfiguration config";
+ String classTitle = "MyGenericBean.java";
+ checkAllGenericPointsForAtribute(parameter, classTitle);
+ }
+
+ private void checkMyGenericBean2() {
+ String classTitle = "MyGenericBean2.java";
+
+ checkAllGenericPointsForAtribute("MyConfiguration config", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean c", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean2 c2", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean3 c3", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean parameter1", classTitle);
+
+ }
+ private void checkFirstOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("first1", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("first1", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+
+ checkOpenOnAndGeneric("first2", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("first2", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+
+ checkOpenOnAndGeneric("first3", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("first3", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+ }
+
+ private void checkSecondOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("second1", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("second1", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+
+ checkOpenOnAndGeneric("second2", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("second2", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+
+ checkOpenOnAndGeneric("second3", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("second3", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+ }
+
+ private void checkThirdOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("third1", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("third1", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+
+ checkOpenOnAndGeneric("third2", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("third2", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+
+ checkOpenOnAndGeneric("third3", "MyBeanInjections.java", "Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("third3", "MyBeanInjections.java", "@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+ }
+
+ private void checkOpenOnAndGeneric(String openOnString, String titleName, String chosenOption,
+ String afterOpenOnTitleName, String injectSelectionAtribute) {
+ openOnUtil.openOnByOption(openOnString, titleName, chosenOption);
+ String activeEditor = bot.activeEditor().getTitle();
+ String selectedString = bot.activeEditor().toTextEditor().getSelection();
+ assertTrue(activeEditor, activeEditor.equals(afterOpenOnTitleName));
+ assertTrue(selectedString, selectedString.equals(injectSelectionAtribute));
+ }
+
+ private void checkAllGenericPointsForAtribute(String parameter, String classTitle) {
+ openOnUtil.openOnByOption(parameter, classTitle, "Show All Generic Configuration Points...");
+ bot.sleep(Timing.time1S());
+ SWTBotTable genericPointTable = bot.table(0);
+ assertTrue(checkAllGenericConfPoints(genericPointTable));
+ //getEd().pressShortcut(Keystrokes.ESC);
+ bot.sleep(Timing.time2S());
+ }
+
+ private boolean checkAllGenericConfPoints(SWTBotTable genericPointTable) {
+ boolean isGenericPoint1Present = false;
+ boolean isGenericPoint2Present = false;
+ boolean isGenericPoint3Present = false;
+ for (int rowIterator = 0; rowIterator < genericPointTable.rowCount(); rowIterator++) {
+ String itemInTable = genericPointTable.getTableItem(rowIterator).getText();
+ if (itemInTable.contains(genericPoint1)) {
+ isGenericPoint1Present = true;
+ continue;
+ }
+ if (itemInTable.contains(genericPoint2)) {
+ isGenericPoint2Present = true;
+ continue;
+ }
+ if (itemInTable.contains(genericPoint3)) {
+ isGenericPoint3Present = true;
+ continue;
+ }
+ }
+ return isGenericPoint1Present && isGenericPoint2Present && isGenericPoint3Present;
+ }
+
+}
+
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewFileWizardAction;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.DynamicWebProjectWizard;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class CDIProjectHelper extends CDIBase{
+
+
+ public void createCDIProject(String projectName) {
+ createDynamicWebProject(projectName);
+ addCDISupport(projectName);
+ }
+
+ public void createDynamicWebProjectWithCDIPreset(String projectName) {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(projectName).setCDIPreset().finish();
+ util.waitForNonIgnoredJobs();
+ }
+
+ public void createDynamicWebProjectWithCDIFacets(String projectName) {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(projectName).setCDIFacet().finish();
+ bot.sleep(Timing.time5S());
+ util.waitForNonIgnoredJobs();
+ }
+
+ public boolean projectExists(String projectName) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ boolean projectExists = false;
+ try {
+ tree.getTreeItem(projectName);
+ projectExists = true;
+ }catch (WidgetNotFoundException exc) {
+ }
+ return projectExists;
+ }
+
+ private void createDynamicWebProject(String projectName) {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(projectName).finish();
+ util.waitForNonIgnoredJobs();
+ }
+
+ private void addCDISupport(String projectName) {
+ projectExplorer.selectProject(projectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(projectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item, "Configure",
+ "Add CDI (Context and Dependency Injection) support...")
+ .click();
+ bot.activeShell().bot().button("OK").click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Scanner;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.TreeHelper;
+
+public class EditorResourceHelper extends CDIBase {
+
+ /**
+ * method replaces whole content of class "classEdit" by inputstream resource
+ * If closeEdit param is true, editor is not only saved but closed as well
+ * Prerequisite: editor has been set
+ * @param classEdit
+ * @param resource
+ * @param closeEdit
+ */
+ public void replaceClassContentByResource(InputStream resource, boolean closeEdit) {
+ SWTBotEclipseEditor st = getEd().toTextEditor();
+ st.selectRange(0, 0, st.getText().length());
+ String code = readStream(resource);
+ st.setText(code);
+ getEd().save();
+ if (closeEdit) {
+ getEd().close();
+ }
+ }
+
+ /**
+ * method copies resource from folder "src" param to folder "target" param
+ * @param src
+ * @param target
+ */
+ public void copyResource(String src, String target) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProjects()[0];
+ IFile f = project.getFile(target);
+ if (f.exists()) {
+ try {
+ f.delete(true, new NullProgressMonitor());
+ } catch (CoreException ce) {
+ }
+ }
+ InputStream is = null;
+ try {
+ is = BeansEditorTest.class.getResourceAsStream(src);
+ f.create(is, true, new NullProgressMonitor());
+ } catch (CoreException ce) {
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Method replaces string "target" by string "replacement.
+ * Prerequisite: editor has been set
+ * @param target
+ * @param replacement
+ */
+ public void replaceInEditor(String target, String replacement) {
+ getEd().selectRange(0, 0, getEd().getText().length());
+ getEd().setText(getEd().getText().replace(
+ target + (replacement.equals("") ? System
+ .getProperty("line.separator") : ""),
+ replacement));
+ bot.sleep(Timing.time1S());
+ getEd().save();
+ }
+
+ /**
+ * Method inserts the string "insertText" on location ("line", "column")
+ * Prerequisite: editor has been set
+ * @param line
+ * @param column
+ * @param insertText
+ */
+ public void insertInEditor(int line, int column, String insertText) {
+ getEd().toTextEditor().insertText(line, column, insertText);
+ bot.sleep(Timing.time1S());
+ getEd().save();
+ }
+
+ /**
+ * in Project Explorer View, the file which is located in "sourceFolder"
+ * is moved to location "destFolder"
+ * @param file
+ * @param sourceFolder
+ * @param destFolder
+ */
+ public void moveFileInProjectExplorer(String file, String sourceFolder, String destFolder) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = projectExplorer.selectTreeItem(file, sourceFolder.split("/"));
+
+ NodeContextUtil.nodeContextMenu(tree, item, "Move...").click();
+
+ tree = bot.tree();
+ tree.collapseNode(destFolder.split("/")[0]);
+
+ TreeHelper.expandNode(bot, destFolder.split("/")).select();
+
+ bot.button("OK").click();
+ }
+
+ /**
+ * Method removes the object which is located in "sourceFolder"
+ * is deleted
+ * @param object
+ * @param sourceFolder
+ */
+ public void removeObjectInProjectExplorer(String object, String sourceFolder) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = projectExplorer.selectTreeItem(object, sourceFolder.split("/"));
+
+ NodeContextUtil.nodeContextMenu(tree, item, "Delete").click();
+
+ assertTrue(bot.button("OK").isEnabled());
+
+ bot.button("OK").click();
+
+ bot.sleep(Timing.time2S());
+ }
+
+ /**
+ * Methods converts input stream to string component
+ * @param inputStream
+ * @return String - input stream converted to string
+ */
+ public String readStream(InputStream inputStream) {
+ // we don't care about performance in tests too much, so this should be
+ // OK
+ return new Scanner(inputStream).useDelimiter("\\A").next();
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.cdi.bot.test.PluginActivator;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+
+public class LibraryHelper extends CDIBase{
+
+ /**
+ * Method adds library named "libraryName" located in project folder
+ * to project's classpath
+ * @param projectName
+ * @param libraryName
+ */
+ public void addLibraryToProjectsClassPath(String projectName, String libraryName) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Refresh",false)).click();
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
+
+ bot.tree().expandNode("Java Build Path").select();
+ bot.tabItem("Libraries").activate();
+ bot.button("Add JARs...").click();
+ bot.sleep(Timing.time500MS());
+ String file = libraryName;
+ bot.tree().expandNode(projectName).expandNode(file).select();
+
+ bot.button(IDELabel.Button.OK).click();
+ bot.sleep(Timing.time1S());
+ bot.button(IDELabel.Button.OK).click();
+ bot.sleep(Timing.time1S());
+ }
+
+ /**
+ * Method copies library named "libraryName" located in "projectName"/resources/libraries
+ * into project default folder
+ * @param projectName
+ * @param libraryName
+ * @throws IOException
+ */
+ public void addLibraryIntoProject(String projectName, String libraryName) throws IOException {
+ File in = null;
+ FileChannel inChannel = null;
+ FileChannel outChannel = null;
+
+
+ in = SWTUtilExt.getResourceFile(PluginActivator.PLUGIN_ID, "libraries", libraryName);
+
+ File out = new File(Platform.getLocation() + File.separator + projectName +
+ File.separator + File.separator + libraryName);
+
+ inChannel = new FileInputStream(in).getChannel();
+ outChannel = new FileOutputStream(out).getChannel();
+
+ inChannel.transferTo(0, inChannel.size(), outChannel);
+
+ if (inChannel != null) inChannel.close();
+ if (outChannel != null) outChannel.close();
+ }
+
+ /**
+ * Method checks if library named "libraryName" is set on classpath
+ * of project named "projectName"
+ * @param projectName
+ * @param libraryName
+ * @return boolean - represents fact if library is/isn't set on project classpath
+ */
+ public boolean isLibraryInProjectClassPath(String projectName, String libraryName) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
+
+ SWTBotShell shell = bot.shell("Properties for " + projectName);
+ SWTBot bot = shell.bot();
+
+ bot.tree().expandNode("Java Build Path").select();
+
+ bot.tabItem("Libraries").activate();
+
+ boolean libraryInProject = false;
+ for (int i = 0; i < bot.tree(1).rowCount(); i++) {
+ if (bot.tree(1).getAllItems()[i].getText().contains(libraryName)) {
+ libraryInProject = true;
+ break;
+ }
+ }
+ bot.button(IDELabel.Button.CANCEL).click();
+ bot.sleep(Timing.time1S());
+ return libraryInProject;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,33 @@
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+
+public class NodeContextUtil {
+
+ private NodeContextUtil() {
+ throw new AssertionError();
+ }
+
+ public static SWTBotMenu nodeContextMenu(final SWTBotTree tree,
+ SWTBotTreeItem item, final String... menu) {
+ assert menu.length > 0;
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+ public SWTBotMenu run() {
+ SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+ tree, menu[0], false));
+ for (int i = 1; i < menu.length; i++) {
+ m = m.menu(menu[i]);
+ }
+ return m;
+ }
+ });
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class OpenOnHelper extends CDIBase{
+
+ public void openOnByOption(String openOnString, String titleName, String chosenOption) {
+ selectTextForOpenOn(openOnString, titleName);
+ SWTBotMenu navigateMenu = bot.menu("Navigate");
+ bot.sleep(Timing.time500MS());
+ navigateMenu.menu("Open Hyperlink").click();
+ bot.sleep(Timing.time500MS());
+ SWTBotTable table = bot.activeShell().bot().table(0);
+ for (int i = 0; i < table.rowCount(); i++) {
+ if (table.getTableItem(i).getText().contains(chosenOption)) {
+ table.click(i, 0);
+ break;
+ }
+ }
+ bot.sleep(Timing.time1S());
+ setEd(bot.activeEditor().toTextEditor());
+ }
+
+ public void openOnDirect(String openOnString, String titleName) {
+ selectTextForOpenOn(openOnString, titleName);
+ bot.sleep(Timing.time3S());
+ getEd().pressShortcut(Keystrokes.F3);
+ setEd(bot.activeEditor().toTextEditor());
+ }
+
+ private void selectTextForOpenOn(String openOnString, String titleName) {
+ SWTBotEditor ed = bot.editorByTitle(titleName);
+ ed.show();
+ ed.setFocus();
+ int offset = openOnString.contains("@")?1:0;
+ setEd(SWTJBTExt.selectTextInSourcePane(bot, titleName,
+ openOnString, offset, openOnString.length() - offset));
+ }
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,63 @@
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.AbstractValidationProvider;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+
+public class QuickFixHelper extends CDITestBase{
+
+ protected AbstractValidationProvider validationErrorsProvider;
+
+ public static SWTBotTreeItem[] problemsTrees;
+
+ /**
+ * Method open context menu for given tree item and opens Quick Fix option
+ * @param item
+ */
+ public void openQuickFix(SWTBotTreeItem item) {
+ NodeContextUtil.nodeContextMenu(bot.tree(), item, "Quick Fix").click();
+ }
+
+ /**
+ * Methods gets all problems of given type
+ * @param problemType
+ * @return array of problems of given type
+ */
+ public SWTBotTreeItem[] getProblems(ProblemsType problemType) {
+ SWTBotTreeItem[] problemsTree = null;
+ if (problemType == ProblemsType.WARNINGS) {
+ problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
+ + getProjectName(), null, null);
+ }else if (problemType == ProblemsType.ERRORS) {
+ problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
+ + getProjectName(), null, null);
+ }
+ return problemsTree;
+ }
+
+ public SWTBotTreeItem[] getAllProblems() {
+
+ SWTBotTreeItem[] warningProblemsTree = getProblems(ProblemsType.WARNINGS);
+
+ SWTBotTreeItem[] errorProblemsTree = getProblems(ProblemsType.ERRORS);
+
+ return joinTwoArrays(warningProblemsTree, errorProblemsTree);
+ }
+
+ private SWTBotTreeItem[] joinTwoArrays(SWTBotTreeItem[] aArray, SWTBotTreeItem[] bArray) {
+
+ SWTBotTreeItem[] bigArray = new SWTBotTreeItem[aArray.length + bArray.length];
+
+ for (int i = 0; i < aArray.length; i++) {
+ bigArray[i] = aArray[i];
+ }
+
+ for (int i = aArray.length; i < aArray.length + bArray.length; i++) {
+ bigArray[i] = bArray[i-aArray.length];
+ }
+
+ return bigArray;
+ }
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,41 @@
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class SWTEclipseCDIExtUtil extends SWTEclipseExt {
+
+ private SWTEclipseCDIExtUtil() {
+ throw new AssertionError();
+ }
+
+ public static void disableFolding(SWTBotExt bot, SWTUtilExt util) {
+ editFolding(bot, util, false);
+ }
+
+ public static void enableFolding(SWTBotExt bot, SWTUtilExt util) {
+ editFolding(bot, util, true);
+ }
+
+ public static void editFolding(SWTBotExt bot, SWTUtilExt util,
+ boolean select) {
+ bot.menu("Window").menu("Preferences").click();
+ bot.shell("Preferences").activate();
+ SWTBotTreeItem item = bot.tree(0).expandNode("Java", "Editor");
+ item.select("Folding");
+ SWTBotCheckBox foldCheckBox = bot.checkBox("Enable folding");
+ if (select) {
+ foldCheckBox.select();
+ } else {
+ foldCheckBox.deselect();
+ }
+ bot.button("OK").click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.actions;
import org.eclipse.swtbot.swt.finder.SWTBot;
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.uiutils.actions;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.channels.FileChannel;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.cdi.bot.test.PluginActivator;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.DynamicWebProjectWizard;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTJBTExt;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-import org.jboss.tools.ui.bot.ext.helper.TreeHelper;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
-import org.junit.After;
-import org.junit.Before;
-
-public class CDIBase extends SWTTestExt {
-
- private String projectName = "CDIProject";
- private String packageName = "cdi";
-
- @Before
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createAndCheckCDIProject(bot, util, projectExplorer, getProjectName());
- }
- }
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
- public String getProjectName() {
- return projectName;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public enum CDICOMPONENT {
- STEREOSCOPE, QUALIFIER, SCOPE, BEAN, INTERBINDING, DECORATOR, INTERCEPTOR, ANNLITERAL, BEANSXML
- }
- public enum ANNOTATIONS {SERIALIZABLE, TARGET, RETENTION, NAMED, TYPED, DISPOSES, OBSERVES, INTERCEPTOR,
- SPECIALIZES, DECORATOR, NONBINDING}
- public enum PROBLEM_TYPE {WARNINGS, ERRORS}
-
- private SWTBotEclipseEditor ed;
-
- public SWTBotEclipseEditor getEd() {
- return ed;
- }
-
- public void setEd(SWTBotEclipseEditor ed) {
- this.ed = ed;
- }
-
- public void createComponent(CDICOMPONENT component, String name,
- String packageName, String necessaryParam) {
- if (component == null) {
- CDIUtil.annotation(open, util, packageName, name);
- } else {
- createCDIComponent(component, name, packageName, necessaryParam);
- }
- util.waitForNonIgnoredJobs();
- /*
- * if beans.xml is created as first component in project,
- * it is not opened as default ==> there is no active editor
- */
- if (component != CDICOMPONENT.BEANSXML) {
- setEd(bot.activeEditor().toTextEditor());
- }
- }
-
- private void createCDIComponent(CDICOMPONENT component, String name,
- String packageName, String necessaryParam) {
- switch (component) {
- case STEREOSCOPE:
- boolean alternative = false;
- boolean regInBeansXml = false;
- if (necessaryParam != null) {
- if (necessaryParam.equals("alternative+beansxml")) {
- alternative = true;
- regInBeansXml = true;
- } else if (necessaryParam.equals("alternative")) {
- alternative = true;
- }
- }
- CDIUtil.stereotype(packageName, name, null, null, false, false, alternative, regInBeansXml,
- false).finish();
- break;
- case QUALIFIER:
- CDIUtil.qualifier(packageName, name, false, false).finish();
- break;
- case SCOPE:
- CDIUtil.scope(packageName, name, false, false, true, false).finish();
- break;
- case BEAN:
- alternative = false;
- regInBeansXml = false;
- if (necessaryParam != null) {
- if (necessaryParam.equals("alternative+beansxml")) {
- alternative = true;
- regInBeansXml = true;
- } else if (necessaryParam.equals("alternative")) {
- alternative = true;
- }
- }
- CDIUtil.bean(packageName, name, true, false, false, false, alternative, regInBeansXml, null, null,
- null, null).finish();
- break;
- case INTERCEPTOR:
- CDIUtil.interceptor(packageName, name, null, null, null, false).finish();
- break;
- case DECORATOR:
- CDIUtil.decorator(packageName, name, necessaryParam, null, true, false, false, false)
- .finish();
- break;
- case ANNLITERAL:
- CDIUtil.annLiteral(packageName, name, true, false, false, false, null).finish();
- break;
- case INTERBINDING:
- CDIUtil.binding(packageName, name, null, true, false).finish();
- break;
- case BEANSXML:
- CDIUtil.beansXML(packageName).finish();
- break;
- }
-
- }
-
- public void createAndCheckCDIProject(SWTBotExt bot, SWTUtilExt util,
- ProjectExplorer projectExplorer, String projectName) {
- createCDIProject(util, projectName);
- projectExplorer.selectProject(projectName);
- SWTBotTree tree = projectExplorer.bot().tree();
- SWTBotTreeItem item = tree.getTreeItem(projectName);
- item.expand();
- addCDISupport(tree, item, bot, util);
- }
-
- public void createCDIProject(SWTUtilExt util, String projectName) {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(projectName).finish();
- util.waitForNonIgnoredJobs();
- }
-
- public void createCDIProjectWithCDIPreset(SWTUtilExt util, String projectName) {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(projectName).setCDIPreset().finish();
- util.waitForNonIgnoredJobs();
- }
-
- public void createCDIProjectWithCDIFacets(SWTUtilExt util, String projectName) {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(projectName).setCDIFacet().finish();
- bot.sleep(Timing.time5S());
- util.waitForNonIgnoredJobs();
- }
-
- public void addCDISupport(final SWTBotTree tree, SWTBotTreeItem item,
- SWTBotExt bot, SWTUtilExt util) {
- CDIUtil.nodeContextMenu(tree, item, "Configure",
- "Add CDI (Context and Dependency Injection) support...")
- .click();
- bot.activeShell().bot().button("OK").click();
- bot.sleep(Timing.time2S());
- util.waitForNonIgnoredJobs();
- }
-
- public void openOn(String openOnString, String titleName, String chosenOption) {
- SWTBotEditor ed = bot.editorByTitle(titleName);
- ed.show();
- ed.setFocus();
- int offset = openOnString.contains("@")?1:0;
- setEd(SWTJBTExt.selectTextInSourcePane(bot, titleName,
- openOnString, offset, openOnString.length() - offset));
- if (chosenOption != null) {
- SWTBotMenu navigateMenu = bot.menu("Navigate");
- bot.sleep(Timing.time500MS());
- navigateMenu.menu("Open Hyperlink").click();
- bot.sleep(Timing.time500MS());
- SWTBotTable table = bot.activeShell().bot().table(0);
- for (int i = 0; i < table.rowCount(); i++) {
- if (table.getTableItem(i).getText().contains(chosenOption)) {
- table.click(i, 0);
- break;
- }
- }
- } else {
- getEd().setFocus();
- bot.sleep(Timing.time2S());
- getEd().pressShortcut(Keystrokes.F3);
- }
- bot.sleep(Timing.time1S());
- setEd(bot.activeEditor().toTextEditor());
- }
-
- public void addLibraryToProjectsClassPath(String projectName, String libraryName) {
- SWTBotTree tree = projectExplorer.bot().tree();
-
- ContextMenuHelper.prepareTreeItemForContextMenu(tree);
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Refresh",false)).click();
-
- ContextMenuHelper.prepareTreeItemForContextMenu(tree);
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
-
- bot.tree().expandNode("Java Build Path").select();
- bot.tabItem("Libraries").activate();
- bot.button("Add JARs...").click();
- bot.sleep(Timing.time500MS());
- String file = libraryName;
- bot.tree().expandNode(projectName).expandNode(file).select();
-
- bot.button(IDELabel.Button.OK).click();
- bot.sleep(Timing.time1S());
- bot.button(IDELabel.Button.OK).click();
- bot.sleep(Timing.time1S());
- }
-
- /*
- * copy library located in PROJECT_NAME/resources/libraries into project
- * libraryName must include extension: seam-solder.jar
- */
- public void addLibraryIntoProject(String projectName, String libraryName) throws IOException {
- File in = null;
- FileChannel inChannel = null;
- FileChannel outChannel = null;
-
-
- in = SWTUtilExt.getResourceFile(PluginActivator.PLUGIN_ID, "libraries", libraryName);
-
- File out = new File(Platform.getLocation() + File.separator + projectName +
- File.separator + File.separator + libraryName);
-
- inChannel = new FileInputStream(in).getChannel();
- outChannel = new FileOutputStream(out).getChannel();
-
- inChannel.transferTo(0, inChannel.size(), outChannel);
-
- if (inChannel != null) inChannel.close();
- if (outChannel != null) outChannel.close();
- }
-
- /*
- * check if library with name libraryName is set on classpath of project with name
- * projectName
- */
- public void isLibraryInProjectClassPath(String projectName, String libraryName) {
- SWTBotTree tree = projectExplorer.bot().tree();
-
- ContextMenuHelper.prepareTreeItemForContextMenu(tree);
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
-
- SWTBotShell shell = bot.shell("Properties for " + projectName);
- SWTBot bot = shell.bot();
-
- bot.tree().expandNode("Java Build Path").select();
-
- bot.tabItem("Libraries").activate();
-
- boolean libraryInProject = false;
- for (int i = 0; i < bot.tree(1).rowCount(); i++) {
- if (bot.tree(1).getAllItems()[i].getText().contains(libraryName)) {
- libraryInProject = true;
- break;
- }
- }
- assertTrue("Library " + libraryName + "is not on classPath of project "
- + projectName,libraryInProject);
-
- bot.button(IDELabel.Button.CANCEL).click();
- bot.sleep(Timing.time1S());
- }
-
- public void moveFileInProjectExplorer(String file, String sourceFolder, String destFolder) {
- SWTBotTree tree = projectExplorer.bot().tree();
- SWTBotTreeItem item = projectExplorer.selectTreeItem(file, sourceFolder.split("/"));
-
- CDIUtil.nodeContextMenu(tree, item, "Move...").click();
-
- assertFalse(bot.button("OK").isEnabled());
-
- tree = bot.tree();
- tree.collapseNode(destFolder.split("/")[0]);
-
- TreeHelper.expandNode(bot, destFolder.split("/")).select();
-
- assertTrue(bot.button("OK").isEnabled());
- bot.button("OK").click();
- }
-
- public void removeObjectInProjectExplorer(String object, String sourceFolder) {
- SWTBotTree tree = projectExplorer.bot().tree();
- SWTBotTreeItem item = projectExplorer.selectTreeItem(object, sourceFolder.split("/"));
-
- CDIUtil.nodeContextMenu(tree, item, "Delete").click();
-
- assertTrue(bot.button("OK").isEnabled());
-
- bot.button("OK").click();
-
- bot.sleep(Timing.time2S());
- }
-
- public boolean projectExists(String projectName) {
- SWTBotTree tree = projectExplorer.bot().tree();
- boolean projectExists = false;
- try {
- tree.getTreeItem(projectName);
- projectExists = true;
- }catch (WidgetNotFoundException exc) {
- }
- return projectExists;
- }
-
-}
\ No newline at end of file
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,286 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.uiutils.actions;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Scanner;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.Result;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.cdi.bot.test.editor.CDIBeansEditorTest;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTOpenExt;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaAnnotation;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-
-public class CDIUtil {
-
- private CDIUtil() {
- // this class servers only for static related methods
- // it should not be instantiated
- throw new AssertionError();
- }
-
- public static void openQuickFix(SWTBotTreeItem item, SWTBotExt bot) {
- nodeContextMenu(bot.tree(), item, "Quick Fix").click();
- }
-
- public static void resolveQuickFix(SWTBotTreeItem item, SWTBotExt bot,
- SWTUtilExt util) {
- openQuickFix(item, bot);
- bot.activeShell().bot().button("Finish").click();
- bot.sleep(Timing.time2S());
- util.waitForNonIgnoredJobs();
- }
-
- public static void copyResourceToClass(SWTBotEditor classEdit,
- InputStream resource, boolean closeEdit) {
- SWTBotEclipseEditor st = classEdit.toTextEditor();
- st.selectRange(0, 0, st.getText().length());
- String code = readStream(resource);
- st.setText(code);
- classEdit.save();
- if (closeEdit) {
- classEdit.close();
- }
- }
-
- public static void copyResource(String src, String target) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProjects()[0];
- IFile f = project.getFile(target);
- if (f.exists()) {
- try {
- f.delete(true, new NullProgressMonitor());
- } catch (CoreException ce) {
- }
- }
- InputStream is = null;
- try {
- is = CDIBeansEditorTest.class.getResourceAsStream(src);
- f.create(is, true, new NullProgressMonitor());
- } catch (CoreException ce) {
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException ioe) {
- //ignore
- }
- }
- }
- }
-
- public static void replaceInEditor(SWTBotEclipseEditor ed, SWTBotExt bot,
- String target, String replacement) {
- ed.selectRange(0, 0, ed.getText().length());
- ed.setText(ed.getText().replace(
- target + (replacement.equals("") ? System
- .getProperty("line.separator") : ""),
- replacement));
- bot.sleep(Timing.time1S());
- ed.save();
- }
-
- public static void insertInEditor(SWTBotEclipseEditor ed, SWTBotExt bot,
- int line, int row, String insertText) {
- ed.toTextEditor().insertText(line, row, insertText);
- bot.sleep(Timing.time1S());
- ed.save();
- }
-
- public static void disableFolding(SWTBotExt bot, SWTUtilExt util) {
- editFolding(bot, util, false);
- }
-
- public static void enableFolding(SWTBotExt bot, SWTUtilExt util) {
- editFolding(bot, util, true);
- }
-
- public static void editFolding(SWTBotExt bot, SWTUtilExt util,
- boolean select) {
- bot.menu("Window").menu("Preferences").click();
- bot.shell("Preferences").activate();
- SWTBotTreeItem item = bot.tree(0).expandNode("Java", "Editor");
- item.select("Folding");
- SWTBotCheckBox foldCheckBox = bot.checkBox("Enable folding");
- if (select) {
- foldCheckBox.select();
- } else {
- foldCheckBox.deselect();
- }
- bot.button("OK").click();
- bot.sleep(Timing.time2S());
- util.waitForNonIgnoredJobs();
- }
-
- public static SWTBotMenu nodeContextMenu(final SWTBotTree tree,
- SWTBotTreeItem item, final String... menu) {
- assert menu.length > 0;
- ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
- return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
-
- public SWTBotMenu run() {
- SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
- tree, menu[0], false));
- for (int i = 1; i < menu.length; i++) {
- m = m.menu(menu[i]);
- }
- return m;
- }
- });
- }
-
- public static CDIWizard qualifier(String pkg, String name,
- boolean inherited, boolean comments) {
- return create(CDIWizardType.QUALIFIER, pkg, name, inherited, comments);
- }
-
- public static CDIWizard scope(String pkg, String name, boolean inherited,
- boolean comments, boolean normalScope, boolean passivating) {
- CDIWizard w = create(CDIWizardType.SCOPE, pkg, name, inherited,
- comments);
- w = w.setNormalScope(normalScope);
- return normalScope ? w.setPassivating(passivating) : w;
- }
-
- public static CDIWizard binding(String pkg, String name, String target,
- boolean inherited, boolean comments) {
- CDIWizard w = create(CDIWizardType.INTERCEPTOR_BINDING, pkg, name,
- inherited, comments);
- return target != null ? w.setTarget(target) : w;
- }
-
- public static CDIWizard stereotype(String pkg, String name, String scope,
- String target, boolean inherited, boolean named,
- boolean alternative, boolean regInBeansXML, boolean comments) {
- CDIWizard w = create(CDIWizardType.STEREOTYPE, pkg, name, inherited,
- comments).setAlternative(alternative).setNamed(named);
- if (scope != null) {
- w = w.setScope(scope);
- }
- if (alternative && regInBeansXML) {
- w.setRegisterInBeansXml(regInBeansXML);
- }
- return target != null ? w.setTarget(target) : w;
- }
-
- public static CDIWizard decorator(String pkg, String name, String intf,
- String fieldName, boolean isPublic, boolean isAbstract,
- boolean isFinal, boolean comments) {
- CDIWizard w = create(CDIWizardType.DECORATOR, pkg, name, comments);
- w = w.addInterface(intf).setPublic(isPublic).setFinal(isFinal)
- .setAbstract(isAbstract);
- return fieldName != null ? w.setFieldName(fieldName) : w;
- }
-
- public static CDIWizard interceptor(String pkg, String name,
- String ibinding, String superclass, String method, boolean comments) {
- CDIWizard w = create(CDIWizardType.INTERCEPTOR, pkg, name, comments);
- if (superclass != null) {
- w = w.setSuperclass(superclass);
- }
- if (method != null) {
- w = w.setMethodName(method);
- }
- if (ibinding != null) {
- w = w.addIBinding(ibinding);
- }
- return w;
- }
-
- public static CDIWizard bean(String pkg, String name, boolean isPublic,
- boolean isAbstract, boolean isFinal, boolean comments,
- boolean alternative, boolean registerInBeansXML,
- String named, String interfaces, String scope, String qualifier) {
- CDIWizard w = create(CDIWizardType.BEAN, pkg, name, comments);
- if (named != null) {
- w.setNamed(true);
- if (!"".equals(named.trim())) {
- w.setNamedName(named);
- }
- }
- w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract).setAlternative(alternative);
- //w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
- if (interfaces != null && !"".equals(interfaces.trim())) {
- w.addInterface(interfaces);
- }
- if (scope != null && !"".equals(scope.trim())) {
- w.setScope(scope);
- }
- if (qualifier != null && !"".equals(qualifier.trim())) {
- w.addQualifier(qualifier);
- }
- if (alternative && registerInBeansXML) {
- w.setRegisterInBeansXml(registerInBeansXML);
- }
- return w;
- }
-
- public static void annotation(SWTOpenExt open, SWTUtilExt util, String pkg,
- String name) {
- SWTBot openWizard = open.newObject(JavaAnnotation.LABEL);
- openWizard.textWithLabel("Name:").setText(name);
- openWizard.textWithLabel("Package:").setText(pkg);
- openWizard.button("Finish").click();
- util.waitForNonIgnoredJobs();
- }
-
- public static CDIWizard annLiteral(String pkg, String name,
- boolean isPublic, boolean isAbstract, boolean isFinal,
- boolean comments, String qualifier) {
- assert qualifier != null && !"".equals(qualifier.trim()) : "Qualifier has to be set";
- CDIWizard w = create(CDIWizardType.ANNOTATION_LITERAL, pkg, name,
- comments);
- return w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract)
- .addQualifier(qualifier);
- }
-
- public static CDIWizard beansXML(String pkg) {
- CDIWizard w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
- w.setSourceFolder(pkg);
- return w;
- }
-
- public static CDIWizard create(CDIWizardType type, String pkg, String name,
- boolean inherited, boolean comments) {
- return create(type, pkg, name, comments).setInherited(inherited);
- }
-
- public static CDIWizard create(CDIWizardType type, String pkg, String name,
- boolean comments) {
- CDIWizard p = new NewCDIFileWizard(type).run();
- return p.setPackage(pkg).setName(name).setGenerateComments(comments);
- }
-
- public static String readStream(InputStream is) {
- // we don't care about performance in tests too much, so this should be
- // OK
- return new Scanner(is).useDelimiter("\\A").next();
- }
-
-}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -8,10 +8,11 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.actions;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBase;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.Wizard;
public class NewCDIFileWizard extends NewFileWizardAction {
@@ -24,11 +25,11 @@
}
@Override
- public CDIWizard run() {
+ public CDIWizardBase run() {
Wizard w = super.run();
w.selectTemplate("CDI (Context and Dependency Injection)", type.getAnnotationType());
w.next();
- return new CDIWizard(type);
+ return new CDIWizardBase(type);
}
}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.actions;
import org.eclipse.swtbot.swt.finder.SWTBot;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,427 +1,114 @@
/*******************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc.
+ * Copyright (c) 2010 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
-import java.util.Arrays;
-import java.util.List;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.jboss.tools.ui.bot.ext.Timing;
-
-public class CDIWizard extends Wizard {
-
- private final CDIWizardType type;
-
- public CDIWizard(CDIWizardType type) {
- super(new SWTBot().activeShell().widget);
- assert ("New " + type).equals(getText());
- this.type = type;
+public class CDIWizard extends CDITestBase{
+
+ private CDIWizardBaseExt wizardExt = new CDIWizardBaseExt();
+
+ public void createAnnotation(String name, String packageName) {
+ wizardExt.annotation(open, util, packageName, name);
}
-
- public CDIWizard setName(String name) {
- if (CDIWizardType.BEANS_XML == type) {
- setText("File name:", name);
- } else {
- setText("Name:", name);
- }
- return this;
- }
-
- public CDIWizard setPackage(String pkg) {
- setText("Package:", pkg);
- return this;
- }
-
- public CDIWizard setSourceFolder(String src) {
- if (CDIWizardType.BEANS_XML == type) {
- setText("Enter or select the parent folder:", src);
- } else {
- setText("Source folder:", src);
- }
- return this;
- }
-
- public CDIWizard setInherited(boolean set) {
- setCheckbox("Add @Inherited", set);
- return this;
- }
-
- public boolean isInherited() {
- return isCheckboxSet("Add @Inherited");
- }
-
- public CDIWizard setGenerateComments(boolean set) {
- setCheckbox("Generate comments", set);
- return this;
- }
-
- public boolean isGenerateComments() {
- return isCheckboxSet("Generate comments");
- }
-
- public CDIWizard setNormalScope(boolean set) {
- switch (type) {
- case SCOPE:
- setCheckbox("is normal scope", set);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public boolean isNormalScope() {
- switch (type) {
- case SCOPE:
- return isCheckboxSet("is normal scope");
- default:
- return true;
- }
- }
-
- public CDIWizard setPassivating(boolean set) {
- switch (type) {
- case SCOPE:
- setCheckbox("is passivating", set);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public boolean isPassivating() {
- switch (type) {
- case SCOPE:
- return isCheckboxSet("is passivating");
- default:
- return false;
- }
- }
-
- public CDIWizard setAlternative(boolean set) {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- setCheckbox("Add @Alternative", set);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public boolean isAlternative() {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- return isCheckboxSet("Add @Alternative");
- default:
- return false;
- }
- }
- public CDIWizard setRegisterInBeansXml(boolean set) {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- setCheckbox("Register in beans.xml", set);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
+ public void createComponent(CDIWizardType component, String name,
+ String packageName, String necessaryParam) {
+ createCDIComponent(component, name, packageName, necessaryParam);
+ util.waitForNonIgnoredJobs();
+ /**
+ * if beans.xml is created as first component in project,
+ * it is not opened as default ==> there is no active editor
+ */
+ if (component != CDIWizardType.BEANS_XML) {
+ setEd(bot.activeEditor().toTextEditor());
+ }
}
- public boolean isRegisteredInBeansXML() {
- switch (type) {
+ public void createCDIComponent(CDIWizardType component, String name,
+ String packageName, String necessaryParam) {
+ switch (component) {
case STEREOTYPE:
- case BEAN:
- return isCheckboxSet("Register in beans.xml");
- default:
- return false;
- }
- }
-
- public CDIWizard setNamed(boolean set) {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- setCheckbox("Add @Named", set);
+ boolean alternative = false;
+ boolean regInBeansXml = false;
+ if (necessaryParam != null) {
+ if (necessaryParam.equals("alternative+beansxml")) {
+ alternative = true;
+ regInBeansXml = true;
+ } else if (necessaryParam.equals("alternative")) {
+ alternative = true;
+ }
+ }
+ wizardExt.stereotype(packageName, name, null, null, false, false, alternative, regInBeansXml,
+ false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setNamedName(String name) {
- if (CDIWizardType.BEAN != type) {
- throw new UnsupportedOperationException();
- }
- setText("Bean Name:", name);
- return this;
- }
-
- public boolean isNamed() {
- switch (type) {
- case STEREOTYPE:
- return isCheckboxSet("Add @Named");
- default:
- return false;
- }
- }
-
- public CDIWizard setTarget(String target) {
- switch (type) {
- case STEREOTYPE:
- case INTERCEPTOR_BINDING:
- setCombo("Target:", target);
+ case QUALIFIER:
+ wizardExt.qualifier(packageName, name, false, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getTargets() {
- setFocus();
- return Arrays.asList(bot().comboBoxWithLabel("Target:").items());
- }
-
- public CDIWizard setScope(String scope) {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- setCombo("Scope:", scope);
+ case SCOPE:
+ wizardExt.scope(packageName, name, false, false, true, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getScopes() {
- setFocus();
- return Arrays.asList(bot().comboBoxWithLabel("Scope:").items());
- }
-
- public CDIWizard addIBinding(String ib) {
- switch (type) {
- case INTERCEPTOR_BINDING:
- case STEREOTYPE:
- case INTERCEPTOR:
- setFocus();
- bot().button("Add", 0).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(ib);
- sh.bot().button("OK").click();
- setFocus();
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getIBindings() {
- setFocus();
- return Arrays.asList(bot().listWithLabel("Interceptor Bindings:")
- .getItems());
- }
-
- public CDIWizard addStereotype(String stereotype) {
- switch (type) {
- case STEREOTYPE:
- setFocus();
- bot().button("Add", 1).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(stereotype);
- sh.bot().button("OK").click();
- setFocus();
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getStereotypes() {
- setFocus();
- return Arrays.asList(bot().listWithLabel("Stereotypes:").getItems());
- }
-
- public CDIWizard setPublic(boolean isPublic) {
- switch (type) {
- case DECORATOR:
case BEAN:
- case ANNOTATION_LITERAL:
- setFocus();
- if (isPublic) {
- bot().radio("public").click();
- } else {
- class Radio2 extends SWTBotRadio {
- Radio2(Button b) {
- super(b);
- }
-
- @Override
- public SWTBotRadio click() {
- return (SWTBotRadio) click(true);
- }
+ alternative = false;
+ regInBeansXml = false;
+ if (necessaryParam != null) {
+ if (necessaryParam.equals("alternative+beansxml")) {
+ alternative = true;
+ regInBeansXml = true;
+ } else if (necessaryParam.equals("alternative")) {
+ alternative = true;
}
- final Button b = bot().radio("default").widget;
- new Radio2(b).click();
}
- setFocus();
+ wizardExt.bean(packageName, name, true, false, false, false, alternative, regInBeansXml, null, null,
+ null, null).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setFieldName(String name) {
- switch (type) {
- case DECORATOR:
- setText("Delegate Field Name:", name);
+ case INTERCEPTOR:
+ wizardExt.interceptor(packageName, name, null, null, null, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard addInterface(String intf) {
- switch (type) {
case DECORATOR:
- case BEAN:
- setFocus();
- bot().button("Add...", 0).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(intf);
- sh.bot().sleep(Timing.time3S());
- sh.bot().table().getTableItem(0).select();
- sh.bot().button("OK").click();
- setFocus();
+ wizardExt.decorator(packageName, name, necessaryParam, null, true, false, false, false)
+ .finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard addQualifier(String qualifier) {
- setFocus();
- switch (type) {
- case BEAN:
- bot().button("Add", 0).click();
- break;
case ANNOTATION_LITERAL:
- bot().button("Browse", 0).click();
+ wizardExt.annLiteral(packageName, name, true, false, false, false, null).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(qualifier);
- sh.bot().sleep(Timing.time2S());
- sh.bot().table().getTableItem(0).select();
- sh.bot().button("OK").click();
- setFocus();
- return this;
- }
-
- public CDIWizard setAbstract(boolean isAbstract) {
- switch (type) {
- case DECORATOR:
- case BEAN:
- case ANNOTATION_LITERAL:
- setCheckbox("abstract", isAbstract);
+ case INTERCEPTOR_BINDING:
+ wizardExt.binding(packageName, name, null, true, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setFinal(boolean isFinal) {
- switch (type) {
- case DECORATOR:
- case BEAN:
- case ANNOTATION_LITERAL:
- setCheckbox("final", isFinal);
+ case BEANS_XML:
+ wizardExt.beansXML(packageName).finish();
break;
- default:
- throw new UnsupportedOperationException();
+ }
+ util.waitForNonIgnoredJobs();
+ if (component != CDIWizardType.BEANS_XML) {
+ setEd(bot.activeEditor().toTextEditor());
}
- return this;
}
-
- public CDIWizard setSuperclass(String name) {
- switch (type) {
- case INTERCEPTOR:
- setFocus();
- bot().button("Browse...", 2).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(name);
- sh.bot().table().getTableItem(0).select();
- sh.bot().button("OK").click();
- setFocus();
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setMethodName(String name) {
- switch (type) {
- case INTERCEPTOR:
- setText("Around Invoke Method Name:", name);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- private void setCheckbox(String label, boolean set) {
- setFocus();
- SWTBotCheckBox c = bot().checkBox(label);
- if (c.isChecked() != set) {
- if (set) {
- c.select();
- } else {
- c.deselect();
- }
+ public void createClearBeansXML(String projectName) {
+ if (!projectExplorer.isFilePresent(projectName,
+ "WebContent/META-INF/beans.xml".split("/")) &&
+ !projectExplorer.isFilePresent(projectName,
+ "WebContent/WEB-INF/beans.xml".split("/"))) {
+ createComponent(CDIWizardType.BEANS_XML, null, projectName + "/WebContent/WEB-INF", null);
}
- }
+ projectExplorer.openFile(projectName, "WebContent/WEB-INF/beans.xml".split("/"));
+ bot.cTabItem("Source").activate();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/codeCompletion/beans.xml.cdi"), false);
- private boolean isCheckboxSet(String label) {
- setFocus();
- SWTBotCheckBox c = bot().checkBox(label);
- return c.isChecked();
}
- private void setCombo(String label, String value) {
- setFocus();
- SWTBotCombo c = bot().comboBoxWithLabel(label);
- c.setSelection(value);
- }
-
}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,429 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class CDIWizardBase extends Wizard {
+
+ private final CDIWizardType type;
+
+ public CDIWizardBase(CDIWizardType type) {
+ super(new SWTBot().activeShell().widget);
+ assert ("New " + type).equals(getText());
+ this.type = type;
+ }
+
+ public CDIWizardBase setName(String name) {
+ if (CDIWizardType.BEANS_XML == type) {
+ setText("File name:", name);
+ } else {
+ setText("Name:", name);
+ }
+ return this;
+ }
+
+ public CDIWizardBase setPackage(String pkg) {
+ setText("Package:", pkg);
+ return this;
+ }
+
+ public CDIWizardBase setSourceFolder(String src) {
+ if (CDIWizardType.BEANS_XML == type) {
+ setText("Enter or select the parent folder:", src);
+ } else {
+ setText("Source folder:", src);
+ }
+ return this;
+ }
+
+ public CDIWizardBase setInherited(boolean set) {
+ setCheckbox("Add @Inherited", set);
+ return this;
+ }
+
+ public boolean isInherited() {
+ return isCheckboxSet("Add @Inherited");
+ }
+
+ public CDIWizardBase setGenerateComments(boolean set) {
+ setCheckbox("Generate comments", set);
+ return this;
+ }
+
+ public boolean isGenerateComments() {
+ return isCheckboxSet("Generate comments");
+ }
+
+ public CDIWizardBase setNormalScope(boolean set) {
+ switch (type) {
+ case SCOPE:
+ setCheckbox("is normal scope", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isNormalScope() {
+ switch (type) {
+ case SCOPE:
+ return isCheckboxSet("is normal scope");
+ default:
+ return true;
+ }
+ }
+
+ public CDIWizardBase setPassivating(boolean set) {
+ switch (type) {
+ case SCOPE:
+ setCheckbox("is passivating", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isPassivating() {
+ switch (type) {
+ case SCOPE:
+ return isCheckboxSet("is passivating");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizardBase setAlternative(boolean set) {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ setCheckbox("Add @Alternative", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isAlternative() {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ return isCheckboxSet("Add @Alternative");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizardBase setRegisterInBeansXml(boolean set) {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ setCheckbox("Register in beans.xml", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isRegisteredInBeansXML() {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ return isCheckboxSet("Register in beans.xml");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizardBase setNamed(boolean set) {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ setCheckbox("Add @Named", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setNamedName(String name) {
+ if (CDIWizardType.BEAN != type) {
+ throw new UnsupportedOperationException();
+ }
+ setText("Bean Name:", name);
+ return this;
+ }
+
+ public boolean isNamed() {
+ switch (type) {
+ case STEREOTYPE:
+ return isCheckboxSet("Add @Named");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizardBase setTarget(String target) {
+ switch (type) {
+ case STEREOTYPE:
+ case INTERCEPTOR_BINDING:
+ setCombo("Target:", target);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getTargets() {
+ setFocus();
+ return Arrays.asList(bot().comboBoxWithLabel("Target:").items());
+ }
+
+ public CDIWizardBase setScope(String scope) {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ setCombo("Scope:", scope);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getScopes() {
+ setFocus();
+ return Arrays.asList(bot().comboBoxWithLabel("Scope:").items());
+ }
+
+ public CDIWizardBase addIBinding(String ib) {
+ switch (type) {
+ case INTERCEPTOR_BINDING:
+ case STEREOTYPE:
+ case INTERCEPTOR:
+ setFocus();
+ bot().button("Add", 0).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(ib);
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getIBindings() {
+ setFocus();
+ return Arrays.asList(bot().listWithLabel("Interceptor Bindings:")
+ .getItems());
+ }
+
+ public CDIWizardBase addStereotype(String stereotype) {
+ switch (type) {
+ case STEREOTYPE:
+ setFocus();
+ bot().button("Add", 1).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(stereotype);
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getStereotypes() {
+ setFocus();
+ return Arrays.asList(bot().listWithLabel("Stereotypes:").getItems());
+ }
+
+ public CDIWizardBase setPublic(boolean isPublic) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ case ANNOTATION_LITERAL:
+ setFocus();
+ if (isPublic) {
+ bot().radio("public").click();
+ } else {
+ class Radio2 extends SWTBotRadio {
+ Radio2(Button b) {
+ super(b);
+ }
+
+ @Override
+ public SWTBotRadio click() {
+ return (SWTBotRadio) click(true);
+ }
+ }
+ final Button b = bot().radio("default").widget;
+ new Radio2(b).click();
+ }
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setFieldName(String name) {
+ switch (type) {
+ case DECORATOR:
+ setText("Delegate Field Name:", name);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase addInterface(String intf) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ setFocus();
+ bot().button("Add...", 0).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(intf);
+ sh.bot().sleep(Timing.time3S());
+ sh.bot().table().getTableItem(0).select();
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase addQualifier(String qualifier) {
+ setFocus();
+ switch (type) {
+ case BEAN:
+ bot().button("Add", 0).click();
+ break;
+ case ANNOTATION_LITERAL:
+ bot().button("Browse", 0).click();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(qualifier);
+ sh.bot().sleep(Timing.time2S());
+ sh.bot().table().getTableItem(0).select();
+ sh.bot().button("OK").click();
+ setFocus();
+ return this;
+ }
+
+ public CDIWizardBase setAbstract(boolean isAbstract) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ case ANNOTATION_LITERAL:
+ setCheckbox("abstract", isAbstract);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setFinal(boolean isFinal) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ case ANNOTATION_LITERAL:
+ setCheckbox("final", isFinal);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setSuperclass(String name) {
+ switch (type) {
+ case INTERCEPTOR:
+ setFocus();
+ bot().button("Browse...", 2).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(name);
+ sh.bot().table().getTableItem(0).select();
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setMethodName(String name) {
+ switch (type) {
+ case INTERCEPTOR:
+ setText("Around Invoke Method Name:", name);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+
+ private void setCheckbox(String label, boolean set) {
+ setFocus();
+ SWTBotCheckBox c = bot().checkBox(label);
+ if (c.isChecked() != set) {
+ if (set) {
+ c.select();
+ } else {
+ c.deselect();
+ }
+ }
+ }
+
+ private boolean isCheckboxSet(String label) {
+ setFocus();
+ SWTBotCheckBox c = bot().checkBox(label);
+ return c.isChecked();
+ }
+
+ private void setCombo(String label, String value) {
+ setFocus();
+ SWTBotCombo c = bot().comboBoxWithLabel(label);
+ c.setSelection(value);
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,135 @@
+package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaAnnotation;
+
+public class CDIWizardBaseExt {
+
+ public CDIWizardBase qualifier(String pkg, String name,
+ boolean inherited, boolean comments) {
+ return create(CDIWizardType.QUALIFIER, pkg, name, inherited, comments);
+ }
+
+ public CDIWizardBase scope(String pkg, String name, boolean inherited,
+ boolean comments, boolean normalScope, boolean passivating) {
+ CDIWizardBase w = create(CDIWizardType.SCOPE, pkg, name, inherited,
+ comments);
+ w = w.setNormalScope(normalScope);
+ return normalScope ? w.setPassivating(passivating) : w;
+ }
+
+ public CDIWizardBase binding(String pkg, String name, String target,
+ boolean inherited, boolean comments) {
+ CDIWizardBase w = create(CDIWizardType.INTERCEPTOR_BINDING, pkg, name,
+ inherited, comments);
+ return target != null ? w.setTarget(target) : w;
+ }
+
+ public CDIWizardBase stereotype(String pkg, String name, String scope,
+ String target, boolean inherited, boolean named,
+ boolean alternative, boolean regInBeansXML, boolean comments) {
+ CDIWizardBase w = create(CDIWizardType.STEREOTYPE, pkg, name, inherited,
+ comments).setAlternative(alternative).setNamed(named);
+ if (scope != null) {
+ w = w.setScope(scope);
+ }
+ if (alternative && regInBeansXML) {
+ w.setRegisterInBeansXml(regInBeansXML);
+ }
+ return target != null ? w.setTarget(target) : w;
+ }
+
+ public CDIWizardBase decorator(String pkg, String name, String intf,
+ String fieldName, boolean isPublic, boolean isAbstract,
+ boolean isFinal, boolean comments) {
+ CDIWizardBase w = create(CDIWizardType.DECORATOR, pkg, name, comments);
+ w = w.addInterface(intf).setPublic(isPublic).setFinal(isFinal)
+ .setAbstract(isAbstract);
+ return fieldName != null ? w.setFieldName(fieldName) : w;
+ }
+
+ public CDIWizardBase interceptor(String pkg, String name,
+ String ibinding, String superclass, String method, boolean comments) {
+ CDIWizardBase w = create(CDIWizardType.INTERCEPTOR, pkg, name, comments);
+ if (superclass != null) {
+ w = w.setSuperclass(superclass);
+ }
+ if (method != null) {
+ w = w.setMethodName(method);
+ }
+ if (ibinding != null) {
+ w = w.addIBinding(ibinding);
+ }
+ return w;
+ }
+
+ public CDIWizardBase bean(String pkg, String name, boolean isPublic,
+ boolean isAbstract, boolean isFinal, boolean comments,
+ boolean alternative, boolean registerInBeansXML,
+ String named, String interfaces, String scope, String qualifier) {
+ CDIWizardBase w = create(CDIWizardType.BEAN, pkg, name, comments);
+ if (named != null) {
+ w.setNamed(true);
+ if (!"".equals(named.trim())) {
+ w.setNamedName(named);
+ }
+ }
+ w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract).setAlternative(alternative);
+ //w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
+ if (interfaces != null && !"".equals(interfaces.trim())) {
+ w.addInterface(interfaces);
+ }
+ if (scope != null && !"".equals(scope.trim())) {
+ w.setScope(scope);
+ }
+ if (qualifier != null && !"".equals(qualifier.trim())) {
+ w.addQualifier(qualifier);
+ }
+ if (alternative && registerInBeansXML) {
+ w.setRegisterInBeansXml(registerInBeansXML);
+ }
+ return w;
+ }
+
+ public void annotation(SWTOpenExt open, SWTUtilExt util, String pkg,
+ String name) {
+ SWTBot openWizard = open.newObject(JavaAnnotation.LABEL);
+ openWizard.textWithLabel("Name:").setText(name);
+ openWizard.textWithLabel("Package:").setText(pkg);
+ openWizard.button("Finish").click();
+ util.waitForNonIgnoredJobs();
+ }
+
+ public CDIWizardBase annLiteral(String pkg, String name,
+ boolean isPublic, boolean isAbstract, boolean isFinal,
+ boolean comments, String qualifier) {
+ assert qualifier != null && !"".equals(qualifier.trim()) : "Qualifier has to be set";
+ CDIWizardBase w = create(CDIWizardType.ANNOTATION_LITERAL, pkg, name,
+ comments);
+ return w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract)
+ .addQualifier(qualifier);
+ }
+
+ public CDIWizardBase beansXML(String pkg) {
+ CDIWizardBase w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ w.setSourceFolder(pkg);
+ return w;
+ }
+
+ public CDIWizardBase create(CDIWizardType type, String pkg, String name,
+ boolean inherited, boolean comments) {
+ return create(type, pkg, name, comments).setInherited(inherited);
+ }
+
+ public CDIWizardBase create(CDIWizardType type, String pkg, String name,
+ boolean comments) {
+ CDIWizardBase p = new NewCDIFileWizard(type).run();
+ return p.setPackage(pkg).setName(name).setGenerateComments(comments);
+ }
+
+
+}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.uiutils.wizards;
-
-public enum CDIWizardType {
-
- INTERCEPTOR_BINDING, QUALIFIER, SCOPE, STEREOTYPE,
- DECORATOR, INTERCEPTOR, BEAN, ANNOTATION_LITERAL,
- BEANS_XML;
-
- String getName() {
- switch (this) {
- case INTERCEPTOR_BINDING:
- return "Interceptor Binding";
- case QUALIFIER:
- return "Qualifier";
- case SCOPE:
- return "Scope";
- case STEREOTYPE:
- return "Stereotype";
- case DECORATOR:
- return "Decorator";
- case INTERCEPTOR:
- return "Interceptor";
- case BEAN:
- return "Bean";
- case ANNOTATION_LITERAL:
- return "Annotation Literal";
- case BEANS_XML:
- return "File beans.xml";
- default:
- throw new AssertionError("Unknown type");
- }
- }
-
- public String getAnnotationType() {
- return isAnnotation() ? getName() + " Annotation" : getName();
- }
-
- private boolean isAnnotation() {
- return this.ordinal() < DECORATOR.ordinal();
- }
-}
\ No newline at end of file
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
import org.eclipse.swtbot.swt.finder.SWTBot;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
import org.eclipse.swt.widgets.Shell;
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIATWizardTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIATWizardTest.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIATWizardTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,395 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.wizard;
-
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
-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;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * @author Lukas Jungmann
- * @author jjankovi
- */
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
-public class CDIATWizardTest extends CDIBase {
-
- private static final Logger L = Logger.getLogger(CDIATWizardTest.class.getName());
-
- public String getProjectName() {
- return "CDIWizardTest";
- }
-
- @Override
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- /**
- * needed for creating non-dependant components
- */
- projectExplorer.selectProject(getProjectName());
- }
-
- @Test
- public void testQualifier() {
- CDIUtil.qualifier(getPackageName(), "Q1", false, false).finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Q1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Qualifier"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
- assertFalse(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.qualifier(getPackageName(), "Q2", true, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Q2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Qualifier"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
- assertTrue(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testScope() {
- CDIUtil.scope(getPackageName(), "Scope1", true, false, true, false).finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Scope1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@NormalScope"));
- assertFalse(code.contains("@Scope"));
- assertFalse(code.contains("passivating"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertTrue(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.scope(getPackageName(), "Scope2", false, true, true, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Scope2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@NormalScope(passivating = true)"));
- assertFalse(code.contains("@Scope"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
-
- CDIUtil.scope(getPackageName(), "Scope3", false, true, false, false).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Scope3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Scope"));
- assertFalse(code.contains("@NormalScope"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testIBinding() {
- CDIWizard w = CDIUtil.binding(getPackageName(), "B1", null, true, false);
- assertEquals(2, w.getTargets().size());
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD })"));
- assertTrue(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.binding(getPackageName(), "B2", "TYPE", false, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
-
- CDIUtil.binding(getPackageName(), "B3", "TYPE", false, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
-
- w = CDIUtil.binding(getPackageName(), "B4", "TYPE", true, false);
- w.addIBinding(getPackageName() + ".B2");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B4.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertTrue(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
- assertTrue(code.contains("@B2"));
- }
-
- @Test
- public void testStereotype() {
- CDIWizard w = CDIUtil.stereotype(getPackageName(), "S1", null, null, false, false, false, false,
- false);
- assertEquals(9, w.getScopes().size());
- assertEquals(5, w.getTargets().size());
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("S1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Stereotype"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertFalse(code.contains("@Named"));
- assertFalse(code.contains("@Alternative"));
- assertFalse(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.stereotype(getPackageName(), "S2", "@Scope3", "FIELD", true, true, true, false, true)
- .finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("S2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Stereotype"));
- assertTrue(code.contains("@Scope3"));
- assertTrue(code.contains("@Named"));
- assertTrue(code.contains("@Alternative"));
- assertTrue(code.contains("@Inherited"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ FIELD })"));
- assertTrue(code.startsWith("/**"));
-
- w = CDIUtil.stereotype(getPackageName(), "S3", null, null, false, false, true, false, false);
- w.addIBinding(getPackageName() + ".B1");
- w.addStereotype(getPackageName() + ".S1");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("S3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Stereotype"));
- assertFalse(code.contains("@Scope3"));
- assertFalse(code.contains("@Named"));
- assertTrue(code.contains("@Alternative"));
- assertTrue(code.contains("@B1"));
- assertTrue(code.contains("@S1"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertFalse(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
- }
-
- @Test
- public void testDecorator() {
- bot.sleep(Timing.time1S());
- CDIWizard w = CDIUtil.decorator(getPackageName(), "", "java.lang.Comparable", null, true, true, false, false);
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("ComparableDecorator.java");
- assertTrue(("ComparableDecorator.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Decorator"));
- assertTrue(code.contains("abstract class"));
- assertTrue(code.contains("@Delegate"));
- assertTrue(code.contains("@Inject"));
- assertTrue(code.contains("@Any"));
- assertTrue(code.contains("private Comparable<T> comparable;"));
- assertFalse(code.contains("final"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.decorator(getPackageName(), "", "java.util.Map", "field", false, false, true, true);
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().editorByTitle("MapDecorator.java");
- assertTrue(("MapDecorator.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Decorator"));
- assertFalse(code.contains("abstract"));
- assertTrue(code.contains("@Delegate"));
- assertTrue(code.contains("@Inject"));
- assertTrue(code.contains("@Any"));
- assertTrue(code.contains("private Map<K, V> field;"));
- assertTrue(code.contains("final class"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testInterceptor() {
- CDIWizard w = CDIUtil.interceptor(getPackageName(), "I1", "B2", null, null, false);
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("I1.java");
- assertTrue(("I1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@B2"));
- assertTrue(code.contains("@Interceptor"));
- assertTrue(code.contains("@AroundInvoke"));
- assertTrue(code.contains("public Object manage(InvocationContext ic) throws Exception {"));
- assertFalse(code.contains("final"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.interceptor(getPackageName(), "I2", "B4", "java.util.Date", "sample", true);
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().editorByTitle("I2.java");
- assertTrue(("I2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@B4"));
- assertTrue(code.contains("@Interceptor"));
- assertTrue(code.contains("@AroundInvoke"));
- assertTrue(code.contains("public Object sample(InvocationContext ic) throws Exception {"));
- assertFalse(code.contains("final"));
- assertTrue(code.startsWith("/**"));
- assertTrue(code.contains("extends Date"));
- }
-
- @Test
- public void testBeansXml() {
- CDIWizard w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
- w.setSourceFolder(getProjectName() + "/WebContent/WEB-INF");
- assertFalse(w.canFinish());
- w.setSourceFolder(getProjectName() + "/src/" + getPackageName().replaceAll(".", "/"));
- assertTrue(w.canFinish());
- w.cancel();
- w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
- assertFalse(w.canFinish());
- w.cancel();
- }
-
- @Test
- public void testBean() {
- CDIWizard w = CDIUtil.bean(getPackageName(), "Bean1", true, true, false, false, false, false, null, null, null, null);
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Bean1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("package cdi;"));
- assertTrue(code.contains("public abstract class Bean1 {"));
- assertFalse(code.contains("@Named"));
- assertFalse(code.contains("final"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.bean(getPackageName(), "Bean2", false, false, true, true, false, false, "", null, "@Dependent", null);
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Bean2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("package cdi;"));
- assertTrue(code.contains("@Named"));
- assertFalse(code.contains("@Named("));
- assertTrue(code.contains("@Dependent"));
- assertTrue(code.contains("final class Bean2 {"));
- assertTrue(code.startsWith("/**"));
-
- w = CDIUtil.bean(getPackageName(), "Bean3", true, false, false, true, false, false, "TestedBean", null, "@Scope2", "Q1");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Bean3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("package cdi;"));
- assertTrue(code.contains("@Named(\"TestedBean\")"));
- assertTrue(code.contains("@Scope2"));
- assertTrue(code.contains("@Q1"));
- assertTrue(code.contains("public class Bean3 {"));
- assertFalse(code.contains("final"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testAnnLiteral() {
- CDIWizard w = CDIUtil.annLiteral(getPackageName(), "AnnL1", true, false, true, false, getPackageName() + ".Q1");
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("AnnL1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.info(code);
- assertTrue(code.contains("package cdi;"));
- assertTrue(code.contains("public final class AnnL1 extends AnnotationLiteral<Q1> implements Q1"));
- assertTrue(code.contains("public static final Q1 INSTANCE = new AnnL1();"));
- assertFalse(code.contains("abstract"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.annLiteral(getPackageName(), "AnnL2", false, true, false, true, "Q2");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("AnnL2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.info(code);
- assertTrue(code.contains("package cdi;"));
- assertTrue(code.contains("abstract class AnnL2 extends AnnotationLiteral<Q2> implements Q2 {"));
- assertTrue(code.contains("public static final Q2 INSTANCE = new AnnL2();"));
- assertFalse(code.substring(code.indexOf("final") + 5).contains("final"));
- assertTrue(code.contains("abstract"));
- assertTrue(code.startsWith("/**"));
- }
-}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.wizard;
-
-
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
-import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-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;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
-* Test checks if CDI configuration preset sets CDI support correctly
-*
-* @author Jaroslav Jankovic
-*/
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
-public class CDIConfigurationPresetTest extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDIConfigurationPresetTest.class.getName());
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createCDIProjectWithCDIPreset(util, getProjectName());
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDIPresetProject";
- }
-
- @Test
- public void testCDIPreset() {
- LOGGER.info("Dynamic Web Project with CDI Configuration Preset created");
- assertTrue(checkCDISupport(getProjectName()));
- }
-
- private boolean checkCDISupport(String projectName) {
- projectExplorer.selectProject(projectName);
-
- SWTBotTree tree = projectExplorer.bot().tree();
- ContextMenuHelper.prepareTreeItemForContextMenu(tree);
- new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
-
- bot.tree().expandNode("CDI (Context and Dependency Injection) Settings").select();
- boolean isCDISupported = bot.checkBox().isChecked();
- bot.button("Cancel").click();
- return isCDISupported;
- }
-
-
-}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,53 +0,0 @@
-package org.jboss.tools.cdi.bot.test.wizard;
-
-import java.util.logging.Logger;
-
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
-import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-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;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
-* Test checks if beans.xml is created when selectin CDI Facet
-*
-* @author Jaroslav Jankovic
-*/
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
-public class CDIFacetTest extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDIFacetTest.class.getName());
-
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createCDIProjectWithCDIFacets(util, getProjectName());
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDIFacetsProject";
- }
-
- @Test
- public void testCDIFacet() {
- LOGGER.info("Dynamic Web Project with CDI Facet created");
- assertTrue("Error: beans.xml should be created when selecting CDI Facet",
- projectExplorer.isFilePresent(getProjectName(), getBeansXmlLocation().split("/")));
- }
-
- private String getBeansXmlLocation() {
- return "WebContent/WEB-INF/beans.xml";
- }
-
-}
Deleted: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.wizard;
-
-
-import java.util.logging.Logger;
-
-import org.eclipse.swt.SWTException;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
-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;
-import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
-* Test operates on CDI perspective
-*
-* @author Jaroslav Jankovic
-*/
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
-public class CDIPerspectiveTest extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDIPerspectiveTest.class.getName());
- private enum CDIARTIFACTS {
- BEAN, QUALIFIER, STEREOTYPE, SCOPE, INTERBINDING, INTERCEPTOR, DECORATOR, ANNOTLITERAL, BEANSXML
- }
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createAndCheckCDIProject(bot, util, projectExplorer, getProjectName());
- eclipse.openPerspective(PerspectiveType.CDI);
- LOGGER.info("CDI perspective selected");
- bot.sleep(Timing.time2S());
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDIPerspectiveTest";
- }
-
- @Test
- public void testCDIArtifactBeanWizard() {
-
- assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.BEAN));
- }
-
- @Test
- public void testCDIArtifactAnnotationLiteralWizard() {
-
- assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.ANNOTLITERAL));
- }
-
- @Test
- public void testCDIArtifactBeanXMLWizard() {
-
- assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.BEANSXML));
- }
-
- @Test
- public void testCDIArtifactDecoratorWizard() {
-
- assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.DECORATOR));
- }
-
- @Test
- public void testCDIArtifactQualifierWizard() {
-
- assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.QUALIFIER));
- }
-
- @Test
- public void testCDIArtifactScopeWizard() {
-
- assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.SCOPE));
- }
-
- @Test
- public void testCDIArtifactStereoscopeWizard() {
-
- assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.STEREOTYPE));
- }
-
- private boolean openCDIArtifactsWizard(CDIARTIFACTS artifact) {
-
- SWTBotTree tree = packageExplorer.bot().tree();
- SWTBotTreeItem item = tree.getTreeItem(getProjectName());
- item.expand();
- boolean artifactWizardExists = true;
- try {
- CDIUtil.nodeContextMenu(tree, item, "New", getArtifactMenuItem(artifact)).click();
- bot.sleep(Timing.time500MS());
- bot.activeShell().bot().button("Cancel").click();
-
- } catch (SWTException exc) {
- artifactWizardExists = false;
- }
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
- return artifactWizardExists;
- }
-
- private String getArtifactMenuItem(CDIARTIFACTS artifact) {
- switch (artifact) {
- case ANNOTLITERAL:
- return "Annotation Literal";
- case BEAN:
- return "Bean";
- case BEANSXML:
- return "File beans.xml";
- case DECORATOR:
- return "Decorator";
- case INTERBINDING:
- return "Interceptor Binding Annotation";
- case INTERCEPTOR:
- return "Interceptor";
- case QUALIFIER:
- return "Qualifier Annotation";
- case SCOPE:
- return "Scope Annotation";
- case STEREOTYPE:
- return "Stereotype Annotation";
- default:
- return null;
- }
- }
-
-}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.wizard;
+
+
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test checks if CDI configuration preset sets CDI support correctly
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
+public class ConfigurationPresetTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(ConfigurationPresetTest.class.getName());
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createDynamicWebProjectWithCDIPreset(getProjectName());
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIPresetProject";
+ }
+
+ @Test
+ public void testCDIPreset() {
+ LOGGER.info("Dynamic Web Project with CDI Configuration Preset created");
+ assertTrue(checkCDISupport(getProjectName()));
+ }
+
+ private boolean checkCDISupport(String projectName) {
+ projectExplorer.selectProject(projectName);
+
+ SWTBotTree tree = projectExplorer.bot().tree();
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
+
+ bot.tree().expandNode("CDI (Context and Dependency Injection) Settings").select();
+ boolean isCDISupported = bot.checkBox().isChecked();
+ bot.button("Cancel").click();
+ return isCDISupported;
+ }
+
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.wizard;
+
+import java.util.logging.Logger;
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test checks if beans.xml is created when selectin CDI Facet
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
+public class FacetTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(FacetTest.class.getName());
+
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createDynamicWebProjectWithCDIFacets(getProjectName());
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIFacetsProject";
+ }
+
+ @Test
+ public void testCDIFacet() {
+ LOGGER.info("Dynamic Web Project with CDI Facet created");
+ assertTrue("Error: beans.xml should be created when selecting CDI Facet",
+ projectExplorer.isFilePresent(getProjectName(), "WebContent/WEB-INF/beans.xml".split("/")));
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.wizard;
+
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWTException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.NodeContextUtil;
+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;
+import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test operates on CDI perspective
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
+public class PerspectiveTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(PerspectiveTest.class.getName());
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ eclipse.openPerspective(PerspectiveType.CDI);
+ LOGGER.info("CDI perspective selected");
+ bot.sleep(Timing.time2S());
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIPerspectiveTest";
+ }
+
+ @Test
+ public void testCDIArtifactBeanWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.BEAN));
+ }
+
+ @Test
+ public void testCDIArtifactAnnotationLiteralWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.ANNOTATION_LITERAL));
+ }
+
+ @Test
+ public void testCDIArtifactBeanXMLWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.BEANS_XML));
+ }
+
+ @Test
+ public void testCDIArtifactDecoratorWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.DECORATOR));
+ }
+
+ @Test
+ public void testCDIArtifactQualifierWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.QUALIFIER));
+ }
+
+ @Test
+ public void testCDIArtifactScopeWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.SCOPE));
+ }
+
+ @Test
+ public void testCDIArtifactStereoscopeWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.STEREOTYPE));
+ }
+
+ private boolean openCDIArtifactsWizard(CDIWizardType wizardType) {
+
+ SWTBotTree tree = packageExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(getProjectName());
+ item.expand();
+ boolean artifactWizardExists = true;
+ try {
+ NodeContextUtil.nodeContextMenu(tree, item, "New", wizardType.getAnnotationType()).click();
+ bot.sleep(Timing.time500MS());
+ bot.activeShell().bot().button("Cancel").click();
+
+ } catch (SWTException exc) {
+ artifactWizardExists = false;
+ }
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ return artifactWizardExists;
+ }
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java 2011-11-21 09:33:15 UTC (rev 36468)
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.cdi.bot.test.wizard;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBase;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBaseExt;
+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;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * @author Lukas Jungmann
+ * @author jjankovi
+ */
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
+public class WizardTest extends CDITestBase {
+
+ private static final Logger L = Logger.getLogger(WizardTest.class.getName());
+ private final CDIWizardBaseExt wizard = new CDIWizardBaseExt();
+
+ public String getProjectName() {
+ return "CDIWizardTest";
+ }
+
+ @Override
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ /**
+ * needed for creating non-dependant components
+ */
+ projectExplorer.selectProject(getProjectName());
+ }
+
+ @Test
+ public void testQualifier() {
+ wizard.qualifier(getPackageName(), "Q1", false, false).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Q1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Qualifier"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ wizard.qualifier(getPackageName(), "Q2", true, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Q2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Qualifier"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testScope() {
+ wizard.scope(getPackageName(), "Scope1", true, false, true, false).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@NormalScope"));
+ assertFalse(code.contains("@Scope"));
+ assertFalse(code.contains("passivating"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ wizard.scope(getPackageName(), "Scope2", false, true, true, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@NormalScope(passivating = true)"));
+ assertFalse(code.contains("@Scope"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ wizard.scope(getPackageName(), "Scope3", false, true, false, false).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Scope"));
+ assertFalse(code.contains("@NormalScope"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testIBinding() {
+ CDIWizardBase w = wizard.binding(getPackageName(), "B1", null, true, false);
+ assertEquals(2, w.getTargets().size());
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ wizard.binding(getPackageName(), "B2", "TYPE", false, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ wizard.binding(getPackageName(), "B3", "TYPE", false, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ w = wizard.binding(getPackageName(), "B4", "TYPE", true, false);
+ w.addIBinding(getPackageName() + ".B2");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B4.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+ assertTrue(code.contains("@B2"));
+ }
+
+ @Test
+ public void testStereotype() {
+ CDIWizardBase w = wizard.stereotype(getPackageName(), "S1", null, null, false, false, false, false,
+ false);
+ assertEquals(9, w.getScopes().size());
+ assertEquals(5, w.getTargets().size());
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Named"));
+ assertFalse(code.contains("@Alternative"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ wizard.stereotype(getPackageName(), "S2", "@Scope3", "FIELD", true, true, true, false, true)
+ .finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertTrue(code.contains("@Scope3"));
+ assertTrue(code.contains("@Named"));
+ assertTrue(code.contains("@Alternative"));
+ assertTrue(code.contains("@Inherited"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ FIELD })"));
+ assertTrue(code.startsWith("/**"));
+
+ w = wizard.stereotype(getPackageName(), "S3", null, null, false, false, true, false, false);
+ w.addIBinding(getPackageName() + ".B1");
+ w.addStereotype(getPackageName() + ".S1");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertFalse(code.contains("@Scope3"));
+ assertFalse(code.contains("@Named"));
+ assertTrue(code.contains("@Alternative"));
+ assertTrue(code.contains("@B1"));
+ assertTrue(code.contains("@S1"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testDecorator() {
+ bot.sleep(Timing.time1S());
+ CDIWizardBase w = wizard.decorator(getPackageName(), "", "java.lang.Comparable", null, true, true, false, false);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("ComparableDecorator.java");
+ assertTrue(("ComparableDecorator.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Decorator"));
+ assertTrue(code.contains("abstract class"));
+ assertTrue(code.contains("@Delegate"));
+ assertTrue(code.contains("@Inject"));
+ assertTrue(code.contains("@Any"));
+ assertTrue(code.contains("private Comparable<T> comparable;"));
+ assertFalse(code.contains("final"));
+ assertFalse(code.startsWith("/**"));
+
+ w = wizard.decorator(getPackageName(), "", "java.util.Map", "field", false, false, true, true);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().editorByTitle("MapDecorator.java");
+ assertTrue(("MapDecorator.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Decorator"));
+ assertFalse(code.contains("abstract"));
+ assertTrue(code.contains("@Delegate"));
+ assertTrue(code.contains("@Inject"));
+ assertTrue(code.contains("@Any"));
+ assertTrue(code.contains("private Map<K, V> field;"));
+ assertTrue(code.contains("final class"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testInterceptor() {
+ CDIWizardBase w = wizard.interceptor(getPackageName(), "I1", "B2", null, null, false);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("I1.java");
+ assertTrue(("I1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@B2"));
+ assertTrue(code.contains("@Interceptor"));
+ assertTrue(code.contains("@AroundInvoke"));
+ assertTrue(code.contains("public Object manage(InvocationContext ic) throws Exception {"));
+ assertFalse(code.contains("final"));
+ assertFalse(code.startsWith("/**"));
+
+ w = wizard.interceptor(getPackageName(), "I2", "B4", "java.util.Date", "sample", true);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().editorByTitle("I2.java");
+ assertTrue(("I2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@B4"));
+ assertTrue(code.contains("@Interceptor"));
+ assertTrue(code.contains("@AroundInvoke"));
+ assertTrue(code.contains("public Object sample(InvocationContext ic) throws Exception {"));
+ assertFalse(code.contains("final"));
+ assertTrue(code.startsWith("/**"));
+ assertTrue(code.contains("extends Date"));
+ }
+
+ @Test
+ public void testBeansXml() {
+ CDIWizardBase w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ w.setSourceFolder(getProjectName() + "/WebContent/WEB-INF");
+ assertFalse(w.canFinish());
+ w.setSourceFolder(getProjectName() + "/src/" + getPackageName().replaceAll(".", "/"));
+ assertTrue(w.canFinish());
+ w.cancel();
+ w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ assertFalse(w.canFinish());
+ w.cancel();
+ }
+
+ @Test
+ public void testBean() {
+ CDIWizardBase w = wizard.bean(getPackageName(), "Bean1", true, true, false, false, false, false, null, null, null, null);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Bean1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("public abstract class Bean1 {"));
+ assertFalse(code.contains("@Named"));
+ assertFalse(code.contains("final"));
+ assertFalse(code.startsWith("/**"));
+
+ w = wizard.bean(getPackageName(), "Bean2", false, false, true, true, false, false, "", null, "@Dependent", null);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Bean2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("@Named"));
+ assertFalse(code.contains("@Named("));
+ assertTrue(code.contains("@Dependent"));
+ assertTrue(code.contains("final class Bean2 {"));
+ assertTrue(code.startsWith("/**"));
+
+ w = wizard.bean(getPackageName(), "Bean3", true, false, false, true, false, false, "TestedBean", null, "@Scope2", "Q1");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Bean3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("@Named(\"TestedBean\")"));
+ assertTrue(code.contains("@Scope2"));
+ assertTrue(code.contains("@Q1"));
+ assertTrue(code.contains("public class Bean3 {"));
+ assertFalse(code.contains("final"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testAnnLiteral() {
+ CDIWizardBase w = wizard.annLiteral(getPackageName(), "AnnL1", true, false, true, false, getPackageName() + ".Q1");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("AnnL1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.info(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("public final class AnnL1 extends AnnotationLiteral<Q1> implements Q1"));
+ assertTrue(code.contains("public static final Q1 INSTANCE = new AnnL1();"));
+ assertFalse(code.contains("abstract"));
+ assertFalse(code.startsWith("/**"));
+
+ w = wizard.annLiteral(getPackageName(), "AnnL2", false, true, false, true, "Q2");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("AnnL2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.info(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("abstract class AnnL2 extends AnnotationLiteral<Q2> implements Q2 {"));
+ assertTrue(code.contains("public static final Q2 INSTANCE = new AnnL2();"));
+ assertFalse(code.substring(code.indexOf("final") + 5).contains("final"));
+ assertTrue(code.contains("abstract"));
+ assertTrue(code.startsWith("/**"));
+ }
+}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt 2011-11-19 09:55:17 UTC (rev 36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt 2011-11-21 09:33:15 UTC (rev 36468)
@@ -1,7 +1,7 @@
/**
* what tests have to be done(JBDS50_0010):
- * 1. Classes indication for Open Injected Class works
- * 2. CDI Facets can create beans.xml file when selected
+ * 1. Validations works good for Inconsistent specialization,
+ Ambiguous EL names, Unproxyable bean types, Decorator resolution
* 3. Code completion works in beans.xml
* 4. Classes in beans.xml are validated
* 5. Complex test from Weld is working in JBDS and CDI functionality works without errors
13 years, 1 month
JBoss Tools SVN: r36467 - in workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim: resources/config and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: yradtsevich
Date: 2011-11-19 04:55:17 -0500 (Sat, 19 Nov 2011)
New Revision: 36467
Modified:
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListHolder.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListStorage.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/BrowserSim.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/EditDeviceDialog.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/ManageDevicesDialog.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/Messages.java
workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/messages.properties
Log:
https://issues.jboss.org/browse/JBIDE-9539 : Browsersim app for testing mobile/desktop web apps
- added support of default width\height\user-agent, part 2
- added more devices
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListHolder.java
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListHolder.java 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListHolder.java 2011-11-19 09:55:17 UTC (rev 36467)
@@ -17,19 +17,11 @@
* @author Yahor Radtsevich (yradtsevich)
*/
public class DevicesListHolder extends Observable {
- private static DevicesListHolder instance;
private DevicesList devicesList;
- protected DevicesListHolder() {
+ public DevicesListHolder() {
}
-
- public static DevicesListHolder getInstance() {
- if (instance == null) {
- instance = new DevicesListHolder();
- }
- return instance;
- }
-
+
public DevicesList getDevicesList() {
return devicesList;
}
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListStorage.java
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListStorage.java 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/model/DevicesListStorage.java 2011-11-19 09:55:17 UTC (rev 36467)
@@ -108,7 +108,7 @@
if (nextLine != null) {
selectedDeviceIndex = Integer.parseInt(nextLine);
}
- Pattern devicePattern = Pattern.compile("^(.*)\\t([0-9]*)\\t([0-9]*)(\\t(.*))?$");
+ Pattern devicePattern = Pattern.compile("^(.*)\\t(\\-?[0-9]*)\\t(\\-?[0-9]*)(\\t(.*))?$");
List<Device> devices = new ArrayList<Device>();
while ((nextLine = reader.readLine()) != null) {
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/resources/config/devices.cfg 2011-11-19 09:55:17 UTC (rev 36467)
@@ -1,7 +1,15 @@
0
-Default 0 0
-Apple iPad 2 768 1024 Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5
-Apple iPhone 3 320 480 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
-Apple iPhone 4 640 960 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
+PC (Default) -1 -1
+Apple iPad 2 (Portrait) 768 1024 Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5
+Apple iPad 2 (Landscape) 1024 768 Mozilla/5.0 (iPad; U; CPU OS 4_3_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8G4 Safari/6533.18.5
+Apple iPhone 3 (Portrait) 320 480 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
+Apple iPhone 3 (Landscape) 480 320 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
+Apple iPhone 4 (Portrait) 640 960 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
+Apple iPhone 4 (Landscape) 960 640 Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7
RIM BlackBerry Bold Touch 9900 640 480 Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.246 Mobile Safari/534.1+
-Samsung Galaxy S II 640 800 Mozilla/5.0 (Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
+Samsung Galaxy S (Portrait) 480 800 Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; GT-I9000 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
+Samsung Galaxy S (Landscape) 800 480 Mozilla/5.0 (Linux; U; Android 2.3.3; en-us; GT-I9000 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
+Samsung Galaxy S II (Portrait) 480 800 Mozilla/5.0 (Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
+Samsung Galaxy S II (Landscape) 800 480 Mozilla/5.0 (Linux; U; Android 2.3; en-us; GT-I9100 Build/GRH78) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
+Samsung Galaxy Tab 10.1 (Portrait) 800 1280 Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; GT-P7100 Build/HRI83) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 MobileSafari/534.13
+Samsung Galaxy Tab 10.1 (Landscape) 1280 800 Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; GT-P7100 Build/HRI83) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 MobileSafari/534.13
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/BrowserSim.java
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/BrowserSim.java 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/BrowserSim.java 2011-11-19 09:55:17 UTC (rev 36467)
@@ -10,11 +10,8 @@
******************************************************************************/
package org.jboss.tools.browsersim.ui;
-import java.io.File;
-import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
-import java.util.ArrayList;
import java.util.Observable;
import java.util.Observer;
@@ -68,7 +65,7 @@
private ProgressBar progressBar;
private String initialUrl;
private Menu devicesMenu;
- private DevicesListHolder devicesManager;
+ private DevicesListHolder devicesListHolder;
public static void main(String[] args) {
String initialUrl;
@@ -97,8 +94,8 @@
shell = new Shell(display);
shell.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
- if (devicesManager != null) {
- DevicesListStorage.saveUserDefinedDevicesList(devicesManager.getDevicesList());
+ if (devicesListHolder != null) {
+ DevicesListStorage.saveUserDefinedDevicesList(devicesListHolder.getDevicesList());
}
}
});
@@ -184,6 +181,7 @@
}
});
+ devicesListHolder = new DevicesListHolder();
fillMenuBar(appMenuBar);
locationText.addListener(SWT.DefaultSelection, new Listener() {
@@ -192,7 +190,7 @@
}
});
- DevicesList devicesList = DevicesListHolder.getInstance().getDevicesList();
+ DevicesList devicesList = devicesListHolder.getDevicesList();
if (devicesList != null && devicesList.getDevices() != null
&& devicesList.getSelectedDeviceIndex() < devicesList.getDevices().size()) {
setDevice(devicesList.getDevices().get(devicesList.getSelectedDeviceIndex()));
@@ -287,8 +285,7 @@
});
devicesMenu = createDropDownMenu(appMenuBar, Messages.BrowserSim_DEVICES);
- devicesManager = DevicesListHolder.getInstance();
- devicesManager.addObserver(new Observer() {
+ devicesListHolder.addObserver(new Observer() {
public void update(Observable o, Object arg) {
DevicesListHolder devicesManager = (DevicesListHolder) o;
DevicesList devicesList = devicesManager.getDevicesList();
@@ -309,8 +306,8 @@
devicesList = DevicesListStorage.loadDefaultDevicesList();
}
- devicesManager.setDevicesList(devicesList);
- devicesManager.notifyObservers();
+ devicesListHolder.setDevicesList(devicesList);
+ devicesListHolder.notifyObservers();
new MenuItem(devicesMenu, SWT.BAR);
MenuItem manageDevicesMenuItem = new MenuItem(devicesMenu, SWT.PUSH);
@@ -318,10 +315,10 @@
manageDevicesMenuItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DevicesList newDevicesList = new ManageDevicesDialog(shell, SWT.APPLICATION_MODAL | SWT.SHELL_TRIM,
- devicesManager.getDevicesList()).open();
+ devicesListHolder.getDevicesList()).open();
if (newDevicesList != null) {
- devicesManager.setDevicesList(newDevicesList);
- devicesManager.notifyObservers();
+ devicesListHolder.setDevicesList(newDevicesList);
+ devicesListHolder.notifyObservers();
}
}
});
@@ -343,7 +340,7 @@
public void widgetSelected(SelectionEvent e) {
MenuItem menuItem = (MenuItem)e.widget;
if (menuItem.getSelection()) {
- DevicesList devicesList = devicesManager.getDevicesList();
+ DevicesList devicesList = devicesListHolder.getDevicesList();
int selectedDeviceIndex = devicesList.getDevices().indexOf(menuItem.getData());
if (selectedDeviceIndex < 0) {
selectedDeviceIndex = 0;
@@ -378,13 +375,13 @@
Rectangle clientArea = display.getClientArea();
int shellWidthHint = SWT.DEFAULT;
- if (device.getWidth() != 0) {
+ if (device.getWidth() != Device.DEFAULT_SIZE) {
data.widthHint = device.getWidth();
} else if (data.widthHint == SWT.DEFAULT) {
shellWidthHint = clientArea.width;
}
int shellHeightHint = SWT.DEFAULT;
- if (device.getHeight() != 0) {
+ if (device.getHeight() != Device.DEFAULT_SIZE) {
data.heightHint = device.getHeight();
} else if (data.heightHint == SWT.DEFAULT) {
shellHeightHint = clientArea.height;
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/EditDeviceDialog.java
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/EditDeviceDialog.java 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/EditDeviceDialog.java 2011-11-19 09:55:17 UTC (rev 36467)
@@ -27,6 +27,9 @@
private Text textWidth;
private Text textHeight;
private Text textUserAgent;
+ private Button checkButtonWidth;
+ private Button checkButtonHeight;
+ private Button checkButtonUserAgent;
/**
* Create the dialog.
@@ -68,29 +71,31 @@
shell.setLayout(new GridLayout(2, false));
Label labelName = new Label(shell, SWT.NONE);
- labelName.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
labelName.setText(Messages.EditDeviceDialog_NAME);
textName = new Text(shell, SWT.BORDER);
textName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
textName.addFocusListener(new FocusGainedTextListener());
textName.setText(initialDevice.getName());
+
+ checkButtonWidth = new Button(shell, SWT.CHECK);
+ checkButtonWidth.setText(Messages.EditDeviceDialog_WIDTH);
+ checkButtonWidth.setSelection(initialDevice.getWidth() != Device.DEFAULT_SIZE);
- Label labelWidth = new Label(shell, SWT.NONE);
- labelWidth.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- labelWidth.setText(Messages.EditDeviceDialog_WIDTH);
-
textWidth = new Text(shell, SWT.BORDER);
textWidth.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
textWidth.setTextLimit(4);
textWidth.addVerifyListener(new VerifyDigitsListener());
textWidth.addFocusListener(new FocusLostDigitsListener());
textWidth.addFocusListener(new FocusGainedTextListener());
- textWidth.setText(String.valueOf(initialDevice.getWidth()));
+ if (initialDevice.getWidth() != Device.DEFAULT_SIZE) {
+ textWidth.setText(String.valueOf(initialDevice.getWidth()));
+ }
+ attachCheckBoxToText(checkButtonWidth, textWidth);
- Label labelHeight = new Label(shell, SWT.NONE);
- labelHeight.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- labelHeight.setText(Messages.EditDeviceDialog_HEIGHT);
+ checkButtonHeight = new Button(shell, SWT.CHECK);
+ checkButtonHeight.setText(Messages.EditDeviceDialog_HEIGHT);
+ checkButtonHeight.setSelection(initialDevice.getHeight() != Device.DEFAULT_SIZE);
textHeight = new Text(shell, SWT.BORDER);
textHeight.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
@@ -98,22 +103,24 @@
textHeight.addVerifyListener(new VerifyDigitsListener());
textHeight.addFocusListener(new FocusLostDigitsListener());
textHeight.addFocusListener(new FocusGainedTextListener());
- textHeight.setText(String.valueOf(initialDevice.getHeight()));
+ if (initialDevice.getHeight() != Device.DEFAULT_SIZE) {
+ textHeight.setText(String.valueOf(initialDevice.getHeight()));
+ }
+ attachCheckBoxToText(checkButtonHeight, textHeight);
- Label labelUseragent = new Label(shell, SWT.NONE);
- labelUseragent.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- labelUseragent.setText(Messages.EditDeviceDialog_USER_AGENT);
+ checkButtonUserAgent = new Button(shell, SWT.CHECK);
+ checkButtonUserAgent.setText(Messages.EditDeviceDialog_USER_AGENT);
+ checkButtonUserAgent.setSelection(initialDevice.getUserAgent() != null);
textUserAgent = new Text(shell, SWT.BORDER);
textUserAgent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
textUserAgent.addFocusListener(new FocusGainedTextListener());
if (initialDevice.getUserAgent() != null) {
textUserAgent.setText(initialDevice.getUserAgent());
- } else {
- textUserAgent.setText("Default User-Agent");
- textUserAgent.setEnabled(false);
}
+ attachCheckBoxToText(checkButtonUserAgent, textUserAgent);
+
Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new FillLayout(SWT.HORIZONTAL));
composite.setLayoutData(new GridData(SWT.RIGHT, SWT.BOTTOM, true, true, 2, 1));
@@ -122,8 +129,10 @@
buttonOk.setText(Messages.EditDeviceDialog_OK);
buttonOk.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
- resultDevice = new Device(textName.getText(), Integer.valueOf(textWidth.getText()),
- Integer.valueOf(textHeight.getText()), textUserAgent.isEnabled() ? textUserAgent.getText() : null);
+ resultDevice = new Device(textName.getText(),
+ checkButtonWidth.getSelection() ? Integer.valueOf("0" + textWidth.getText()) : Device.DEFAULT_SIZE,
+ checkButtonHeight.getSelection() ? Integer.valueOf("0" + textHeight.getText()) : Device.DEFAULT_SIZE,
+ checkButtonUserAgent.getSelection() ? textUserAgent.getText() : null);
shell.close();
}
});
@@ -138,6 +147,23 @@
}
});
}
+
+ private void attachCheckBoxToText(Button checkBox, final Text text) {
+ if (checkBox.getSelection()) {
+ text.setEnabled(true);
+ } else {
+ text.setEnabled(false);
+ }
+ checkBox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ if (((Button)e.widget).getSelection()) {
+ text.setEnabled(true);
+ } else {
+ text.setEnabled(false);
+ }
+ }
+ });
+ }
}
final class VerifyDigitsListener implements VerifyListener {
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/ManageDevicesDialog.java
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/ManageDevicesDialog.java 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/ManageDevicesDialog.java 2011-11-19 09:55:17 UTC (rev 36467)
@@ -9,7 +9,6 @@
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.browsersim.ui;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -31,7 +30,6 @@
import org.jboss.tools.browsersim.model.Device;
import org.jboss.tools.browsersim.model.DevicesList;
import org.jboss.tools.browsersim.model.DevicesListStorage;
-import org.jboss.tools.browsersim.util.ResourcesUtil;
/**
* @author Yahor Radtsevich (yradtsevich)
@@ -212,7 +210,12 @@
table.removeAll();
for (Device device : devices) {
TableItem tableItem = new TableItem(table, SWT.NONE);
- tableItem.setText(new String[] {device.getName(), String.valueOf(device.getWidth()), String.valueOf(device.getHeight()), device.getUserAgent()});
+ tableItem.setText(new String[] {
+ device.getName(),
+ device.getWidth() == Device.DEFAULT_SIZE ? Messages.ManageDevicesDialog_DEFAULT : String.valueOf(device.getWidth()),
+ device.getHeight() == Device.DEFAULT_SIZE ? Messages.ManageDevicesDialog_DEFAULT : String.valueOf(device.getHeight()),
+ device.getUserAgent() == null ? Messages.ManageDevicesDialog_DEFAULT : device.getUserAgent()
+ });
}
table.setSelection(selectedDeviceIndex);
}
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/Messages.java
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/Messages.java 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/Messages.java 2011-11-19 09:55:17 UTC (rev 36467)
@@ -35,6 +35,7 @@
public static String EditDeviceDialog_WIDTH;
public static String ManageDevicesDialog_ADD;
public static String ManageDevicesDialog_CANCEL;
+ public static String ManageDevicesDialog_DEFAULT;
public static String ManageDevicesDialog_DEVICES;
public static String ManageDevicesDialog_EDIT;
public static String ManageDevicesDialog_HEIGHT;
Modified: workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/messages.properties
===================================================================
--- workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/messages.properties 2011-11-19 01:14:21 UTC (rev 36466)
+++ workspace/yradtsevich/browsersim/swt-webkit-browsersim/org.jboss.tools.browsersim/src/org/jboss/tools/browsersim/ui/messages.properties 2011-11-19 09:55:17 UTC (rev 36467)
@@ -16,6 +16,7 @@
EditDeviceDialog_WIDTH=Width:
ManageDevicesDialog_ADD=Add
ManageDevicesDialog_CANCEL=Cancel
+ManageDevicesDialog_DEFAULT=DEFAULT
ManageDevicesDialog_DEVICES=Devices
ManageDevicesDialog_EDIT=Edit
ManageDevicesDialog_HEIGHT=Height
13 years, 1 month
JBoss Tools SVN: r36466 - in trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf: project and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-11-18 20:14:21 -0500 (Fri, 18 Nov 2011)
New Revision: 36466
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java
Log:
JBIDE-10177
https://issues.jboss.org/browse/JBIDE-10177
JBIDE-812
https://issues.jboss.org/browse/JBIDE-812
Multiple web roots loaded into XModel.
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java 2011-11-19 01:12:43 UTC (rev 36465)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectsRoot.java 2011-11-19 01:14:21 UTC (rev 36466)
@@ -15,6 +15,7 @@
import org.eclipse.core.runtime.CoreException;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.impl.ExtraRootImpl;
@@ -84,9 +85,15 @@
if(fs == null) return new XModelObject[0];
webroot = fs.getChildByPath("WEB-ROOT");
webxml = WebAppHelper.getWebApp(getModel());
- XModelObject[] cs = getChildren();
List<XModelObject> list = new ArrayList<XModelObject>();
if(webroot != null) list.add(webroot);
+ XModelObject[] ss = fs.getChildren("FileSystemFolder");
+ for (XModelObject s: ss) {
+ if(s.getAttributeValue(XModelObjectConstants.ATTR_NAME).startsWith("WEB-ROOT-")) {
+ list.add(s);
+ }
+ }
+ XModelObject[] cs = getChildren();
for (int i = 0; i < cs.length; i++) list.add(cs[i]);
if(webxml != null) list.add(webxml);
treeChildren = list.toArray(new XModelObject[0]);
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java 2011-11-19 01:12:43 UTC (rev 36465)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java 2011-11-19 01:14:21 UTC (rev 36466)
@@ -1,88 +1,188 @@
package org.jboss.tools.jsf.project;
import java.io.IOException;
-import java.util.Properties;
+import java.util.ArrayList;
+import java.util.List;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
-import org.jboss.tools.common.model.filesystems.impl.FileSystemImpl;
+import org.jboss.tools.common.model.impl.XModelImpl;
import org.jboss.tools.common.model.project.IAutoLoad;
-import org.jboss.tools.common.model.project.ProjectHome;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelObjectUtil;
+import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jsf.model.pv.JSFProjectsTree;
+import org.jboss.tools.jst.web.WebUtils;
+import org.jboss.tools.jst.web.model.pv.WebProjectNode;
-public class JSFAutoLoad implements IAutoLoad {
+public class JSFAutoLoad implements IAutoLoad, XModelObjectConstants {
+ static String WEB_INF = "WEB-INF"; //$NON-NLS-1$
+ static String WEB_ROOT = "WEB-ROOT"; //$NON-NLS-1$
public void load(XModel model) {
- Properties properties = null;
XModelObject fs = FileSystemsHelper.getFileSystems(model);
IProject project = EclipseResourceUtil.getProject(fs);
if(project == null) return;
- fs.setAttributeValue("application name", project.getName());
+ fs.setAttributeValue("application name", project.getName()); //$NON-NLS-1$
- String fsLoc = null;
- FileSystemImpl s = null;
- properties = new Properties();
-
- fsLoc = project.getLocation().toString();
- properties.setProperty("location", fsLoc);
- properties.setProperty("name", project.getName());
- s = (FileSystemImpl)model.createModelObject("FileSystemFolder", properties);
+ XModelObject s = createFileSystemFolder(model, project.getName(), project.getLocation().toString());
fs.addChild(s);
- XModelObject webinf = model.createModelObject("FileSystemFolder", null); //$NON-NLS-1$
- webinf.setAttributeValue("name", "WEB-INF"); //$NON-NLS-1$ //$NON-NLS-2$
- webinf.setAttributeValue("location", XModelConstants.WORKSPACE_REF); //$NON-NLS-1$
+ XModelObject webinf = createFileSystemFolder(model, WEB_INF, XModelConstants.WORKSPACE_REF);
fs.addChild(webinf);
String webInfLocation = XModelObjectUtil.expand(XModelConstants.WORKSPACE_REF, model, null);
- String webRootLocation = getWebRootPath(project, webInfLocation);
-
- XModelObject webroot = model.createModelObject("FileSystemFolder", null); //$NON-NLS-1$
- webroot.setAttributeValue("name", "WEB-ROOT"); //$NON-NLS-1$ //$NON-NLS-2$
- webroot.setAttributeValue("location", webRootLocation); //$NON-NLS-1$ //$NON-NLS-2$
- fs.addChild(webroot);
-
- XModelObject lib = model.createModelObject("FileSystemFolder", null); //$NON-NLS-1$
- lib.setAttributeValue("name", "lib"); //$NON-NLS-1$ //$NON-NLS-2$
- lib.setAttributeValue("location", XModelConstants.WORKSPACE_REF + "/lib"); //$NON-NLS-1$ //$NON-NLS-2$
+ List<String> webRootLocations = getWebRootPaths(project, webInfLocation);
+
+ int i = 0;
+ for (String webRootLocation: webRootLocations) {
+ String name = WEB_ROOT;
+ if(i > 0) name += "-" + i;
+ XModelObject webroot = createFileSystemFolder(model, name, webRootLocation);
+ fs.addChild(webroot);
+ i++;
+ }
+
+ XModelObject lib = createFileSystemFolder(model, "lib", XModelConstants.WORKSPACE_REF + "/lib"); //$NON-NLS-1$ //$NON-NLS-2$
fs.addChild(lib);
}
+ XModelObject createFileSystemFolder(XModel model, String name, String location) {
+ XModelObject f = model.createModelObject(ENT_FILE_SYSTEM_FOLDER, null);
+ f.setAttributeValue(ATTR_NAME, name);
+ f.setAttributeValue(ATTR_NAME_LOCATION, location);
+ return f;
+ }
+
- static String getWebRootPath(IProject project, String webInfLocation) {
- String webRootLocation = XModelConstants.WORKSPACE_REF + "/..";
+ public void update(XModel model) {
+ XModelObject fs = FileSystemsHelper.getFileSystems(model);
+ IProject project = EclipseResourceUtil.getProject(fs);
+ if(project == null) return;
+
+ String webInfLocation = XModelObjectUtil.expand(XModelConstants.WORKSPACE_REF, model, null);
+ List<String> webRootLocations = getWebRootPaths(project, webInfLocation);
+
+ boolean modified = false;
+ XModelObject webinf = fs.getChildByPath(WEB_INF);
+ String rWebInfLocation = getWebInfPath(project, webInfLocation);
+ if(rWebInfLocation != null) {
+ if(webinf != null && !rWebInfLocation.equals(webinf.getAttributeValue(ATTR_NAME_LOCATION))) {
+ webinf.removeFromParent();
+ webinf = null;
+ modified = true;
+ }
+ if(webinf == null) {
+ webinf = createFileSystemFolder(model, WEB_INF, rWebInfLocation);
+ fs.addChild(webinf);
+ modified = true;
+ }
+ } else if(webinf != null) {
+ webinf.removeFromParent();
+ modified = true;
+ }
+
+ List<XModelObject> existingRoots = getExistingWebRoots(fs);
+ boolean rootsChanged = rootsChanged(webRootLocations, existingRoots);
+ if(rootsChanged) {
+ modified = true;
+ for (XModelObject c: existingRoots) {
+ c.removeFromParent();
+ }
+ int i = 0;
+ for (String webRootLocation: webRootLocations) {
+ String name = WEB_ROOT;
+ if(i > 0) name += "-" + i;
+ XModelObject webroot = createFileSystemFolder(model, name, webRootLocation);
+ fs.addChild(webroot);
+ i++;
+ }
+ }
- IPath wrp = ProjectHome.getFirstWebContentPath(project);
- IPath wip = ProjectHome.getWebInfPath(project);
+ if(modified) {
+ ((XModelImpl)fs.getModel()).fireStructureChanged(fs);
+ WebProjectNode n = JSFProjectsTree.getProjectsRoot(model);
+ if(n != null) {
+ n.invalidate();
+ }
+ }
+ }
- if(wrp == null || wip == null) {
- return webRootLocation;
+ boolean rootsChanged(List<String> webRootLocations, List<XModelObject> rs) {
+ if(webRootLocations.size() != rs.size()) return true;
+ for (int i = 0; i < webRootLocations.size(); i++) {
+ String s = webRootLocations.get(i);
+ XModelObject o = rs.get(i);
+ if(!o.getAttributeValue(ATTR_NAME_LOCATION).equals(s)) {
+ return true;
+ }
}
-
- IResource wrpc = ResourcesPlugin.getWorkspace().getRoot().findMember(wrp);
- IResource wipc = ResourcesPlugin.getWorkspace().getRoot().findMember(wip);
- if(wrpc != null && wipc != null && wipc.isLinked()) {
- IPath p = wrpc.getLocation();
- if(p != null) {
- try {
- webRootLocation = p.toFile().getCanonicalPath().replace('\\', '/');
- } catch (IOException e) {
- }
- String relative = org.jboss.tools.common.util.FileUtil.getRelativePath(webInfLocation, webRootLocation);
+ return false;
+ }
+
+ List<XModelObject> getExistingWebRoots(XModelObject fs) {
+ List<XModelObject> result = new ArrayList<XModelObject>();
+ XModelObject[] cs = fs.getChildren(ENT_FILE_SYSTEM_FOLDER);
+ for (XModelObject c: cs) {
+ if(c.getAttributeValue(ATTR_NAME).startsWith(WEB_ROOT)) {
+ result.add(c);
+ }
+ }
+ return result;
+ }
+
+ static List<String> getWebRootPaths(IProject project, String webInfLocation) {
+ List<String> result = new ArrayList<String>();
+ IContainer[] cs = WebUtils.getWebRootFolders(project);
+ for (IContainer c: cs) {
+ IPath path = c.getLocation();
+ if(path == null) continue;
+ String webRootLocation = null;
+ try {
+ webRootLocation = path.toFile().getCanonicalPath().replace('\\', '/');
+ String relative = FileUtil.getRelativePath(webInfLocation, webRootLocation);
if(relative != null) {
webRootLocation = XModelConstants.WORKSPACE_REF + relative;
}
+ result.add(webRootLocation);
+ } catch (IOException e) {
+ continue;
}
}
- return webRootLocation;
+ return result;
}
+ static String getWebInfPath(IProject project, String webInfLocation) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if(component != null && component.getRootFolder() != null) {
+ IContainer[] cs = WebUtils.getWebRootFolders(project, true);
+ for (IContainer c: cs) {
+ if(c.exists()) {
+ IFolder f = c.getFolder(new Path("/WEB-INF")); //$NON-NLS-1$
+ if(f.exists()) {
+ try {
+ String location = f.getLocation().toFile().getCanonicalPath().replace('\\', '/');
+ String relative = FileUtil.getRelativePath(webInfLocation, location);
+ return (relative != null) ? XModelConstants.WORKSPACE_REF + relative : location;
+ } catch (IOException e) {
+ continue;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
+
}
13 years, 1 month
JBoss Tools SVN: r36465 - in trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model: project and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-11-18 20:12:43 -0500 (Fri, 18 Nov 2011)
New Revision: 36465
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ThreadSafeCopyFactory.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-10177
https://issues.jboss.org/browse/JBIDE-10177
JBIDE-812
https://issues.jboss.org/browse/JBIDE-812
Multiple web roots loaded into XModel.
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2011-11-19 01:09:55 UTC (rev 36464)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2011-11-19 01:12:43 UTC (rev 36465)
@@ -62,6 +62,12 @@
public boolean update(XModelObject object) throws XModelException {
boolean b = true;
+
+ IAutoLoad auto = (IAutoLoad)object.getModel().getProperties().get(XModelConstants.AUTOLOAD);
+ if(auto != null) {
+ auto.update(object.getModel());
+ }
+
XModelObject[] cs = object.getChildren();
for (int i = 0; i < cs.length; i++) {
XObjectLoader loader = XModelObjectLoaderUtil.getObjectLoader(cs[i]);
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ThreadSafeCopyFactory.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ThreadSafeCopyFactory.java 2011-11-19 01:09:55 UTC (rev 36464)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/ThreadSafeCopyFactory.java 2011-11-19 01:12:43 UTC (rev 36465)
@@ -63,7 +63,10 @@
if(copy != null) {
// System.out.println("Created copy of " + copy.getPath() + " for thread " + Thread.currentThread() + ". Main object is being loaded by thread " + loadingThread);
//Let us wait a bit for this object, maybe there is no lock.
- for (int i = 0; i < 50; i++) {
+ for (int i = 0; i < 5; i++) {
+ if(loadingThread != null && !loadingThread.isAlive()) {
+ loadingThread = null;
+ }
Thread t = loadingThread;
if (t != null) try {
t.join(100);
@@ -76,8 +79,12 @@
}
}
if(map == null) {
- map = new HashMap<Thread, XModelObject>();
- concurrentlyLoaded = map;
+ if(concurrentlyLoaded != null) {
+ map = concurrentlyLoaded;
+ } else {
+ map = new HashMap<Thread, XModelObject>();
+ concurrentlyLoaded = map;
+ }
}
map.put(Thread.currentThread(), (AbstractExtendedXMLFileImpl)copy);
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java 2011-11-19 01:09:55 UTC (rev 36464)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java 2011-11-19 01:12:43 UTC (rev 36465)
@@ -5,5 +5,6 @@
public interface IAutoLoad {
public void load(XModel model);
+ public void update(XModel model);
}
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2011-11-19 01:09:55 UTC (rev 36464)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2011-11-19 01:12:43 UTC (rev 36465)
@@ -70,6 +70,7 @@
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.project.ModelNature;
import org.jboss.tools.common.model.project.ModelNatureExtension;
+import org.jboss.tools.common.web.WebUtils;
import org.osgi.framework.Bundle;
public class EclipseResourceUtil extends EclipseUtil {
@@ -457,10 +458,16 @@
IVirtualComponent vc = ComponentCore.createComponent(project);
if (vc == null || vc.getRootFolder() == null)
return null;
+ IPath path = WebUtils.getFirstWebContentPath(project);
+ if(path != null) {
+ IFolder f = ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
+ if(f.exists()) {
+ return f;
+ }
+ }
if (ModuleCoreNature.isFlexibleProject(project)) {
return vc.getRootFolder().getUnderlyingResource();
}
-
return null;
}
13 years, 1 month
JBoss Tools SVN: r36464 - in trunk/seam/tests/org.jboss.tools.seam.ui.test: src/org/jboss/tools/seam/ui/test/view and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2011-11-18 20:09:55 -0500 (Fri, 18 Nov 2011)
New Revision: 36464
Modified:
trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
Log:
JBIDE-10195
https://issues.jboss.org/browse/JBIDE-10195
Seam 2 Components view should show Seam 2 project when it is opened in new window. Test added.
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2011-11-19 00:53:14 UTC (rev 36463)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2011-11-19 01:09:55 UTC (rev 36464)
@@ -45,7 +45,25 @@
org.jboss.tools.jst.web,
org.eclipse.jst.jee.web,
org.jboss.tools.jst.text.ext.test,
- org.jboss.tools.jst.web.kb.test
+ org.jboss.tools.jst.web.kb.test,
+ org.eclipse.jst.servlet.ui;bundle-version="1.1.500",
+ org.hibernate.eclipse.console,
+ org.eclipse.jst.j2ee.ui;bundle-version="1.1.500",
+ org.eclipse.wst.xml.ui;bundle-version="1.1.200",
+ org.apache.ant;bundle-version="1.7.1",
+ org.eclipse.datatools.connectivity.ui.dse;bundle-version="1.1.4",
+ org.eclipse.datatools.connectivity.db.generic.ui;bundle-version="1.0.1",
+ org.jboss.tools.common.model.ui,
+ org.hibernate.eclipse,
+ org.eclipse.wst.server.core;bundle-version="1.1.302",
+ org.eclipse.wst.server.ui;bundle-version="1.1.305",
+ org.eclipse.debug.ui;bundle-version="3.7.0",
+ org.eclipse.search;bundle-version="3.6.100",
+ org.eclipse.ltk.core.refactoring;bundle-version="3.5.200",
+ org.eclipse.ltk.ui.refactoring;bundle-version="3.5.100",
+ org.jboss.ide.eclipse.as.core,
+ org.jboss.tools.jsf,
+ org.eclipse.jst.j2ee.web;bundle-version="1.1.500"
Export-Package: org.jboss.tools.seam.ui.test,
org.jboss.tools.seam.ui.test.ca,
org.jboss.tools.seam.ui.test.hyperlink,
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2011-11-19 00:53:14 UTC (rev 36463)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/view/SeamComponentsViewTest.java 2011-11-19 01:09:55 UTC (rev 36464)
@@ -84,6 +84,22 @@
this.project.build(IncrementalProjectBuilder.FULL_BUILD, null);
JobUtils.waitForIdle();
}
+
+ public void testViewInNewWindow() throws CoreException{
+ int itemCount = 0;
+ SeamCorePlugin.getSeamProject(project, true);
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchPage page = workbench.getActiveWorkbenchWindow().openPage(SeamPerspectiveFactory.PERSPECTIVE_ID, project);
+ try {
+ CommonNavigator navigator = getSeamComponentsView();
+ navigator.getCommonViewer().expandAll();
+ Tree tree = navigator.getCommonViewer().getTree();
+ itemCount = tree.getItemCount();
+ } finally {
+ page.getWorkbenchWindow().close();
+ }
+ assertEquals(1, itemCount);
+ }
public void testAddComponentInXmlFile() throws CoreException{
CommonNavigator navigator = getSeamComponentsView();
13 years, 1 month
JBoss Tools SVN: r36463 - in branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes: lib and 11 other directories.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-11-18 19:53:14 -0500 (Fri, 18 Nov 2011)
New Revision: 36463
Added:
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/dom4j-1.6.1.jar
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/hibernate-core-4.0.0.CR6.jar
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/HibernateUtil.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/PeopleManager.java
Removed:
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/hibernate3.jar
Modified:
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/hibernate.cfg.xml
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/hql/ClassificationType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/instrument/domain/CustomBlobType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/CustomPersister.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/DoubleStringType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/MultiplicityType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/rowid/RowIdType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java
Log:
sampleproject.project mappingtypes migrated to hibernate4
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath 2011-11-19 00:53:14 UTC (rev 36463)
@@ -2,6 +2,7 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/hibernate3.jar"/>
+ <classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
+ <classpathentry kind="lib" path="lib/hibernate-core-4.0.0.CR6.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/dom4j-1.6.1.jar
===================================================================
(Binary files differ)
Property changes on: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/dom4j-1.6.1.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/hibernate-core-4.0.0.CR6.jar
===================================================================
(Binary files differ)
Property changes on: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/hibernate-core-4.0.0.CR6.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/hibernate3.jar
===================================================================
(Binary files differ)
Added: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/HibernateUtil.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/HibernateUtil.java (rev 0)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/HibernateUtil.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -0,0 +1,28 @@
+import org.hibernate.SessionFactory;
+import org.hibernate.cfg.Configuration;
+import org.hibernate.service.ServiceRegistryBuilder;
+
+public class HibernateUtil {
+
+ private static final SessionFactory sessionFactory = buildSessionFactory();
+
+ private static SessionFactory buildSessionFactory() {
+ try {
+ // Create the SessionFactory from hibernate.cfg.xml
+ return new Configuration().configure().buildSessionFactory(new ServiceRegistryBuilder()
+ .configure().buildServiceRegistry());
+// return new MetadataSources(new ServiceRegistryBuilder()
+// .configure().buildServiceRegistry()).buildMetadata().buildSessionFactory();
+
+ }
+ catch (Throwable ex) {
+ // Make sure you log the exception, as it might be swallowed
+ System.err.println("Initial SessionFactory creation failed." + ex);
+ throw new ExceptionInInitializerError(ex);
+ }
+ }
+
+ public static SessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+}
\ No newline at end of file
Property changes on: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/HibernateUtil.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/PeopleManager.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/PeopleManager.java (rev 0)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/PeopleManager.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -0,0 +1,28 @@
+import mapping.compositeelement.*;
+
+import org.hibernate.Session;
+
+import java.util.*;
+
+ public class PeopleManager {
+
+ public static void main(String[] args) {
+ PeopleManager mgr = new PeopleManager();
+ mgr.createAndStoreParent();
+ HibernateUtil.getSessionFactory().close();
+ }
+
+ private void createAndStoreParent() {
+ HibernateUtil.getSessionFactory().openSession();
+ Session session = HibernateUtil.getSessionFactory().getCurrentSession();
+ session.beginTransaction();
+
+ Parent theParent = new Parent("Parent2");
+ theParent.getChildren().add(new Child("Child1"));
+ theParent.getChildren().add(new Child("Child2"));
+ session.save(theParent);
+ session.getTransaction().commit();
+ }
+
+
+ }
\ No newline at end of file
Property changes on: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/PeopleManager.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/hibernate.cfg.xml
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/hibernate.cfg.xml 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/hibernate.cfg.xml 2011-11-19 00:53:14 UTC (rev 36463)
@@ -1,473 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE hibernate-configuration PUBLIC
- "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
-<hibernate-configuration>
- <session-factory>
- <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
+<p:hibernate-configuration xmlns:p="http://www.hibernate.org/xsd/hibernate-configuration" xmlns="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration /home/eskimo/Java/hibernate-release-4.0.0.CR5/project/hibernate-core/src/main/resources/org/hibernate/hibernate-configuration-4.0.xsd" >
+ <p:session-factory>
+ <!-- Database connection settings -->
+ <p:property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</p:property>
+ <p:property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost:1701</p:property>
+ <p:property name="hibernate.connection.username">sa</p:property>
+ <p:property name="hibernate.connection.password"></p:property>
-<!--
- <mapping resource="mapping/declaration/id/MappedClassWithId.hbm.xml"/>
- <mapping resource="mapping/declaration/id/MappedClassWithoutId.hbm.xml"/>
- <mapping resource="mapping/declaration/id/composite/v1/KeyManyToOneClass.hbm.xml"/>
- <mapping resource="mapping/declaration/id/composite/v1/mapping.hbm.xml"/>
- <mapping resource="mapping/declaration/id/composite/v2/mapping.hbm.xml"/>
- <mapping resource="mapping/value/type/collection/list/CollectionList.hbm.xml"/>
- <mapping resource="mapping/value/type/collection/list/CollectionListItem.hbm.xml"/>
- <mapping resource="mapping/value/type/collection/map/CollectionListMap.hbm.xml"/>
- <mapping resource="mapping/value/type/collection/map/CollectionMap.hbm.xml"/>
- <mapping resource="mapping/value/type/collection/map/CollectionMapMany.hbm.xml"/>
- <mapping resource="mapping/value/type/collection/set/CollectionSet.hbm.xml"/>
- <mapping resource="mapping/value/type/collection/set/CollectionSetItem.hbm.xml"/>
+ <!-- JDBC connection pool (use the built-in) -->
+ <p:property name="hibernate.connection.pool_size">1</p:property>
- <mapping resource="mapping/abstractembeddedcomponents/cid/abstractembeddedcomponents.cid.hbm.xml"/>
- <mapping resource="mapping/abstractembeddedcomponents/propertyref/Mappings.hbm.xml"/>
+ <!-- SQL dialect -->
+ <p:property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</p:property>
- <mapping resource="mapping/any/Person.hbm.xml"/>
- <mapping resource="mapping/any/Properties.hbm.xml"/>
+ <!-- Enable Hibernate's automatic session context management -->
+ <p:property name="hibernate.current_session_context_class">thread</p:property>
- <mapping resource="mapping/array/A.hbm.xml"/>
+ <!-- Disable the second-level cache -->
+ <p:property name="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</p:property>
- <mapping resource="mapping/batch/DataPoint.hbm.xml"/>
+ <!-- Echo all executed SQL to stdout -->
+ <p:property name="hibernate.show_sql">true</p:property>
- <mapping resource="mapping/batchfetch/ProductLine.hbm.xml"/>
+ <!-- Drop and re-create the database schema on startup -->
+ <p:property name="hibernate.hbm2ddl.auto">update</p:property>
- <mapping resource="mapping/bidi/Auction.hbm.xml"/>
- <mapping resource="mapping/bidi/Auction2.hbm.xml"/>
-
- <mapping resource="mapping/bytecode/Bean.hbm.xml"/>
-
- <mapping resource="mapping/cache/Item.hbm.xml"/>
-
- <mapping resource="mapping/cascade/Job.hbm.xml"/>
- <mapping resource="mapping/cascade/JobBatch.hbm.xml"/>
-
- <mapping resource="mapping/cid/Customer.hbm.xml"/>
- <mapping resource="mapping/cid/LineItem.hbm.xml"/>
- <mapping resource="mapping/cid/Order.hbm.xml"/>
- <mapping resource="mapping/cid/Product.hbm.xml"/>
-
- <mapping resource="mapping/collection/bag/Mappings.hbm.xml"/>
- <mapping resource="mapping/collection/idbag/Mappings.hbm.xml"/>
- <mapping resource="mapping/collection/list/Mappings.hbm.xml"/>
- <mapping resource="mapping/collection/map/Mappings.hbm.xml"/>
- <mapping resource="mapping/collection/original/UserPermissions.hbm.xml"/>
- <mapping resource="mapping/collection/set/Mappings.hbm.xml"/>
-
- <mapping resource="mapping/component/basic/User.hbm.xml"/>
- <mapping resource="mapping/component/cascading/collection/Mappings.hbm.xml"/>
- <mapping resource="mapping/component/cascading/toone/Mappings.hbm.xml"/>
-
- <mapping resource="mapping/compositeelement/Parent.hbm.xml"/>
-
- <mapping resource="mapping/connections/Silly.hbm.xml"/>
-
- <mapping resource="mapping/criteria/Enrolment.hbm.xml"/>
-
- <mapping resource="mapping/cuk/Person.hbm.xml"/>
- <mapping resource="mapping/cut/Transaction.hbm.xml"/>
- <mapping resource="mapping/cut/types.hbm.xml"/>
-
- <mapping resource="mapping/deletetransient/Person.hbm.xml"/>
-
- <mapping resource="mapping/dialect/functional/cache/TestInterSystemsFunctionsClass.hbm.xml"/>
-
- <mapping resource="mapping/discriminator/Person.hbm.xml"/>
-
--->
- <mapping resource="mapping/dynamicentity/interceptor/Customer.hbm.xml"/>
-<!--
- <mapping resource="mapping/dynamicentity/tuplizer/Customer.hbm.xml"/>
-
- <mapping resource="mapping/ecid/Course.hbm.xml"/>
-
- <mapping resource="mapping/entitymode/dom4j/many2one/Car.hbm.xml"/>
-
- <mapping resource="mapping/entitymode/multi/Stock.hbm.xml"/>
- <mapping resource="mapping/entitymode/multi/Valuation.hbm.xml"/>
-
- <mapping resource="mapping/entitymode/dom4j/basic/AB.hbm.xml"/>
- <mapping resource="mapping/entitymode/dom4j/basic/Account.hbm.xml"/>
- <mapping resource="mapping/entitymode/dom4j/basic/Employer.hbm.xml"/>
-
- <mapping resource="mapping/exception/Group.hbm.xml"/>
- <mapping resource="mapping/exception/User.hbm.xml"/>
-
- <mapping resource="mapping/extendshbm/allinone.hbm.xml"/>
- <mapping resource="mapping/extendshbm/allseparateinone.hbm.xml"/>
- <mapping resource="mapping/extendshbm/Customer.hbm.xml"/>
- <mapping resource="mapping/extendshbm/Employee.hbm.xml"/>
- <mapping resource="mapping/extendshbm/entitynames.hbm.xml"/>
- <mapping resource="mapping/extendshbm/packageentitynames.hbm.xml"/>
- <mapping resource="mapping/extendshbm/Person.hbm.xml"/>
- <mapping resource="mapping/extendshbm/unionsubclass.hbm.xml"/>
-
- <mapping resource="mapping/extralazy/UserGroup.hbm.xml"/>
-
- <mapping resource="mapping/filter/Category.hbm.xml"/>
- <mapping resource="mapping/filter/defs.hbm.xml"/>
- <mapping resource="mapping/filter/Department.hbm.xml"/>
- <mapping resource="mapping/filter/LineItem.hbm.xml"/>
- <mapping resource="mapping/filter/Order.hbm.xml"/>
- <mapping resource="mapping/filter/Product.hbm.xml"/>
- <mapping resource="mapping/filter/Salesperson.hbm.xml"/>
-
- <mapping resource="mapping/formulajoin/Master.hbm.xml"/>
-
- <mapping resource="mapping/generated/ComponentOwner.hbm.xml"/>
- <mapping resource="mapping/generated/GeneratedPropertyEntity.hbm.xml"/>
- <mapping resource="mapping/generated/MSSQLGeneratedPropertyEntity.hbm.xml"/>
-
- <mapping resource="mapping/generatedkeys/identity/MyEntity.hbm.xml"/>
-
- <mapping resource="mapping/generatedkeys/select/MyEntity.hbm.xml"/>
-
- <mapping resource="mapping/generatedkeys/seqidentity/MyEntity.hbm.xml"/>
-
- <mapping resource="mapping/hql/Animal.hbm.xml"/>
- <mapping resource="mapping/hql/BooleanLiteralEntity.hbm.xml"/>
- <mapping resource="mapping/hql/ComponentContainer.hbm.xml"/>
- <mapping resource="mapping/hql/CrazyIdFieldNames.hbm.xml"/>
- <mapping resource="mapping/hql/WithCrazyCompositeKey.hbm.xml"/>
- <mapping resource="mapping/hql/FooBarCopy.hbm.xml"/>
- <mapping resource="mapping/hql/KeyManyToOneEntity.hbm.xml"/>
- <mapping resource="mapping/hql/SimpleEntityWithAssociation.hbm.xml"/>
- <mapping resource="mapping/hql/SimpleEntityWithAssociation.hbm.xml"/>
- <mapping resource="mapping/hql/Vehicle.hbm.xml"/>
- <mapping resource="mapping/hql/Versions.hbm.xml"/>
-
- <mapping resource="mapping/id/Car.hbm.xml"/>
- <mapping resource="mapping/id/Plane.hbm.xml"/>
- <mapping resource="mapping/id/Product.hbm.xml"/>
- <mapping resource="mapping/id/Radio.hbm.xml"/>
-
- <mapping resource="mapping/idbag/UserGroup.hbm.xml"/>
-
- <mapping resource="mapping/idclass\Customer.hbm.xml"/>
-
- <mapping resource="mapping\idgen\enhanced\forcedtable\Basic.hbm.xml"/>
- <mapping resource="mapping\idgen\enhanced\forcedtable\HiLo.hbm.xml"/>
- <mapping resource="mapping\idgen\enhanced\forcedtable\Pooled.hbm.xml"/>
-
- <mapping resource="mapping\idgen\enhanced\sequence\Basic.hbm.xml"/>
- <mapping resource="mapping\idgen\enhanced\sequence\HiLo.hbm.xml"/>
- <mapping resource="mapping\idgen\enhanced\sequence\Pooled.hbm.xml"/>
-
- <mapping resource="mapping\idgen\enhanced\table\Basic.hbm.xml"/>
- <mapping resource="mapping\idgen\enhanced\table\HiLo.hbm.xml"/>
- <mapping resource="mapping\idgen\enhanced\table\Pooled.hbm.xml"/>
-
- <mapping resource="mapping\idprops\Mapping.hbm.xml"/>
-
- <mapping resource="mapping\immutable\ContractVariation.hbm.xml"/>
-
- <mapping resource="mapping\insertordering\Mapping.hbm.xml"/>
-
- <mapping resource="mapping\instrument\domain\Documents.hbm.xml"/>
- <mapping resource="mapping\instrument\domain\Problematic.hbm.xml"/>
-
- <mapping resource="mapping\interceptor\Image.hbm.xml"/>
- <mapping resource="mapping\interceptor\User.hbm.xml"/>
-
- <mapping resource="mapping\interfaceproxy\Item.hbm.xml"/>
-
- <mapping resource="mapping\iterate\Item.hbm.xml"/>
-
- <mapping resource="mapping\join\Person.hbm.xml"/>
-
- <mapping resource="mapping\joinedsubclass\Person.hbm.xml"/>
-
- <mapping resource="mapping\joinfetch\ItemBid.hbm.xml"/>
- <mapping resource="mapping\joinfetch\UserGroup.hbm.xml"/>
-
- <mapping resource="mapping\jpa\Item.hbm.xml"/>
- <mapping resource="mapping\jpa\MyEntity.hbm.xml"/>
- <mapping resource="mapping\jpa\Part.hbm.xml"/>
-
- <mapping resource="mapping\jpa\cascade\ParentChild.hbm.xml"/>
-
- <mapping resource="mapping\jpa\fetch\Person.hbm.xml"/>
-
- <mapping resource="mapping\keymanytoone\bidir\component\EagerMapping.hbm.xml"/>
- <mapping resource="mapping\keymanytoone\bidir\component\LazyMapping.hbm.xml"/>
-
- <mapping resource="mapping\keymanytoone\bidir\embedded\Mapping.hbm.xml"/>
-
- <mapping resource="mapping\lazycache\Documents.hbm.xml"/>
-
- <mapping resource="mapping\lazyonetoone\Person.hbm.xml"/>
-
-
-
-
-
-
- <mapping resource="mapping\legacy\ABC.hbm.xml"/>
- <mapping resource="mapping\legacy\ABCExtends.hbm.xml"/>
-
- <mapping resource="mapping\legacy\ABCProxy.hbm.xml"/>
-
- <mapping resource="mapping\legacy\AltSimple.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Baz.hbm.xml"/>
- <mapping resource="mapping\legacy\FooBar.hbm.xml"/>
- <mapping resource="mapping\legacy\Glarch.hbm.xml"/>
- <mapping resource="mapping\legacy\Fee.hbm.xml"/> java.lang.NullPointerException at org.hibernate.mapping.ManyToOne.createPropertyRefConstraints(ManyToOne.java:47)
- <mapping resource="mapping\legacy\Fum.hbm.xml"/>
- <mapping resource="mapping\legacy\Qux.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Blobber.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Broken.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Category.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Circular.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Commento.hbm.xml"/>
- <mapping resource="mapping\legacy\Marelo.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Componentizable.hbm.xml"/>
-
- <mapping resource="mapping\legacy\ComponentNotNullMaster.hbm.xml"/> org.hibernate.MappingException: component class not found: mapping.legacy.ComponentNotNullMaster$ContainerInnerClass
- <mapping resource="mapping\legacy\Many.hbm.xml"/>
- <mapping resource="mapping\legacy\Simple.hbm.xml"/>
- <mapping resource="mapping\legacy\One.hbm.xml"/>
-
- <mapping resource="mapping\legacy\CompositeIdId.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Container.hbm.xml"/> org.hibernate.MappingException: java.lang.ClassNotFoundException: mapping.legacy.GlarchProxy
- <mapping resource="mapping\legacy\Simple.hbm.xml"/>
- <mapping resource="mapping\legacy\Holder.hbm.xml"/>
- <mapping resource="mapping\legacy\Many.hbm.xml"/>
- <mapping resource="mapping\legacy\One.hbm.xml"/>
- <mapping resource="mapping\legacy\FooBar.hbm.xml"/>
- <mapping resource="mapping\legacy\Glarch.hbm.xml"/>
- <mapping resource="mapping\legacy\Baz.hbm.xml"/>
- <mapping resource="mapping\legacy\Fee.hbm.xml"/>
- <mapping resource="mapping\legacy\Qux.hbm.xml"/>
- <mapping resource="mapping\legacy\Fum.hbm.xml"/>
- <mapping resource="mapping\legacy\Simple.hbm.xml"/>
- <mapping resource="mapping\legacy\Many.hbm.xml"/>
- <mapping resource="mapping\legacy\One.hbm.xml"/>
- <mapping resource="mapping\legacy\Glarch.hbm.xml"/>
- <mapping resource="mapping\legacy\Fee.hbm.xml"/>
- <mapping resource="mapping\legacy\Qux.hbm.xml"/>
- <mapping resource="mapping\legacy\Fum.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Custom.hbm.xml"/>
-
- <mapping resource="mapping\legacy\CustomSQL.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Eye.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Fo.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Fumm.hbm.xml"/>
- <mapping resource="mapping\legacy\Fum.hbm.xml"/>
- <mapping resource="mapping\legacy\Qux.hbm.xml"/>
-
- <mapping resource="mapping\legacy\IJ.hbm.xml"/>
-
- <mapping resource="mapping\legacy\IJ2.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Immutable.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Location.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Map.hbm.xml"/>
-
- <mapping resource="mapping\legacy\MasterDetail.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Middle.hbm.xml"/>
-
- <mapping resource="mapping\legacy\MultiExtends.hbm.xml"/>
- <mapping resource="mapping\legacy\Multi.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Nameable.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Object2.hbm.xml"/>
- <mapping resource="mapping\legacy\MainObject.hbm.xml"/>
-
- <mapping resource="mapping\legacy\ParentChild.hbm.xml"/>
-
- <mapping resource="mapping\legacy\SingleSeveral.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Stuff.hbm.xml"/>
- <mapping resource="mapping\legacy\FooBar.hbm.xml"/>
- <mapping resource="mapping\legacy\Glarch.hbm.xml"/>
- <mapping resource="mapping\legacy\Baz.hbm.xml"/>
- <mapping resource="mapping\legacy\Fee.hbm.xml"/>
- <mapping resource="mapping\legacy\Qux.hbm.xml"/>
- <mapping resource="mapping\legacy\Fum.hbm.xml"/>
-
- <mapping resource="mapping\legacy\UpDown.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Vetoer.hbm.xml"/>
-
- <mapping resource="mapping\legacy\Wicked.hbm.xml"/>
-
- <mapping resource="mapping\legacy\WZ.hbm.xml"/>
-
- <mapping resource="mapping\legacy\XY.hbm.xml"/>
-
-
-
-
- <mapping resource="mapping\lob\LobMappings.hbm.xml"/>
-
- <mapping resource="mapping\manytomany\UserGroup.hbm.xml"/>
-
- <mapping resource="mapping\manytomany\ordered\UserGroup.hbm.xml"/>
-
- <mapping resource="mapping\map\UserGroup.hbm.xml"/>
-
- <mapping resource="mapping\mapcompelem\ProductPart.hbm.xml"/>
-
- <mapping resource="mapping\mapelemformula\UserGroup.hbm.xml"/>
-
- <mapping resource="mapping\mappingexception\InvalidMapping.hbm.xml"/>
- <mapping resource="mapping\mappingexception\User.hbm.xml"/>
-
- <mapping resource="mapping\mixed\Item.hbm.xml"/>
-
- <mapping resource="mapping\naturalid\User.hbm.xml"/>
-
- <mapping resource="mapping\ondelete\Person.hbm.xml"/>
-
- <mapping resource="mapping\onetomany\Parent.hbm.xml"/>
-
- <mapping resource="mapping\onetoone\formula\Person.hbm.xml"/>
-
- <mapping resource="mapping\onetoone\joined\Person.hbm.xml"/>
-
- <mapping resource="mapping\onetoone\link\Person.hbm.xml"/>
-
- <mapping resource="mapping\onetoone\nopojo\Person.hbm.xml"/>
-
- <mapping resource="mapping\onetoone\optional\Person.hbm.xml"/>
-
- <mapping resource="mapping\onetoone\singletable\Person.hbm.xml"/>
-
- <mapping resource="mapping\ops\Competition.hbm.xml"/>
- <mapping resource="mapping\ops\Employer.hbm.xml"/>
- <mapping resource="mapping\ops\Node.hbm.xml"/>
- <mapping resource="mapping\ops\OneToOne.hbm.xml"/>
- <mapping resource="mapping\ops\OptLockEntity.hbm.xml"/>
-
- <mapping resource="mapping\optlock\Document.hbm.xml"/>
-
- <mapping resource="mapping\ordered\Search.hbm.xml"/>
-
- <mapping resource="mapping\orphan\Mail.hbm.xml"/>
- <mapping resource="mapping\orphan\Product.hbm.xml"/>
- <mapping resource="mapping\orphan\User.hbm.xml"/>
-
- <mapping resource="mapping\pagination\DataPoint.hbm.xml"/>
-
- <mapping resource="mapping\propertyref\basic\Person.hbm.xml"/>
-
- <mapping resource="mapping\propertyref\component\complete\Mapping.hbm.xml"/>
-
- <mapping resource="mapping\propertyref\component\partial\Mapping.hbm.xml"/>
-
- <mapping resource="mapping\propertyref\inheritence\discrim\Person.hbm.xml"/>
-
- <mapping resource="mapping\propertyref\inheritence\joined\Person.hbm.xml"/>
-
- <mapping resource="mapping\propertyref\inheritence\union\Person.hbm.xml"/>
-
- <mapping resource="mapping\proxy\DataPoint.hbm.xml"/>
-
- <mapping resource="mapping\querycache\Item.hbm.xml"/>
-
- <mapping resource="mapping\readonly\DataPoint.hbm.xml"/>
-
- <mapping resource="mapping\reattachment\Mappings.hbm.xml"/>
-
- <mapping resource="mapping\rowid\Point.hbm.xml"/>
-
- <mapping resource="mapping\schemaupdate\1_Version.hbm.xml"/>
- <mapping resource="mapping\schemaupdate\2_Version.hbm.xml"/>
-
- <mapping resource="mapping\sorted\Search.hbm.xml"/>
-
- <mapping resource="mapping\sql\check\oracle-mappings.hbm.xml"/>
-
- <mapping resource="mapping\sql\hand\custom\datadirect\oracle\StoredProcedures.hbm.xml"/>
-
- <mapping resource="mapping\stateless\Document.hbm.xml"/>
-
- <mapping resource="mapping\stats\Continent.hbm.xml"/>
- <mapping resource="mapping\stats\Continent2.hbm.xml"/>
-
- <mapping resource="mapping\subclassfilter\discrim-subclass.hbm.xml"/>
- <mapping resource="mapping\subclassfilter\joined-subclass.hbm.xml"/>
- <mapping resource="mapping\subclassfilter\union-subclass.hbm.xml"/>
-
- <mapping resource="mapping\subselect\Beings.hbm.xml"/>
-
- <mapping resource="mapping\subselectfetch\ParentChild.hbm.xml"/>
-
- <mapping resource="mapping\ternary\Ternary.hbm.xml"/>
-
- <mapping resource="mapping\ternary\Ternary.hbm.xml"/>
-
- <mapping resource="mapping\timestamp\User.hbm.xml"/>
-
- <mapping resource="mapping\tm\Item.hbm.xml"/>
-
- <mapping resource="mapping\tool\Team.hbm.xml"/>
-
- <mapping resource="mapping\typedmanytoone\Customer.hbm.xml"/>
-
- <mapping resource="mapping\typedonetoone\Customer.hbm.xml"/>
-
- <mapping resource="mapping\typeparameters\Typedef.hbm.xml"/>
- <mapping resource="mapping\typeparameters\Widget.hbm.xml"/>
-
- <mapping resource="mapping\unconstrained\Person.hbm.xml"/>
-
- <mapping resource="mapping\unidir\ParentChild.hbm.xml"/>
-
- <mapping resource="mapping\unionsubclass\Beings.hbm.xml"/>
-
- <mapping resource="mapping\unionsubclass2\Person.hbm.xml"/>
-
- <mapping resource="mapping\usercollection\basic\UserPermissions.hbm.xml"/>
-
- <mapping resource="mapping\usercollection\parameterized\Mapping.hbm.xml"/>
-
- <mapping resource="mapping\util\dtd\Parent.hbm.xml"/>
-
- <mapping resource="mapping\version\PersonThing.hbm.xml"/>
-
- <mapping resource="mapping\version\db\User.hbm.xml"/>
-
- <mapping resource="mapping\where\File.hbm.xml"/>
- -->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<!--
- <mapping resource="mapping/propertyref/inheritence/joined/Person.hbm.xml"/>
--->
-
- </session-factory>
-</hibernate-configuration>
+ <p:mapping resource="mapping/onetomany/Parent.hbm.xml"/>
+
+ </p:session-factory>
+
+</p:hibernate-configuration>
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.hbm.xml 2011-11-19 00:53:14 UTC (rev 36463)
@@ -1,17 +1,8 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<!--
-
- This mapping demonstrates how to use a composite
- element mapping to model a parent/child association.
-
--->
-
-<hibernate-mapping
- package="mapping.compositeelement">
+ "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="mapping.compositeelement">
<import class="Child"/>
@@ -31,6 +22,4 @@
</composite-element>
</set>
</class>
-
-
</hibernate-mapping>
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/compositeelement/Parent.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -11,7 +11,7 @@
private Long id;
private String name;
private Collection children = new HashSet();
- Parent() {}
+ public Parent() {}
public Parent(String name) {
this.name = name;
}
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/cut/MonetoryAmountUserType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -10,7 +10,9 @@
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.type.BigDecimalType;
+import org.hibernate.type.CurrencyType;
import org.hibernate.type.Type;
import org.hibernate.usertype.CompositeUserType;
@@ -24,7 +26,7 @@
}
public Type[] getPropertyTypes() {
- return new Type[] { Hibernate.BIG_DECIMAL, Hibernate.CURRENCY };
+ return new Type[] { BigDecimalType.INSTANCE, CurrencyType.INSTANCE };
}
public Object getPropertyValue(Object component, int property) throws HibernateException {
@@ -62,8 +64,8 @@
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
throws HibernateException, SQLException {
- BigDecimal amt = (BigDecimal) Hibernate.BIG_DECIMAL.nullSafeGet( rs, names[0] );
- Currency cur = (Currency) Hibernate.CURRENCY.nullSafeGet( rs, names[1] );
+ BigDecimal amt = (BigDecimal) BigDecimalType.INSTANCE.nullSafeGet( rs, names[0],session );
+ Currency cur = (Currency) CurrencyType.INSTANCE.nullSafeGet( rs, names[1], session );
if (amt==null) return null;
return new MonetoryAmount(amt, cur);
}
@@ -73,8 +75,8 @@
MonetoryAmount ma = (MonetoryAmount) value;
BigDecimal amt = ma == null ? null : ma.getAmount();
Currency cur = ma == null ? null : ma.getCurrency();
- Hibernate.BIG_DECIMAL.nullSafeSet(st, amt, index);
- Hibernate.CURRENCY.nullSafeSet(st, cur, index+1);
+ BigDecimalType.INSTANCE.nullSafeSet(st, amt, index, session);
+ CurrencyType.INSTANCE.nullSafeSet(st, cur, index+1, session);
}
public Object deepCopy(Object value) throws HibernateException {
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/hql/ClassificationType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/hql/ClassificationType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/hql/ClassificationType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -1,5 +1,7 @@
package mapping.hql;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.type.IntegerType;
import org.hibernate.usertype.EnhancedUserType;
import org.hibernate.HibernateException;
import org.hibernate.Hibernate;
@@ -45,14 +47,14 @@
return x.hashCode();
}
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
- Integer ordinal = ( Integer ) Hibernate.INTEGER.nullSafeGet( rs, names[0] );
+ public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException {
+ Integer ordinal = ( Integer ) IntegerType.INSTANCE.nullSafeGet( rs, names[0], session);
return Classification.valueOf( ordinal );
}
- public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
+ public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException {
Integer ordinal = value == null ? null : new Integer( ( ( Classification ) value ).ordinal() );
- Hibernate.INTEGER.nullSafeSet( st, ordinal, index );
+ IntegerType.INSTANCE.nullSafeSet( st, ordinal, index, session );
}
public Object deepCopy(Object value) throws HibernateException {
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/instrument/domain/CustomBlobType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/instrument/domain/CustomBlobType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/instrument/domain/CustomBlobType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -9,6 +9,8 @@
import org.hibernate.HibernateException;
import org.hibernate.Hibernate;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.type.BinaryType;
import org.hibernate.usertype.UserType;
/**
@@ -18,17 +20,17 @@
/**
* {@inheritDoc}
*/
- public Object nullSafeGet(ResultSet rs, String names[], Object owner) throws SQLException {
+ public Object nullSafeGet(ResultSet rs, String names[], SessionImplementor session, Object owner) throws SQLException {
// cast just to make sure...
- return ( byte[] ) Hibernate.BINARY.nullSafeGet( rs, names );
+ return ( byte[] ) BinaryType.INSTANCE.nullSafeGet( rs, names[0], session );
}
/**
* {@inheritDoc}
*/
- public void nullSafeSet(PreparedStatement ps, Object value, int index) throws SQLException, HibernateException {
+ public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session) throws SQLException, HibernateException {
// cast just to make sure...
- Hibernate.BINARY.nullSafeSet( ps, ( byte[] ) value, index );
+ BinaryType.INSTANCE.nullSafeSet( ps, ( byte[] ) value, index,session );
}
/**
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/CustomPersister.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/CustomPersister.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/CustomPersister.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -2,37 +2,43 @@
package mapping.legacy;
import java.io.Serializable;
+import java.util.Comparator;
import java.util.Hashtable;
import java.util.Map;
-import java.util.Comparator;
import org.hibernate.EntityMode;
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
import org.hibernate.LockMode;
+import org.hibernate.LockOptions;
import org.hibernate.MappingException;
-import org.hibernate.cache.CacheConcurrencyStrategy;
-import org.hibernate.cache.entry.CacheEntryStructure;
-import org.hibernate.cache.entry.UnstructuredCacheEntry;
-import org.hibernate.engine.CascadeStyle;
-import org.hibernate.engine.EntityKey;
-import org.hibernate.engine.Mapping;
-import org.hibernate.engine.SessionFactoryImplementor;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.engine.TwoPhaseLoad;
-import org.hibernate.event.EventSource;
-import org.hibernate.event.PostLoadEvent;
-import org.hibernate.event.PreLoadEvent;
+import org.hibernate.annotations.CacheConcurrencyStrategy;
+import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.spi.entry.CacheEntryStructure;
+import org.hibernate.cache.spi.entry.UnstructuredCacheEntry;
+import org.hibernate.engine.internal.TwoPhaseLoad;
+import org.hibernate.engine.spi.CascadeStyle;
+import org.hibernate.engine.spi.EntityKey;
+import org.hibernate.engine.spi.Mapping;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.engine.spi.ValueInclusion;
+import org.hibernate.event.spi.EventSource;
+import org.hibernate.event.spi.PostLoadEvent;
+import org.hibernate.event.spi.PreLoadEvent;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.UUIDHexGenerator;
+import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.sql.QuerySelect;
import org.hibernate.sql.Select;
+import org.hibernate.tuple.entity.EntityMetamodel;
+import org.hibernate.tuple.entity.EntityTuplizer;
+import org.hibernate.type.StringType;
import org.hibernate.type.Type;
import org.hibernate.type.VersionType;
-import org.hibernate.util.EqualsHelper;
public class CustomPersister implements EntityPersister {
@@ -111,7 +117,7 @@
public Object[] getPropertyValuesToInsert(Object object, Map mergeMap, SessionImplementor session)
throws HibernateException {
- return getPropertyValues( object, session.getEntityMode() );
+ return getPropertyValues( object, session.getEntityPersister(null, object).getEntityMode() );
}
public void processInsertGeneratedProperties(Serializable id, Object entity, Object[] state, SessionImplementor session) {
@@ -293,7 +299,7 @@
if (obj!=null) {
clone = (Custom) obj.clone();
TwoPhaseLoad.addUninitializedEntity(
- new EntityKey( id, this, session.getEntityMode() ),
+ new EntityKey( id, session.getEntityPersister(null, clone), null ),
clone,
this,
LockMode.NONE,
@@ -379,7 +385,7 @@
}
- private static final Type[] TYPES = new Type[] { Hibernate.STRING };
+ private static final Type[] TYPES = new Type[] { StringType.INSTANCE };
private static final String[] NAMES = new String[] { "name" }; //$NON-NLS-1$
private static final boolean[] MUTABILITY = new boolean[] { true };
private static final boolean[] GENERATION = new boolean[] { false };
@@ -409,7 +415,7 @@
* @see EntityPersister#getIdentifierType()
*/
public Type getIdentifierType() {
- return Hibernate.STRING;
+ return StringType.INSTANCE;
}
/**
@@ -624,4 +630,155 @@
return false;
}
+ @Override
+ public EntityRegionAccessStrategy getCacheAccessStrategy() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public EntityMetamodel getEntityMetamodel() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Serializable getIdentifier(Object arg0, SessionImplementor arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ValueInclusion[] getPropertyInsertGenerationInclusions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public ValueInclusion[] getPropertyUpdateGenerationInclusions() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object instantiate(Serializable arg0, SessionImplementor arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object load(Serializable arg0, Object arg1, LockOptions arg2,
+ SessionImplementor arg3) throws HibernateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void lock(Serializable arg0, Object arg1, Object arg2,
+ LockOptions arg3, SessionImplementor arg4)
+ throws HibernateException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void resetIdentifier(Object arg0, Serializable arg1, Object arg2,
+ SessionImplementor arg3) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setIdentifier(Object arg0, Serializable arg1,
+ SessionImplementor arg2) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public boolean isInstrumented() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean implementsLifecycle() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public Class getConcreteProxyClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setPropertyValues(Object object, Object[] values) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setPropertyValue(Object object, int i, Object value) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object[] getPropertyValues(Object object) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getPropertyValue(Object object, int i)
+ throws HibernateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Serializable getIdentifier(Object object) throws HibernateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getVersion(Object object) throws HibernateException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isInstance(Object object) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean hasUninitializedLazyProperties(Object object) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public EntityPersister getSubclassEntityPersister(Object instance,
+ SessionFactoryImplementor factory) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public EntityMode getEntityMode() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public EntityTuplizer getEntityTuplizer() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
}
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/DoubleStringType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/DoubleStringType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/DoubleStringType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -9,7 +9,8 @@
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
-import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.type.StringType;
import org.hibernate.type.Type;
import org.hibernate.usertype.CompositeUserType;
@@ -50,8 +51,8 @@
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
throws HibernateException, SQLException {
- String first = (String) Hibernate.STRING.nullSafeGet(rs, names[0]);
- String second = (String) Hibernate.STRING.nullSafeGet(rs, names[1]);
+ String first = (String) StringType.INSTANCE.nullSafeGet(rs, names[0], session);
+ String second = (String) StringType.INSTANCE.nullSafeGet(rs, names[1], session);
return ( first==null && second==null ) ? null : new String[] { first, second };
}
@@ -61,8 +62,8 @@
String[] strings = (value==null) ? new String[2] : (String[]) value;
- Hibernate.STRING.nullSafeSet(st, strings[0], index);
- Hibernate.STRING.nullSafeSet(st, strings[1], index+1);
+ StringType.INSTANCE.nullSafeSet(st, strings[0], index, session);
+ StringType.INSTANCE.nullSafeSet(st, strings[1], index+1, session);
}
public String[] getPropertyNames() {
@@ -70,7 +71,7 @@
}
public Type[] getPropertyTypes() {
- return new Type[] { Hibernate.STRING, Hibernate.STRING };
+ return new Type[] { StringType.INSTANCE, StringType.INSTANCE };
}
public Object getPropertyValue(Object component, int property) {
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/MultiplicityType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/MultiplicityType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/legacy/MultiplicityType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -8,21 +8,34 @@
import org.hibernate.Hibernate;
import org.hibernate.HibernateException;
-import org.hibernate.engine.ForeignKeys;
-import org.hibernate.engine.SessionImplementor;
+import org.hibernate.engine.internal.ForeignKeys;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.type.IntegerType;
+import org.hibernate.type.ManyToOneType;
+import org.hibernate.type.StringType;
import org.hibernate.type.Type;
+import org.hibernate.type.TypeFactory;
import org.hibernate.usertype.CompositeUserType;
public class MultiplicityType implements CompositeUserType {
+ private static class NoScope implements TypeFactory.TypeScope {
+ public static final NoScope INSTANCE = new NoScope();
+
+ public SessionFactoryImplementor resolveFactory() {
+ throw new HibernateException( "Cannot access SessionFactory from here" );
+ }
+ }
+
private static final String[] PROP_NAMES = new String[] {
"count", "glarch" //$NON-NLS-1$ //$NON-NLS-2$
};
private static final int[] SQL_TYPES = new int[] {
- Hibernate.INTEGER.sqlType(), Hibernate.STRING.sqlType()
+ IntegerType.INSTANCE.sqlType(), StringType.INSTANCE.sqlType()
};
private static final Type[] TYPES = new Type[] {
- Hibernate.INTEGER, Hibernate.entity(Glarch.class)
+ IntegerType.INSTANCE, new ManyToOneType( NoScope.INSTANCE, Glarch.class.getName())
};
public String[] getPropertyNames() {
@@ -78,8 +91,8 @@
public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner)
throws HibernateException, SQLException {
- Integer c = (Integer) Hibernate.INTEGER.nullSafeGet( rs, names[0] );
- GlarchProxy g = (GlarchProxy) Hibernate.entity(Glarch.class).nullSafeGet(rs, names[1], session, owner);
+ Integer c = (Integer) IntegerType.INSTANCE.nullSafeGet( rs, names[0], session );
+ GlarchProxy g = (GlarchProxy) new ManyToOneType( NoScope.INSTANCE, Glarch.class.getName()).nullSafeGet(rs, names[1], session, owner);
Multiplicity m = new Multiplicity();
m.count = c==null ? 0 : c.intValue();
m.glarch = g;
@@ -100,8 +113,8 @@
g = o.glarch;
c = new Integer(o.count);
}
- Hibernate.INTEGER.nullSafeSet(st, c, index, session);
- Hibernate.entity(Glarch.class).nullSafeSet(st, g, index+1, session);
+ IntegerType.INSTANCE.nullSafeSet(st, c, index, session);
+ new ManyToOneType( NoScope.INSTANCE, Glarch.class.getName()).nullSafeSet(st, g, index+1, session);
}
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/rowid/RowIdType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/rowid/RowIdType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/rowid/RowIdType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -8,6 +8,7 @@
import java.sql.Types;
import org.hibernate.HibernateException;
+import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.UserType;
/**
@@ -31,16 +32,6 @@
return x.hashCode();
}
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner)
- throws HibernateException, SQLException {
- return rs.getObject( names[0] );
- }
-
- public void nullSafeSet(PreparedStatement st, Object value, int index)
- throws HibernateException, SQLException {
- throw new UnsupportedOperationException();
- }
-
public Object deepCopy(Object value) throws HibernateException {
return value;
}
@@ -61,4 +52,17 @@
return null;
}
+ @Override
+ public Object nullSafeGet(ResultSet rs, String[] names,
+ SessionImplementor session, Object owner)
+ throws HibernateException, SQLException {
+ return rs.getObject( names[0] );
+ }
+
+ @Override
+ public void nullSafeSet(PreparedStatement st, Object value, int index,
+ SessionImplementor session) throws HibernateException, SQLException {
+ throw new UnsupportedOperationException();
+ }
+
}
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/typeparameters/DefaultValueIntegerType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -8,6 +8,7 @@
import java.util.Properties;
import org.hibernate.HibernateException;
+import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.usertype.ParameterizedType;
import org.hibernate.usertype.UserType;
@@ -33,19 +34,6 @@
return x.equals(y);
}
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException {
- Number result = (Number) rs.getObject(names[0]);
- return result==null ? defaultValue : new Integer(result.intValue());
- }
-
- public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
- if (value == null || defaultValue.equals(value) ) {
- st.setNull(index, Types.INTEGER);
- } else {
- st.setInt(index, ((Integer)value).intValue());
- }
- }
-
public Object deepCopy(Object value) throws HibernateException {
return new Integer(((Integer)value).intValue());
}
@@ -76,4 +64,22 @@
this.defaultValue = Integer.valueOf((String) parameters.get("default")); //$NON-NLS-1$
}
+ @Override
+ public Object nullSafeGet(ResultSet rs, String[] names,
+ SessionImplementor session, Object owner)
+ throws HibernateException, SQLException {
+ Number result = (Number) rs.getObject(names[0]);
+ return result==null ? defaultValue : new Integer(result.intValue());
+ }
+
+ @Override
+ public void nullSafeSet(PreparedStatement st, Object value, int index,
+ SessionImplementor session) throws HibernateException, SQLException {
+ if ( value == null || defaultValue.equals(value) ) {
+ st.setNull(index, Types.INTEGER);
+ } else {
+ st.setInt(index, ((Integer)value).intValue());
+ }
+ }
+
}
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/MyListType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -5,8 +5,8 @@
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.SessionImplementor;
+import org.hibernate.collection.spi.PersistentCollection;
+import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.usertype.UserCollectionType;
@@ -19,12 +19,7 @@
}
public PersistentCollection wrap(SessionImplementor session, Object collection) {
- if ( session.getEntityMode()==EntityMode.DOM4J ) {
- throw new IllegalStateException("dom4j not supported"); //$NON-NLS-1$
- }
- else {
- return new PersistentMyList( session, (IMyList) collection );
- }
+ return new PersistentMyList( session, (IMyList) collection );
}
public Iterator getElementsIterator(Object collection) {
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/basic/PersistentMyList.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -1,7 +1,7 @@
package mapping.usercollection.basic;
-import org.hibernate.collection.PersistentList;
-import org.hibernate.engine.SessionImplementor;
+import org.hibernate.collection.internal.PersistentList;
+import org.hibernate.engine.spi.SessionImplementor;
public class PersistentMyList extends PersistentList implements IMyList {
@@ -12,7 +12,4 @@
public PersistentMyList(SessionImplementor session, IMyList list) {
super(session, list);
}
-
-
-
}
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/DefaultableListType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -1,16 +1,16 @@
package mapping.usercollection.parameterized;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
-import java.util.List;
-import org.hibernate.usertype.UserCollectionType;
-import org.hibernate.usertype.ParameterizedType;
-import org.hibernate.collection.PersistentCollection;
-import org.hibernate.engine.SessionImplementor;
-import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.EntityMode;
+import org.hibernate.collection.spi.PersistentCollection;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.usertype.ParameterizedType;
+import org.hibernate.usertype.UserCollectionType;
/**
* Our Hibernate type-system extension for defining our specialized collection
@@ -35,12 +35,7 @@
}
public PersistentCollection wrap(SessionImplementor session, Object collection) {
- if ( session.getEntityMode() == EntityMode.DOM4J ) {
- throw new IllegalStateException( "dom4j not supported" ); //$NON-NLS-1$
- }
- else {
return new PersistentDefaultableList( session, ( List ) collection );
- }
}
public Iterator getElementsIterator(Object collection) {
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/usercollection/parameterized/PersistentDefaultableList.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -2,8 +2,8 @@
import java.util.List;
-import org.hibernate.collection.PersistentList;
-import org.hibernate.engine.SessionImplementor;
+import org.hibernate.collection.internal.PersistentList;
+import org.hibernate.engine.spi.SessionImplementor;
/**
* The "persistent wrapper" around our specialized collection contract
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java 2011-11-19 00:48:27 UTC (rev 36462)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/mapping/where/NumericTrueFalseType.java 2011-11-19 00:53:14 UTC (rev 36463)
@@ -29,7 +29,7 @@
}
}
- public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ public void set(PreparedStatement st, Boolean value, int index) throws SQLException {
if ( value == null ) {
st.setNull( index, Types.INTEGER );
}
@@ -39,14 +39,10 @@
}
}
- public String objectToSQLString(Object value, Dialect dialect) throws Exception {
+ public String objectToSQLString(Boolean value, Dialect dialect) {
return ( ( Boolean ) value ).booleanValue() ? "1" : "0"; //$NON-NLS-1$ //$NON-NLS-2$
}
- public int sqlType() {
- return Types.INTEGER;
- }
-
public String getName() {
return "numeric_boolean"; //$NON-NLS-1$
}
13 years, 1 month
JBoss Tools SVN: r36462 - in trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui: refactoring and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2011-11-18 19:48:27 -0500 (Fri, 18 Nov 2011)
New Revision: 36462
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactoringProcessor.java
Log:
Quickfix and Wizard for fixing ambigious injection warning is confusing https://issues.jboss.org/browse/JBIDE-9940
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-11-19 00:02:46 UTC (rev 36461)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/marker/MarkerResolutionUtils.java 2011-11-19 00:48:27 UTC (rev 36462)
@@ -589,9 +589,13 @@
for(ValuedQualifier vq : deployed){
String qualifierName = vq.getQualifier().getSourceType().getFullyQualifiedName();
String value = vq.getValue();
+ String elName = getELName(bean);
- if(!value.isEmpty())
+ if(!value.isEmpty() && (!value.equals(elName) || !qualifierName.equals(CDIConstants.NAMED_QUALIFIER_TYPE_NAME))){
value = "(\""+value+"\")";
+ }else{
+ value = "";
+ }
if(!qualifierName.equals(CDIConstants.ANY_QUALIFIER_TYPE_NAME) && !qualifierName.equals(CDIConstants.DEFAULT_QUALIFIER_TYPE_NAME)){
addAnnotation(qualifierName, compilationUnit, beanElement, value, edit);
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactoringProcessor.java
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactoringProcessor.java 2011-11-19 00:02:46 UTC (rev 36461)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.ui/src/org/jboss/tools/cdi/ui/refactoring/CDIRefactoringProcessor.java 2011-11-19 00:48:27 UTC (rev 36462)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.cdi.ui.refactoring;
-import java.lang.reflect.InvocationTargetException;
import java.util.Set;
import org.eclipse.core.resources.IFile;
@@ -20,9 +19,6 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
@@ -32,11 +28,13 @@
import org.eclipse.ltk.core.refactoring.participants.RefactoringProcessor;
import org.eclipse.ltk.core.refactoring.participants.SharableParticipants;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.cdi.core.CDICoreMessages;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDICorePlugin;
@@ -44,6 +42,7 @@
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.ui.CDIUIPlugin;
+import org.jboss.tools.common.text.ext.IMultiPageEditor;
public abstract class CDIRefactoringProcessor extends RefactoringProcessor {
protected static final RefactoringParticipant[] EMPTY_REF_PARTICIPANT = new RefactoringParticipant[0];
@@ -180,33 +179,17 @@
super(name, file);
}
- protected void releaseDocument(IDocument document, IProgressMonitor pm)
+ @Override
+ protected void releaseDocument(final IDocument document, IProgressMonitor pm)
throws CoreException {
super.releaseDocument(document, pm);
-
- final IEditorPart editor = getEditor(getFile());
- if(editor != null){
- IRunnableContext context = new ProgressMonitorDialog(editor.getSite().getShell());
-
- IRunnableWithProgress resolutionsRunnable = new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- IEditorPart editor = getEditor(getFile());
- if(editor != null){
- editor.doSave(new NullProgressMonitor());
- }
- }
- };
- try {
- PlatformUI.getWorkbench().getProgressService().runInUI(context,
- resolutionsRunnable, null);
- } catch (InvocationTargetException e) {
- CDIUIPlugin.getDefault().logError(e);
- } catch (InterruptedException e) {
- CDIUIPlugin.getDefault().logError(e);
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ IEditorPart editor = getEditor(getFile());
+ editor.doSave(new NullProgressMonitor());
}
- }
+
+ });
}
-
}
-
}
13 years, 1 month
JBoss Tools SVN: r36461 - branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-11-18 19:02:46 -0500 (Fri, 18 Nov 2011)
New Revision: 36461
Modified:
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project
Log:
Mapppingtypes project migrated to hibernate 4
Modified: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project 2011-11-18 23:30:55 UTC (rev 36460)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project 2011-11-19 00:02:46 UTC (rev 36461)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>org.jboss.tools.hibernate.sampleproject.mappingtypes</name>
+ <name>org.jboss.tools.hibernate4.sampleproject.mappingtypes</name>
<comment></comment>
<projects>
</projects>
13 years, 1 month
JBoss Tools SVN: r36460 - branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes.
by jbosstools-commits@lists.jboss.org
Author: dgolovin
Date: 2011-11-18 18:30:55 -0500 (Fri, 18 Nov 2011)
New Revision: 36460
Added:
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.settings/
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/lib/
branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/src/
Log:
Copied: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath (from rev 36459, branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/.classpath)
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath (rev 0)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.classpath 2011-11-18 23:30:55 UTC (rev 36460)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/hibernate3.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Copied: branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project (from rev 36459, branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate.sampleproject.mappingtypes/.project)
===================================================================
--- branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project (rev 0)
+++ branches/hibernatetools-multiversion2/sampleprojects/org.jboss.tools.hibernate4.sampleproject.mappingtypes/.project 2011-11-18 23:30:55 UTC (rev 36460)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.hibernate.sampleproject.mappingtypes</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.hibernate.eclipse.console.hibernateBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.hibernate.eclipse.console.hibernateNature</nature>
+ </natures>
+</projectDescription>
13 years, 1 month