Author: vpakan(a)redhat.com
Date: 2010-03-31 11:10:08 -0400 (Wed, 31 Mar 2010)
New Revision: 21153
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/types/IDELabel.java
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/CreateNewStrutsProjectTest.java
Log:
Set properly server runtime for struts test. Added timeouts when starting application
server.
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-03-31
14:12:35 UTC (rev 21152)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTJBTExt.java 2010-03-31
15:10:08 UTC (rev 21153)
@@ -18,6 +18,7 @@
import org.apache.log4j.Logger;
import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Table;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
@@ -137,11 +138,12 @@
SWTEclipseExt swtEclipseExt = new SWTEclipseExt();
SWTBot servers = swtEclipseExt.showView(ViewType.SERVERS);
SWTBotTree serverTree = servers.tree();
-
ContextMenuHelper.prepareTreeItemForContextMenu(serverTree, index);
-
- new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree,
- menuLabel, false)).click();
+ SWTTestExt.util.waitForAll(timeOut);
+ SWTBotMenu menu = new SWTBotMenu(ContextMenuHelper.getContextMenu(serverTree,
+ menuLabel, false));
+ SWTTestExt.util.waitForAll(timeOut);
+ menu.click();
SWTTestExt.util.waitForAll(timeOut);
}
/**
@@ -192,19 +194,20 @@
if (serverTreeItemChildren != null && serverTreeItemChildren.length >
0){
int itemIndex = 0;
boolean found = false;
+ String treeItemlabel = null;
do{
- String treeItemlabel = serverTreeItemChildren[itemIndex].getText();
+ treeItemlabel = serverTreeItemChildren[itemIndex].getText();
found = treeItemlabel.startsWith(projectName)
&& (suffix == null || treeItemlabel.endsWith(suffix));
} while (!found && ++itemIndex < serverTreeItemChildren.length);
// Server Tree Item has Child with Text equal to JSF TEst Project
if (found){
- log.info("Found project to be removed from server: " +
serverTreeItemChildren[itemIndex].getText());
+ log.info("Found project to be removed from server: " +
treeItemlabel);
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();
- log.info("Removed project from server: " +
serverTreeItemChildren[itemIndex].getText());
+ log.info("Removed project from server: " + treeItemlabel);
bot.sleep(10*1000L);
}
}
@@ -394,5 +397,51 @@
removeProjectFromServers(projectName);
removeProjectFromServers("/" + projectName,"-ds.xml");
}
-
+ /**
+ * Returns string representing version of defined Server Runtime on rowIndex position
in Defined Server Runtime table
+ * @param bot
+ * @param rowIndex
+ * @return null when no server runtime is specified, "unknown when not possible to
determine server runtime version" or server runtime version
+ */
+ public static String getDefinedServerRuntimeVersion(SWTWorkbenchBot bot , int
rowIndex){
+
+ String result = null;
+
+ bot.menu(IDELabel.Menu.WINDOW).menu(IDELabel.Menu.PREFERENCES).click();
+ bot.shell(IDELabel.Shell.PREFERENCES).activate();
+ bot.tree().expandNode(IDELabel.PreferencesDialog.SERVER_GROUP).select(
+ PreferencesDialog.RUNTIME_ENVIRONMENTS);
+
+ SWTBotTable serverRuntimesTable = bot.table();
+ if (serverRuntimesTable.rowCount() > rowIndex){
+ String[] splitServerRuntimeType = serverRuntimesTable.cell(rowIndex,
1).split(" ");
+ int index = 0;
+ while (index < splitServerRuntimeType.length && result == null){
+ if (splitServerRuntimeType[index].length() > 0 &&
+ splitServerRuntimeType[index].charAt(0) >= '0' &&
+ splitServerRuntimeType[index].charAt(0) <= '9'){
+ result = splitServerRuntimeType[index].trim();
+ }
+ else{
+ index++;
+ }
+ }
+ }
+
+ bot.button(IDELabel.Button.OK).click();
+
+ return result;
+
+ }
+
+ /**
+ * Returns string representing version of defined Server Runtime on index position in
Defined Server Runtime table
+ * @param rowIndex
+ * @return null when no server runtime is specified, "unknown when not possible to
determine server runtime version" or server runtime version
+ */
+ public String getDefinedServerRuntimeVersion(int index){
+
+ return SWTJBTExt.getDefinedServerRuntimeVersion(bot,index);
+
+ }
}
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-03-31
14:12:35 UTC (rev 21152)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-03-31
15:10:08 UTC (rev 21153)
@@ -261,6 +261,7 @@
public static final String JBOSS_EAP_4_3 = "JBoss EAP 4.3 Runtime";
// Server Runtime with this Label is created during JBDS installation for bundled
EAP
public static final String JBOSS_EAP = "jboss-eap Runtime";
+ public static final String JBOSS_EAP_5_0 = "JBoss EAP 5.0 Runtime";
}
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-03-31
14:12:35 UTC (rev 21152)
+++
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/smoke/CreateNewStrutsProjectTest.java 2010-03-31
15:10:08 UTC (rev 21153)
@@ -30,28 +30,51 @@
* Test create new Struts Project
*/
@Test
- public void testCreateNewStrutsProject() {
- if (!SWTJBTExt.isServerRuntimeDefined(bot)){
+ public void testCreateNewStrutsProject() {
+ // Default server version is 4.3
+ String serverGroup = IDELabel.ServerGroup.JBOSS_EAP_4_3;
+ String serverType = IDELabel.ServerType.JBOSS_EAP_4_3;
+
+ if (!SWTJBTExt.isServerRuntimeDefined(bot)) {
eclipse.addServerRuntime(IDELabel.ServerRuntimeName.JBOSS_EAP_4_3,
IDELabel.ServerGroup.JBOSS_EAP_4_3,
- IDELabel.ServerRuntimeType.JBOSS_EAP_4_3,
- StrutsAllBotTests.getProperty("JBossEap4.3Home"));
+ IDELabel.ServerRuntimeType.JBOSS_EAP_4_3, StrutsAllBotTests
+ .getProperty("JBossEap4.3Home"));
}
- eclipse.showView(ViewType.WEB_PROJECTS);
- eclipse.createNew(EntityType.STRUTS_PROJECT);
- bot.shell(IDELabel.Shell.NEW_STRUTS_PROJECT).activate();
-
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();
- SWTJBTExt.addServerToServerViewOnWizardPage(bot, IDELabel.ServerGroup.JBOSS_EAP_4_3,
IDELabel.ServerType.JBOSS_EAP_4_3);
- bot.sleep(1000L);
- bot.button(IDELabel.Button.NEXT).click();
- bot.button(IDELabel.Button.FINISH).click();
+ else{
+ // Check version of already defined server runtime
+ String serverRuntimeVersion = SWTJBTExt.getDefinedServerRuntimeVersion(bot, 0);
+ if (serverRuntimeVersion != null){
+ if (serverRuntimeVersion.equals("5.0")){
+ serverGroup = IDELabel.ServerGroup.JBOSS_EAP_5_0;
+ serverType = IDELabel.ServerType.JBOSS_EAP_5_0;
+ }else if(!serverRuntimeVersion.equals("4.3")){
+ throw new RuntimeException("Unsupported server runtime: " +
serverRuntimeVersion);
+ }
+ }
+ else{
+ throw new RuntimeException("Unsupported server runtime: " +
serverRuntimeVersion);
+ }
+ }
+ eclipse.showView(ViewType.WEB_PROJECTS);
+ eclipse.createNew(EntityType.STRUTS_PROJECT);
+ bot.shell(IDELabel.Shell.NEW_STRUTS_PROJECT).activate();
+ 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();
+ SWTJBTExt.addServerToServerViewOnWizardPage(bot,
+ serverGroup, serverType);
+ bot.sleep(1000L);
+ bot.button(IDELabel.Button.NEXT).click();
+ bot.button(IDELabel.Button.FINISH).click();
eclipse.closeOpenAssociatedPerspectiveShellIfOpened(false);
-
- assertTrue("Project "+ StrutsAllBotTests.STRUTS_PROJECT_NAME + " was not
created properly.",
-
SWTEclipseExt.treeContainsItemWithLabel(bot.viewByTitle(IDELabel.View.WEB_PROJECTS).bot().tree(),
- StrutsAllBotTests.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));
+ }
+
}
Show replies by date