Author: jlukas(a)redhat.com
Date: 2010-07-16 08:57:08 -0400 (Fri, 16 Jul 2010)
New Revision: 23495
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.classpath
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.settings/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.settings/org.eclipse.jdt.core.prefs
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/META-INF/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/META-INF/MANIFEST.MF
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/build.properties
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/pom.xml
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/Activator.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/
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/CDIWizardType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
Log:
adding basic bot tests for cdi wizards
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.classpath
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.classpath (rev
0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.classpath 2010-07-16 12:57:08 UTC (rev
23495)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.project 2010-07-16 12:57:08 UTC (rev
23495)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.cdi.bot.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/.settings/org.eclipse.jdt.core.prefs 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,8 @@
+#Wed Jul 14 12:01:07 CEST 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/META-INF/MANIFEST.MF 2010-07-16 12:57:08
UTC (rev 23495)
@@ -0,0 +1,19 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: CDI SWTBot Test
+Bundle-SymbolicName: org.jboss.tools.cdi.bot.test
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.jboss.tools.cdi.bot.test.Activator
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.swtbot.eclipse.core;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.ui;bundle-version="2.0.0",
+ org.eclipse.swtbot.junit4_x;bundle-version="2.0.0",
+ org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
+ org.hamcrest;bundle-version="1.1.0",
+ org.junit4;bundle-version="4.8.1",
+ org.apache.log4j;bundle-version="1.2.15",
+ org.eclipse.ui;bundle-version="3.6.0",
+ org.jboss.tools.ui.bot.ext;bundle-version="3.2.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/build.properties
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/build.properties
(rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/build.properties 2010-07-16 12:57:08 UTC
(rev 23495)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/pom.xml
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/pom.xml (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/pom.xml 2010-07-16 12:57:08 UTC (rev
23495)
@@ -0,0 +1,16 @@
+<project
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
+
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <relativePath>../../../parent-pom.xml</relativePath>
+ <groupId>org.jboss.tools</groupId>
+ <artifactId>org.jboss.tools.parent.pom</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.cdi.tests</groupId>
+ <artifactId>org.jboss.tools.cdi.bot.test</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-test-plugin</packaging>
+</project>
+
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/Activator.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/Activator.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/Activator.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ private static BundleContext context;
+
+ static BundleContext getContext() {
+ return context;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext bundleContext) throws Exception {
+ Activator.context = bundleContext;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext bundleContext) throws Exception {
+ Activator.context = null;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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 org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+
+public abstract class Action<T> {
+
+ private final SWTBotExt bot = new SWTBotExt();
+ private final String[] path;
+
+ public Action(String... path) {
+ this.path = path;
+ }
+
+ public abstract T run();
+
+ protected SWTBot performMenu() {
+ assert path.length > 0;
+ SWTBotMenu m = bot.menu(path[0]);
+ for (int i = 1; i < path.length; i++) {
+ m = m.menu(path[i]);
+ }
+ m.click();
+ return new SWTBot();
+ }
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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 org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.Wizard;
+
+public class NewCDIFileWizard extends NewFileWizardAction {
+
+ private final CDIWizardType type;
+
+ public NewCDIFileWizard(CDIWizardType type) {
+ super();
+ this.type = type;
+ }
+
+ @Override
+ public CDIWizard run() {
+ Wizard w = super.run();
+ w.selectTemplate("CDI", type.getAnnotationType());
+ w.next();
+ return new CDIWizard(type);
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.uiutils.actions;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.Wizard;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+
+public class NewFileWizardAction extends Action<Wizard> {
+
+ public NewFileWizardAction() {
+ super(IDELabel.Menu.FILE, IDELabel.Menu.NEW, IDELabel.Menu.OTHER);
+ }
+
+ @Override
+ public Wizard run() {
+ SWTBot b = performMenu();
+ return new Wizard(b.activeShell().widget);
+ }
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+
+public class CDIWizard extends Wizard {
+
+ private final CDIWizardType type;
+
+ public CDIWizard(CDIWizardType type) {
+ super(new SWTBot().activeShell().widget);
+ assert ("New " + type).equals(getText());
+ this.type = type;
+ }
+
+ public CDIWizard setName(String name) {
+ setText("Name:", name);
+ return this;
+ }
+
+ public CDIWizard setPackage(String pkg) {
+ setText("Package:", pkg);
+ return this;
+ }
+
+ public CDIWizard setInherited(boolean set) {
+ setCheckbox("Add @Inherited", set);
+ return this;
+ }
+
+ public boolean isInherited() {
+ return isCheckboxSet("Add @Inherited");
+ }
+
+ public CDIWizard setGenerateComments(boolean set) {
+ setCheckbox("Generate comments", set);
+ return this;
+ }
+
+ public boolean isGenerateComments() {
+ return isCheckboxSet("Generate comments");
+ }
+
+ public CDIWizard setNormalScope(boolean set) {
+ switch (type) {
+ case SCOPE:
+ setCheckbox("is normal scope", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isNormalScope() {
+ switch (type) {
+ case SCOPE:
+ return isCheckboxSet("is normal scope");
+ default:
+ return true;
+ }
+ }
+
+ public CDIWizard setPassivating(boolean set) {
+ switch (type) {
+ case SCOPE:
+ setCheckbox("is passivating", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isPassivating() {
+ switch (type) {
+ case SCOPE:
+ return isCheckboxSet("is passivating");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizard setAlternative(boolean set) {
+ switch (type) {
+ case STEREOTYPE:
+ setCheckbox("Add @Alternative", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isAlternative() {
+ switch (type) {
+ case STEREOTYPE:
+ return isCheckboxSet("Add @Alternative");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizard setNamed(boolean set) {
+ switch (type) {
+ case STEREOTYPE:
+ setCheckbox("Add @Named", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isNamed() {
+ switch (type) {
+ case STEREOTYPE:
+ return isCheckboxSet("Add @Named");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizard setTarget(String target) {
+ switch (type) {
+ case STEREOTYPE:
+ case INTERCEPTOR_BINDING:
+ setCombo("Target:", target);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getTargets() {
+ return Arrays.asList(bot().comboBoxWithLabel("Target:").items());
+ }
+
+ public CDIWizard setScope(String scope) {
+ switch (type) {
+ case STEREOTYPE:
+ setCombo("Scope:", scope);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getScopes() {
+ return Arrays.asList(bot().comboBoxWithLabel("Scope:").items());
+ }
+
+ private void setCheckbox(String label, boolean set) {
+ SWTBotCheckBox c = bot().checkBox(label);
+ if (c.isChecked() != set) {
+ if (set) {
+ c.select();
+ } else {
+ c.deselect();
+ }
+ }
+ }
+
+ private boolean isCheckboxSet(String label) {
+ SWTBotCheckBox c = bot().checkBox(label);
+ return c.isChecked();
+ }
+
+ private void setCombo(String label, String value) {
+ SWTBotCombo c = bot().comboBoxWithLabel(label);
+ c.setSelection(value);
+ }
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+
+public enum CDIWizardType {
+ INTERCEPTOR_BINDING, QUALIFIER, SCOPE, STEREOTYPE;
+
+ String getName() {
+ switch (this) {
+ case INTERCEPTOR_BINDING:
+ return "Interceptor Binding";
+ case QUALIFIER:
+ return "Qualifier";
+ case SCOPE:
+ return "Scope";
+ case STEREOTYPE:
+ return "Stereotype";
+ default:
+ throw new AssertionError("Unknown type");
+ }
+ }
+
+ public String getAnnotationType() {
+ return getName() + " Annotation Type";
+ }
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+
+public class DynamicWebProjectWizard extends Wizard {
+
+ public DynamicWebProjectWizard() {
+ super(new SWTBot().activeShell().widget);
+ assert "New Dynamic Web Project".equals(getText());
+ }
+
+ public DynamicWebProjectWizard setProjectName(String name) {
+ setText("Project name:", name);
+ return this;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+
+import org.eclipse.swt.widgets.Shell;
+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;
+
+public class Wizard extends SWTBotShell {
+
+ public Wizard(Shell shell) {
+ super(shell);
+ assert getText().contains("New ");
+ }
+
+ public Wizard selectTemplate(String... item) {
+ assert item.length > 0;
+ SWTBotTree tree = bot().tree();
+ SWTBotTreeItem ti = null;
+ for (int i = 0; i < item.length - 1; i++) {
+ ti = ti != null ? ti.expandNode(item[i]).select() :
tree.expandNode(item[i]).select();
+ }
+ if (ti != null) {
+ ti.select(item[item.length - 1]);
+ } else {
+ tree.select(item[item.length - 1]);
+ }
+ return this;
+ }
+
+ public Wizard back() {
+ clickButton("< Back");
+ return this;
+ }
+
+ public Wizard next() {
+ clickButton("Next >");
+ return this;
+ }
+
+ public void cancel() {
+ clickButton("Cancel");
+ }
+
+ public void finish() {
+ clickButton("Finish");
+ }
+
+ protected void clickButton(String text) {
+ bot().button(text).click();
+ }
+
+ protected void setText(String label, String text) {
+ SWTBotText t = bot().textWithLabel(label);
+ t.setText(text);
+ }
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2010-07-16
12:57:08 UTC (rev 23495)
@@ -0,0 +1,257 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.wizard;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewFileWizardAction;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.DynamicWebProjectWizard;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+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.jboss.tools.ui.bot.ext.types.ViewType;
+import org.junit.After;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+@SWTBotTestRequires(perspective = "Java EE", server = @Server(state =
ServerState.NotRunning, version = "6.0", operator = "<="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CdiATWizardTest.class })
+public class CdiATWizardTest extends SWTTestExt {
+
+ private static final String PROJECT_NAME = "CDIProject";
+ private static final Logger L = Logger.getLogger(CdiATWizardTest.class
+ .getName());
+
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ }
+
+ @Test
+ public void createProject() {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(PROJECT_NAME).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBot v = eclipse.showView(ViewType.PROJECT_EXPLORER);
+ SWTBotTree tree = v.tree();
+ tree.setFocus();
+ assertTrue("Project " + PROJECT_NAME + " was not created
properly.",
+ SWTEclipseExt.treeContainsItemWithLabel(tree, PROJECT_NAME));
+ SWTBotTreeItem t = tree.getTreeItem(PROJECT_NAME);
+ t.expand();
+
+ // Configure Add CDI Support...
+ nodeContextMenu(tree, t, "Configure", "Add CDI
support...").click();
+ bot.activeShell().bot().button("OK").click();
+ util.waitForNonIgnoredJobs();
+ }
+
+ @Test
+ public void testQualifier() {
+ qualifier("cdi", "Q1", false, false).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Q1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Qualifier"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ qualifier("cdi", "Q2", true, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Q2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Qualifier"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testScope() {
+ scope("cdi", "Scope1", true, false, true, false).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@NormalScope"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ scope("cdi", "Scope2", false, true, true, false).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@NormalScope"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ scope("cdi", "Scope3", false, true, false, false).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Scope"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testIBinding() {
+ CDIWizard w = binding("cdi", "B1", null, true, false);
+ assertEquals(2, w.getTargets().size());
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ binding("cdi", "B2", "TYPE", false, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testStereotype() {
+ CDIWizard w = stereotype("cdi", "S1", null, null, false, false,
false,
+ false);
+ assertEquals(9, w.getScopes().size());
+ assertEquals(5, w.getTargets().size());
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ stereotype("cdi", "S2", "@Scope3", "FIELD",
true, true, true, true)
+ .finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ FIELD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ private static SWTBotMenu nodeContextMenu(final SWTBotTree tree,
+ SWTBotTreeItem item, final String... menu) {
+ assert menu.length > 0;
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+ public SWTBotMenu run() {
+ SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+ tree, menu[0], false));
+ for (int i = 1; i < menu.length; i++) {
+ m = m.menu(menu[i]);
+ }
+ return m;
+ }
+ });
+ }
+
+ private CDIWizard qualifier(String pkg, String name, boolean inherited,
+ boolean comments) {
+ return create(CDIWizardType.QUALIFIER, pkg, name, inherited, comments);
+ }
+
+ private CDIWizard scope(String pkg, String name, boolean inherited,
+ boolean comments, boolean normalScope, boolean passivating) {
+ CDIWizard w = create(CDIWizardType.SCOPE, pkg, name, inherited,
+ comments);
+ w = w.setNormalScope(normalScope);
+ return normalScope ? w.setPassivating(passivating) : w;
+ }
+
+ private CDIWizard binding(String pkg, String name, String target,
+ boolean inherited, boolean comments) {
+ CDIWizard w = create(CDIWizardType.INTERCEPTOR_BINDING, pkg, name,
+ inherited, comments);
+ return target != null ? w.setTarget(target) : w;
+ }
+
+ private CDIWizard stereotype(String pkg, String name, String scope,
+ String target, boolean inherited, boolean named,
+ boolean alternative, boolean comments) {
+ CDIWizard w = create(CDIWizardType.STEREOTYPE, pkg, name, inherited,
+ comments).setAlternative(alternative).setNamed(named);
+ if (scope != null) {
+ w = w.setScope(scope);
+ }
+ return target != null ? w.setTarget(target) : w;
+ }
+
+ private CDIWizard create(CDIWizardType type, String pkg, String name,
+ boolean inherited, boolean comments) {
+ CDIWizard p = new NewCDIFileWizard(type).run();
+ return p.setPackage(pkg).setName(name).setInherited(inherited)
+ .setGenerateComments(comments);
+ }
+
+}