Author: vpakan(a)redhat.com
Date: 2010-11-10 02:27:01 -0500 (Wed, 10 Nov 2010)
New Revision: 26401
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotBrowserExt.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
Log:
Use BRMS runtime and client jars for Drools SWTBot tests.
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-11-10
06:15:09 UTC (rev 26400)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-11-10
07:27:01 UTC (rev 26401)
@@ -51,7 +51,7 @@
DomainSpecificLanguageEditorTest.class,
RuleFlowTest.class,
DecisionTableTest.class,
- GuvnorRepositoriesTest.class})
+ GuvnorRepositoriesTest.class})
public class DroolsAllBotTests extends SWTTestExt {
public static final String DROOLS_PROJECT_NAME = "droolsTest";
public static final String DROOLS_RUNTIME_NAME = "Drools Test Runtime";
@@ -68,7 +68,10 @@
public static final String RULE_FLOW_JAVA_TEST_FILE_NAME =
"ProcessTest.java";
public static final String RULE_FLOW_RF_FILE_NAME = "ruleflow.rf";
public static final String DECISION_TABLE_JAVA_TEST_FILE_NAME =
"DecisionTableTest.java";
- public static final String EAP_50_WITH_GUVNOR_PROPERTY_NAME=
"jboss-eap5.0-with-drools-home";
+ public static final String USE_EXTERNAL_DROOLS_RUNTIME_PROPERTY_NAME=
"use-external-drools-runtime";
+ public static final String EXTERNAL_DROOLS_RUTIME_HOME_PROPERTY_NAME=
"external-drools-runtime-home";
+ private static boolean USE_EXTERNAL_DROOLS_RUNTIME;
+
private static String testDroolsRuntimeName = null;
public static String getTestDroolsRuntimeName() {
return testDroolsRuntimeName;
@@ -90,11 +93,20 @@
@BeforeClass
public static void setUpTest() {
jbt.closeReportUsageWindowIfOpened(false);
- DroolsAllBotTests.DROOLS_RUNTIME_LOCATION =
System.getProperty("java.io.tmpdir");
- DroolsAllBotTests.CREATE_DROOLS_RUNTIME_LOCATION =
DroolsAllBotTests.DROOLS_RUNTIME_LOCATION + File.separator + "drools";
+ properties = util.loadProperties(Activator.PLUGIN_ID);
+ String useExternalDroolRuntime =
properties.getProperty(DroolsAllBotTests.USE_EXTERNAL_DROOLS_RUNTIME_PROPERTY_NAME);
+ DroolsAllBotTests.USE_EXTERNAL_DROOLS_RUNTIME = useExternalDroolRuntime != null
&& useExternalDroolRuntime.equalsIgnoreCase("true");
+ String droolsRuntimeLocation =
properties.getProperty(DroolsAllBotTests.EXTERNAL_DROOLS_RUTIME_HOME_PROPERTY_NAME);
+ String tmpDir = System.getProperty("java.io.tmpdir");
+ if (droolsRuntimeLocation == null || droolsRuntimeLocation.length() ==0){
+ DroolsAllBotTests.DROOLS_RUNTIME_LOCATION = tmpDir;
+ }
+ else{
+ DroolsAllBotTests.DROOLS_RUNTIME_LOCATION = droolsRuntimeLocation;
+ }
+ DroolsAllBotTests.CREATE_DROOLS_RUNTIME_LOCATION = tmpDir + File.separator +
"drools";
// Create directory for Drools Runtime which will be created as a part of test
new File(DroolsAllBotTests.CREATE_DROOLS_RUNTIME_LOCATION).mkdir();
- properties = util.loadProperties(Activator.PLUGIN_ID);
try{
SWTBotView welcomeView = eclipse.getBot().viewByTitle(IDELabel.View.WELCOME);
welcomeView.close();
@@ -105,6 +117,10 @@
eclipse.maximizeActiveShell();
}
+ public static boolean useExternalDroolsRuntime() {
+ return USE_EXTERNAL_DROOLS_RUNTIME;
+ }
+
@AfterClass
public static void tearDownTest() {
// delete created drools runtime
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java 2010-11-10
06:15:09 UTC (rev 26400)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/GuvnorRepositoriesTest.java 2010-11-10
07:27:01 UTC (rev 26401)
@@ -27,7 +27,6 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.hamcrest.Matcher;
@@ -36,7 +35,6 @@
import org.jboss.tools.ui.bot.ext.config.requirement.RequirementNotFulfilledException;
import org.jboss.tools.ui.bot.ext.config.requirement.StartServer;
import org.jboss.tools.ui.bot.ext.config.requirement.StopServer;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.View.GuvnorGuvnorResourceHistory;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
import org.jboss.tools.ui.bot.ext.helper.DragAndDropHelper;
@@ -63,13 +61,14 @@
private static final String GUVNOR_TEST_FILE = "Dummy rule.drl";
private static final String GUVNOR_REPOSITORY_IMPORT_TEST_FILE =
"Underage.brl";
private static final String GUVNOR_REPOSITORY_HISTORY_TEST_FILE =
"MortgageModel.model.drl";
+ private static final String GUVNOR_USER_NAME = "admin";
+ private static final String GUVNOR_PASSWORD = "admin";
private GuvnorRepositories guvnorRepositories = new GuvnorRepositories();
/**
* Tests Guvnor Repositories
*/
@Test
public void testGuvnorRepositories() {
- setGuvnorTemplate();
startGuvnor();
addGuvnorRepository();
deleteGuvnorRepository();
@@ -128,6 +127,8 @@
IDELabel.Menu.OPEN_GUVNOR_CONSOLE, false)).click();
bot.sleep(Timing.time5S());
SWTBotBrowserExt browser =
bot.browserByTitle(IDELabel.GuvnorConsole.GUVNOR_CONSOLE_TITLE);
+ browser.setInputTextViaJavaScript(GuvnorRepositoriesTest.GUVNOR_USER_NAME, 0, bot);
+ browser.setInputTextViaJavaScript(GuvnorRepositoriesTest.GUVNOR_PASSWORD, 1, bot);
browser.clickOnButtonViaJavaScript(0, bot);
browser.clickOnButtonViaJavaScript(IDELabel.GuvnorConsole.BUTTON_YES_INSTALL_SAMPLES,
bot);
bot.sleep(Timing.time1S());
@@ -349,8 +350,18 @@
}
private void drillIntoFunctionalityCheck(){
SWTBotView guvnorReposioryView = guvnorRepositories.show();
- guvnorRepositories.selectTreeItem(Timing.time2S(),
IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM,
- new String[]{IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM});
+ SWTBotTreeItem tiRoot =
guvnorRepositories.selectTreeItem(IDELabel.GuvnorRepositories.GUVNOR_REPOSITORY_ROOT_TREE_ITEM,null)
+ .doubleClick();
+ bot.sleep(Timing.time2S());
+ SWTBot dialogBot = bot.shell("").activate().bot();
+ dialogBot.textWithLabel(IDELabel.GuvnorConsoleLoginDialog.USER_NAME).setText(
+ GuvnorRepositoriesTest.GUVNOR_USER_NAME);
+ dialogBot.textWithLabel(IDELabel.GuvnorConsoleLoginDialog.PASSWORD).setText(
+ GuvnorRepositoriesTest.GUVNOR_PASSWORD);
+ dialogBot.button(IDELabel.Button.OK).click();
+ tiRoot.expand();
+ bot.sleep(Timing.time2S());
+ tiRoot.select(IDELabel.GuvnorRepositories.PACKAGES_TREE_ITEM);
SWTUtilExt.getViewToolbarButtonWithTooltip(guvnorReposioryView,
IDELabel.GuvnorRepositories.GO_INTO_GUVNOR_REPOSITORY_TOOLTIP)
.click();
@@ -511,14 +522,5 @@
"Content should start with " + addedChange +
"\n but is " + editorText,editorText.startsWith(addedChange));
}
- /**
- * Sets properly Guvnor Template
- */
- private void setGuvnorTemplate(){
- SWTBot dialogBot = open.preferenceOpen(ActionItem.Preference.Guvnor.LABEL);
- SWTBotText guvnorTemplateText =
dialogBot.textWithLabel(IDELabel.GuvnorPropertiesDialog.GUVNOR_URL_TEMPLATE);
-
guvnorTemplateText.setText(guvnorTemplateText.getText().replaceFirst("jboss-brms",
"drools-guvnor"));
- dialogBot.button(IDELabel.Button.OK).click();
- SWTEclipseExt.hideWarningIfDisplayed(bot);
- }
+
}
\ No newline at end of file
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java 2010-11-10
06:15:09 UTC (rev 26400)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/ManageDroolsRuntime.java 2010-11-10
07:27:01 UTC (rev 26401)
@@ -35,19 +35,24 @@
*/
@Test
public void testManageDroolsRuntime() {
-
addDroolsRuntime(DroolsAllBotTests.DROOLS_RUNTIME_NAME,DroolsAllBotTests.DROOLS_RUNTIME_LOCATION);
+
addDroolsRuntime(DroolsAllBotTests.DROOLS_RUNTIME_NAME,DroolsAllBotTests.DROOLS_RUNTIME_LOCATION,true);
editDroolsRuntime(DroolsAllBotTests.getTestDroolsRuntimeName(),
DroolsAllBotTests.getTestDroolsRuntimeLocation(),
"edited" , "testedit");
removeDroolsRuntime(DroolsAllBotTests.getTestDroolsRuntimeName());
createDroolsRuntime(DroolsAllBotTests.DROOLS_RUNTIME_NAME,DroolsAllBotTests.CREATE_DROOLS_RUNTIME_LOCATION);
+ if (DroolsAllBotTests.useExternalDroolsRuntime()){
+ removeDroolsRuntime(DroolsAllBotTests.DROOLS_RUNTIME_NAME);
+
addDroolsRuntime(DroolsAllBotTests.DROOLS_RUNTIME_NAME,DroolsAllBotTests.DROOLS_RUNTIME_LOCATION,true);
+ }
}
/**
* Adds Drools Runtime
* @param runtimeName
* @param runtimeLocation
+ * @param setAsDefault
*/
- private void addDroolsRuntime(String runtimeName, String runtimeLocation){
+ private void addDroolsRuntime(String runtimeName, String runtimeLocation, boolean
setAsDefault){
selectDroolsPreferences();
bot.button(IDELabel.Button.ADD).click();
bot.shell(IDELabel.Shell.DROOLS_RUNTIME).activate();
@@ -59,12 +64,17 @@
boolean droolsRuntimeAdded =
SWTEclipseExt.isItemInTableColumn(table,runtimeName,IDELabel.DroolsRuntimeDialog.COLUMN_NAME_INDEX)
&&
SWTEclipseExt.isItemInTableColumn(table,runtimeLocation,IDELabel.DroolsRuntimeDialog.COLUMN_LOCATION_INDEX);
+ // Set new runtime as default
+ if (setAsDefault){
+ table.getTableItem(0).check();
+ }
bot.button(IDELabel.Button.OK).click();
assertTrue("Drools Runtime with name [" + runtimeName +
"] and location [" + runtimeLocation +
"] was not added properly.",droolsRuntimeAdded);
DroolsAllBotTests.setTestDroolsRuntimeName(runtimeName);
DroolsAllBotTests.setTestDroolsRuntimeLocation(runtimeLocation);
+ SWTEclipseExt.hideWarningIfDisplayed(bot);
}
/**
* Selects Drools Preferences within Preferences Dialog
@@ -107,6 +117,7 @@
"] was not renamed properly.",droolsRuntimeEdited);
DroolsAllBotTests.setTestDroolsRuntimeName(editedDroolsRuntimeName);
DroolsAllBotTests.setTestDroolsRuntimeLocation(editedDroolsRuntimeLocation);
+ SWTEclipseExt.hideWarningIfDisplayed(bot);
}
/**
@@ -125,7 +136,7 @@
assertTrue("Drools Runtime with name [" + runtimeName +
"] was not removed properly.",droolsRuntimeRemoved);
// Remove temporary directory created within editDroolsRuntime() method
- if
(!DroolsAllBotTests.getTestDroolsRuntimeLocation().equals(DroolsAllBotTests.DROOLS_RUNTIME_NAME)){
+ if
(!DroolsAllBotTests.getTestDroolsRuntimeName().equals(DroolsAllBotTests.DROOLS_RUNTIME_NAME)){
File tempDir = new File (DroolsAllBotTests.getTestDroolsRuntimeLocation());
if (tempDir.isDirectory()){
tempDir.delete();
@@ -133,6 +144,7 @@
}
DroolsAllBotTests.setTestDroolsRuntimeName(null);
DroolsAllBotTests.setTestDroolsRuntimeLocation(null);
+ SWTEclipseExt.hideWarningIfDisplayed(bot);
}
/**
* Creates Drools Runtime
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotBrowserExt.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotBrowserExt.java 2010-11-10
06:15:09 UTC (rev 26400)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/parts/SWTBotBrowserExt.java 2010-11-10
07:27:01 UTC (rev 26401)
@@ -235,4 +235,15 @@
new SWTUtilExt(bot).waitForBrowserLoadsPage(this);
bot.sleep(Timing.time5S());
}
+ /**
+ * Set Text of Input on position specified by index via Java script
+ * @param text
+ * @param index
+ */
+ public void setInputTextViaJavaScript(String text, int index,SWTWorkbenchBot bot){
+ executeScriptAsync("document.getElementsByTagName('input')[" +
+ index +
+ "].value = \""+ text +"\";");
+ bot.sleep(Timing.time5S());
+ }
}
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-11-10
06:15:09 UTC (rev 26400)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/types/IDELabel.java 2010-11-10
07:27:01 UTC (rev 26401)
@@ -151,6 +151,8 @@
public static final String ADD_PALETTE_MACRO = "Add Palette Macro";
public static final String CONFIRMATION = "Confirmation";
public static final String USER_SPECIFIED_TAG_TEMPLATE = "User specified tag
template";
+ public static final String PAGE_DESIGN_OPTIONS = "Page Design Options";
+ public static final String ADD_TAGLIB_REFRENCE = "Add Taglib Reference";
}
public class EntityGroup {
@@ -497,7 +499,7 @@
public static final String ADD_GUVNOR_REPOSITORY_TOOLTIP = "Add a Guvnor
respository connection";
public static final String REMOVE_GUVNOR_REPOSITORY_TOOLTIP = "Delete Guvnor
repository connection";
public static final String REMOVE_GUVNOR_REPOSITORY_DIALOG_TITLE = "Remove
repository connection";
- public static final String GUVNOR_REPOSITORY_ROOT_TREE_ITEM =
"http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/webdav/";
+ public static final String GUVNOR_REPOSITORY_ROOT_TREE_ITEM =
"http://localhost:8080/jboss-brms/org.drools.guvnor.Guvnor/webdav/";
public static final String PACKAGES_TREE_ITEM = "packages/";
public static final String MORTGAGE_TREE_ITEM = "mortgages/";
public static final String GO_INTO_GUVNOR_REPOSITORY_TOOLTIP = "Go Into";
@@ -509,7 +511,7 @@
public static final class GuvnorConsole {
- public static final String GUVNOR_CONSOLE_TITLE = "JBoss Guvnor";
+ public static final String GUVNOR_CONSOLE_TITLE = "JBoss BRMS";
public static final String BUTTON_YES_INSTALL_SAMPLES = "Yes, please install
samples";
}
@@ -595,4 +597,22 @@
}
+ public static class PageDesignOptionsDialog{
+
+ public static final String INCLUDED_TAG_LIBS_TAB = "Included tag tibs";
+
+ }
+
+ public static class AddTaglibReferenceDialog{
+
+ public static final String INCLUDED_TAG_LIBS_TAB = "Included tag libs";
+
+ }
+
+ public static class GuvnorConsoleLoginDialog{
+
+ public static final String USER_NAME = "User Name: ";
+ public static final String PASSWORD = "Password: ";
+
+ }
}