[jbosstools-commits] JBoss Tools SVN: r22725 - in trunk/struts/tests/org.jboss.tools.struts.ui.bot.test: resources and 3 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jun 10 11:26:14 EDT 2010


Author: jlukas at redhat.com
Date: 2010-06-10 11:26:14 -0400 (Thu, 10 Jun 2010)
New Revision: 22725

Added:
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm.java.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm67.java.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GreetingAction.java.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/greeting.jsp.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/index.jsp.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname.jsp.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname63.jsp.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname65.jsp.gf
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/PartMatcher.java
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/ValidationUIEditorBot.java
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/WizardBot.java
Modified:
   trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF
Log:
initial version of sanity test suite for struts tooling based on the struts tools tutorial

Modified: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF	2010-06-10 15:12:46 UTC (rev 22724)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/META-INF/MANIFEST.MF	2010-06-10 15:26:14 UTC (rev 22725)
@@ -4,14 +4,22 @@
 Bundle-SymbolicName: org.jboss.tools.struts.ui.bot.test
 Bundle-Version: 3.1.0.qualifier
 Bundle-Activator: org.jboss.tools.struts.ui.bot.test.Activator
-Require-Bundle: org.eclipse.ui,
+Require-Bundle: org.apache.log4j;bundle-version="1.2.13",
  org.eclipse.core.runtime,
- org.jboss.tools.jst.ui.bot.test;bundle-version="1.0.0",
+ org.eclipse.gef;bundle-version="3.5.1",
  org.eclipse.swtbot.eclipse.core;bundle-version="2.0.0",
  org.eclipse.swtbot.eclipse.finder;bundle-version="2.0.0",
