Author: jjankovi
Date: 2011-10-18 09:46:55 -0400 (Tue, 18 Oct 2011)
New Revision: 35763
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBeanInjections.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyConfigProd.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyExtendConfig.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean2.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericType.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.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/PluginActivator.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/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/wizards/CDIWizard.java
Log:
Big refactoring of CDI Bot tests + seam3 generic openon test added
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBean.java.cdi 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,7 @@
+package org.cdi.generic;
+
+public class MyBeanX {
+
+ public MyBeanX(String s) {}
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBeanInjections.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBeanInjections.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyBeanInjections.java.cdi 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,82 @@
+package org.cdi.generic;
+
+import javax.inject.Inject;
+
+public class MyBeanInjections {
+
+ /**
+ * Injected method producer MyGenericBean.createMyFirstBean()
+ * Configuration produced by MyConfigurationProducer.getOneConfig()
+ */
+ @Inject
+ MyBean first1;
+
+ /**
+ * Injected method producer MyGenericBean.createMyFirstBean()
+ * Configuration produced by MyConfigurationProducer.getSecondConfig()
+ */
+ @Inject
+ @Qualifier1
+ MyBean first2;
+
+ /**
+ * Injected method producer MyGenericBean.createMyFirstBean()
+ * Configuration produced by MyExtendedConfiguration
+ */
+ @Inject
+ @Qualifier2
+ MyBean first3;
+
+
+
+
+ /**
+ * Injected method producer MyGenericBean.createMySecondBean()
+ * Configuration produced by MyConfigurationProducer.getOneConfig()
+ */
+ @Inject
+ MyBean2 second1;
+
+ /**
+ * Injected method producer MyGenericBean.createMySecondBean()
+ * Configuration produced by MyConfigurationProducer.getSecondConfig()
+ */
+ @Inject
+ @Qualifier1
+ MyBean2 second2;
+
+ /**
+ * Injected method producer MyGenericBean.createMySecondBean()
+ * Configuration produced by MyExtendedConfiguration
+ */
+ @Inject
+ @Qualifier2
+ MyBean2 second3;
+
+
+
+
+ /**
+ * Injected field producer MyGenericBean.myThirdBean
+ * Configuration produced by MyConfigurationProducer.getOneConfig()
+ */
+ @Inject
+ MyBean3 third1;
+
+ /**
+ * Injected field producer MyGenericBean.myThirdBean
+ * Configuration produced by MyConfigurationProducer.getSecondConfig()
+ */
+ @Inject
+ @Qualifier1
+ MyBean3 third2;
+
+ /**
+ * Injected field producer MyGenericBean.myThirdBean
+ * Configuration produced by MyExtendedConfiguration
+ */
+ @Inject
+ @Qualifier2
+ MyBean3 third3;
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyConfigProd.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyConfigProd.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyConfigProd.java.cdi 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,29 @@
+package org.cdi.generic;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.Produces;
+
+public class MyConfigurationProducer {
+
+ /**
+ * Configuration created by field producer.
+ */
+ @Produces
+ @MyGenericType("first")
+ @Default
+ MyConfiguration getOneConfig() {
+ return null;
+ }
+
+ /**
+ * Configuration created by method producer with specified scope.
+ */
+ @Produces
+ @MyGenericType("second")
+ @Qualifier1
+ @SessionScoped
+ MyConfiguration getSecondConfig() {
+ return null;
+ }
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyExtendConfig.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyExtendConfig.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyExtendConfig.java.cdi 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,9 @@
+package org.cdi.generic;
+
+@MyGenericType("third")
+@Qualifier2
+public class MyExtendedConfiguration extends MyConfiguration {
+ public MyExtendedConfiguration() {
+ super("");
+ }
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean.java.cdi 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,27 @@
+package org.cdi.generic;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.jboss.seam.solder.bean.generic.ApplyScope;
+import org.jboss.seam.solder.bean.generic.Generic;
+import org.jboss.seam.solder.bean.generic.GenericConfiguration;
+
+(a)GenericConfiguration(MyGenericType.class)
+public class MyGenericBean {
+ @Inject
+ @Generic
+ MyConfiguration config;
+
+ @Inject
+ MyGenericType type;
+
+ @Produces @ApplyScope
+ MyBean createMyFirstBean() {
+ return new MyBean("bean1");
+ }
+
+ @Produces @ApplyScope
+ MyBean3 myThirdBean = new MyBean3("bean3");
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean2.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean2.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericBean2.java.cdi 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,35 @@
+package org.cdi.generic;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+import org.jboss.seam.solder.bean.generic.Generic;
+import org.jboss.seam.solder.bean.generic.GenericConfiguration;
+
+(a)GenericConfiguration(MyGenericType.class)
+public class MyGenericBean2 {
+ @Inject
+ @Generic
+ MyConfiguration config;
+
+ @Inject
+ @Generic
+ MyBean c;
+
+ @Inject
+ void setMyBean(@Generic MyBean c) {}
+
+ @Inject
+ @Generic
+ MyBean2 c2;
+
+ @Inject
+ @Generic
+ MyBean3 c3;
+
+ @Produces
+ MyBean2 createMySecondBean() {
+ return new MyBean2("");
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericType.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericType.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/generic/MyGenericType.java.cdi 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,8 @@
+package org.cdi.generic;
+
+import org.jboss.seam.solder.bean.generic.GenericType;
+
+(a)GenericType(MyConfiguration.class)
+public @interface MyGenericType {
+ String value();
+}
\ 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-10-18
13:26:50 UTC (rev 35762)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -13,8 +13,13 @@
import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
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.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
+import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -34,7 +39,7 @@
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 12min
+ * Suite duration: aprox. 14min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
@@ -44,7 +49,20 @@
CdiATWizardTest.class,
BeansEditorTest.class,
CDIQuickFixTest.class,
- CDIOpenOnTest.class
+ CDIOpenOnTest.class,
+ CDISeam3Test.class
})
-public class CDIAllBotTests {
+public class CDIAllBotTests extends CDIBase{
+
+
+ /*
+ * init method "setup()" shows a project explorer view as default,
+ * disable folding (due to easier source code editing)
+ */
+ @BeforeClass
+ public static void setUpSuite() {
+ eclipse.showView(ViewType.PROJECT_EXPLORER);
+ CDIUtil.disableFolding(bot, util);
+ }
+
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/PluginActivator.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/PluginActivator.java 2011-10-18
13:26:50 UTC (rev 35762)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/PluginActivator.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -1,13 +1,13 @@
- /*******************************************************************************
- * Copyright (c) 2007-2009 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
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+/*******************************************************************************
+ * 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.ui.plugin.AbstractUIPlugin;
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-18
13:26:50 UTC (rev 35762)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -1,11 +1,17 @@
+/*******************************************************************************
+ * 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.io.IOException;
-import java.util.logging.Level;
import java.util.logging.Logger;
-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.quickfix.CDIQuickFixTest;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
@@ -14,24 +20,21 @@
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.TreeHelper;
-import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.After;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
/*
- * Test operates on hyperlinks-openons
+ * Test operates on hyperlinks-openons using CDI tools
*
* @author Jaroslav Jankovic
*
*
* TO DO
*
- * - OpenOn for Disposer/Produce and for injection point works
* - Classes indication for Open Injected Class works
+ * -
https://issues.jboss.org/browse/JBIDE-6179
*
*
*/
@@ -44,12 +47,7 @@
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);
- }
-
+
@After
public void waitForJobs() {
util.waitForNonIgnoredJobs();
@@ -61,7 +59,7 @@
}
@Test
- public void testInjectOpenOn() {
+ public void testBeanInjectOpenOn() {
createComponent(CDICOMPONENT.BEAN, "Animal", PACKAGE_NAME, null);
@@ -70,18 +68,27 @@
CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
.getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
false);
+ LOGGER.info("Content of \"BrokenFarm.java.cdi\" copied to
BrokenFarm");
openOn("@Inject", "BrokenFarm.java", "@Inject");
assertTrue("ERROR: redirected to " + getEd().getTitle(), getEd()
.getTitle().equals("Animal.java"));
}
+ /*
+ *
https://issues.jboss.org/browse/JBIDE-7025
+ */
@Test
public void testBeansXMLClassesOpenOn() {
-
- //
https://issues.jboss.org/browse/JBIDE-7025
- createComponent(CDICOMPONENT.BEANSXML, null, PROJECT_NAME
- + "/WebContent/WEB-INF", null);
+ /*
+ * check if beans.xml was not created in previous tests. If so, I cannot create
+ * beans.xml into PROJECT_NAME/WebContent/WEB-INF/beans.xml.
+ */
+ if (!projectExplorer.isFilePresent(PROJECT_NAME,
"WebContent/META-INF/beans.xml") &&
+ !projectExplorer.isFilePresent(PROJECT_NAME,
"WebContent/WEB-INF/beans.xml")) {
+ createComponent(CDICOMPONENT.BEANSXML, null, PROJECT_NAME +
"/WebContent/WEB-INF", null);
+ }
+
createComponent(CDICOMPONENT.DECORATOR, "D1", PACKAGE_NAME,
"java.util.Set");
bot.editorByTitle("beans.xml").show();
@@ -112,70 +119,49 @@
getEd().getTitle().equals("S1.java"));
}
-
+
+ /*
+ *
https://issues.jboss.org/browse/JBIDE-6251
+ */
@Test
- public void testResourceOpenOn() {
-
- //
https://issues.jboss.org/browse/JBIDE-8202
- addLibrary("seam-solder.jar");
-
- createComponent(CDICOMPONENT.BEAN, "B2", PACKAGE_NAME, null);
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/B2.java.cdi"), false);
- openOn("beansXml", "B2.java", "Open Resource");
- String destinationFile = getEd().getTitle();
- assertTrue("ERROR: redirected to " + destinationFile,
- destinationFile.equals("beans.xml"));
-
- moveFileInProjectExplorer("beans.xml", PROJECT_NAME +
"/WebContent/WEB-INF",
- PROJECT_NAME + "/WebContent/META-INF");
- LOGGER.info("bean.xml was moved to META-INF");
+ public void testDisposerOpenOn() {
+ /*
+ * not implemented yet
+ */
- 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-6311
+ *
https://issues.jboss.org/browse/JBIDE-6251
+ *
https://issues.jboss.org/browse/JBIDE-5928
+ */
@Test
- public void testGenericOpenOn() {
-
- //
https://issues.jboss.org/browse/JBIDE-8692
-
+ public void testProducerOpenOn() {
/*
- * copy files from project which is mentioned in JIRA, then it will be easy
+ * not implemented yet
*/
+
}
- private void moveFileInProjectExplorer(String file, String sourceFolder, String
destFolder) {
- SWTBotTree tree = projectExplorer.bot().tree();
- SWTBotTreeItem item = projectExplorer.selectTreeItem(file,
sourceFolder.split("/"));
+ @Test
+ public void testObserverOpenOn() {
+ /*
+ * not implemented yet
+ *
+ * Bean 1
+ * @Inject
+ * @Qualifier1
+ * Event<MyBean> event2;
+ *
+ * Bean 2
+ * void myObserver(@Observes MyBean bean) {
+ *
+ * }
+ *
+ */
- 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();
}
- private void addLibrary(String libraryName) {
- try {
- addLibraryIntoProject(PROJECT_NAME, libraryName);
- LOGGER.info("Library: \"" + libraryName + "\" copied");
- addLibraryToProjectsClassPath(PROJECT_NAME, libraryName);
- } catch (IOException exc) {
- LOGGER.log(Level.SEVERE, "Error while adding seam solder library into
project");
- }
- }
}
\ 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-18
13:26:50 UTC (rev 35762)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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;
@@ -10,10 +20,8 @@
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;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -35,17 +43,6 @@
private static final String LINE_SEPARATOR =
System.getProperty("line.separator");
/*
- * init method "setup()" shows a project explorer view as default,
- * disable folding (due to easier source code editing) and add
- * cdi extension
- */
- @BeforeClass
- public static void setup() {
- eclipse.showView(ViewType.PROJECT_EXPLORER);
- CDIUtil.disableFolding(bot, util);
- }
-
- /*
* check problems (warnings and errors in Problems View)
*/
@After
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -0,0 +1,290 @@
+/*******************************************************************************
+ * 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.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+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.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.TreeHelper;
+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(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 static final String PROJECT_NAME = "CDISeamProject";
+ private static final String PACKAGE_NAME = "org.cdi.test";
+ private static final String GENERIC_PACKAGE_NAME = "org.cdi.generic";
+
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ }
+
+ @Test
+ public void testCreateProjectWithSeamLibraries() {
+ createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
+ addLibrary("seam-solder.jar");
+ checkLibrary("seam-solder.jar");
+ }
+
+ /*
+ *
https://issues.jboss.org/browse/JBIDE-8202
+ */
+ @Test
+ public void testResourceOpenOn() {
+
+ createComponent(CDICOMPONENT.BEANSXML, "beans.xml", PROJECT_NAME +
"/WebContent/WEB-INF", null);
+
+ createComponent(CDICOMPONENT.BEAN, "B2", PACKAGE_NAME, 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", PROJECT_NAME +
"/WebContent/WEB-INF",
+ PROJECT_NAME + "/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() {
+
+ /*
+ * create all necessary components
+ */
+ prepareGenericOpenOn();
+ /*
+ * test openon for inject and generic
+ * configuration point in class "MyBeanInjections"
+ */
+ checkMyBeanInjections();
+ /*
+ * not implemented yet
+ */
+ checkMyGenericBean();
+ /*
+ * not implemented yet
+ */
+ checkMyGenericBean2();
+
+ /*
+ * what will I test:
+ * 2. MyBeanInjections - three beany with different generic configuration
+ * 3. MyGenericBean - atribute config - Show all Generic Configuration Type
+ * 4. MyGenericBean2 - atributes config, c1, c2, c3 + set Method
+ */
+ }
+
+
+ private 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();
+ }
+
+ private void addLibrary(String libraryName) {
+ try {
+ addLibraryIntoProject(PROJECT_NAME, libraryName);
+ LOGGER.info("Library: \"" + libraryName + "\" copied");
+ addLibraryToProjectsClassPath(PROJECT_NAME, libraryName);
+ LOGGER.info("Library: \"" + libraryName + "\" on class path
of project\"" + PROJECT_NAME + "\"");
+ } catch (IOException exc) {
+ LOGGER.log(Level.SEVERE, "Error while adding seam solder library into
project");
+ }
+ }
+
+ private void checkLibrary(String libraryName) {
+ isLibraryInProjectClassPath(PROJECT_NAME, libraryName);
+ }
+
+ private void prepareGenericOpenOn() {
+ /*
+ * injectable beans + qualifiers + generic configuration components
+ */
+ createComponent(CDICOMPONENT.BEAN, "MyBean", GENERIC_PACKAGE_NAME, null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean");
+
+ createComponent(CDICOMPONENT.BEAN, "MyBean2", GENERIC_PACKAGE_NAME, null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean2");
+
+ createComponent(CDICOMPONENT.BEAN, "MyBean3", GENERIC_PACKAGE_NAME, null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean3");
+
+ createComponent(CDICOMPONENT.BEAN, "MyConfiguration", GENERIC_PACKAGE_NAME,
null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX",
"MyConfiguration");
+
+ createComponent(CDICOMPONENT.BEAN, "MyGenericType", GENERIC_PACKAGE_NAME,
null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericType.java.cdi"), false);
+
+ createComponent(CDICOMPONENT.QUALIFIER, "Qualifier1", GENERIC_PACKAGE_NAME,
null);
+ createComponent(CDICOMPONENT.QUALIFIER, "Qualifier2", GENERIC_PACKAGE_NAME,
null);
+
+ createComponent(CDICOMPONENT.BEAN, "MyExtendedConfiguration",
GENERIC_PACKAGE_NAME, null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyExtendConfig.java.cdi"),
false);
+
+ createComponent(CDICOMPONENT.BEAN, "MyConfigurationProducer",
GENERIC_PACKAGE_NAME, 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", GENERIC_PACKAGE_NAME,
null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyBeanInjections.java.cdi"),
false);
+
+ createComponent(CDICOMPONENT.BEAN, "MyGenericBean", GENERIC_PACKAGE_NAME,
null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericBean.java.cdi"), false);
+
+ createComponent(CDICOMPONENT.BEAN, "MyGenericBean2", GENERIC_PACKAGE_NAME,
null);
+ CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericBean2.java.cdi"),
false);
+ }
+
+ private void checkMyBeanInjections() {
+ checkFirstOpenOnAndGeneric();
+ checkSecondOpenOnAndGeneric();
+ checkThirdOpenOnAndGeneric();
+ }
+
+ private void checkMyGenericBean() {
+
+ }
+
+ private void checkMyGenericBean2() {
+
+ }
+ private void checkFirstOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("first1", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("first1", "@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+
+ checkOpenOnAndGeneric("first2", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("first2", "@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+
+ checkOpenOnAndGeneric("first3", "Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("first3", "@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+ }
+
+ private void checkSecondOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("second1", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("second1", "@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+
+ checkOpenOnAndGeneric("second2", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("second2", "@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+
+ checkOpenOnAndGeneric("second3", "Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("second3", "@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+ }
+
+ private void checkThirdOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("third1", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("third1", "@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+
+ checkOpenOnAndGeneric("third2", "Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("third2", "@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+
+ checkOpenOnAndGeneric("third3", "Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("third3", "@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+ }
+
+ private void checkOpenOnAndGeneric(String openOnString, String chosenOption,
+ String afterOpenOnTitleName, String injectSelectionAtribute) {
+ String titleName = "MyBeanInjections.java";
+ 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));
+ }
+
+}
+
Modified:
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-10-18
13:26:50 UTC (rev 35762)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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;
@@ -9,8 +19,10 @@
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.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;
@@ -51,8 +63,14 @@
} else {
createCDIComponent(component, name, packageName, necessaryParam);
}
- util.waitForNonIgnoredJobs();
- setEd(bot.activeEditor().toTextEditor());
+ 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,
@@ -212,5 +230,36 @@
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 static 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(TIME_1S);
+ }
}
\ 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-18
13:26:50 UTC (rev 35762)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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.InputStream;
@@ -42,16 +52,16 @@
String code = readStream(resource);
st.setText(code);
classEdit.save();
- if (closeEdit)
+ if (closeEdit) {
classEdit.close();
+ }
}
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
+ target + (replacement.equals("") ? System
.getProperty("line.separator") : ""),
replacement));
bot.sleep(Timing.time1S());
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-10-18
13:26:50 UTC (rev 35762)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java 2011-10-18
13:46:55 UTC (rev 35763)
@@ -19,6 +19,7 @@
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 {
@@ -312,7 +313,7 @@
bot().button("Add...", 0).click();
SWTBotShell sh = bot().activeShell();
sh.bot().text().setText(intf);
- sh.bot().sleep(1000);
+ sh.bot().sleep(Timing.time2S());
sh.bot().table().getTableItem(0).select();
sh.bot().button("OK").click();
setFocus();
@@ -337,7 +338,7 @@
}
SWTBotShell sh = bot().activeShell();
sh.bot().text().setText(qualifier);
- sh.bot().sleep(1000);
+ sh.bot().sleep(Timing.time2S());
sh.bot().table().getTableItem(0).select();
sh.bot().button("OK").click();
setFocus();