Author: jjankovi
Date: 2011-11-14 07:39:50 -0500 (Mon, 14 Nov 2011)
New Revision: 36321
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/EventsProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean1.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean2.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/ObserverBean.java.cdi
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/wizard/CDIFacetTest.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.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/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/wizards/Wizard.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/CDIPerspectiveTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt
Log:
CDIFindObserverForEventTest + CDIFacetTest + huge refactoring + resources, needed for
tests, added
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/EventsProducer.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/EventsProducer.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/EventsProducer.java.cdi 2011-11-14
12:39:50 UTC (rev 36321)
@@ -0,0 +1,67 @@
+package cdi;
+
+import javax.ejb.Stateless;
+import javax.enterprise.event.Event;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+@Stateless
+public class EventsProducer {
+
+ public EventsProducer() {
+
+ }
+
+ @Inject
+ @Q1
+ Event<MyBean1> myBean1Q1Event;
+
+ @Inject
+ @Any
+ Event<MyBean1> myBean1AnyEvent;
+
+
+ @Inject
+ @Q1
+ Event<MyBean2> myBean2Q1Event;
+
+ @Inject
+ @Any
+ Event<MyBean2> myBean2AnyEvent;
+
+ @Inject
+ @Q2
+ Event<MyBean1> myBean1Q2Event;
+
+ @Inject
+ @Q2
+ Event<MyBean2> myBean2Q2Event;
+
+ public void fireEvent1() {
+ myBean1Q1Event.fire(new MyBean1());
+ }
+
+ public void fireEvent2() {
+ myBean1AnyEvent.fire(new MyBean1());
+ }
+
+ public void fireEvent3() {
+ myBean2Q1Event.fire(new MyBean2());
+ }
+
+ public void fireEvent4() {
+ myBean2AnyEvent.fire(new MyBean2());
+ }
+
+ public void fireEvent5() {
+ myBean1Q2Event.fire(new MyBean1());
+ }
+
+ public void fireEvent6() {
+ myBean2Q2Event.fire(new MyBean2());
+ }
+
+ public void fireEvent7() {
+ myBean1AnyEvent.fire(new MyBean2());
+ }
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean1.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean1.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean1.java.cdi 2011-11-14
12:39:50 UTC (rev 36321)
@@ -0,0 +1,15 @@
+package cdi;
+
+public class MyBean1 {
+
+ String message;
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean2.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean2.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/MyBean2.java.cdi 2011-11-14
12:39:50 UTC (rev 36321)
@@ -0,0 +1,5 @@
+package cdi;
+
+public class MyBean2 extends MyBean1 {
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/ObserverBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/ObserverBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/events/ObserverBean.java.cdi 2011-11-14
12:39:50 UTC (rev 36321)
@@ -0,0 +1,41 @@
+package cdi;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+
+public class ObserverBean {
+
+
+ public void observeNoQualifierMyBean1(@Observes MyBean1 bean) {
+
+ }
+
+ public void observeAnyMyBean1(@Observes @Any MyBean1 bean) {
+
+ }
+
+ public void observeQ1MyBean1(@Observes @Q1 MyBean1 bean) {
+
+ }
+
+ public void observeNoQualifierMyBean2(@Observes MyBean2 bean) {
+
+ }
+
+ public void observeAnyMyBean2(@Observes @Any MyBean2 bean) {
+
+ }
+
+ public void observeQ1MyBean2(@Observes @Q1 MyBean2 bean) {
+
+ }
+
+ public void observeQ2MyBean1(@Observes @Q2 MyBean1 bean) {
+
+ }
+
+ public void observeQ2MyBean2(@Observes @Q2 MyBean2 bean) {
+
+ }
+
+}
\ 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-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -10,7 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test;
-import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
+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;
@@ -19,7 +19,7 @@
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.CDIPerspectiveTest;
+import org.jboss.tools.cdi.bot.test.wizard.CDIFacetTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -42,7 +42,7 @@
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 14min
+ * Suite duration: aprox. 19min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
@@ -50,9 +50,10 @@
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
//CDIPerspectiveTest.class,
- CDIConfigurationPresetTest.class,
+ CDIConfigurationPresetTest.class,
+ CDIFacetTest.class,
CDIATWizardTest.class,
- BeansEditorTest.class,
+ CDIBeansEditorTest.class,
CDIQuickFixTest.class,
CDIOpenOnTest.class,
CDIFindObserverForEventTest.class,
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-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -10,10 +10,12 @@
******************************************************************************/
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.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -36,7 +38,7 @@
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 12min
+ * Suite duration: aprox. 3min
*
* @author Jaroslav Jankovic
*/
@@ -44,7 +46,9 @@
@SuiteClasses({
//CDIPerspectiveTest.class,
CDIConfigurationPresetTest.class,
+ CDIFacetTest.class,
CDIATWizardTest.class,
+ CDIBeansEditorTest.class,
})
public class CDISmokeBotTests extends CDIBase {
Deleted:
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-11-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -1,287 +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.io.InputStream;
-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.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.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-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.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.types.EntityType;
-import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-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
- *
- *
- * TO DO - copy resources into right location - PACKAGE_NAME
- *
- * @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 CDIBase {
-
- private static final String descPath = "WebContent/WEB-INF/beans.xml";
- private static final String project = "CDIProject";
- private static final String PACKAGE_NAME = "cdi";
- private static final Logger LOGGER = Logger.getLogger(BeansEditorTest.class.getName());
-
- @BeforeClass
- public static void prepare() {
- if (!projectExists(project)) {
- createAndCheckCDIProject(bot, util, projectExplorer, project);
- createPackage(PACKAGE_NAME);
- }
-
- copyResource("resources/beans.xml", descPath);
- copyResource("resources/Foo.jav_", "src/" + PACKAGE_NAME +
"/Foo.java");
- copyResource("resources/Bar.jav_", "src/" + PACKAGE_NAME +
"/Bar.java");
- }
-
- @AfterClass
- public static void clean() {
- removeObjectInProjectExplorer(PACKAGE_NAME, project + "/Java
Resources/src");
- removeObjectInProjectExplorer("beans.xml", project +
"/WebContent/WEB-INF");
- }
-
- @Before
- public void setup() {
- new ProjectExplorer().openFile(project, descPath.split("/"));
- }
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
- @Test
- public void testClasses() {
- addItem(Item.CLASS, PACKAGE_NAME + ".Foo");
- addItem(Item.CLASS, PACKAGE_NAME + ".Bar");
- removeItem(Item.CLASS, PACKAGE_NAME + ".Foo");
- }
-
- @Test
- public void testInterceptors() {
- addItem(Item.INTERCEPTOR, PACKAGE_NAME + ".I1");
- removeItem(Item.INTERCEPTOR, PACKAGE_NAME + ".I1");
- addItem(Item.INTERCEPTOR, PACKAGE_NAME + ".I2");
- }
-
-
- @Test
- public void testDecorators() {
- addItem(Item.DECORATOR, PACKAGE_NAME + ".MapDecorator");
- addItem(Item.DECORATOR, PACKAGE_NAME + ".ComparableDecorator");
- removeItem(Item.DECORATOR, PACKAGE_NAME + ".ComparableDecorator");
- }
-
-
- @Test
- public void testStereotypes() {
- addItem(Item.STEREOTYPE, PACKAGE_NAME + ".S2");
- addItem(Item.STEREOTYPE, PACKAGE_NAME + ".S3");
- removeItem(Item.STEREOTYPE, PACKAGE_NAME + ".S3");
- addItem(Item.STEREOTYPE, PACKAGE_NAME + ".S1");
- removeItem(Item.STEREOTYPE, PACKAGE_NAME + ".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, PACKAGE_NAME + ".I2"));
-
- nl = getItems(text, Item.DECORATOR);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, PACKAGE_NAME + ".MapDecorator"));
-
- nl = getItems(text, Item.CLASS);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, PACKAGE_NAME + ".Bar"));
-
- nl = getItems(text, Item.STEREOTYPE);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, PACKAGE_NAME + ".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;
- }
-
- private static void createPackage(String packageName) {
- projectExplorer.selectProject(project);
- eclipse.createNew(EntityType.JAVA_PACKAGE);
- SWTBot packageDialogBot = bot.activeShell().bot();
- packageDialogBot.textWithLabel("Name:").typeText(packageName);
- packageDialogBot.button("Finish").click();
- util.waitForNonIgnoredJobs();
- LOGGER.info("Package " + PACKAGE_NAME + " created");
- }
-
- private static void copyResource(String src, String target) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProjects()[0];
- IFile f = project.getFile(target);
- if (f.exists()) {
- LOGGER.info("Replacing " + target + " file");
- try {
- f.delete(true, new NullProgressMonitor());
- } catch (CoreException ce) {
- LOGGER.log(Level.WARNING, ce.getMessage(), ce);
- }
- }
- InputStream is = null;
- try {
- is = BeansEditorTest.class.getResourceAsStream(src);
- f.create(is, true, new NullProgressMonitor());
- } catch (CoreException ce) {
- LOGGER.log(Level.WARNING, ce.getMessage(), ce);
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException ioe) {
- //ignore
- }
- }
- }
- }
-}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -0,0 +1,225 @@
+/*******************************************************************************
+ * 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;
+ }
+
+}
Modified:
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-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -10,64 +10,327 @@
******************************************************************************/
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.After;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
/**
-* Test operates on CDI perspective
-*
-* @author Jaroslav Jankovic
-*/
+ * Test operates on CDI perspective
+ *
+ * @author Jaroslav Jankovic
+ */
-@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
public class CDIFindObserverForEventTest extends CDIBase {
- //private static final Logger LOGGER =
Logger.getLogger(CDIFindObserverForEventTest.class.getName());
- private static final String PROJECT_NAME = "CDIProject";
- //private static final String PACKAGE_NAME = "cdi";
-
-
- @BeforeClass
- public static void checkAndCreateProject() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
- }
+ 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";
}
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
- //not implemented yet
@Test
- public void testSimpleObserverFinding() {
+ public void testSimpleCaseObserverFinding() {
+
prepareSimpleObserverFinding();
-
+
+ testSimpleObserverFinding();
+
}
- //not implemented yet
+
+ // not implemented yet
@Test
- public void testComplexObserverFinding() {
- prepareComplexObserverFinding();
+ 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 prepareComplexObserverFinding() {
+
+ 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)
+ */
+ }
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-11-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -20,9 +20,6 @@
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.AfterClass;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -36,43 +33,28 @@
* TO DO
*
* - Classes indication for Open Injected Class works
- * -
https://issues.jboss.org/browse/JBIDE-6179
*
*
*/
-@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
public class CDIOpenOnTest extends CDIBase {
private static final Logger LOGGER = Logger.getLogger(CDIQuickFixTest.class.getName());
- private static final String PROJECT_NAME = "CDIProject";
- private static final String PACKAGE_NAME = "cdi";
- @BeforeClass
- public static void checkAndCreateProject() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
- }
+ @Override
+ public String getProjectName() {
+ return "CDIOpenOnTest";
}
-
- @AfterClass
- public static void clean() {
- removeObjectInProjectExplorer("beans.xml", PROJECT_NAME +
"/WebContent/WEB-INF");
- }
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
+
@Test
public void testBeanInjectOpenOn() {
- createComponent(CDICOMPONENT.BEAN, "Animal", PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, "Animal", getPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, "BrokenFarm", PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, "BrokenFarm", getPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
.getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
@@ -91,39 +73,39 @@
/*
* 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.
+ * beans.xml into getProjectName()/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);
+ 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", PACKAGE_NAME,
+ createComponent(CDICOMPONENT.DECORATOR, "D1", getPackageName(),
"java.util.Set");
bot.editorByTitle("beans.xml").show();
bot.cTabItem("Source").activate();
- openOn(PACKAGE_NAME + ".D1", "beans.xml", null);
+ openOn(getPackageName() + ".D1", "beans.xml", null);
assertTrue("ERROR: redirected to " + getEd().getTitle(),
getEd().getTitle().equals("D1.java"));
- createComponent(CDICOMPONENT.INTERCEPTOR, "Interceptor1", PACKAGE_NAME,
+ createComponent(CDICOMPONENT.INTERCEPTOR, "Interceptor1", getPackageName(),
null);
bot.editorByTitle("beans.xml").show();
- openOn(PACKAGE_NAME + ".Interceptor1", "beans.xml", null);
+ openOn(getPackageName() + ".Interceptor1", "beans.xml", null);
assertTrue("ERROR: redirected to " + getEd(),
getEd().getTitle().equals("Interceptor1.java"));
- createComponent(CDICOMPONENT.BEAN, "B1", PACKAGE_NAME,
+ createComponent(CDICOMPONENT.BEAN, "B1", getPackageName(),
"alternative+beansxml");
bot.editorByTitle("beans.xml").show();
- openOn(PACKAGE_NAME + ".B1", "beans.xml", null);
+ openOn(getPackageName() + ".B1", "beans.xml", null);
assertTrue("ERROR: redirected to " + getEd(),
getEd().getTitle().equals("B1.java"));
- createComponent(CDICOMPONENT.STEREOSCOPE, "S1", PACKAGE_NAME,
+ createComponent(CDICOMPONENT.STEREOSCOPE, "S1", getPackageName(),
"alternative+beansxml");
bot.editorByTitle("beans.xml").show();
- openOn(PACKAGE_NAME + ".S1", "beans.xml", null);
+ openOn(getPackageName() + ".S1", "beans.xml", null);
assertTrue("ERROR: redirected to " + getEd(),
getEd().getTitle().equals("S1.java"));
@@ -137,8 +119,8 @@
public void testDisposerProducerOpenOn() {
String testedBean = "DisposerProducerBean";
- createComponent(CDICOMPONENT.BEAN, "MyBean", PACKAGE_NAME, null);
- createComponent(CDICOMPONENT.BEAN, testedBean, PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, "MyBean", getPackageName(), null);
+ createComponent(CDICOMPONENT.BEAN, testedBean, getPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
.getResourceAsStream("/resources/cdi/" + testedBean +
".java.cdi"),
false);
@@ -151,12 +133,12 @@
@Test
public void testObserverOpenOn() {
- createComponent(CDICOMPONENT.QUALIFIER, "Q1", PACKAGE_NAME, null);
- createComponent(CDICOMPONENT.BEAN, "MyBean3", PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
+ createComponent(CDICOMPONENT.BEAN, "MyBean3", getPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
.getResourceAsStream("/resources/cdi/MyBean3.java.cdi"),
false);
- createComponent(CDICOMPONENT.BEAN, "MyBean4", PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, "MyBean4", getPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
.getResourceAsStream("/resources/cdi/MyBean4.java.cdi"),
false);
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-11-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -21,9 +21,6 @@
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.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -34,45 +31,39 @@
* @author Jaroslav Jankovic
*/
-@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
public class CDIQuickFixTest extends CDIBase {
- private static final String PROJECT_NAME = "CDIProject";
- private static final String PACKAGE_NAME = "cdi";
private static SWTBotTreeItem[] problemsTrees;
private static final String LINE_SEPARATOR =
System.getProperty("line.separator");
-
- @BeforeClass
- public static void checkAndCreateProject() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
- }
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixTest";
}
- @AfterClass
- public static void clean() {
- removeObjectInProjectExplorer(PACKAGE_NAME, PROJECT_NAME + "/Java
Resources/src");
- }
-
/*
* check problems (warnings and errors in Problems View)
*/
- @After
+ @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, PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, className, getPackageName(), null);
//
https://issues.jboss.org/browse/JBIDE-8550
checkSerializableAnnotation(CDICOMPONENT.BEAN, className);
@@ -81,7 +72,7 @@
@Test
public void testMultipleBeansQF() {
String className = "BrokenFarm";
- createComponent(CDICOMPONENT.BEAN, className, PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, className, getPackageName(), null);
//
https://issues.jboss.org/browse/JBIDE-7635
checkMultipleBeans(CDICOMPONENT.BEAN, className);
@@ -208,7 +199,7 @@
* method edits default Target form because of "one space inconsistency"
*/
private void prepareCdiComponent(CDICOMPONENT component, String name) {
- createComponent(component, name, PACKAGE_NAME, null);
+ createComponent(component, name, getPackageName(), null);
switch (component) {
case QUALIFIER:
CDIUtil.replaceInEditor(getEd(), bot, "@Target({ TYPE, METHOD, PARAMETER, FIELD
})",
@@ -237,11 +228,11 @@
}
private void prepareMultipleBeans(String className) {
- createComponent(CDICOMPONENT.BEAN, "Animal", PACKAGE_NAME, null);
- createComponent(CDICOMPONENT.BEAN, "Dog", PACKAGE_NAME, null);
+ 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", PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
bot.editorByTitle(className + ".java").show();
setEd(bot.activeEditor().toTextEditor());
CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
@@ -326,9 +317,9 @@
}
private void prepareComponentsForSpecializeAnnotation(String testBeanName) {
- createComponent(CDICOMPONENT.BEAN, "AnyBean", PACKAGE_NAME, null);
- createComponent(CDICOMPONENT.INTERBINDING, "AnyBinding", PACKAGE_NAME,
null);
- createComponent(CDICOMPONENT.BEAN, testBeanName, PACKAGE_NAME, null);
+ 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);
}
@@ -605,18 +596,18 @@
private void checkNonBindingAnnotationWithAddon(CDICOMPONENT comp, String className,
String replacement) {
if (comp == CDICOMPONENT.INTERBINDING) {
- boolean interceptorCreated = projectExplorer.isFilePresent(PROJECT_NAME,
- "Java Resources", "src", PACKAGE_NAME, className +
".java");
+ boolean interceptorCreated = projectExplorer.isFilePresent(getProjectName(),
+ "Java Resources", "src", getPackageName(), className +
".java");
if (!interceptorCreated) {
- createComponent(CDICOMPONENT.INTERBINDING, className, PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.INTERBINDING, className, getPackageName(), null);
}
}
if (replacement.equals("Annotation")) {
- boolean annotationCreated = projectExplorer.isFilePresent(PROJECT_NAME,
- "Java Resources", "src", PACKAGE_NAME,
"AAnnotation.java");
+ boolean annotationCreated = projectExplorer.isFilePresent(getProjectName(),
+ "Java Resources", "src", getPackageName(),
"AAnnotation.java");
if (!annotationCreated) {
- createComponent(null, "AAnnotation", PACKAGE_NAME, null);
+ createComponent(null, "AAnnotation", getPackageName(), null);
}
bot.editorByTitle(className + ".java").show();
setEd(bot.activeEditor().toTextEditor());
@@ -684,7 +675,7 @@
problemsContains = "Multiple beans are eligible";
}
problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, problemsContains,
"/"
- + PROJECT_NAME, className, "CDI Problem");
+ + getProjectName(), className, "CDI Problem");
} else {
if (className.equals("InterDecor.java")) {
if (getEd().toTextEditor().getText().contains("produceString")) {
@@ -698,7 +689,7 @@
}
}
problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, problemsContains,
"/"
- + PROJECT_NAME, className, "CDI Problem");
+ + getProjectName(), className, "CDI Problem");
}
return problemsTree;
}
@@ -754,7 +745,7 @@
util.waitForNonIgnoredJobs();
assertFalse(bot.button("Add >").isEnabled());
assertFalse(bot.button("Finish").isEnabled());
- bot.table(0).click(bot.table(0).indexOf("Q1 - " + PACKAGE_NAME), 0);
+ bot.table(0).click(bot.table(0).indexOf("Q1 - " + getPackageName()), 0);
assertTrue(bot.button("Add >").isEnabled());
assertFalse(bot.button("Finish").isEnabled());
bot.clickButton("Add >");
@@ -785,24 +776,24 @@
SWTBotTreeItem[] problemsTree = null;
if (problemType == PROBLEM_TYPE.WARNINGS) {
problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + PROJECT_NAME, null, null);
+ + getProjectName(), null, null);
}else if (problemType == PROBLEM_TYPE.ERRORS) {
problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
- + PROJECT_NAME, null, null);
+ + getProjectName(), null, null);
}
return problemsTree;
}
private void cleanWarnings(String className) {
problemsTrees = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + PROJECT_NAME, className + ".java", 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, "/"
- + PROJECT_NAME, className, "CDI Problem");
+ + getProjectName(), className, "CDI Problem");
assertTrue(problemsTrees.length == 0);
}
}
Modified:
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-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -27,7 +27,6 @@
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.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -38,29 +37,35 @@
* @author Jaroslav Jankovic
*/
-@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
@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 = "CDIProject";
- private static final String PACKAGE_NAME = "cdi";
- private static final String GENERIC_PACKAGE_NAME = "org.cdi.generic";
private final String genericPoint1 = "MyExtendedConfiguration ";
private final String genericPoint2 =
"MyConfigurationProducer.getOneConfig()";
private final String genericPoint3 =
"MyConfigurationProducer.getSecondConfig()";
- @BeforeClass
- public static void checkAndCreateProject() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectExists(getProjectName())) {
+ createAndCheckCDIProject(bot, util, projectExplorer,getProjectName());
+ addLibrary("seam-solder.jar");
+ checkLibrary("seam-solder.jar");
}
- 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();
@@ -72,9 +77,9 @@
@Test
public void testResourceOpenOn() {
- createComponent(CDICOMPONENT.BEANSXML, "beans.xml", PROJECT_NAME +
"/WebContent/WEB-INF", null);
+ createComponent(CDICOMPONENT.BEANSXML, "beans.xml", getProjectName() +
"/WebContent/WEB-INF", null);
- createComponent(CDICOMPONENT.BEAN, "B2", PACKAGE_NAME, 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");
@@ -83,8 +88,8 @@
assertTrue("ERROR: redirected to " + destinationFile,
destinationFile.equals("beans.xml"));
- moveFileInProjectExplorer("beans.xml", PROJECT_NAME +
"/WebContent/WEB-INF",
- PROJECT_NAME + "/WebContent/META-INF");
+ 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"));
@@ -112,19 +117,20 @@
checkMyGenericBean2();
}
- private static void addLibrary(String libraryName) {
+ private void addLibrary(String libraryName) {
try {
- addLibraryIntoProject(PROJECT_NAME, libraryName);
+ addLibraryIntoProject(getProjectName(), libraryName);
LOGGER.info("Library: \"" + libraryName + "\" copied");
- addLibraryToProjectsClassPath(PROJECT_NAME, libraryName);
- LOGGER.info("Library: \"" + libraryName + "\" on class path
of project\"" + PROJECT_NAME + "\"");
+ 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 static void checkLibrary(String libraryName) {
- isLibraryInProjectClassPath(PROJECT_NAME, libraryName);
+ private void checkLibrary(String libraryName) {
+ isLibraryInProjectClassPath(getProjectName(), libraryName);
}
/**
@@ -134,38 +140,38 @@
/*
* injectable beans + qualifiers + generic configuration components
*/
- createComponent(CDICOMPONENT.BEAN, "MyBean", GENERIC_PACKAGE_NAME, null);
+ 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", GENERIC_PACKAGE_NAME, null);
+ 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", GENERIC_PACKAGE_NAME, null);
+ 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", GENERIC_PACKAGE_NAME,
null);
+ 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", GENERIC_PACKAGE_NAME,
null);
+ createComponent(CDICOMPONENT.BEAN, "MyGenericType", getGenericPackageName(),
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.QUALIFIER, "Qualifier1",
getGenericPackageName(), null);
+ createComponent(CDICOMPONENT.QUALIFIER, "Qualifier2",
getGenericPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, "MyExtendedConfiguration",
GENERIC_PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, "MyExtendedConfiguration",
getGenericPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
.getResourceAsStream("/resources/generic/MyExtendConfig.java.cdi"),
false);
- createComponent(CDICOMPONENT.BEAN, "MyConfigurationProducer",
GENERIC_PACKAGE_NAME, null);
+ createComponent(CDICOMPONENT.BEAN, "MyConfigurationProducer",
getGenericPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
.getResourceAsStream("/resources/generic/MyConfigProd.java.cdi"),
false);
@@ -174,15 +180,15 @@
* generic configurations
*/
- createComponent(CDICOMPONENT.BEAN, "MyBeanInjections", GENERIC_PACKAGE_NAME,
null);
+ createComponent(CDICOMPONENT.BEAN, "MyBeanInjections",
getGenericPackageName(), null);
CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
.getResourceAsStream("/resources/generic/MyBeanInjections.java.cdi"),
false);
- createComponent(CDICOMPONENT.BEAN, "MyGenericBean", GENERIC_PACKAGE_NAME,
null);
+ createComponent(CDICOMPONENT.BEAN, "MyGenericBean", getGenericPackageName(),
null);
CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
.getResourceAsStream("/resources/generic/MyGenericBean.java.cdi"), false);
- createComponent(CDICOMPONENT.BEAN, "MyGenericBean2", GENERIC_PACKAGE_NAME,
null);
+ createComponent(CDICOMPONENT.BEAN, "MyGenericBean2", getGenericPackageName(),
null);
CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
.getResourceAsStream("/resources/generic/MyGenericBean2.java.cdi"),
false);
}
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-11-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -2,7 +2,7 @@
* 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,
+ * Eclipse public License v1.0 which accompanies this distribution,
* and is available at
http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
@@ -38,8 +38,33 @@
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
@@ -132,7 +157,7 @@
}
- public static void createAndCheckCDIProject(SWTBotExt bot, SWTUtilExt util,
+ public void createAndCheckCDIProject(SWTBotExt bot, SWTUtilExt util,
ProjectExplorer projectExplorer, String projectName) {
createCDIProject(util, projectName);
projectExplorer.selectProject(projectName);
@@ -142,21 +167,29 @@
addCDISupport(tree, item, bot, util);
}
- public static void createCDIProject(SWTUtilExt util, String projectName) {
+ public 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 createCDIProjectWithCDIPreset(SWTUtilExt util, String projectName) {
+ 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 static void addCDISupport(final SWTBotTree tree, SWTBotTreeItem item,
+ public void addCDISupport(final SWTBotTree tree, SWTBotTreeItem item,
SWTBotExt bot, SWTUtilExt util) {
CDIUtil.nodeContextMenu(tree, item, "Configure",
"Add CDI (Context and Dependency Injection) support...")
@@ -194,7 +227,7 @@
setEd(bot.activeEditor().toTextEditor());
}
- public static void addLibraryToProjectsClassPath(String projectName, String libraryName)
{
+ public void addLibraryToProjectsClassPath(String projectName, String libraryName) {
SWTBotTree tree = projectExplorer.bot().tree();
ContextMenuHelper.prepareTreeItemForContextMenu(tree);
@@ -220,7 +253,7 @@
* copy library located in PROJECT_NAME/resources/libraries into project
* libraryName must include extension: seam-solder.jar
*/
- public static void addLibraryIntoProject(String projectName, String libraryName) throws
IOException {
+ public void addLibraryIntoProject(String projectName, String libraryName) throws
IOException {
File in = null;
FileChannel inChannel = null;
FileChannel outChannel = null;
@@ -244,7 +277,7 @@
* check if library with name libraryName is set on classpath of project with name
* projectName
*/
- public static void isLibraryInProjectClassPath(String projectName, String libraryName)
{
+ public void isLibraryInProjectClassPath(String projectName, String libraryName) {
SWTBotTree tree = projectExplorer.bot().tree();
ContextMenuHelper.prepareTreeItemForContextMenu(tree);
@@ -288,7 +321,7 @@
bot.button("OK").click();
}
- public static void removeObjectInProjectExplorer(String object, String sourceFolder) {
+ public void removeObjectInProjectExplorer(String object, String sourceFolder) {
SWTBotTree tree = projectExplorer.bot().tree();
SWTBotTreeItem item = projectExplorer.selectTreeItem(object,
sourceFolder.split("/"));
@@ -301,7 +334,7 @@
bot.sleep(Timing.time2S());
}
- public static boolean projectExists(String projectName) {
+ public boolean projectExists(String projectName) {
SWTBotTree tree = projectExplorer.bot().tree();
boolean projectExists = false;
try {
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-11-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -10,9 +10,15 @@
******************************************************************************/
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;
@@ -22,6 +28,7 @@
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;
@@ -33,6 +40,12 @@
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();
}
@@ -56,6 +69,31 @@
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) {
@@ -187,6 +225,7 @@
}
}
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);
}
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-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -11,10 +11,12 @@
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
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.jboss.tools.ui.bot.ext.Timing;
public class Wizard extends SWTBotShell {
@@ -66,6 +68,27 @@
return this;
}
+ public Wizard setCDIFacet() {
+ clickButton("Modify...");
+ SWTBot bot = bot().shell("Project Facets").bot();
+ setCDIFacet(bot);
+ bot().sleep(Timing.time1S());
+ return this;
+ }
+
+ private void setCDIFacet(SWTBot bot) {
+ SWTBotTree tree= bot.tree();
+ for (SWTBotTreeItem ti: tree.getAllItems()) {
+ if (ti.cell(0).contains("CDI (Contexts and Dependency Injection)")) {
+ ti.check();
+ break;
+ }
+ }
+ bot.sleep(Timing.time1S());
+ bot.button("OK").click();
+ }
+
+
protected void clickButton(String text) {
bot().button(text).click();
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-11-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIATWizardTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -22,11 +22,10 @@
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.After;
-import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -35,30 +34,29 @@
* @author Lukas Jungmann
* @author jjankovi
*/
-@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
public class CDIATWizardTest extends CDIBase {
- private static final String PROJECT_NAME = "CDIProject";
- private static final String PACKAGE_NAME = "cdi";
private static final Logger L = Logger.getLogger(CDIATWizardTest.class.getName());
- @After
+ public String getProjectName() {
+ return "CDIWizardTest";
+ }
+
+ @Override
public void waitForJobs() {
util.waitForNonIgnoredJobs();
+ /**
+ * needed for creating non-dependant components
+ */
+ projectExplorer.selectProject(getProjectName());
}
-
- @BeforeClass
- public static void checkAndCreateProject() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
- }
- }
@Test
public void testQualifier() {
- CDIUtil.qualifier(PACKAGE_NAME, "Q1", false, false).finish();
+ CDIUtil.qualifier(getPackageName(), "Q1", false, false).finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Q1.java").equals(ed.getTitle()));
@@ -70,7 +68,7 @@
assertFalse(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- CDIUtil.qualifier(PACKAGE_NAME, "Q2", true, true).finish();
+ CDIUtil.qualifier(getPackageName(), "Q2", true, true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Q2.java").equals(ed.getTitle()));
@@ -85,7 +83,7 @@
@Test
public void testScope() {
- CDIUtil.scope(PACKAGE_NAME, "Scope1", true, false, true, false).finish();
+ CDIUtil.scope(getPackageName(), "Scope1", true, false, true,
false).finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Scope1.java").equals(ed.getTitle()));
@@ -99,7 +97,7 @@
assertTrue(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- CDIUtil.scope(PACKAGE_NAME, "Scope2", false, true, true, true).finish();
+ CDIUtil.scope(getPackageName(), "Scope2", false, true, true, true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Scope2.java").equals(ed.getTitle()));
@@ -112,7 +110,7 @@
assertFalse(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
- CDIUtil.scope(PACKAGE_NAME, "Scope3", false, true, false, false).finish();
+ CDIUtil.scope(getPackageName(), "Scope3", false, true, false,
false).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Scope3.java").equals(ed.getTitle()));
@@ -128,7 +126,7 @@
@Test
public void testIBinding() {
- CDIWizard w = CDIUtil.binding(PACKAGE_NAME, "B1", null, true, false);
+ CDIWizard w = CDIUtil.binding(getPackageName(), "B1", null, true, false);
assertEquals(2, w.getTargets().size());
w.finish();
util.waitForNonIgnoredJobs();
@@ -142,7 +140,7 @@
assertTrue(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- CDIUtil.binding(PACKAGE_NAME, "B2", "TYPE", false, true).finish();
+ CDIUtil.binding(getPackageName(), "B2", "TYPE", false,
true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("B2.java").equals(ed.getTitle()));
@@ -154,7 +152,7 @@
assertFalse(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
- CDIUtil.binding(PACKAGE_NAME, "B3", "TYPE", false, true).finish();
+ CDIUtil.binding(getPackageName(), "B3", "TYPE", false,
true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("B3.java").equals(ed.getTitle()));
@@ -166,8 +164,8 @@
assertFalse(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
- w = CDIUtil.binding(PACKAGE_NAME, "B4", "TYPE", true, false);
- w.addIBinding(PACKAGE_NAME + ".B2");
+ w = CDIUtil.binding(getPackageName(), "B4", "TYPE", true, false);
+ w.addIBinding(getPackageName() + ".B2");
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -184,7 +182,7 @@
@Test
public void testStereotype() {
- CDIWizard w = CDIUtil.stereotype(PACKAGE_NAME, "S1", null, null, false,
false, false, false,
+ CDIWizard w = CDIUtil.stereotype(getPackageName(), "S1", null, null, false,
false, false, false,
false);
assertEquals(9, w.getScopes().size());
assertEquals(5, w.getTargets().size());
@@ -202,7 +200,7 @@
assertFalse(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- CDIUtil.stereotype(PACKAGE_NAME, "S2", "@Scope3",
"FIELD", true, true, true, false, true)
+ CDIUtil.stereotype(getPackageName(), "S2", "@Scope3",
"FIELD", true, true, true, false, true)
.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -218,9 +216,9 @@
assertTrue(code.contains("@Target({ FIELD })"));
assertTrue(code.startsWith("/**"));
- w = CDIUtil.stereotype(PACKAGE_NAME, "S3", null, null, false, false, true,
false, false);
- w.addIBinding(PACKAGE_NAME + ".B1");
- w.addStereotype(PACKAGE_NAME + ".S1");
+ 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();
@@ -241,7 +239,8 @@
@Test
public void testDecorator() {
- CDIWizard w = CDIUtil.decorator(PACKAGE_NAME, "",
"java.lang.Comparable", null, true, true, false, false);
+ 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");
@@ -257,7 +256,7 @@
assertFalse(code.contains("final"));
assertFalse(code.startsWith("/**"));
- w = CDIUtil.decorator(PACKAGE_NAME, "", "java.util.Map",
"field", false, false, true, true);
+ w = CDIUtil.decorator(getPackageName(), "", "java.util.Map",
"field", false, false, true, true);
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().editorByTitle("MapDecorator.java");
@@ -276,7 +275,7 @@
@Test
public void testInterceptor() {
- CDIWizard w = CDIUtil.interceptor(PACKAGE_NAME, "I1", "B2", null,
null, false);
+ CDIWizard w = CDIUtil.interceptor(getPackageName(), "I1", "B2",
null, null, false);
w.finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("I1.java");
@@ -290,7 +289,7 @@
assertFalse(code.contains("final"));
assertFalse(code.startsWith("/**"));
- w = CDIUtil.interceptor(PACKAGE_NAME, "I2", "B4",
"java.util.Date", "sample", true);
+ w = CDIUtil.interceptor(getPackageName(), "I2", "B4",
"java.util.Date", "sample", true);
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().editorByTitle("I2.java");
@@ -309,9 +308,9 @@
@Test
public void testBeansXml() {
CDIWizard w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
- w.setSourceFolder(PROJECT_NAME + "/WebContent/WEB-INF");
+ w.setSourceFolder(getProjectName() + "/WebContent/WEB-INF");
assertFalse(w.canFinish());
- w.setSourceFolder(PROJECT_NAME + "/src/" +
PACKAGE_NAME.replaceAll(".", "/"));
+ w.setSourceFolder(getProjectName() + "/src/" +
getPackageName().replaceAll(".", "/"));
assertTrue(w.canFinish());
w.cancel();
w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
@@ -321,7 +320,7 @@
@Test
public void testBean() {
- CDIWizard w = CDIUtil.bean(PACKAGE_NAME, "Bean1", true, true, false, false,
false, false, null, null, null, null);
+ 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();
@@ -334,7 +333,7 @@
assertFalse(code.contains("final"));
assertFalse(code.startsWith("/**"));
- w = CDIUtil.bean(PACKAGE_NAME, "Bean2", false, false, true, true, false,
false, "", null, "@Dependent", null);
+ w = CDIUtil.bean(getPackageName(), "Bean2", false, false, true, true, false,
false, "", null, "@Dependent", null);
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -348,7 +347,7 @@
assertTrue(code.contains("final class Bean2 {"));
assertTrue(code.startsWith("/**"));
- w = CDIUtil.bean(PACKAGE_NAME, "Bean3", true, false, false, true, false,
false, "TestedBean", null, "@Scope2", "Q1");
+ w = CDIUtil.bean(getPackageName(), "Bean3", true, false, false, true, false,
false, "TestedBean", null, "@Scope2", "Q1");
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -366,7 +365,7 @@
@Test
public void testAnnLiteral() {
- CDIWizard w = CDIUtil.annLiteral(PACKAGE_NAME, "AnnL1", true, false, true,
false, PACKAGE_NAME + ".Q1");
+ CDIWizard w = CDIUtil.annLiteral(getPackageName(), "AnnL1", true, false,
true, false, getPackageName() + ".Q1");
w.finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
@@ -379,7 +378,7 @@
assertFalse(code.contains("abstract"));
assertFalse(code.startsWith("/**"));
- w = CDIUtil.annLiteral(PACKAGE_NAME, "AnnL2", false, true, false, true,
"Q2");
+ w = CDIUtil.annLiteral(getPackageName(), "AnnL2", false, true, false, true,
"Q2");
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
Modified:
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-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -23,7 +23,6 @@
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.After;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -40,18 +39,23 @@
public class CDIConfigurationPresetTest extends CDIBase {
private static final Logger LOGGER =
Logger.getLogger(CDIConfigurationPresetTest.class.getName());
- private static final String PROJECT_NAME = "CDIPresetProject";
-
- @After
- public void waitForJobs() {
- jbt.deleteProject(PROJECT_NAME);
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectExists(getProjectName())) {
+ createCDIProjectWithCDIPreset(util, getProjectName());
+ }
}
+ @Override
+ public String getProjectName() {
+ return "CDIPresetProject";
+ }
+
@Test
public void testCDIPreset() {
- createCDIProjectWithCDIPreset(util, PROJECT_NAME);
LOGGER.info("Dynamic Web Project with CDI Configuration Preset created");
- assertTrue(checkCDISupport(PROJECT_NAME));
+ assertTrue(checkCDISupport(getProjectName()));
}
private boolean checkCDISupport(String projectName) {
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -0,0 +1,53 @@
+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";
+ }
+
+}
Modified:
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-13
19:35:17 UTC (rev 36320)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java 2011-11-14
12:39:50 UTC (rev 36321)
@@ -26,7 +26,6 @@
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.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -37,28 +36,31 @@
* @author Jaroslav Jankovic
*/
-@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
public class CDIPerspectiveTest extends CDIBase {
private static final Logger LOGGER =
Logger.getLogger(CDIPerspectiveTest.class.getName());
- private static final String PROJECT_NAME = "CDIProject";
private enum CDIARTIFACTS {
BEAN, QUALIFIER, STEREOTYPE, SCOPE, INTERBINDING, INTERCEPTOR, DECORATOR, ANNOTLITERAL,
BEANSXML
}
-
- @BeforeClass
- public static void checkAndCreateProject() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
+ @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());
}
- eclipse.openPerspective(PerspectiveType.CDI);
- LOGGER.info("CDI perspective selected");
- bot.sleep(Timing.time2S());
}
+ @Override
+ public String getProjectName() {
+ return "CDIPerspectiveTest";
+ }
+
@Test
public void testCDIArtifactBeanWizard() {
@@ -104,7 +106,7 @@
private boolean openCDIArtifactsWizard(CDIARTIFACTS artifact) {
SWTBotTree tree = packageExplorer.bot().tree();
- SWTBotTreeItem item = tree.getTreeItem(PROJECT_NAME);
+ SWTBotTreeItem item = tree.getTreeItem(getProjectName());
item.expand();
boolean artifactWizardExists = true;
try {
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-13 19:35:17 UTC (rev
36320)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt 2011-11-14 12:39:50 UTC (rev
36321)
@@ -1,3 +1,32 @@
+/**
+ * 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
+ * 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
+ * 6. CDI @Named beans are renamed via refactoring and shows up correctly
+ * when using Find References for EL Expressions
+ * 8. Create new decorator from existing Web Bean
+ * 9. EL refactoring for @Named beans works
+ *
+ *
+ * what tests have to be done(JBDS50_0015):
+ * 1. OpenOn works for injected classes
+ * 2. OpenOn works in Seam Config for given beans
+ * 3. OpenOn works for Bean injected into java source files declard in seam-config.xml
can be navigated
+ * 4. Seam-beans.xml validation works
+ * 5. Seam3 not-trivial example works with JBDS without errors and as expected
+ * 6. Wel extension(beans_1_1.xsd) is now supported by beans.xml editor
+ * 7. Non-serializable passivating-scoped beans are now validated correctly
+ * 8. Code completion and validation works in seam config for annotated CDI beans
+ * 9. Seam3 features is enabled automatically for CDI support enabled project containing
corresponding Seam module
+ * 10.CDI supports Seam3 annotations
(@Veto,@Requires,@Exact,@MessageLogger,@MessageBundle
+ * @DefaultBean,@Unwraps,@ServiceHandlerType,@FullyQualified,@Resource)
+ * 11.CDI tools can work with generic beans and validation, code completion, hyperlinks,
+ * refactoring is working as expected
+ */
+
UI tests to implement for CDI (based on F2F meeting)
hyperlinks (...open ons etc)