+ org.eclipse.swtbot.eclipse.gef.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.junit4;bundle-version="4.5.0",
- org.jboss.tools.ui.bot.ext;bundle-version="1.0.0"
+ org.eclipse.ui,
+ org.eclipse.ui.ide;bundle-version="3.5.2",
+ org.jboss.tools.common.model.ui;bundle-version="3.1.0",
+ org.jboss.tools.struts.ui;bundle-version="3.1.0",
+ org.jboss.tools.jst.ui.bot.test;bundle-version="1.0.0",
+ org.jboss.tools.ui.bot.ext;bundle-version="1.0.0",
+ org.junit4;bundle-version="4.5.0"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-Vendor: JBoss by Red Hat

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm.java.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm.java.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm.java.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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 sample;
+
+import javax.servlet.http.HttpServletRequest;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionMapping;
+
+public class GetNameForm extends org.apache.struts.action.ActionForm {
+
+    private String name = "";
+
+    public GetNameForm() {
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void reset(ActionMapping actionMapping, HttpServletRequest request) {
+        this.name = "";
+    }
+
+    public ActionErrors validate(ActionMapping actionMapping,
+
+    HttpServletRequest request) {
+        ActionErrors errors = new ActionErrors();
+        return errors;
+    }
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm67.java.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm67.java.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GetNameForm67.java.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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 sample;
+
+import javax.servlet.http.HttpServletRequest;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionMapping;
+
+public class GetNameForm extends org.apache.struts.validator.ValidatorForm {
+
+    private String name = "";
+
+    public GetNameForm() {
+    }
+
+    /**
+     * @return Returns the name.
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * @param name The name to set.
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void reset(ActionMapping actionMapping, HttpServletRequest request) {
+        this.name = "";
+    }
+
+    public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest request) {
+        ActionErrors errors = new ActionErrors();
+        return errors;
+    }
+
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GreetingAction.java.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GreetingAction.java.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/GreetingAction.java.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -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 sample;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+
+public class GreetingAction extends org.apache.struts.action.Action {
+
+    // Global Forwards
+    public static final String GLOBAL_FORWARD_getName = "getName";
+
+    // Local Forwards
+    public static final String FORWARD_sayHello = "sayHello";
+
+    public GreetingAction() {
+    }
+
+    public ActionForward execute(ActionMapping mapping, ActionForm form,
+            HttpServletRequest request, HttpServletResponse response) throws Exception {
+        String name = ((GetNameForm)form).getName();
+        String greeting = "Hello, " + name + "!";
+        ((GetNameForm) form).setName(greeting);
+        return mapping.findForward(FORWARD_sayHello);
+    }
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/greeting.jsp.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/greeting.jsp.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/greeting.jsp.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,23 @@
+<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
+<!--
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+-->
+<html>
+<head>
+    <title>Greeting</title>
+</head>
+    <body>
+        <p>
+            <bean:write name="GetNameForm" property="name"/>
+        </p>
+    </body>
+</html>
\ No newline at end of file

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/index.jsp.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/index.jsp.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/index.jsp.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,14 @@
+<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
+<!--
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+-->
+<logic:redirect forward="getName"/>

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname.jsp.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname.jsp.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname.jsp.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,25 @@
+<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
+<!--
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+-->
+<html:html>
+<head>
+    <title></title>
+</head>
+<body>
+    <html:form action="/greeting.do">Input name:
+        <html:text property="name" />
+        <html:submit value="Say Hello!">
+        </html:submit>
+    </html:form>
+</body>
+</html:html>

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname63.jsp.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname63.jsp.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname63.jsp.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,24 @@
+<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
+<!--
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+-->
+<html:html>
+    <head>
+        <html:javascript formName="GetNameForm"/>
+        <title></title>
+    </head>
+    <body>
+        <html:form action="/greeting.do" onsubmit="return validateGetNameForm(this)">
+            Input name:<html:text property="name"/><html:submit value="Say Hello!"/>
+         </html:form>
+    </body>
+</html:html>

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname65.jsp.gf
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname65.jsp.gf	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/resources/inputname65.jsp.gf	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,25 @@
+<%@ taglib uri="/WEB-INF/struts-html" prefix="html" %>
+<!--
+/*******************************************************************************
+ * 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
+ ******************************************************************************/
+-->
+<html:html >
+<head>
+    <html:javascript formName="GetNameForm"/>
+        <title></title>
+    </head>
+    <body>
+        <html:form action="/greeting.do" >Input name:<html:text property="name"/>
+            <html:submit value="Say Hello!"/>
+        </html:form>
+        <html:errors/>
+    </body>
+</html:html>

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,497 @@
+/*******************************************************************************
+ * 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.struts.ui.bot.test.tutorial;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefContextMenu;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+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.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.struts.ui.bot.test.utils.DndSupport;
+import org.jboss.tools.struts.ui.bot.test.utils.PartMatcher;
+import org.jboss.tools.struts.ui.bot.test.utils.StrutsUIEditorBot;
+import org.jboss.tools.struts.ui.bot.test.utils.ValidationUIEditorBot;
+import org.jboss.tools.struts.ui.bot.test.utils.WizardBot;
+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.parts.SWTBotBrowserExt;
+import org.jboss.tools.ui.bot.ext.types.EntityType;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
+import org.jboss.tools.ui.bot.test.SWTBotJSPMultiPageEditor;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Sanity test for Struts tooling support in JBoss Tools based on the Struts Tools tutorial
+ *
+ * @author jlukas
+ * @see <a href="http://download.jboss.org/jbosstools/nightly-docs/en/struts_tools_tutorial/html/index.html">Struts Tutorial</a>
+ */
+ at SWTBotTestRequires(server = @Server(state = ServerState.NotRunning), perspective = "Web Development")
+ at RunWith(RequirementAwareSuite.class)
+ at SuiteClasses({TutorialTest.class})
+public class TutorialTest extends SWTTestExt {
+
+    private static final Logger L = Logger.getLogger(TutorialTest.class.getName());
+    private static final String PROJECT_NAME = "StrutsHello";
+
+    /**
+     * 2.1. Starting Up
+     */
+    @Test
+    public void testCreateProject() {
+        eclipse.createNew(EntityType.STRUTS_PROJECT);
+        bot.shell(IDELabel.Shell.NEW_STRUTS_PROJECT).activate();
+        bot.textWithLabel(IDELabel.NewStrutsProjectDialog.NAME).setText(
+                PROJECT_NAME);
+        bot.button(IDELabel.Button.NEXT).click();
+        bot.button(IDELabel.Button.NEXT).click();
+        SWTBotTreeItem[] ti = bot.tree().getAllItems();
+        Assert.assertTrue("struts-html.tld checked", ti[1].isChecked());
+        Assert.assertTrue("struts-logic.tld checked", ti[3].isChecked());
+        Assert.assertTrue("struts-bean.tld checked", ti[4].isChecked());
+        bot.button(IDELabel.Button.FINISH).click();
+        SWTBot v = eclipse.showView(ViewType.PACKAGE_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();
+        t = t.expandNode("WebContent", "WEB-INF");
+        assertNotNull("Project " + PROJECT_NAME + " was not created properly.",
+                t.getNode("struts-config.xml"));
+    }
+
+    /**
+     * 2.2. Creating the Application Components
+     */
+    @Test
+    public void testAddJSPs() {
+        //2.2.1.1. Creating the Page Placeholders
+        SWTBotView v = bot.viewByTitle(IDELabel.View.WEB_PROJECTS);
+        v.show();
+        SWTBotTree tree = v.bot().tree();
+        final SWTBotTreeItem projectNode = tree.getTreeItem(PROJECT_NAME);
+        UIThreadRunnable.syncExec(new VoidResult() {
+
+            public void run() {
+                projectNode.expand();
+            }
+        });
+        SWTBotTreeItem webRootNode = projectNode.getNode("WEB-ROOT (WebContent)");
+        nodeContextMenu(tree, webRootNode, "New", "Folder...").click();
+        handleWizard("pages");
+
+        nodeContextMenu(tree, webRootNode.getNode("pages"), "New", "File", "JSP...").click();
+        handleWizard("inputname", "StrutsForm");
+
+        nodeContextMenu(tree, webRootNode.getNode("pages"), "New", "File", "JSP...").click();
+        handleWizard("greeting");
+
+        //2.2.1.2. Placing the Page Placeholders
+        nodeContextMenu(
+                tree,
+                projectNode.getNode("Configuration").expand().getNode("default").expand().getNode("struts-config.xml"), "Open").click();
+        SWTBotEditor botEditor = bot.activeEditor();
+        StrutsUIEditorBot ge = new StrutsUIEditorBot(botEditor.getReference());
+        Control c = ge.getControl();
+
+        SWTBotTreeItem s = webRootNode.getNode("pages").getNode("inputname.jsp");
+        Widget w1 = s.widget;
+        s.select();
+
+        DndSupport.dnd((TreeItem) w1, (FigureCanvas) c);
+        s = webRootNode.getNode("pages").getNode("greeting.jsp");
+        s.select();
+        w1 = s.widget;
+        DndSupport.dnd((TreeItem) w1, (FigureCanvas) c);
+        ge.clickContextMenu("Auto-Layout");
+        SWTBotShell sh = bot.activeShell();
+        sh.bot().button("OK").click();
+        botEditor.save();
+
+        //2.2.2. Creating an Action Mappings
+        new SWTBotGefContextMenu(c, "Action...").click();
+        sh = bot.activeShell();
+        sh.bot().textWithLabel("Path*").setText("/greeting");
+        sh.bot().comboBoxWithLabel("Name").setText("GetNameForm");
+        sh.bot().comboBoxWithLabel("Scope").setSelection("request");
+        sh.bot().textWithLabel("Type").setText("sample.GreetingAction");
+        sh.bot().button("Finish").click();
+        botEditor.save();
+
+        //2.2.3. Creating a Link
+        ge.activateTool("Create New Connection");
+        SWTBotGefEditPart part = ge.mainEditPart();
+        part.descendants(new PartMatcher("inputname.jsp")).get(0).click();
+        part.descendants(new PartMatcher("GetNameForm")).get(0).click();
+
+        //2.2.4. Creating a Forward
+        ge.activateTool("Create New Connection");
+        part.descendants(new PartMatcher("GetNameForm")).get(0).click();
+        part.descendants(new PartMatcher("greeting.jsp")).get(0).click();
+        ge.clickContextMenu("Auto-Layout");
+        sh = bot.activeShell();
+        sh.bot().button("OK").click();
+        botEditor.save();
+
+        ge.selectPage("Tree");
+        SWTBotTreeItem item = botEditor.bot().tree().expandNode("struts-config.xml", "action-mappings", "/greeting");
+        item.getNode("greeting").select();
+        bot.activeEditor().bot().textWithLabel("Name").setText("sayHello");
+        ge.selectPage("Diagram");
+        botEditor.save();
+
+        //2.2.5. Creating a Global Forward
+        new SWTBotGefContextMenu(c, "Global Forward...").click();
+        sh = bot.activeShell();
+        sh.bot().textWithLabel("Name*").setText("getName");
+        sh.bot().button(0).click();
+        SWTBotShell sh2 = sh.bot().activeShell();
+        sh2.bot().tabItem("Pages").activate();
+        sh2.bot().tree().expandNode("StrutsHello", "WEB-ROOT (WebContent)", "pages").getNode("inputname.jsp").select();
+        sh2.bot().button(0).click();
+        sh.bot().button("Finish").click();
+        botEditor.save();
+
+        //2.2.6. Creating a Form Bean
+        ge.selectPage("Tree");
+        tree = botEditor.bot().tree();
+        item = tree.getTreeItem("struts-config.xml").getNode("form-beans");
+        nodeContextMenu(tree, item, "Create Form Bean...").click();
+        sh = bot.activeShell();
+        sh.bot().textWithLabel("Name*").setText("GetNameForm");
+        sh.bot().textWithLabel("Type*").setText("sample.GetNameForm");
+        sh.bot().button("Finish").click();
+        botEditor.save();
+    }
+
+    /**
+     * Chapter 3. Generating Stub Coding
+     */
+    @Test
+    public void testGenerateClasses() {
+        StrutsUIEditorBot guiBot = new StrutsUIEditorBot(bot.activeEditor().getReference());
+        guiBot.selectPage("Diagram");
+        guiBot.clickContextMenu("Generate Java Code...");
+        SWTBot sh = bot.activeShell().bot();
+        sh.button(1).click();
+        sh.sleep(1500);
+        String status = sh.text().getText();
+        Assert.assertTrue(status.contains("Generated classes: 2"));
+        Assert.assertTrue(status.contains("Actions: 1"));
+        Assert.assertTrue(status.contains("Form beans: 1"));
+        sh.button(0).click();
+    }
+
+    /**
+     * Chapter 4. Coding the Various Files
+     */
+    @Test
+    public void testCoding() {
+    	SWTBotView pe = new SWTWorkbenchBot().viewByTitle("Package Explorer");
+    	pe.show();
+        SWTBotTree fTree = pe.bot().tree();
+        nodeContextMenu(fTree, fTree.getTreeItem(PROJECT_NAME), "Refresh");
+        bot.sleep(3000);
+        //4.1.1. GetNameForm.java
+        SWTBotEditor editor = packageExplorer.openFile(PROJECT_NAME, "JavaSource", "sample", "GetNameForm.java");
+        SWTBotEclipseEditor eeditor = editor.toTextEditor();
+        eeditor.selectRange(0, 0, eeditor.getText().length());
+        eeditor.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/GetNameForm.java.gf")));
+        editor.saveAndClose();
+
+        //4.1.2. GreetingAction.java
+        editor = packageExplorer.openFile(PROJECT_NAME, "JavaSource", "sample", "GreetingAction.java");
+        eeditor = editor.toTextEditor();
+        eeditor.selectRange(0, 0, eeditor.getText().length());
+        eeditor.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/GreetingAction.java.gf")));
+        editor.saveAndClose();
+
+        //4.2.1. inputname.jsp
+        SWTBotView v = bot.viewByTitle(IDELabel.View.WEB_PROJECTS);
+        v.show();
+//TODO: D'n'D
+//		SWTBotTree tree = v.bot().tree();
+//		final SWTBotTreeItem projectNode = tree.getTreeItem(PROJECT_NAME);
+//		SWTBotTreeItem item = projectNode.getNode("Configuration").expand().getNode("default").expand().getNode("struts-config.xml").expand().getNode("action-mappings").expand().getNode("/greeting");
+//		item.select();
+
+        editor = bot.editorByTitle("inputname.jsp");
+        editor.show();
+        SWTBotJSPMultiPageEditor editorA = new SWTBotJSPMultiPageEditor(bot.editorByTitle("inputname.jsp").getReference(), new SWTWorkbenchBot());
+        editorA.selectTab("Source");
+        SWTBotStyledText st = bot.styledText();
+        st.selectRange(0, 0, st.getText().length());
+        st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/inputname.jsp.gf")));
+        editor.saveAndClose();
+
+//		st.navigateTo(7, 24);
+//		st.typeText("x");
+//		final StyledText text = st.widget;
+//
+//		Point p = UIThreadRunnable.syncExec(new Result<Point>() {
+//
+//			public Point run() {
+//				int i = text.getCaretOffset();
+//				L.info("caret offset: " + i);
+//				L.info("caret locati: " + text.getLocationAtOffset(i).x + ":" + text.getLocationAtOffset(i).y);
+//				return text.getLocationAtOffset(i);
+//			}
+//		});
+//		DndSupport.dnd(item.widget, (Control) editorA.getWidget(), p.x + 2, p.y + 2);
+//		bot.sleep(30000);
+
+        //4.2.2. greeting.jsp
+        editor = bot.editorByTitle("greeting.jsp");
+        editor.show();
+        editorA = new SWTBotJSPMultiPageEditor(bot.editorByTitle("greeting.jsp").getReference(), new SWTWorkbenchBot());
+        editorA.selectTab("Source");
+        st = bot.styledText();
+        st.selectRange(0, 0, st.getText().length());
+        st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/greeting.jsp.gf")));
+        editor.saveAndClose();
+
+        //4.2.3. index.jsp
+        SWTBotTree tree = v.bot().tree();
+        final SWTBotTreeItem projectNode = tree.getTreeItem(PROJECT_NAME);
+        nodeContextMenu(tree, projectNode.getNode("WEB-ROOT (WebContent)"), "New", "File", "JSP...").click();
+        handleWizard("index");
+        editor = bot.editorByTitle("index.jsp");
+        editor.show();
+        editorA = new SWTBotJSPMultiPageEditor(bot.editorByTitle("index.jsp").getReference(), new SWTWorkbenchBot());
+        editorA.selectTab("Source");
+        st = bot.styledText();
+        st.selectRange(0, 0, st.getText().length());
+        st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/index.jsp.gf")));
+        editor.saveAndClose();
+    }
+
+    /**
+     * Chapter 5. Compiling the Classes and Running the Application
+     */
+    @Test
+    public void testStartServer() {
+        servers.startServer(configuredState.getServer().name);
+        configuredState.getServer().isRunning = true;
+        StrutsUIEditorBot gui = new StrutsUIEditorBot(bot.activeEditor().getReference());
+        gui.mainEditPart().descendants(new PartMatcher("getName")).get(0).select();
+        gui.save();
+        new SWTBotGefContextMenu(gui.getControl(), "Run on Server").click();
+        SWTBotBrowserExt browser = bot.browser();
+        bot.sleep(5000);
+        L.info(browser.getText());
+        Assert.assertTrue(browser.getText().contains("Input name:"));
+    }
+
+    /**
+     * Chapter 6. Struts Validation Examples
+     */
+    @Test
+    public void testValidators() {
+        //6.1. Starting Point
+        SWTBotView v = bot.viewByTitle(IDELabel.View.WEB_PROJECTS);
+        v.show();
+
+        //6.2. Defining the Validation Rule
+        SWTBotTree tree = v.bot().tree();
+        SWTBotTreeItem projectNode = tree.getTreeItem(PROJECT_NAME);
+        final SWTBotTreeItem config = projectNode.expandNode("Configuration", "default", "struts-config.xml");
+        nodeContextMenu(
+                tree, config.getNode("plug-ins"), "Create Special Plug-in", "Validators").click();
+        nodeContextMenu(tree, projectNode.getNode("Resource Bundles"), "New", "Properties File...").click();
+        SWTBotShell sh = bot.activeShell();
+        sh.bot().button("Browse...").click();
+        SWTBotShell sh2 = sh.bot().activeShell();
+        sh2.bot().tree().getTreeItem("StrutsHello").expand().getNode("JavaSource").expand().getNode("sample").select();
+        sh2.bot().button("OK").click();
+        sh.bot().textWithLabel("Name*").setText("applResources");
+        sh.bot().button("Finish").click();
+        SWTBotTreeItem item = projectNode.getNode("Resource Bundles").getNode("sample.applResources");
+        nodeContextMenu(tree, item, "New", "Default Error Messages").click();
+        DndSupport.dnd(item.widget, config.getNode("resources").widget);
+        nodeContextMenu(tree, projectNode.expandNode("Validation").getNode("validation.xml"), "Open").click();
+        
+        SWTBotEditor editor = bot.activeEditor();
+        ValidationUIEditorBot vb = new ValidationUIEditorBot(editor.getReference(), new SWTWorkbenchBot());
+        vb.toolbarButton("Create Formset").click();
+
+        sh = bot.activeShell();
+        sh.bot().button("Finish").click();
+        SWTBotTree t = vb.bot().tree();
+        SWTBotTreeItem ti = t.getTreeItem("formset (default)").expand();
+        item = UIThreadRunnable.syncExec(new Result<SWTBotTreeItem>() {
+
+            public SWTBotTreeItem run() {
+                return config.expandNode("form-beans");
+            }
+        }).getNode("GetNameForm").select();
+        DndSupport.dnd(item.widget, ti.widget);
+        ti = t.expandNode("formset (default)").getNode("GetNameForm").select();
+        vb.toolbarButton("Create Field").click();
+        sh = bot.activeShell();
+        sh.bot().textWithLabel("Property*").setText("name");
+        sh.bot().button("Finish").click();
+        ti = ti.expand().getNode("name").select();
+        vb.toolbarButton("Edit").click();
+        sh = bot.activeShell();
+        SWTBotTable table = sh.bot().table();
+        table.click(2, 1);
+        sh.bot().button("...").click();
+        sh2 = bot.activeShell();
+        sh2.bot().table().select("required");
+        sh2.bot().button("Add ->").click();
+        sh2.bot().button("Ok").click();
+        sh.bot().button("Close").click();
+        vb.bot().button("Add", 1).click();
+        sh = bot.activeShell();
+        sh.bot().button("Browse...").click();
+        sh2 = bot.activeShell();
+        sh2.bot().button("Add").click();
+        SWTBotShell sh3 = bot.activeShell();
+        sh3.bot().textWithLabel("Name*").setText("name.required");
+        sh3.bot().textWithLabel("Value").setText("Person's name");
+        sh3.bot().button("Finish").click();
+        sh2.bot().button("Ok").click();
+        sh.bot().button("Finish").click();
+        vb.saveAndClose();
+
+        //6.3. Client-Side Validation
+        v.show();
+        ti = projectNode.expandNode("WEB-ROOT (WebContent)", "pages").getNode("inputname.jsp");
+        nodeContextMenu(tree, ti, "Open").click();
+
+        SWTBotJSPMultiPageEditor jspEditor = new SWTBotJSPMultiPageEditor(bot.editorByTitle("inputname.jsp").getReference(), new SWTWorkbenchBot());
+        jspEditor.selectTab("Source");
+        SWTBotStyledText st = jspEditor.bot().styledText();
+        st.selectRange(0, 0, st.getText().length());
+        st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/inputname63.jsp.gf")));
+        jspEditor.save();
+        bot.editorByTitle("struts-config.xml").save();
+        bot.sleep(5000);
+        
+        //6.4. Server Side Validation
+
+        //6.5. Editing the JSP File
+        st.selectRange(0, 0, st.getText().length());
+        st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/inputname65.jsp.gf")));
+        jspEditor.saveAndClose();
+
+        //6.6. Editing the Action
+        nodeContextMenu(tree, config.expandNode("action-mappings").getNode("/greeting"), "Properties").click();
+        sh = bot.activeShell();
+        table = sh.bot().table();
+        table.click(7, 1);
+        sh.bot().button("...").click();
+        sh2 = bot.activeShell();
+        sh2.bot().tabItem("Pages").activate();
+        sh2.bot().tree().expandNode("StrutsHello", "WEB-ROOT (WebContent)", "pages").getNode("inputname.jsp").select();
+        sh2.bot().button("OK").click();
+        sh.bot().button("Close").click();
+
+        //6.7. Editing the Form Bean
+        nodeContextMenu(tree, config.expandNode("action-mappings").getNode("/greeting"), "Open Form-bean Source").click();
+        editor = bot.editorByTitle("GetNameForm.java");
+        editor.show();
+        st = editor.bot().styledText();
+        st.selectRange(0, 0, st.getText().length());
+        st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/GetNameForm67.java.gf")));
+        editor.saveAndClose();
+        bot.activeShell().bot().menu("File").menu("Save All").click();
+        bot.sleep(40000);
+    }
+
+    private 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 void handleWizard(String itemName) {
+        handleWizard(itemName, null);
+    }
+
+    private void handleWizard(String itemName, String template) {
+        assert itemName != null && itemName.trim().length() > 0;
+        WizardBot sh = new WizardBot(bot.activeShell());
+        sh.setName(itemName);
+        if (template != null) {
+            sh.setTemplate(template);
+        }
+        sh.finish();
+    }
+
+    private String readResource(InputStream is) {
+        StringBuilder sb = new StringBuilder();
+        BufferedReader br = null;
+        try {
+            br = new BufferedReader(new InputStreamReader(is));
+            String s;
+            while ((s = br.readLine()) != null) {
+                sb.append(s);
+                sb.append('\n');
+            }
+        } catch (IOException e) {
+            L.log(Level.WARNING, e.getMessage(), e);
+        } finally {
+            if (br != null) {
+                try {
+                    br.close();
+                } catch (IOException e) {
+                    L.log(Level.FINEST, e.getMessage(), e);
+                }
+            }
+        }
+        return sb.toString();
+    }
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/DndSupport.java	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.struts.ui.bot.test.utils;
+
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.InputEvent;
+import java.text.MessageFormat;
+
+import org.apache.log4j.Logger;
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.jface.util.Geometry;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+
+/**
+ * Drag and Drop implementation based on the last patch available
+ * at https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271
+ *
+ * @author jlukas
+ * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=285271#c10">Original Patch</a>
+ */
+public class DndSupport {
+
+    private static final Logger L = Logger.getLogger(DndSupport.class.getName());
+    private static final int robotDelay = Integer.getInteger("org.jboss.tools.struts.ui.bot.test.dndDelay", 150);
+
+    public static void dnd(final TreeItem ti, final TreeItem ti2) {
+        Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+            public Rectangle run() {
+                return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
+            }
+        });
+        final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
+                new Point(10, 10));
+
+        Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+            public Rectangle run() {
+                return ti2.getDisplay().map(ti2.getParent(), null,
+                        ti2.getBounds());
+            }
+        });
+
+        doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
+                Geometry.centerPoint(r2));
+    }
+
+    public static void dnd(final TreeItem ti, final FigureCanvas fc) {
+        Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+            public Rectangle run() {
+                return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
+            }
+        });
+        final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
+                new Point(10, 10));
+
+        Rectangle r2 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+            public Rectangle run() {
+                return fc.getDisplay().map(fc.getParent(), null, fc.getBounds());
+            }
+        });
+
+        doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset),
+                Geometry.centerPoint(r2));
+    }
+
+    public static void dnd(final TreeItem ti, final Control fc, final int x,
+            final int y) {
+        Rectangle r1 = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+
+            public Rectangle run() {
+                return ti.getDisplay().map(ti.getParent(), null, ti.getBounds());
+            }
+        });
+        final Point slightOffset = Geometry.add(Geometry.getLocation(r1),
+                new Point(10, 10));
+
+        Point r2 = UIThreadRunnable.syncExec(new Result<Point>() {
+
+            public Point run() {
+                L.info("xxx: " + fc.getLocation().x + ":"
+                        + fc.getLocation().y);
+                return fc.getDisplay().map(fc, null, x, y);
+            }
+        });
+
+        doDragAndDrop(Geometry.min(Geometry.centerPoint(r1), slightOffset), r2);
+    }
+
+    /**
+     *
+     */
+    private static void doDragAndDrop(final Point source, final Point dest) {
+        L.info(MessageFormat.format(
+                "Drag-and-dropping from ({0},{1}) to ({2},{3})", source.x,
+                source.y, dest.x, dest.y));
+        try {
+            final Robot awtRobot = new Robot();
+            awtRobot.setAutoDelay(robotDelay);
+            // the x+10 motion is needed to let native functions register a drag
+            // detect. It did not work under Windows
+            // otherwise and has been reported to be required for linux, too.
+            // But I could not test that.
+            UIThreadRunnable.syncExec(new VoidResult() {
+
+                public void run() {
+                    awtRobot.mouseMove(source.x, source.y);
+                    awtRobot.mousePress(InputEvent.BUTTON1_MASK);
+                    awtRobot.mouseMove((source.x + 10), source.y);
+                }
+            });
+
+            // now pause the test until all runnables on the Display thread have
+            // run this is necessary for the pick up
+            // to register on linux
+            waitForIdle(awtRobot);
+
+            UIThreadRunnable.syncExec(new VoidResult() {
+
+                public void run() {
+                    awtRobot.mouseMove((dest.x + 10), dest.y);
+                    awtRobot.mouseMove(dest.x, dest.y);
+                }
+            });
+
+            waitForIdle(awtRobot);
+
+            UIThreadRunnable.syncExec(new VoidResult() {
+
+                public void run() {
+                    awtRobot.mouseRelease(InputEvent.BUTTON1_MASK);
+                }
+            });
+            waitForIdle(awtRobot);
+        } catch (final AWTException e) {
+            L.info(e.getMessage(), e);
+            throw new RuntimeException(e);
+        }
+        try {
+			Thread.sleep(1000);
+		} catch (InterruptedException e) {
+			//ignore
+		}
+    }
+
+    private static void waitForIdle(final Robot robot) {
+        if (SWT.getPlatform().equals("gtk")) {
+            robot.waitForIdle();
+        }
+    }
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/PartMatcher.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/PartMatcher.java	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/PartMatcher.java	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * 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.struts.ui.bot.test.utils;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+import org.hamcrest.Description;
+import org.jboss.tools.struts.ui.editor.model.IProcessItem;
+
+public class PartMatcher extends AbstractMatcher<EditPart> {
+
+    private final String name;
+
+    public PartMatcher(String name) {
+        assert name != null;
+        assert name.trim().length() > 0;
+        this.name = name;
+    }
+
+    @Override
+    protected boolean doMatch(Object item) {
+        EditPart ep = (EditPart) item;
+        IProcessItem ipi = (IProcessItem) ep.getModel();
+        return name.equalsIgnoreCase(ipi.getName());
+    }
+
+    public void describeTo(Description d) {
+        d.appendText("Edit Part with name: " + name);
+    }
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/StrutsUIEditorBot.java	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.struts.ui.bot.test.utils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.draw2d.FigureCanvas;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefFigureCanvas;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.part.EditorPart;
+import org.jboss.tools.common.editor.ObjectMultiPageEditor;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+import org.junit.Assert;
+
+public class StrutsUIEditorBot extends SWTBotGefEditor {
+
+    private static final Logger L = Logger.getLogger(StrutsUIEditorBot.class.getName());
+
+    public StrutsUIEditorBot(IEditorReference reference) throws WidgetNotFoundException {
+        super(reference, new SWTWorkbenchBot());
+    }
+
+    @Override
+    protected void init() throws WidgetNotFoundException {
+        UIThreadRunnable.syncExec(new VoidResult() {
+
+            public void run() {
+                final IEditorPart/*EditorPartWrapper*/ editor = partReference.getEditor(true);
+                EditorPart/*StrutsEditor*/ ep = null;
+                try {
+                    Field f = editor.getClass().getDeclaredField("editor");
+                    f.setAccessible(true);
+                    Object/*StrutsConfigEditor*/ o = f.get(editor);
+                    f.setAccessible(false);
+                    f = o.getClass().getDeclaredField("guiEditor");
+                    f.setAccessible(true);
+                    Object/*StrutsConfigGuiEditor*/ o2 = f.get(o);
+                    f.setAccessible(false);
+                    Method m = o2.getClass().getMethod("getGUI");
+                    ep = (EditorPart) m.invoke(o2);
+                } catch (SecurityException e) {
+                    L.log(Level.WARNING, e.getMessage(), e);
+                } catch (NoSuchFieldException e) {
+                    L.log(Level.WARNING, e.getMessage(), e);
+                } catch (IllegalArgumentException e) {
+                    L.log(Level.WARNING, e.getMessage(), e);
+                } catch (IllegalAccessException e) {
+                    L.log(Level.WARNING, e.getMessage(), e);
+                } catch (NoSuchMethodException e) {
+                    L.log(Level.WARNING, e.getMessage(), e);
+                } catch (InvocationTargetException e) {
+                    L.log(Level.WARNING, e.getMessage(), e);
+                }
+                graphicalViewer = (GraphicalViewer) ep.getAdapter(GraphicalViewer.class);
+                final Control control = graphicalViewer.getControl();
+                if (control instanceof FigureCanvas) {
+                    canvas = new SWTBotGefFigureCanvas((FigureCanvas) control);
+                }
+                editDomain = graphicalViewer.getEditDomain();
+            }
+        });
+
+        if (graphicalViewer == null) {
+            throw new WidgetNotFoundException("Editor does not adapt to a GraphicalViewer");
+        }
+    }
+
+    public void selectPage(final String page) {
+        IWorkbenchPart p = ((EditorPartWrapper) (getReference().getPart(true))).getEditor();
+        Assert.assertTrue(p instanceof ObjectMultiPageEditor);
+        final ObjectMultiPageEditor editor = (ObjectMultiPageEditor) p;
+        // Select page
+        Display.getDefault().syncExec(new Runnable() {
+
+            public void run() {
+                editor.selectPageByName(page);
+            }
+        });
+    }
+
+    public Control/*FigureCanvas*/ getControl() {
+        return UIThreadRunnable.syncExec(new Result<Control>() {
+
+            public Control run() {
+                return graphicalViewer.getControl();
+            }
+        });
+    }
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/ValidationUIEditorBot.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/ValidationUIEditorBot.java	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/ValidationUIEditorBot.java	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * 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.struts.ui.bot.test.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+import org.eclipse.swtbot.swt.finder.results.ListResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarPushButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarRadioButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarSeparatorButton;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton;
+import org.eclipse.ui.IEditorReference;
+import org.eclipse.ui.IWorkbenchPart;
+import org.hamcrest.Description;
+import org.jboss.tools.common.editor.ObjectMultiPageEditor;
+import org.jboss.tools.common.model.ui.editor.EditorPartWrapper;
+import org.junit.Assert;
+
+public class ValidationUIEditorBot extends SWTBotEditor {
+
+    private static final Logger L = Logger.getLogger(ValidationUIEditorBot.class.getName());
+
+    public ValidationUIEditorBot(IEditorReference editorReference,
+            SWTWorkbenchBot bot) throws WidgetNotFoundException {
+        super(editorReference, bot);
+    }
+
+    /**
+     * Gets the toolbar buttons currently visible.
+     *
+     * @return The set of toolbar buttons.
+     */
+    @Override
+    public List<SWTBotToolbarButton> getToolbarButtons() {
+        final ToolBar toolbar = bot().widget(new AbstractMatcher<ToolBar>() {
+
+            @Override
+            protected boolean doMatch(Object item) {
+                return item instanceof ToolBar;
+            }
+
+            public void describeTo(Description description) {
+            }
+        });
+        return UIThreadRunnable.syncExec(new ListResult<SWTBotToolbarButton>() {
+
+            public List<SWTBotToolbarButton> run() {
+                final List<SWTBotToolbarButton> l = new ArrayList<SWTBotToolbarButton>();
+                if (toolbar == null) {
+                    return l;
+                }
+                ToolItem[] items = toolbar.getItems();
+                L.fine("number of items : " + items.length);
+                for (int i = 0; i < items.length; i++) {
+                    try {
+                        if (SWTUtils.hasStyle(items[i], SWT.PUSH)) {
+                            l.add(new SWTBotToolbarPushButton(items[i]));
+                        } else if (SWTUtils.hasStyle(items[i], SWT.CHECK)) {
+                            l.add(new SWTBotToolbarToggleButton(items[i]));
+                        } else if (SWTUtils.hasStyle(items[i], SWT.RADIO)) {
+                            l.add(new SWTBotToolbarRadioButton(items[i]));
+                        } else if (SWTUtils.hasStyle(items[i], SWT.DROP_DOWN)) {
+                            l.add(new SWTBotToolbarDropDownButton(items[i]));
+                        } else if (SWTUtils.hasStyle(items[i], SWT.SEPARATOR)) {
+                            l.add(new SWTBotToolbarSeparatorButton(items[i]));
+                        }
+                    } catch (WidgetNotFoundException e) {
+                        L.log(Level.WARNING, "Failed to find widget " + items[i].getText(), e);
+                    }
+                }
+                return l;
+            }
+        });
+    }
+
+    public void selectPage(final String page) {
+        IWorkbenchPart p = ((EditorPartWrapper) (getReference().getPart(true))).getEditor();
+        Assert.assertTrue(p instanceof ObjectMultiPageEditor);
+        final ObjectMultiPageEditor editor = (ObjectMultiPageEditor) p;
+        // Select page
+        Display.getDefault().syncExec(new Runnable() {
+
+            public void run() {
+                editor.selectPageByName(page);
+            }
+        });
+    }
+}

Added: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/WizardBot.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/WizardBot.java	                        (rev 0)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/utils/WizardBot.java	2010-06-10 15:26:14 UTC (rev 22725)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.struts.ui.bot.test.utils;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.common.model.Messages;
+
+public class WizardBot {
+
+    private SWTBot bot;
+
+    public WizardBot(SWTBotShell bot) {
+        this.bot = bot.bot();
+    }
+
+    public void setName(String name) {
+        bot.textWithLabel("Name*").setText(name);
+    }
+
+    public void setTemplate(String template) {
+        bot.comboBoxWithLabel("Template").setSelection(template);
+    }
+
+    public void setTemplate(int index) {
+        bot.comboBoxWithLabel("Template").setSelection(index);
+    }
+
+    public void next() {
+        bot.button(Messages.SpecialWizardSupport_NextArrow).click();
+    }
+
+    public void cancel() {
+        clickAndWait(Messages.SpecialWizardSupport_Cancel);
+    }
+
+    public void finish() {
+        clickAndWait(Messages.SpecialWizardSupport_Finish);
+    }
+
+    private void clickAndWait(String buttonText) {
+        SWTBotShell sh = bot.activeShell();
+        bot.button(buttonText).click();
+        bot.waitUntil(Conditions.shellCloses(sh), 10000);
+        bot.sleep(100);
+    }
+}



More information about the jbosstools-commits mailing list