Author: jjankovi
Date: 2012-01-31 12:07:50 -0500 (Tue, 31 Jan 2012)
New Revision: 38331
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/BuildPathHelper.java
Log:
Modifying BuildPathHelper to be able to overwrite existing external Jar file
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/BuildPathHelper.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/BuildPathHelper.java 2012-01-31
17:06:09 UTC (rev 38330)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/helper/BuildPathHelper.java 2012-01-31
17:07:50 UTC (rev 38331)
@@ -27,66 +27,102 @@
*
*/
public class BuildPathHelper {
- /**
- * Adds External Jar File to Project Build Path
- * @param externalJarLocation
- * @param projectName
- * @return
- */
+
+ /**
+ * Add External Jar File to Project Build Path. If External Jar File already
+ * exists method will fail
+ *
+ * @param externalJarLocation
+ * @param projectName
+ * @return
+ */
public static String addExternalJar(final String externalJarLocation,
final String projectName) {
-
- assertTrue("External Jar Location cannot be empty but is " +
externalJarLocation,
- externalJarLocation != null && externalJarLocation.length() > 0);
- SWTBotExt bot = new SWTEclipseExt().openPropertiesOfProject(projectName);
-
bot.tree().expandNode(IDELabel.JavaBuildPathPropertiesEditor.JAVA_BUILD_PATH_TREE_ITEM_LABEL).select();
- bot.tabItem(IDELabel.JavaBuildPathPropertiesEditor.LIBRARIES_TAB_LABEL).activate();
- bot.button(IDELabel.Button.ADD_VARIABLE).click();
- bot.shell(IDELabel.Shell.NEW_VARIABLE_CLASS_PATH_ENTRY).activate();
- bot.button(IDELabel.Button.CONFIGURE_VARIABLES).click();
- bot.shell(IDELabel.Shell.PREFERENCES_FILTERED).activate();
- bot.button(IDELabel.Button.NEW).click();
- bot.shell(IDELabel.Shell.NEW_VARIABLE_ENTRY).activate();
- String jarFileName = new File(externalJarLocation).getName();
- bot.textWithLabel(IDELabel.NewVariableEntryDialog.NAME_TEXT_LABEL)
- .setText(jarFileName.toUpperCase() + "_LOCATION");
- bot.textWithLabel(IDELabel.NewVariableEntryDialog.PATH_TEXT_LABEL)
- .setText(externalJarLocation);
- bot.clickButton(IDELabel.Button.OK).click();
- String result = TableHelper.getSelectionText(bot.table());
- bot.clickButton(IDELabel.Button.OK).click();
- bot.clickButton(IDELabel.Button.OK).click();
- bot.clickButton(IDELabel.Button.OK).click();
- new SWTUtilExt(bot).waitForNonIgnoredJobs();
- return result;
-
+
+ return addExternalJar(externalJarLocation, projectName, false);
+
}
+
/**
+ * Adds External Jar File to Project Build Path. If External Jar File already
+ * exists and 'overwriteIfExists' parameter is set to true, it is overwritten
+ *
+ * @param externalJarLocation
+ * @param projectName
+ * @return
+ */
+ public static String addExternalJar(final String externalJarLocation,
+ final String projectName, boolean overwriteIfExists) {
+
+ assertTrue("External Jar Location cannot be empty but is " +
externalJarLocation,
+ externalJarLocation != null && externalJarLocation.length() > 0);
+ SWTBotExt bot = new SWTEclipseExt().openPropertiesOfProject(projectName);
+ bot.tree().expandNode(IDELabel.JavaBuildPathPropertiesEditor.JAVA_BUILD_PATH_TREE_ITEM_LABEL).select();
+ bot.tabItem(IDELabel.JavaBuildPathPropertiesEditor.LIBRARIES_TAB_LABEL).activate();
+ bot.button(IDELabel.Button.ADD_VARIABLE).click();
+ bot.shell(IDELabel.Shell.NEW_VARIABLE_CLASS_PATH_ENTRY).activate();
+ String jarFileName = new File(externalJarLocation).getName();
+ String variableEntryName = jarFileName.toUpperCase() + "_LOCATION";
+ boolean externalJarExists = false;
+ for (int i = 0; i < bot.table().rowCount(); i++) {
+ if (bot.table().getTableItem(i).getText().split(" -
")[0].equals(variableEntryName)) {
+ bot.table().getTableItem(i).select();
+ externalJarExists = true;
+ break;
+ }
+ }
+ bot.button(IDELabel.Button.CONFIGURE_VARIABLES).click();
+ bot.shell(IDELabel.Shell.PREFERENCES_FILTERED).activate();
+ if (externalJarExists && overwriteIfExists) {
+ bot.button(IDELabel.Button.EDIT).click();
+ bot.shell(IDELabel.Shell.EDIT_VARIABLE_ENTRY).activate();
+ bot.textWithLabel(IDELabel.NewVariableEntryDialog.PATH_TEXT_LABEL)
+ .setText(externalJarLocation);
+ } else {
+ bot.button(IDELabel.Button.NEW).click();
+ bot.shell(IDELabel.Shell.NEW_VARIABLE_ENTRY).activate();
+ bot.textWithLabel(IDELabel.NewVariableEntryDialog.NAME_TEXT_LABEL)
+ .setText(variableEntryName);
+ bot.textWithLabel(IDELabel.NewVariableEntryDialog.PATH_TEXT_LABEL)
+ .setText(externalJarLocation);
+ }
+ bot.clickButton(IDELabel.Button.OK).click();
+ String result = TableHelper.getSelectionText(bot.table());
+ bot.clickButton(IDELabel.Button.OK).click();
+ bot.clickButton(IDELabel.Button.OK).click();
+ bot.clickButton(IDELabel.Button.OK).click();
+ new SWTUtilExt(bot).waitForNonIgnoredJobs();
+ return result;
+ }
+
+ /**
* Removes variable from project classpath
+ *
* @param variableLabel
* @param removeGlobaly
*/
- public static void removeVariable (String projectName , String variableLabel, boolean
removeGlobaly){
- SWTBotExt bot = new SWTEclipseExt().openPropertiesOfProject(projectName);
-
bot.tree().expandNode(IDELabel.JavaBuildPathPropertiesEditor.JAVA_BUILD_PATH_TREE_ITEM_LABEL).select();
- bot.tabItem(IDELabel.JavaBuildPathPropertiesEditor.LIBRARIES_TAB_LABEL).activate();
- bot.tree(1).select(variableLabel);
- bot.button(IDELabel.Button.REMOVE).click();
- if (removeGlobaly){
- bot.button(IDELabel.Button.ADD_VARIABLE).click();
- bot.shell(IDELabel.Shell.NEW_VARIABLE_CLASS_PATH_ENTRY).activate();
- bot.table().select(variableLabel);
- bot.button(IDELabel.Button.CONFIGURE_VARIABLES).click();
- bot.shell(IDELabel.Shell.PREFERENCES_FILTERED).activate();
- bot.button(IDELabel.Button.REMOVE).click();
- bot.button(IDELabel.Button.OK).click();
- bot.shell(IDELabel.Shell.CLASSPATH_VARIABLES_CHANGED).activate();
- bot.button(IDELabel.Button.YES).click();
- new SWTUtilExt(bot).waitForNonIgnoredJobs();
- bot.clickButton(IDELabel.Button.CANCEL).click();
- }
- bot.button(IDELabel.Button.OK).click();
- new SWTUtilExt(bot).waitForNonIgnoredJobs();
+ public static void removeVariable(String projectName, String variableLabel,
+ boolean removeGlobaly) {
+ SWTBotExt bot = new SWTEclipseExt().openPropertiesOfProject(projectName);
+ bot.tree().expandNode(IDELabel.JavaBuildPathPropertiesEditor.JAVA_BUILD_PATH_TREE_ITEM_LABEL).select();
+ bot.tabItem(IDELabel.JavaBuildPathPropertiesEditor.LIBRARIES_TAB_LABEL).activate();
+ bot.tree(1).select(variableLabel);
+ bot.button(IDELabel.Button.REMOVE).click();
+ if (removeGlobaly) {
+ bot.button(IDELabel.Button.ADD_VARIABLE).click();
+ bot.shell(IDELabel.Shell.NEW_VARIABLE_CLASS_PATH_ENTRY).activate();
+ bot.table().select(variableLabel);
+ bot.button(IDELabel.Button.CONFIGURE_VARIABLES).click();
+ bot.shell(IDELabel.Shell.PREFERENCES_FILTERED).activate();
+ bot.button(IDELabel.Button.REMOVE).click();
+ bot.button(IDELabel.Button.OK).click();
+ bot.shell(IDELabel.Shell.CLASSPATH_VARIABLES_CHANGED).activate();
+ bot.button(IDELabel.Button.YES).click();
+ new SWTUtilExt(bot).waitForNonIgnoredJobs();
+ bot.clickButton(IDELabel.Button.CANCEL).click();
+ }
+ bot.button(IDELabel.Button.OK).click();
+ new SWTUtilExt(bot).waitForNonIgnoredJobs();
}
}
Show replies by date