Author: vpakan(a)redhat.com
Date: 2010-01-06 07:39:12 -0500 (Wed, 06 Jan 2010)
New Revision: 19661
Added:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/StrutsAllBotTests.java
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/CreateNewStrutsProjectTest.java
Log:
Added test of adding and removing Struts capabilites
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-01-06
10:15:31 UTC (rev 19660)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTEclipseExt.java 2010-01-06
12:39:12 UTC (rev 19661)
@@ -381,7 +381,12 @@
}
}
-
+ /**
+ * Test if tree contains item with itemLabel
+ * @param tree
+ * @param itemLabel
+ * @return
+ */
public static boolean treeContainsItemWithLabel(SWTBotTree tree, String itemLabel){
boolean containsItem = false;
try {
@@ -391,5 +396,18 @@
}
return containsItem;
}
+ /**
+ * if Open Associated Perspective Shell is opened close it
+ * and depend on switchPerspective parameter change current perspective
+ * @param switchPerspective
+ */
+ public void closeOpenAssociatedPerspectiveShellIfOpened(boolean switchPerspective){
+ try{
+ bot.shell(IDELabel.Shell.OPEN_ASSOCIATED_PERSPECTIVE).activate();
+ bot.button(switchPerspective ? IDELabel.Button.YES : IDELabel.Button.NO).click();
+ } catch (WidgetNotFoundException wnfe){
+ // do nothing
+ }
+ }
}
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2010-01-06
10:15:31 UTC (rev 19660)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2010-01-06
12:39:12 UTC (rev 19661)
@@ -11,12 +11,15 @@
package org.jboss.tools.ui.bot.ext;
+import static org.jboss.tools.ui.bot.ext.SWTTestExt.eclipse;
+
import org.apache.log4j.Logger;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
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.ui.bot.ext.helper.ContextMenuHelper;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.ViewType;
@@ -150,4 +153,40 @@
bot.shell(IDELabel.Shell.DELETE_SERVER).activate();
bot.button(IDELabel.Button.OK).click();
}
+ /**
+ * Remove Project from all Servers
+ */
+ public void removeProjectFromServers(String projectName){
+
+ eclipse.showView(ViewType.SERVERS);
+
+ delay();
+
+ SWTBotTree serverTree = bot.viewByTitle(IDELabel.View.SERVERS).bot().tree();
+
+ // Expand All
+ for (SWTBotTreeItem serverTreeItem : serverTree.getAllItems()){
+ serverTreeItem.expand();
+ // if JSF Test Project is deployed to server remove it
+ int itemIndex = 0;
+ SWTBotTreeItem[] serverTreeItemChildren = serverTreeItem.getItems();
+ while (itemIndex < serverTreeItemChildren.length
+ &&
!serverTreeItemChildren[itemIndex].getText().startsWith(projectName)){
+ itemIndex++;
+ }
+ // Server Tree Item has Child with Text equal to JSF TEst Project
+ if (itemIndex < serverTreeItemChildren.length){
+
ContextMenuHelper.prepareTreeItemForContextMenu(serverTree,serverTreeItemChildren[itemIndex]);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree, IDELabel.Menu.REMOVE,
false)).click();
+ bot.shell("Server").activate();
+ bot.button(IDELabel.Button.OK).click();
+ }
+ }
+ delay();
+ }
+
+ public void delay() {
+ bot.sleep(500);
+ }
+
}
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-01-06
10:15:31 UTC (rev 19660)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-01-06
12:39:12 UTC (rev 19661)
@@ -25,6 +25,7 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.jboss.tools.ui.bot.ext.types.JobLists;
@@ -322,7 +323,33 @@
log.error(msg);
fail(msg);
}
-
-
-
+ /**
+ * Write all running processes names to log
+ */
+ public void logAllRunningProcesses(){
+ Job[] jobs = Job.getJobManager().find(null);
+
+ for (Job job : jobs) {
+ log.info(job.getName());
+ }
+ }
+ /**
+ * Write all menu items of menu to log
+ * @param menu
+ */
+ public void logAllSubmenus(MenuItem menuItem){
+
+ final MenuItem miTmp = menuItem;
+
+ menuItem.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ int index = 0;
+ for (MenuItem miSubmenu : miTmp.getMenu().getItems()){
+ log.info(index++ + ": " + miSubmenu);
+ }
+
+ }
+ });
+
+ }
}
\ No newline at end of file
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-01-06
10:15:31 UTC (rev 19660)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-01-06
12:39:12 UTC (rev 19661)
@@ -56,6 +56,10 @@
public static final String STOP = "Stop";
public static final String STRUTS_PROJECT = "Struts Project";
public static final String PREFERENCES = "Preferences";
+ public static final String JBDS_REMOVE_STRUTS_CAPABILITIES = "Remove Red Hat
Capabilities";
+ public static final String JBT_REMOVE_STRUTS_CAPABILITIES = "Remove Struts
Capabilities";
+ public static final String ADD_STRUTS_CAPABILITIES = "Add Struts
Capabilities...";
+ public static final String WEB_PROJECT_JBT_STRUTS = "JBoss Tools Struts";
}
Modified:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/StrutsAllBotTests.java
===================================================================
---
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/StrutsAllBotTests.java 2010-01-06
10:15:31 UTC (rev 19660)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/StrutsAllBotTests.java 2010-01-06
12:39:12 UTC (rev 19661)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.struts.ui.bot.test;
+import org.jboss.tools.struts.ui.bot.test.smoke.AddRemoveStrutsCapabilities;
import org.jboss.tools.struts.ui.bot.test.smoke.CreateNewStrutsProjectTest;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
@@ -27,8 +28,10 @@
*
*/
@RunWith(Suite.class)
-@SuiteClasses( {CreateNewStrutsProjectTest.class})
+@SuiteClasses( {CreateNewStrutsProjectTest.class,
+ AddRemoveStrutsCapabilities.class})
public class StrutsAllBotTests extends SWTTestExt {
+ public static final String STRUTS_PROJECT_NAME = "strutsTest";
@BeforeClass
public static void setUp() {
properties = util.loadProperties(Activator.PLUGIN_ID);
Added:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java
===================================================================
---
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java
(rev 0)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java 2010-01-06
12:39:12 UTC (rev 19661)
@@ -0,0 +1,124 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.struts.ui.bot.test.smoke;
+
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.struts.ui.bot.test.StrutsAllBotTests;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ui.bot.ext.types.ViewType;
+import org.junit.Test;
+/**
+ * Test adding and removing Struts Capabilities from/to Struts Project
+ * @author Vladimir Pakan
+ *
+ */
+public class AddRemoveStrutsCapabilities extends SWTTestExt{
+ private SWTJBTExt swtJbtExt = null;
+ public AddRemoveStrutsCapabilities (){
+ swtJbtExt = new SWTJBTExt(bot);
+ }
+ @Test
+ public void testCreateNewStrutsProject() {
+ boolean jbdsIsRunning = SWTJBTExt.isJBDSRun(bot);
+ removeStrutsCapabilities(jbdsIsRunning);
+ addStrutsCapabilities();
+ }
+
+ /**
+ * Remove Struts Capabilities from Struts Project
+ * @param jbdsIsRunning
+ */
+ private void removeStrutsCapabilities(boolean jbdsIsRunning) {
+
+ swtJbtExt.removeProjectFromServers(StrutsAllBotTests.STRUTS_PROJECT_NAME);
+ util.delay();
+ eclipse.showView(ViewType.WEB_PROJECTS);
+
+ SWTBotTree tree = bot.viewByTitle(IDELabel.View.WEB_PROJECTS).bot().tree();
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree,
+ tree.getTreeItem(StrutsAllBotTests.STRUTS_PROJECT_NAME));
+
+ if (jbdsIsRunning){
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ IDELabel.Menu.JBDS_REMOVE_STRUTS_CAPABILITIES, true)).click();
+ }
+ else{
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ IDELabel.Menu.WEB_PROJECT_JBT_STRUTS, false)).menu(
+ IDELabel.Menu.JBT_REMOVE_STRUTS_CAPABILITIES).click();
+ }
+
+ bot.shell("Confirmation").activate();
+ bot.button(IDELabel.Button.OK).click();
+
+ util.waitForNonIgnoredJobs(5L*1000);
+
+ assertTrue(
+ "Project "
+ + StrutsAllBotTests.STRUTS_PROJECT_NAME
+ + " was not removed from Web Projects view after Struts Capabilities were
removed.",
+
!SWTEclipseExt.treeContainsItemWithLabel(bot.viewByTitle(IDELabel.View.WEB_PROJECTS).bot().tree(),
+ StrutsAllBotTests.STRUTS_PROJECT_NAME));
+
+ }
+
+ /**
+ * Add Struts Capabilities to JSF Project
+ */
+ private void addStrutsCapabilities() {
+
+ swtJbtExt.removeProjectFromServers(StrutsAllBotTests.STRUTS_PROJECT_NAME);
+
+ SWTBotTree tree = eclipse.showView(ViewType.PACKAGE_EXPLORER).tree();
+
+ util.delay();
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree,
+ tree.getTreeItem(StrutsAllBotTests.STRUTS_PROJECT_NAME));
+
+ try{
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ IDELabel.Menu.PACKAGE_EXPLORER_JBT, false)).menu(
+ IDELabel.Menu.ADD_STRUTS_CAPABILITIES).click();
+ } catch (WidgetNotFoundException wnfe){
+ // From 3.1.0.RC1 version this menu is moved to Configure submenu
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ IDELabel.Menu.PACKAGE_EXPLORER_CONFIGURE, false)).menu(
+ IDELabel.Menu.ADD_STRUTS_CAPABILITIES).click();
+ }
+
+ bot.shell("Add Struts Capabilities").activate();
+ bot.button(IDELabel.Button.NEXT).click();
+ bot.button(IDELabel.Button.FINISH).click();
+
+ eclipse.closeOpenAssociatedPerspectiveShellIfOpened(false);
+
+ util.waitForNonIgnoredJobs(5L*1000);
+
+ eclipse.showView(ViewType.WEB_PROJECTS);
+
+ assertTrue("JSF Capabilities were not added to project "
+ + StrutsAllBotTests.STRUTS_PROJECT_NAME,
+
SWTEclipseExt.treeContainsItemWithLabel(bot.viewByTitle(IDELabel.View.WEB_PROJECTS).bot().tree(),
+ StrutsAllBotTests.STRUTS_PROJECT_NAME));
+
+ }
+}
Property changes on:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/AddRemoveStrutsCapabilities.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/CreateNewStrutsProjectTest.java
===================================================================
---
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/CreateNewStrutsProjectTest.java 2010-01-06
10:15:31 UTC (rev 19660)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/CreateNewStrutsProjectTest.java 2010-01-06
12:39:12 UTC (rev 19661)
@@ -13,7 +13,6 @@
import static org.junit.Assert.assertTrue;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.types.EntityType;
@@ -28,12 +27,12 @@
*/
public class CreateNewStrutsProjectTest extends SWTTestExt{
- public static final String STRUTS_PROJECT_NAME = "strutsTest";
-
+ /**
+ * Test create new Struts Project
+ */
@Test
public void testCreateNewStrutsProject() {
-
- // Test create new Struts Project
+
eclipse.showView(ViewType.WEB_PROJECTS);
eclipse.addServerRuntime(IDELabel.ServerRuntimeName.JBOSS_EAP_4_3,
IDELabel.ServerGroup.JBOSS_EAP_4_3,
@@ -41,21 +40,16 @@
StrutsAllBotTests.getProperty("JBossEap4.3Home"));
eclipse.createNew(EntityType.STRUTS_PROJECT);
bot.shell(IDELabel.Shell.NEW_STRUTS_PROJECT).activate();
- bot.textWithLabel(IDELabel.NewStrutsProjectDialog.NAME).setText(STRUTS_PROJECT_NAME);
+
bot.textWithLabel(IDELabel.NewStrutsProjectDialog.NAME).setText(StrutsAllBotTests.STRUTS_PROJECT_NAME);
bot.comboBoxWithLabel(IDELabel.NewStrutsProjectDialog.TEMPLATE).setSelection(IDELabel.NewStrutsProjectDialog.TEMPLATE_KICK_START);
bot.button(IDELabel.Button.NEXT).click();
bot.button(IDELabel.Button.NEXT).click();
bot.button(IDELabel.Button.FINISH).click();
- // if Open Associated Perspective Shell is opened close it
- try{
- bot.shell(IDELabel.Shell.OPEN_ASSOCIATED_PERSPECTIVE).activate();
- bot.button(IDELabel.Button.NO).click();
- } catch (WidgetNotFoundException wnfe){
- // do nothing
- }
+ eclipse.closeOpenAssociatedPerspectiveShellIfOpened(false);
- assertTrue("Project "+ STRUTS_PROJECT_NAME + " was not created
properly.",
-
SWTEclipseExt.treeContainsItemWithLabel(bot.viewByTitle(IDELabel.View.WEB_PROJECTS).bot().tree(),STRUTS_PROJECT_NAME));
+ assertTrue("Project "+ StrutsAllBotTests.STRUTS_PROJECT_NAME + " was not
created properly.",
+
SWTEclipseExt.treeContainsItemWithLabel(bot.viewByTitle(IDELabel.View.WEB_PROJECTS).bot().tree(),
+ StrutsAllBotTests.STRUTS_PROJECT_NAME));
}