Author: vpakan(a)redhat.com
Date: 2009-11-12 06:35:36 -0500 (Thu, 12 Nov 2009)
New Revision: 18641
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/CreateNewJSFProjectTest.java
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java
Log:
Added SWTBot tests testing creation of JSF Project and adding/removing JSF Capabilities
Modified:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java 2009-11-12
09:42:37 UTC (rev 18640)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/JSFAllBotTests.java 2009-11-12
11:35:36 UTC (rev 18641)
@@ -1,6 +1,5 @@
package org.jboss.tools.jsf.ui.bot.test;
-import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -9,6 +8,8 @@
import org.jboss.tools.jsf.ui.bot.test.cssdialog.jbide.JBIDE3579Test;
import org.jboss.tools.jsf.ui.bot.test.cssdialog.jbide.JBIDE3920Test;
import org.jboss.tools.jsf.ui.bot.test.cssdialog.jbide.JBIDE4391Test;
+import org.jboss.tools.jsf.ui.bot.test.smoke.AddRemoveJSFCapabilitiesTest;
+import org.jboss.tools.jsf.ui.bot.test.smoke.CreateNewJSFProjectTest;
/**
*
@@ -17,12 +18,15 @@
*/
public class JSFAllBotTests{
public static Test suite(){
- TestSuite suite = new TestSuite("CSS dialog JBIDE tests");
+ TestSuite suite = new TestSuite("JSF all tests");
+ suite.addTestSuite(CreateNewJSFProjectTest.class);
+ suite.addTestSuite(AddRemoveJSFCapabilitiesTest.class);
suite.addTestSuite(JBIDE3148and4441Test.class);
suite.addTestSuite(JBIDE4391Test.class);
suite.addTestSuite(JBIDE3577Test.class);
suite.addTestSuite(JBIDE3579Test.class);
suite.addTestSuite(JBIDE3920Test.class);
+
return suite;
}
}
\ No newline at end of file
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java 2009-11-12
11:35:36 UTC (rev 18641)
@@ -0,0 +1,365 @@
+/*******************************************************************************
+ * 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.jsf.ui.bot.test.smoke;
+
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRegex;
+
+import java.io.File;
+
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.StringResult;
+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.jsf.ui.bot.test.JSFAutoTestCase;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.test.WidgetVariables;
+
+/**
+ * Test adding and removing JSF Capabilities from/to JSF Project
+ *
+ * @author Vladimir Pakan
+ */
+
+public class AddRemoveJSFCapabilitiesTest extends JSFAutoTestCase {
+
+ private static final String WEB_PROJECT_JBT_JSF_POPUP_MENU = "JBoss Tools
JSF";
+ private static final String PACKAGE_EXPLORER_JBT_POPUP_MENU = "JBoss Tools";
+ private static final String REMOVE_JSF_CAPABILITIES_POPUP_MENU = "Remove JSF
Capabilities";
+ private static final String ADD_JSF_CAPABILITIES_POPUP_MENU = "Add JSF
Capabilities...";
+ private static final String CLOSE_PROJECT_POPUP_MENU = "Clo&se Project";
+ private static final String OPEN_PROJECT_POPUP_MENU = "Op&en Project";
+ private static final String DELETE_PROJECT_POPUP_MENU = "Delete";
+ private static final String IMPORT_PROJECT_POPUP_MENU = "Import Existing JSF
Project...";
+
+ private MenuItem miRunOnServer = null;
+
+ public void testAddRemoveJSFCapabilities() {
+
+ removeJSFCapabilities();
+ addJSFCapabilities();
+ // Test add/remove JSF capabilities after project is closed and reopened
+ closeOpenJsfProject();
+ removeJSFCapabilities();
+ addJSFCapabilities();
+ // Test import of deleted JSF project
+ deleteJsfProject();
+ importJsfProject();
+
+ }
+ /**
+ * Import existing JSF Project to Workspace
+ */
+ private void importJsfProject() {
+
+ openWebProjects();
+
+ openWebProjects();
+ SWTBot webProjects = bot.viewByTitle(WidgetVariables.WEB_PROJECTS).bot();
+ SWTBotTree tree = webProjects.tree();
+
+ tree.setFocus();
+ tree.select(0);
+
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ IMPORT_PROJECT_POPUP_MENU, false)).click();
+
+ bot.shell("Import JSF Project").activate();
+
+ String[] parts =
System.getProperty("eclipse.commands").split("\n");
+
+ int index = 0;
+
+ for (index = 0;parts.length > index + 1 &&
!parts[index].equals("-data");index+=2){
+ // do nothing just go through
+ }
+
+ if (parts.length > index + 1){
+ String webXmlFileLocation = parts[index + 1] + File.separator
+ + JBT_TEST_PROJECT_NAME + File.separator
+ + "WebContent" + File.separator
+ + "WEB-INF" + File.separator
+ + "web.xml";
+ bot.textWithLabel("web.xml Location*").setText(webXmlFileLocation);
+ }
+ else{
+ throw new RuntimeException("eclipse.commands property doesn't contain
-data option");
+ }
+
+ bot.button(WidgetVariables.NEXT_BUTTON).click();
+ // Specify Application Server for Deployment
+ bot.button(WidgetVariables.NEW_BUTTON, 1).click();
+ bot.shell("New Server").activate();
+ bot.tree().expandNode("JBoss Enterprise Middleware")
+ .select("JBoss Enterprise Application Platform 4.3");
+ bot.button(WidgetVariables.FINISH_BUTTON).click();
+ delay();
+ // Finish Import
+ bot.button(WidgetVariables.FINISH_BUTTON).click();
+ bot.shell("Warning").activate();
+ bot.button(WidgetVariables.CONTINUE_BUTTON).click();
+
+ waitForBlockingJobsAcomplished(BUILDING_WS);
+ // Start Application Server
+ openServerView();
+ SWTBot servers = bot.viewByTitle(WidgetVariables.SERVERS)
+ .bot();
+ SWTBotTree serverTree = servers.tree();
+ serverTree.setFocus();
+ serverTree.select(0);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree,
+ "Start", false)).click();
+ waitForBlockingJobsAcomplished(45*1000L,STARTING_JBOSS_EAP_43_RUNTIME);
+ // Run it on server
+ openPackageExplorer();
+ SWTBot packageExplorer = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER)
+ .bot();
+ SWTBotTree packageExplorerTree = packageExplorer.tree();
+
+ packageExplorerTree.setFocus();
+
+ SWTBotTreeItem packageExplorerTreeItem = packageExplorerTree
+ .getTreeItem(JBT_TEST_PROJECT_NAME);
+ packageExplorerTreeItem.select();
+ packageExplorerTreeItem.click();
+ // Search for Menu Item with Run on Server substring within label
+ final SWTBotMenu menuRunAs = bot.menu("Run").menu("Run As");
+ bot.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ int menuItemIndex = 0;
+ boolean isFound = false;
+ final MenuItem[] menuItems = menuRunAs.widget.getMenu().getItems();
+ while (!isFound && menuItemIndex < menuItems.length){
+ if (menuItems[menuItemIndex].getText().indexOf("Run on Server") >
- 1){
+ isFound = true;
+ }
+ else{
+ menuItemIndex++;
+ }
+ }
+ if (isFound){
+ setMiRunOnServer(menuItems[menuItemIndex]);
+ }
+ else{
+ setMiRunOnServer(null);
+ }
+ }
+ });
+
+ if (getMiRunOnServer() != null){
+ new SWTBotMenu(getMiRunOnServer()).click();
+ }
+ else
+ {
+ throw new WidgetNotFoundException("Menu item with mnemonic Run on
Server");
+ }
+
+ bot.shell("Run On Server").activate();
+ bot.button(WidgetVariables.FINISH_BUTTON).click();
+
+ waitForBlockingJobsAcomplished(10*1000L , BUILDING_WS);
+ waitForBlockingJobsAcomplished(10*1000L , UPDATING_INDEXES);
+ // Check Browser Content
+ final SWTBotEditor editor = bot.editorByTitle("Input User Name Page");
+ final Browser browser =
((Browser)editor.bot().widgets(withRegex("<HTML><HEAD>.*\n*.*")).get(0));
+ final String browserText = UIThreadRunnable
+ .syncExec(new StringResult() {
+ public String run() {
+ return browser.getText();
+ }
+ });
+ assertTrue("Displayed HTML page has wrong content",
+ browserText.indexOf("<TITLE>Input User Name Page</TITLE>")
> - 1);
+ editor.close();
+ // Stop Application Server and remove Application Server from Server View
+ openServerView();
+ serverTree.setFocus();
+ serverTree.select(0);
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree,
+ "Stop", false)).click();
+
+ waitForBlockingJobsAcomplished(10*1000L , STOPPING_JBOSS_EAP_43_RUNTIME);
+
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree,
+ "Delete", false)).click();
+ bot.shell("Delete Server").activate();
+ bot.button(WidgetVariables.OK_BUTTON).click();
+
+ setException(null);
+
+ }
+ /**
+ * Delete JSF Project from workspace
+ */
+ private void deleteJsfProject() {
+
+ openPackageExplorer();
+ SWTBot packageExplorer = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER)
+ .bot();
+ SWTBotTree tree = packageExplorer.tree();
+
+ tree.setFocus();
+
+ SWTBotTreeItem packageExplorerTreeItem = tree
+ .getTreeItem(JBT_TEST_PROJECT_NAME);
+ packageExplorerTreeItem.select();
+ packageExplorerTreeItem.click();
+
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ DELETE_PROJECT_POPUP_MENU, false)).click();
+
+ bot.shell("Delete Resources").activate();
+ bot.button(WidgetVariables.OK_BUTTON).click();
+
+ delay();
+
+ }
+
+ /**
+ * Remove JSF Capabilities from JSF Project
+ */
+ private void removeJSFCapabilities() {
+
+ openWebProjects();
+ SWTBot webProjects = bot.viewByTitle(WidgetVariables.WEB_PROJECTS).bot();
+ SWTBotTree tree = webProjects.tree();
+
+ tree.setFocus();
+
+ SWTBotTreeItem webProjectsTreeItem = tree
+ .getTreeItem(JBT_TEST_PROJECT_NAME);
+ webProjectsTreeItem.select();
+ webProjectsTreeItem.click();
+
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ WEB_PROJECT_JBT_JSF_POPUP_MENU, true)).menu(
+ REMOVE_JSF_CAPABILITIES_POPUP_MENU).click();
+
+ bot.shell("Confirmation").activate();
+ bot.button(WidgetVariables.OK_BUTTON).click();
+
+ assertTrue(
+ "Project "
+ + JBT_TEST_PROJECT_NAME
+ + " was not removed from Web Projects view after JSF Capabilities were
removed.",
+ !isTreeItemWithinWebProjectsView(JBT_TEST_PROJECT_NAME));
+ }
+
+ @Override
+ protected void closeUnuseDialogs() {
+ // not used
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+
+ /**
+ * Add JSF Capabilities to JSF Project
+ */
+ private void addJSFCapabilities() {
+
+ openPackageExplorer();
+ SWTBot packageExplorer = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER)
+ .bot();
+ SWTBotTree tree = packageExplorer.tree();
+
+ tree.setFocus();
+
+ SWTBotTreeItem packageExplorerTreeItem = tree
+ .getTreeItem(JBT_TEST_PROJECT_NAME);
+ packageExplorerTreeItem.select();
+ packageExplorerTreeItem.click();
+
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ PACKAGE_EXPLORER_JBT_POPUP_MENU, false)).menu(
+ ADD_JSF_CAPABILITIES_POPUP_MENU).click();
+
+ bot.shell("Add JSF Capabilities").activate();
+ bot.button(WidgetVariables.NEXT_BUTTON).click();
+ bot.button(WidgetVariables.FINISH_BUTTON).click();
+
+ delay();
+
+ assertTrue("JSF Capabilities were not added to project "
+ + JBT_TEST_PROJECT_NAME,
+ isTreeItemWithinWebProjectsView(JBT_TEST_PROJECT_NAME));
+
+ }
+
+ /**
+ * Return true when Web Projects Tree contains item with label treeItemLabel
+ *
+ * @param treeItemLabel
+ * @return
+ */
+ private boolean isTreeItemWithinWebProjectsView(String treeItemLabel) {
+
+ openWebProjects();
+ SWTBot webProjects = bot.viewByTitle(WidgetVariables.WEB_PROJECTS).bot();
+ SWTBotTree tree = webProjects.tree();
+
+ boolean isTreeItemWithinWebProjectsView = false;
+
+ try {
+ tree.getTreeItem(JBT_TEST_PROJECT_NAME);
+ isTreeItemWithinWebProjectsView = true;
+ } catch (WidgetNotFoundException e) {
+ isTreeItemWithinWebProjectsView = false;
+ }
+
+ return isTreeItemWithinWebProjectsView;
+
+ }
+
+ /**
+ * Close and reopen JSF test project
+ */
+ private void closeOpenJsfProject() {
+
+ openPackageExplorer();
+ SWTBot packageExplorer = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER)
+ .bot();
+ SWTBotTree tree = packageExplorer.tree();
+
+ tree.setFocus();
+
+ SWTBotTreeItem packageExplorerTreeItem = tree
+ .getTreeItem(JBT_TEST_PROJECT_NAME);
+ packageExplorerTreeItem.select();
+ packageExplorerTreeItem.click();
+
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ CLOSE_PROJECT_POPUP_MENU, false)).click();
+
+ delay();
+
+ new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,
+ OPEN_PROJECT_POPUP_MENU, false)).click();
+
+ }
+
+ private void setMiRunOnServer(MenuItem menuItem){
+ miRunOnServer = menuItem;
+ }
+
+ private MenuItem getMiRunOnServer(){
+ return miRunOnServer;
+ }
+
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/AddRemoveJSFCapabilitiesTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/CreateNewJSFProjectTest.java
===================================================================
---
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/CreateNewJSFProjectTest.java
(rev 0)
+++
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/CreateNewJSFProjectTest.java 2009-11-12
11:35:36 UTC (rev 18641)
@@ -0,0 +1,54 @@
+ /*******************************************************************************
+ * 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.jsf.ui.bot.test.smoke;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.jsf.ui.bot.test.JSFAutoTestCase;
+import org.jboss.tools.ui.bot.test.WidgetVariables;
+/**
+ * Test adding new JSF Project
+ * @author Vladimir Pakan
+ *
+ */
+public class CreateNewJSFProjectTest extends JSFAutoTestCase{
+
+ public void testCreateNewJSFProject() {
+
+ // Test create new JSF Project
+ // New JSF Project is created via setUp() method of super class VPEAutoTestCase.java
+ openPackageExplorer();
+ SWTBot innerBot = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).bot();
+ SWTBotTree tree = innerBot.tree();
+ boolean isOk = false;
+ try {
+ tree.getTreeItem(JBT_TEST_PROJECT_NAME);
+ isOk = true;
+ } catch (WidgetNotFoundException e) {
+ }
+ assertTrue("Project "
+ + JBT_TEST_PROJECT_NAME
+ + " was not created properly.",isOk);
+ }
+
+ @Override
+ protected void closeUnuseDialogs() {
+ // not used
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+
+}
Property changes on:
trunk/jsf/tests/org.jboss.tools.jsf.ui.bot.test/src/org/jboss/tools/jsf/ui/bot/test/smoke/CreateNewJSFProjectTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain