Author: jjankovi
Date: 2011-10-05 10:13:40 -0400 (Wed, 05 Oct 2011)
New Revision: 35372
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java
Modified:
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/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/uiutils/actions/CDIUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
Log:
CDI OpenOn test operates on beans.xml
Modified:
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 2011-10-05
14:03:03 UTC (rev 35371)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-10-05
14:13:40 UTC (rev 35372)
@@ -58,7 +58,7 @@
public class BeansEditorTest extends SWTTestExt {
private static final String descPath = "WebContent/WEB-INF/beans.xml";
- private static final String project = "CDIProject";
+ private static final String project = "CDIProject1";
private static final Logger LOGGER = Logger.getLogger(BeansEditorTest.class.getName());
@BeforeClass
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-10-05
14:03:03 UTC (rev 35371)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-10-05
14:13:40 UTC (rev 35372)
@@ -1,18 +1,13 @@
package org.jboss.tools.cdi.bot.test.openon;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-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.SWTJBTExt;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
-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.ViewType;
-import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -23,64 +18,84 @@
* Test operates on hyperlinks-openons
*
* @author Jaroslav Jankovic
+ *
+ *
+ * TO DO
+ *
+ * - OpenOn for Disposer/Produce and for injection point works
+ * - Classes indication for Open Injected Class works
+ *
+ *
*/
@Require(perspective = "Java EE", server = @Server(state =
ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
-public class CDIOpenOnTest extends SWTTestExt {
-
- //private static final Logger LOGGER =
Logger.getLogger(CDIQuickFixTest.class.getName());
- private static final String PROJECT_NAME = "CDIProject";
+public class CDIOpenOnTest extends CDIBase {
+
+ // private static final Logger LOGGER =
+ // Logger.getLogger(CDIQuickFixTest.class.getName());
+ private static final String PROJECT_NAME = "CDIProject3";
private static final String PACKAGE_NAME = "org.cdi.test";
-
-
+
@BeforeClass
public static void setup() {
- eclipse.showView(ViewType.PROJECT_EXPLORER);
- CDIUtil.createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
+ eclipse.showView(ViewType.PROJECT_EXPLORER);
}
-
+
@After
public void waitForJobs() {
util.waitForNonIgnoredJobs();
}
-
+
@Test
- public void testInjectHyperlink() {
- CDIUtil.bean(PACKAGE_NAME, "Animal", true, false, false, false, null,
- null, null, null).finish();
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
+ public void testCreateProject() {
+ createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
+ }
+
+ @Test
+ public void testInjectOpenOn() {
+
+ createComponent(CDICOMPONENT.BEAN, "Animal", PACKAGE_NAME, null);
+
+ createComponent(CDICOMPONENT.BEAN, "BrokenFarm", PACKAGE_NAME, null);
+
+ CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
+ .getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
+ false);
+ openOn("@Inject", "BrokenFarm.java", true);
+ assertTrue("ERROR: redirected to " + getEd().getTitle(), getEd()
+ .getTitle().equals("Animal.java"));
+ }
+
+ @Test
+ public void testBeansXMLClassesOpenOn() {
+
+ //
https://issues.jboss.org/browse/JBIDE-7025
+ createComponent(CDICOMPONENT.BEANSXML, null, PROJECT_NAME +
"/WebContent/WEB-INF", null);
- CDIUtil.bean(PACKAGE_NAME, "BrokenFarm", true, false, false, false, null,
- null, null, null).finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = bot.activeEditor();
- CDIUtil.copyResourceToClass(ed, CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"), false);
+ createComponent(CDICOMPONENT.DECORATOR, "D1", PACKAGE_NAME,
"java.util.Set");
+ bot.editorByTitle("beans.xml").show();
+ bot.cTabItem("Source").activate();
+ openOn(PACKAGE_NAME + ".D1", "beans.xml", false);
+ //assertTrue(bot.activeEditor().getTitle(),
bot.activeEditor().getTitle().equals("D1.java"));
- SWTBotTreeItem warningNode = ProblemsView.getWarningsNode(bot);
- assertNull("Warnings node should be empty.", warningNode);
- String openOnString = "@Inject";
- ed = SWTJBTExt.selectTextInSourcePane(bot, "BrokenFarm.java", openOnString,
1, openOnString.length()-1);
- ed.setFocus();
- bot.menu("Navigate").menu("Open Hyperlink").click();
- bot.activeShell().bot().table(0).click(1, 0);
- bot.sleep(Timing.time1S());
- ed = bot.activeEditor();
- assertTrue("ERROR: redirected to " + ed.getTitle(),
ed.getTitle().equals("Animal.java"));
+ createComponent(CDICOMPONENT.INTERCEPTOR, "Interceptor1", PACKAGE_NAME,
null);
+ bot.editorByTitle("beans.xml").show();
+ openOn(PACKAGE_NAME + ".Interceptor1", "beans.xml", false);
+ //assertTrue("ERROR: redirected to " + getEd(),
getEd().getTitle().equals("Interceptor1.java"));
}
-
- /*
- * TO DO
- *
- * -
https://issues.jboss.org/browse/JBIDE-8202
- * -
https://issues.jboss.org/browse/JBIDE-8692
- * - OpenOn for Disposer/Produce and for injection point works
- * - Classes indication for Open Injected Class works
- * - OpenOn works in beans.xml =>
https://jira.jboss.org/browse/JBIDE-7025
- *
- *
- */
+
+ @Test
+ public void testResourceOpenOn() {
+
+ //
https://issues.jboss.org/browse/JBIDE-8202
+ }
+
+ @Test
+ public void testGenericOpenOn() {
+
+ //
https://issues.jboss.org/browse/JBIDE-8692
+ }
+
}
\ No newline at end of file
Modified:
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-10-05
14:03:03 UTC (rev 35371)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-10-05
14:13:40 UTC (rev 35372)
@@ -1,12 +1,11 @@
package org.jboss.tools.cdi.bot.test.quickfix;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
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.SWTTestExt;
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;
@@ -28,18 +27,12 @@
@Require(perspective = "Java EE", server = @Server(state =
ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
-public class CDIQuickFixTest extends SWTTestExt {
+public class CDIQuickFixTest extends CDIBase {
- private static final String PROJECT_NAME = "CDIProject";
+ private static final String PROJECT_NAME = "CDIProject2";
private static final String PACKAGE_NAME = "org.cdi.test";
private static SWTBotTreeItem[] problemsTrees;
- private static final String LINE_SEPARATOR =
System.getProperty("line.separator");
- private enum PROBLEM_TYPE {WARNINGS, ERRORS}
- private enum ANNOTATIONS {SERIALIZABLE, TARGET, RETENTION, NAMED, TYPED, DISPOSES,
OBSERVES, INTERCEPTOR,
- SPECIALIZES, DECORATOR, NONBINDING}
- private enum CDICOMPONENT {STEREOSCOPE, QUALIFIER, SCOPE, BEAN, ANNOTATION,
INTERBINDING, INTERCEPTOR}
- private SWTBotEclipseEditor ed;
-
+ private static final String LINE_SEPARATOR =
System.getProperty("line.separator");
/*
* init method "setup()" shows a project explorer view as default,
@@ -49,8 +42,7 @@
@BeforeClass
public static void setup() {
eclipse.showView(ViewType.PROJECT_EXPLORER);
- CDIUtil.disableFolding(bot, util);
- CDIUtil.createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ CDIUtil.disableFolding(bot, util);
}
/*
@@ -63,20 +55,27 @@
}
@Test
+ public void testCreateProject() {
+ createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ }
+
+ @Test
public void testSerializableQF() {
+
+
String className = "B1";
- createComponent(CDICOMPONENT.BEAN, className);
+ createComponent(CDICOMPONENT.BEAN, className, PACKAGE_NAME, null);
- //
+ //
https://issues.jboss.org/browse/JBIDE-8550
checkSerializableAnnotation(CDICOMPONENT.BEAN, className);
}
@Test
public void testMultipleBeansQF() {
String className = "BrokenFarm";
- createComponent(CDICOMPONENT.BEAN, className);
+ createComponent(CDICOMPONENT.BEAN, className, PACKAGE_NAME, null);
- //
+ //
https://issues.jboss.org/browse/JBIDE-7635
checkMultipleBeans(CDICOMPONENT.BEAN, className);
}
@@ -196,47 +195,20 @@
* method edits default Target form because of "one space inconsistency"
*/
private void prepareCdiComponent(CDICOMPONENT component, String name) {
- createComponent(component, name);
+ createComponent(component, name, PACKAGE_NAME, null);
switch (component) {
case QUALIFIER:
- CDIUtil.replaceInEditor(ed, bot, "@Target({ TYPE, METHOD, PARAMETER, FIELD
})",
+ CDIUtil.replaceInEditor(getEd(), bot, "@Target({ TYPE, METHOD, PARAMETER, FIELD
})",
"@Target({TYPE, METHOD, PARAMETER, FIELD})");
break;
case STEREOSCOPE:
case SCOPE:
- CDIUtil.replaceInEditor(ed, bot, "@Target({ TYPE, METHOD, FIELD })",
+ CDIUtil.replaceInEditor(getEd(), bot, "@Target({ TYPE, METHOD, FIELD })",
"@Target({TYPE, METHOD, FIELD})");
break;
}
}
- private void createComponent(CDICOMPONENT component, String name) {
- switch (component) {
- case STEREOSCOPE:
- CDIUtil.stereotype(PACKAGE_NAME, name, null, null, false, false, false,
- false).finish();
- break;
- case QUALIFIER:
- CDIUtil.qualifier(PACKAGE_NAME, name, false, false).finish();
- break;
- case SCOPE:
- CDIUtil.scope(PACKAGE_NAME, name, false, false, true, false).finish();
- break;
- case BEAN:
- CDIUtil.bean(PACKAGE_NAME, name, true, false, false, false, null,
- null, null, null).finish();
- break;
- case INTERBINDING:
- CDIUtil.binding(PACKAGE_NAME, name, null, true, false).finish();
- break;
- case ANNOTATION:
-
- }
- util.waitForNonIgnoredJobs();
- ed = bot.activeEditor().toTextEditor();
- }
-
-
/*
****************************************************************
*
@@ -247,19 +219,19 @@
*/
private void prepareSerializableAnnotation() {
- CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/B1.java.cdi"), false);
}
private void prepareMultipleBeans(String className) {
- createComponent(CDICOMPONENT.BEAN, "Animal");
- createComponent(CDICOMPONENT.BEAN, "Dog");
- CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ createComponent(CDICOMPONENT.BEAN, "Animal", PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, "Dog", PACKAGE_NAME, null);
+ CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/Dog.java.cdi"), false);
- createComponent(CDICOMPONENT.QUALIFIER, "Q1");
+ createComponent(CDICOMPONENT.QUALIFIER, "Q1", PACKAGE_NAME, null);
bot.editorByTitle(className + ".java").show();
- ed = bot.activeEditor().toTextEditor();
- CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ setEd(bot.activeEditor().toTextEditor());
+ CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
false);
@@ -268,83 +240,83 @@
private void prepareNamedAnnotation(CDICOMPONENT comp,
String className, boolean add) {
if (comp == CDICOMPONENT.BEAN) {
- CDIUtil.insertInEditor(ed, bot, 1, 0, "import javax.inject.Named;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 3, 0, "@Named" + LINE_SEPARATOR);
+ 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(ed, bot, 2, 0, "import javax.decorator.Decorator;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 4, 0, "@Decorator" + LINE_SEPARATOR);
+ CDIUtil.insertInEditor(getEd(), bot, 2, 0, "import
javax.decorator.Decorator;" + LINE_SEPARATOR);
+ CDIUtil.insertInEditor(getEd(), bot, 4, 0, "@Decorator" + LINE_SEPARATOR);
} else {
- CDIUtil.replaceInEditor(ed, bot, "import javax.decorator.Decorator;",
+ CDIUtil.replaceInEditor(getEd(), bot, "import javax.decorator.Decorator;",
"import javax.interceptor.Interceptor;");
- CDIUtil.replaceInEditor(ed, bot, "@Decorator", "@Interceptor");
+ CDIUtil.replaceInEditor(getEd(), bot, "@Decorator",
"@Interceptor");
}
} else {
if (add) {
- CDIUtil.insertInEditor(ed, bot, ed.getLineCount()-4, 0,
"@Named(\"Name\")" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 6 , 0, "import javax.inject.Named;" +
LINE_SEPARATOR);
+ 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(ed, bot, "@Named", "");
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot, "@Named", "");
+ CDIUtil.replaceInEditor(getEd(), bot,
"import javax.inject.Named;", "");
}
}
}
private void prepareTypedAnnotation() {
- CDIUtil.insertInEditor(ed, bot, ed.getLineCount()-4 , 0, "@Typed" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 6 , 0, "import
javax.enterprise.inject.Typed;" + LINE_SEPARATOR);
+ 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(ed, bot, 3 , 1, "@Inject" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 1 , 0, "import javax.inject.Inject;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 6 , 15, "String aaa");
+ 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(ed, CDIQuickFixTest.class
+ CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/MyBean.java.cdi"), false);
}
private void prepareObserverDisposer() {
prepareProducer();
- CDIUtil.replaceInEditor(ed, bot, "@Produces", "@Inject");
- CDIUtil.replaceInEditor(ed, bot, "import javax.enterprise.inject.Produces;",
"");
- CDIUtil.replaceInEditor(ed, bot, "String produceString", "void
method");
- CDIUtil.replaceInEditor(ed, bot, "return \"test\";",
"");
+ 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(ed, bot, "import javax.inject.Inject;", "import
javax.enterprise.event.Observes;" +
+ CDIUtil.replaceInEditor(getEd(), bot, "import javax.inject.Inject;",
"import javax.enterprise.event.Observes;" +
LINE_SEPARATOR + "import javax.enterprise.inject.Disposes;" +
LINE_SEPARATOR);
- CDIUtil.replaceInEditor(ed, bot, "@Inject", "");
- CDIUtil.replaceInEditor(ed, bot, "MyBean(String aaa)",
+ 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(ed, bot, 3, 0, "import javax.decorator.Decorator;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 4, 0, "import javax.ejb.Stateless;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 5, 0, "@Decorator" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 6, 0, "@Stateless" + LINE_SEPARATOR);
+ 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(ed, CDIQuickFixTest.class
+ CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/MyBean2.java.cdi"), false);
}
}
private void prepareDisposesAnnot() {
- CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/InterDecor.java.cdi"), false);
}
private void prepareComponentsForSpecializeAnnotation(String testBeanName) {
- createComponent(CDICOMPONENT.BEAN, "AnyBean");
- createComponent(CDICOMPONENT.INTERBINDING, "AnyBinding");
- createComponent(CDICOMPONENT.BEAN, testBeanName);
- CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ createComponent(CDICOMPONENT.BEAN, "AnyBean", PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.INTERBINDING, "AnyBinding", PACKAGE_NAME,
null);
+ createComponent(CDICOMPONENT.BEAN, testBeanName, PACKAGE_NAME, null);
+ CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
.getResourceAsStream("/resources/cdi/TestBean.java.cdi"), false);
}
@@ -380,29 +352,29 @@
switch (comp) {
case STEREOSCOPE:
case SCOPE:
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"@Target({TYPE, METHOD, FIELD})", replacement);
break;
case QUALIFIER:
if (replacement.equals("")) {
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"@Target({TYPE, METHOD, FIELD, PARAMETER})", replacement);
} else {
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"@Target({TYPE, METHOD, PARAMETER, FIELD})", replacement);
}
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import static java.lang.annotation.ElementType.PARAMETER;",
"");
break;
}
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import static java.lang.annotation.ElementType.METHOD;", "");
if (replacement.equals("")) {
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import java.lang.annotation.Target;", "");
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import static java.lang.annotation.ElementType.TYPE;", "");
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import static java.lang.annotation.ElementType.FIELD;", "");
}
checkQuickFix(ANNOTATIONS.TARGET, comp, className, replacement);
@@ -415,21 +387,21 @@
private void checkRetentionAnnotWithAddon(CDICOMPONENT comp, String className,
String replacement) {
- CDIUtil.replaceInEditor(ed, bot, "@Retention(RUNTIME)", replacement);
+ CDIUtil.replaceInEditor(getEd(), bot, "@Retention(RUNTIME)", replacement);
if (replacement.equals("@Retention(CLASS)")) {
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import static java.lang.annotation.RetentionPolicy.RUNTIME;",
"import static java.lang.annotation.RetentionPolicy.CLASS;");
} else {
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import static java.lang.annotation.RetentionPolicy.RUNTIME;",
"");
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import java.lang.annotation.Retention;", "");
}
checkQuickFix(ANNOTATIONS.RETENTION, comp, className, replacement);
if (replacement.equals("@Retention(CLASS)")) {
- CDIUtil.replaceInEditor(ed, bot,
+ CDIUtil.replaceInEditor(getEd(), bot,
"import static
java.lang.annotation.RetentionPolicy.CLASS;","");
}
}
@@ -472,17 +444,17 @@
private void checkConstructorWithAddon(CDICOMPONENT comp,
String className, String replacement) {
- CDIUtil.insertInEditor(ed, bot, 6, 15, 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(ed, bot, "MyBean", "InterDecor");
+ CDIUtil.replaceInEditor(getEd(), bot, "MyBean", "InterDecor");
checkProducerWithAddon(comp, annonType, className, "@Interceptor");
prepareProducer();
- CDIUtil.replaceInEditor(ed, bot, "MyBean", "InterDecor");
+ CDIUtil.replaceInEditor(getEd(), bot, "MyBean", "InterDecor");
checkProducerWithAddon(comp, annonType, className, "@Decorator");
} else {
prepareProducer();
@@ -498,12 +470,12 @@
String importAnnot = replacement.equals("@Interceptor")?
"import javax.interceptor.Interceptor;":
"import javax.decorator.Decorator;";
- CDIUtil.insertInEditor(ed, bot, 3, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 1, 0, importAnnot + LINE_SEPARATOR);
+ CDIUtil.insertInEditor(getEd(), bot, 3, 0, annot + LINE_SEPARATOR);
+ CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
checkQuickFix(replacement.equals("(a)Interceptor")?ANNOTATIONS.INTERCEPTOR:
ANNOTATIONS.DECORATOR, comp, className, replacement);
} else {
- CDIUtil.insertInEditor(ed, bot, 11, 29, replacement + " ");
+ CDIUtil.insertInEditor(getEd(), bot, 11, 29, replacement + " ");
dispObserCompletion(comp, className, replacement);
}
}
@@ -516,7 +488,7 @@
private void checkObserverDisposerWithAddon(CDICOMPONENT comp,
String className, String replacement) {
- CDIUtil.insertInEditor(ed, bot, 10, 20, replacement + " ");
+ CDIUtil.insertInEditor(getEd(), bot, 10, 20, replacement + " ");
dispObserCompletion(comp, className, replacement);
}
@@ -529,8 +501,8 @@
private void checkObserWithDisposParamWithAddon(CDICOMPONENT comp,
String className, String replacement) {
if (replacement.equals("@Observes")) {
- CDIUtil.insertInEditor(ed, bot, 3, 0, "import
javax.enterprise.inject.Disposes;");
- CDIUtil.insertInEditor(ed, bot, 6, 46, "@Disposes ");
+ 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, "");
@@ -549,7 +521,7 @@
}
private void dispObserCompletion(CDICOMPONENT comp, String className, String
replacement) {
- CDIUtil.insertInEditor(ed, bot, 2 , 0, "import javax.enterprise." +
+ 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);
@@ -567,30 +539,30 @@
String annot = replacement;
String importAnnot = "import javax." + replacement.substring(1).toLowerCase()
+ "." + replacement.substring(1) + ";";
- CDIUtil.insertInEditor(ed, bot, 2, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 1, 0, importAnnot + LINE_SEPARATOR);
+ 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(ed, bot, "@Interceptor", "");
- CDIUtil.replaceInEditor(ed, bot, "import javax.interceptor.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(ed, bot, "@Disposes", "@Observes");
- CDIUtil.replaceInEditor(ed, bot, "import javax.enterprise.inject.Disposes;",
+ CDIUtil.replaceInEditor(getEd(), bot, "@Disposes", "@Observes");
+ CDIUtil.replaceInEditor(getEd(), bot, "import
javax.enterprise.inject.Disposes;",
"import javax.enterprise.event.Observes;");
- CDIUtil.replaceInEditor(ed, bot, "dispose", "observe");
+ CDIUtil.replaceInEditor(getEd(), bot, "dispose", "observe");
String annot = replacement;
String importAnnot = "import javax." + replacement.substring(1).toLowerCase()
+ "." + replacement.substring(1) + ";";
- CDIUtil.insertInEditor(ed, bot, 2, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(ed, bot, 1, 0, importAnnot + LINE_SEPARATOR);
+ CDIUtil.insertInEditor(getEd(), bot, 2, 0, annot + LINE_SEPARATOR);
+ CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement);
}
@@ -598,14 +570,14 @@
prepareComponentsForSpecializeAnnotation(className);
checkSpecializeAnnotWithAddon(comp, className, "@Interceptor");
checkSpecializeAnnotWithAddon(comp, className, "@Decorator");
- CDIUtil.copyResourceToClass(ed,
+ 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(ed,
+ CDIUtil.copyResourceToClass(getEd(),
CDIQuickFixTest.class.getResourceAsStream("/resources/cdi/TestBean2.java.cdi"),
false);
}
checkQuickFix(ANNOTATIONS.SPECIALIZES, comp, className, replacement);
@@ -623,8 +595,7 @@
boolean interceptorCreated = projectExplorer.isFilePresent(PROJECT_NAME,
"Java Resources", "src", PACKAGE_NAME, className +
".java");
if (!interceptorCreated) {
- CDIUtil.binding(PACKAGE_NAME, className, null, false, false).finish();
- ed = bot.activeEditor().toTextEditor();
+ createComponent(CDICOMPONENT.INTERBINDING, className, PACKAGE_NAME, null);
}
}
@@ -632,13 +603,13 @@
boolean annotationCreated = projectExplorer.isFilePresent(PROJECT_NAME,
"Java Resources", "src", PACKAGE_NAME,
"AAnnotation.java");
if (!annotationCreated) {
- CDIUtil.annotation(open, util, PACKAGE_NAME, "AAnnotation");
- bot.editorByTitle(className + ".java").show();
- ed = bot.activeEditor().toTextEditor();
- }
- CDIUtil.insertInEditor(ed, bot, ed.getLineCount()-3, 1, "AAnnotation
annotValue();" + LINE_SEPARATOR);
+ createComponent(null, "AAnnotation", PACKAGE_NAME, 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(ed, bot, ed.getLineCount()-3, 1, "String[] array();"
+ LINE_SEPARATOR);
+ CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-3, 1, "String[]
array();" + LINE_SEPARATOR);
}
checkQuickFix(ANNOTATIONS.NONBINDING, comp, className, replacement);
}
@@ -701,13 +672,13 @@
+ PROJECT_NAME, className, "CDI Problem");
} else {
if (className.equals("InterDecor.java")) {
- if (ed.toTextEditor().getText().contains("produceString")) {
+ if (getEd().toTextEditor().getText().contains("produceString")) {
problemsContains = "Producer cannot be declared in";
}
- if (ed.toTextEditor().getText().contains("disposeMethod")) {
+ if (getEd().toTextEditor().getText().contains("disposeMethod")) {
problemsContains = "has a method annotated @Disposes";
}
- if (ed.toTextEditor().getText().contains("observeMethod")) {
+ if (getEd().toTextEditor().getText().contains("observeMethod")) {
problemsContains = "have a method with a parameter annotated @Observes";
}
}
@@ -777,7 +748,7 @@
bot.sleep(Timing.time1S());
util.waitForNonIgnoredJobs();
- String code = ed.toTextEditor().getText();
+ String code = getEd().toTextEditor().getText();
assertTrue(code.contains("@Inject @Q1 private Animal animal;"));
code = bot.editorByTitle(qualifBean + ".java").toTextEditor().getText();
assertTrue(code.contains("@Q1"));
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-10-05
14:13:40 UTC (rev 35372)
@@ -0,0 +1,139 @@
+package org.jboss.tools.cdi.bot.test.uiutils.actions;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+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.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.view.ProjectExplorer;
+
+public class CDIBase extends SWTTestExt {
+
+ 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();
+ setEd(bot.activeEditor().toTextEditor());
+ }
+
+ private void createCDIComponent(CDICOMPONENT component, String name,
+ String packageName, String necessaryParam) {
+ switch (component) {
+ case STEREOSCOPE:
+ CDIUtil.stereotype(packageName, name, null, null, false, false, false,
+ 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:
+ CDIUtil.bean(packageName, name, true, false, false, false, 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 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, boolean moreOptions) {
+ 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 (moreOptions) {
+ SWTBotMenu navigateMenu = bot.menu("Navigate");
+ bot.sleep(TIME_500MS);
+ navigateMenu.menu("Open Hyperlink").click();
+ bot.sleep(TIME_500MS);
+ SWTBotTable table = bot.activeShell().bot().table(0);
+ for (int i = 0; i < table.rowCount(); i++) {
+ if (table.getTableItem(i).getText().contains(openOnString)) {
+ table.click(i, 0);
+ break;
+ }
+ }
+ } else {
+ getEd().setFocus();
+ bot.sleep(TIME_500MS);
+ //KeyboardHelper.pressKeyCodeUsingAWT(KeyEvent.VK_F3);
+ }
+ bot.sleep(Timing.time1S());
+ setEd(bot.activeEditor().toTextEditor());
+ }
+
+}
\ No newline at end of file
Modified:
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-10-05
14:03:03 UTC (rev 35371)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-10-05
14:13:40 UTC (rev 35372)
@@ -8,62 +8,33 @@
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.utils.SWTUtils;
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.uiutils.wizards.CDIWizard;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
-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.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;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaAnnotation;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
public class CDIUtil {
-
-
- public static 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();
- CDIUtil.addCDISupport(tree, item, bot, util);
- }
- public static void createCDIProject(SWTUtilExt util, String projectName) {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(projectName).finish();
- util.waitForNonIgnoredJobs();
- }
-
- public static void addCDISupport(final SWTBotTree tree, SWTBotTreeItem item, SWTBotExt
bot, SWTUtilExt util) {
- 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 static void openQuickFix(SWTBotTreeItem item, SWTBotExt bot) {
nodeContextMenu(bot.tree(), item, "Quick Fix").click();
}
-
- public static void resolveQuickFix(SWTBotTreeItem item, SWTBotExt bot, SWTUtilExt util)
{
+
+ 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();
@@ -71,33 +42,39 @@
String code = readStream(resource);
st.setText(code);
classEdit.save();
- if (closeEdit) classEdit.close();
+ if (closeEdit)
+ classEdit.close();
}
-
- public static void replaceInEditor(SWTBotEclipseEditor ed, SWTBotExt bot, String target,
String replacement) {
+
+ 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));
+ 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);
+
+ 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) {
+
+ 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");
@@ -112,7 +89,7 @@
bot.sleep(Timing.time2S());
util.waitForNonIgnoredJobs();
}
-
+
public static SWTBotMenu nodeContextMenu(final SWTBotTree tree,
SWTBotTreeItem item, final String... menu) {
assert menu.length > 0;
@@ -129,12 +106,11 @@
}
});
}
-
- public static CDIWizard qualifier(String pkg, String name, boolean inherited,
- boolean comments) {
+
+ 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) {
@@ -143,7 +119,6 @@
w = w.setNormalScope(normalScope);
return normalScope ? w.setPassivating(passivating) : w;
}
-
public static CDIWizard binding(String pkg, String name, String target,
boolean inherited, boolean comments) {
@@ -151,7 +126,6 @@
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,
@@ -163,18 +137,18 @@
}
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) {
+ 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);
+ 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) {
+
+ 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);
@@ -187,10 +161,10 @@
}
return w;
}
-
- public static CDIWizard bean(String pkg, String name, boolean isPublic, boolean
isAbstract,
- boolean isFinal, boolean comments, String named,
- String interfaces, String scope, String qualifier) {
+
+ public static CDIWizard bean(String pkg, String name, boolean isPublic,
+ boolean isAbstract, boolean isFinal, boolean comments,
+ String named, String interfaces, String scope, String qualifier) {
CDIWizard w = create(CDIWizardType.BEAN, pkg, name, comments);
if (named != null) {
w.setNamed(true);
@@ -210,38 +184,47 @@
}
return w;
}
-
- public static void annotation(SWTOpenExt open, SWTUtilExt util, String pkg, String name)
{
+
+ 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();
+ 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 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);
}
-
- private static CDIWizard create(CDIWizardType type, String pkg, String name,
+
+ 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);
}
- private static CDIWizard create(CDIWizardType type, String pkg, String name, boolean
comments) {
+ 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);
}
-
- private static String readStream(InputStream is) {
+
+ 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/wizard/CdiATWizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2011-10-05
14:03:03 UTC (rev 35371)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2011-10-05
14:13:40 UTC (rev 35372)
@@ -14,23 +14,16 @@
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-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.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.actions.NewFileWizardAction;
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.uiutils.wizards.DynamicWebProjectWizard;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
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.ViewType;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,9 +32,9 @@
@Require(perspective = "Java EE", server = @Server(state =
ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
-public class CdiATWizardTest extends SWTTestExt {
+public class CdiATWizardTest extends CDIBase {
- private static final String PROJECT_NAME = "CDIProject";
+ private static final String PROJECT_NAME = "CDIProject1";
private static final Logger L = Logger.getLogger(CdiATWizardTest.class.getName());
@After
@@ -51,18 +44,7 @@
@Test
public void createProject() {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(PROJECT_NAME).finish();
- util.waitForNonIgnoredJobs();
- SWTBot v = eclipse.showView(ViewType.PROJECT_EXPLORER);
- SWTBotTree tree = v.tree();
- tree.setFocus();
- assertTrue("Project " + PROJECT_NAME + " was not created
properly.",
- SWTEclipseExt.treeContainsItemWithLabel(tree, PROJECT_NAME));
- SWTBotTreeItem t = tree.getTreeItem(PROJECT_NAME);
- t.expand();
- CDIUtil.addCDISupport(tree, t, bot, util);
+ createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
}
@Test