JBoss Tools SVN: r26032 - trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial.
by jbosstools-commits@lists.jboss.org
Author: jlukas(a)redhat.com
Date: 2010-10-25 10:32:07 -0400 (Mon, 25 Oct 2010)
New Revision: 26032
Modified:
trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
Log:
update test wrt JIRA-6256
Modified: trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java
===================================================================
--- trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java 2010-10-25 14:15:48 UTC (rev 26031)
+++ trunk/struts/tests/org.jboss.tools.struts.ui.bot.test/src/org/jboss/tools/struts/ui/bot/test/tutorial/TutorialTest.java 2010-10-25 14:32:07 UTC (rev 26032)
@@ -103,6 +103,7 @@
Assert.assertTrue("struts-logic.tld checked", ti[3].isChecked());
Assert.assertTrue("struts-bean.tld checked", ti[4].isChecked());
bot.button(IDELabel.Button.FINISH).click();
+ bot.sleep(3000);
SWTBot v = eclipse.showView(ViewType.PACKAGE_EXPLORER);
SWTBotTree tree = v.tree();
tree.setFocus();
@@ -136,10 +137,10 @@
handleWizard("pages");
nodeContextMenu(tree, webRootNode.getNode("pages"), "New", "File", "JSP...").click();
- handleWizard("inputname", "StrutsForm");
+ handleStandardWizard("inputname");
nodeContextMenu(tree, webRootNode.getNode("pages"), "New", "File", "JSP...").click();
- handleWizard("greeting");
+ handleStandardWizard("greeting");
//2.2.1.2. Placing the Page Placeholders
nodeContextMenu(
@@ -149,7 +150,7 @@
StrutsUIEditorBot ge = new StrutsUIEditorBot(botEditor.getReference());
Control c = ge.getControl();
- SWTBotTreeItem s = webRootNode.getNode("pages").getNode("inputname.jsp");
+ SWTBotTreeItem s = webRootNode.expandNode("pages").getNode("inputname.jsp");
Widget w1 = s.widget;
s.select();
@@ -165,10 +166,10 @@
//2.2.2. Creating an Action Mappings
new SWTBotGefContextMenu(c, "Action...").click();
sh = bot.activeShell();
- sh.bot().textWithLabel("Path*").setText("/greeting");
- sh.bot().comboBoxWithLabel("Name").setText("GetNameForm");
- sh.bot().comboBoxWithLabel("Scope").setSelection("request");
- sh.bot().textWithLabel("Type").setText("sample.GreetingAction");
+ sh.bot().textWithLabel("Path:*").setText("/greeting");
+ sh.bot().comboBoxWithLabel("Name:").setText("GetNameForm");
+ sh.bot().comboBoxWithLabel("Scope:").setSelection("request");
+ sh.bot().textWithLabel("Type:").setText("sample.GreetingAction");
sh.bot().button("Finish").click();
//2.2.3. Creating a Link
@@ -189,13 +190,13 @@
ge.selectPage("Tree");
SWTBotTreeItem item = botEditor.bot().tree().expandNode("struts-config.xml", "action-mappings", "/greeting");
item.getNode("greeting").select();
- bot.activeEditor().bot().textWithLabel("Name").setText("sayHello");
+ bot.activeEditor().bot().textWithLabel("Name:").setText("sayHello");
ge.selectPage("Diagram");
//2.2.5. Creating a Global Forward
new SWTBotGefContextMenu(c, "Global Forward...").click();
sh = bot.activeShell();
- sh.bot().textWithLabel("Name*").setText("getName");
+ sh.bot().textWithLabel("Name:*").setText("getName");
sh.bot().button(0).click();
SWTBotShell sh2 = sh.bot().activeShell();
sh2.bot().tabItem("Pages").activate();
@@ -210,8 +211,8 @@
item = tree.getTreeItem("struts-config.xml").getNode("form-beans");
nodeContextMenu(tree, item, "Create Form Bean...").click();
sh = bot.activeShell();
- sh.bot().textWithLabel("Name*").setText("GetNameForm");
- sh.bot().textWithLabel("Type*").setText("sample.GetNameForm");
+ sh.bot().textWithLabel("Name:*").setText("GetNameForm");
+ sh.bot().textWithLabel("Type:*").setText("sample.GetNameForm");
sh.bot().button("Finish").click();
botEditor.save();
util.waitForNonIgnoredJobs();
@@ -272,7 +273,7 @@
editor.show();
SWTBotJSPMultiPageEditor editorA = new SWTBotJSPMultiPageEditor(bot.editorByTitle("inputname.jsp").getReference(), new SWTWorkbenchBot());
editorA.selectTab("Source");
- SWTBotStyledText st = bot.styledText();
+ SWTBotStyledText st = editorA.bot().styledText();
st.selectRange(0, 0, st.getText().length());
st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/inputname.jsp.gf")));
editor.saveAndClose();
@@ -298,7 +299,7 @@
editor.show();
editorA = new SWTBotJSPMultiPageEditor(bot.editorByTitle("greeting.jsp").getReference(), new SWTWorkbenchBot());
editorA.selectTab("Source");
- st = bot.styledText();
+ st = editorA.bot().styledText();
st.selectRange(0, 0, st.getText().length());
st.setText(readResource(TutorialTest.class.getResourceAsStream("/resources/greeting.jsp.gf")));
editor.saveAndClose();
@@ -331,6 +332,8 @@
util.waitForNonIgnoredJobs();
new SWTBotGefContextMenu(gui.getControl(), "Run on Server").click();
SWTBotBrowserExt browser = bot.browser();
+ bot.sleep(7500);
+ browser.refresh();
bot.sleep(5000);
L.info(browser.getText());
Assert.assertTrue(browser.getText().contains("Input name:"));
@@ -357,7 +360,7 @@
SWTBotShell sh2 = sh.bot().activeShell();
sh2.bot().tree().getTreeItem("StrutsHello").expandNode("JavaSource", "sample").select();
sh2.bot().button("OK").click();
- sh.bot().textWithLabel("Name*").setText("applResources");
+ sh.bot().textWithLabel("Name:*").setText("applResources");
sh.bot().button("Finish").click();
SWTBotTreeItem item = projectNode.getNode("Resource Bundles").getNode("sample.applResources");
nodeContextMenu(tree, item, "New", "Default Error Messages").click();
@@ -382,7 +385,7 @@
ti = t.expandNode("formset (default)").getNode("GetNameForm").select();
vb.toolbarButton("Create Field").click();
sh = bot.activeShell();
- sh.bot().textWithLabel("Property*").setText("name");
+ sh.bot().textWithLabel("Property:*").setText("name");
sh.bot().button("Finish").click();
ti = ti.expand().getNode("name").select();
vb.toolbarButton("Edit").click();
@@ -401,8 +404,8 @@
sh2 = bot.activeShell();
sh2.bot().button("Add").click();
SWTBotShell sh3 = bot.activeShell();
- sh3.bot().textWithLabel("Name*").setText("name.required");
- sh3.bot().textWithLabel("Value").setText("Person's name");
+ sh3.bot().textWithLabel("Name:*").setText("name.required");
+ sh3.bot().textWithLabel("Value:").setText("Person's name");
sh3.bot().button("Finish").click();
sh2.bot().button("Ok").click();
sh.bot().button("Finish").click();
@@ -421,10 +424,15 @@
jspEditor.save();
bot.editorByTitle("struts-config.xml").save();
util.waitForNonIgnoredJobs();
+ bot.sleep(2500);
servers.show();
SWTBotTree srvs = servers.tree();
SWTBotTreeItem s = getProjectNodeFromServerView(srvs);
nodeContextMenu(servers.tree(), s, "Full Publish").click();
+ bot.sleep(2500);
+ SWTBotToolbarButton tb = bot.activeShell().bot().toolbarButtonWithTooltip("Touch descriptors");
+ tb.click();
+ bot.sleep(2500);
SWTBotEditor ed = new SWTBotEditor(getBrowserReference(), new SWTWorkbenchBot());
ed.show();
Browser b = ed.bot().widget(WidgetOfType.widgetOfType(Browser.class));
@@ -463,13 +471,16 @@
bot.activeShell().bot().menu("File").menu("Save All").click();
bot.sleep(1000);
util.waitForNonIgnoredJobs();
- SWTBotToolbarButton tb = bot.activeShell().bot().toolbarButtonWithTooltip("Touch descriptors");
+ tb = bot.activeShell().bot().toolbarButtonWithTooltip("Touch descriptors");
tb.click();
ed.show();
String out2 = refreshBrowser(browser);
L.info(out2);
- Assert.assertTrue(out1.contains("onsubmit=\"return validateGetNameForm(this)\""));
- Assert.assertFalse(out2.contains("onsubmit=\"return validateGetNameForm(this)\""));
+ boolean b1 = out1.contains("onsubmit=\"return validateGetNameForm(this)\"");
+ boolean b2 = !out2.contains("onsubmit=\"return validateGetNameForm(this)\"");
+ Assert.assertTrue(b1 || b2);
+ Assert.assertTrue(b1);
+ Assert.assertTrue(b2);
}
private SWTBotMenu nodeContextMenu(final SWTBotTree tree,
@@ -503,6 +514,14 @@
sh.finish();
}
+ private void handleStandardWizard(String itemName) {
+ SWTBot sh = bot.activeShell().bot();
+ sh.textWithLabel("File name:").setText(itemName);
+ sh.button("Finish").click();
+ bot.sleep(1500);
+ }
+
+
private String readResource(InputStream is) {
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
@@ -546,6 +565,8 @@
util.waitForNonIgnoredJobs();
bot.sleep(10000);
b.refresh();
+ bot.sleep(5000);
+ b.refresh();
util.waitForNonIgnoredJobs();
bot.sleep(1000);
return b.getText();
14 years, 2 months
JBoss Tools SVN: r26031 - in trunk: jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: dmaliarevich
Date: 2010-10-25 10:15:48 -0400 (Mon, 25 Oct 2010)
New Revision: 26031
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
Log:
https://jira.jboss.org/browse/JBIDE-7380 , Externalize String Dialog suggests to use already defined key from the bundle is the same value has been already externalized. JUnit was updated.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2010-10-25 13:27:36 UTC (rev 26030)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizard.java 2010-10-25 14:15:48 UTC (rev 26031)
@@ -98,39 +98,41 @@
@Override
public boolean performFinish() {
- IFile bundleFile = null;
- if (page1.isNewFile()) {
- bundleFile = page2.createNewFile();
- } else {
- bundleFile = page1.getBundleFile();
- }
- /*
- * Exit when the file is null
- */
- if (bundleFile == null) {
- return false;
- }
- /*
- * Add "key=value" to the bundle file that is already exists.
- * When the file is new key and value will be written to the file content
- * via getInitialContent() method of the page2 during the file creation.
- */
- if (bundleFile.exists() && !page1.isNewFile()) {
+ if (!page1.isDuplicatedKeyValue()) {
+ IFile bundleFile = null;
+ if (page1.isNewFile()) {
+ bundleFile = page2.createNewFile();
+ } else {
+ bundleFile = page1.getBundleFile();
+ }
/*
- * https://jira.jboss.org/browse/JBIDE-7218
- * Add only one line before adding the value.
+ * Exit when the file is null
*/
- String writeToFile = "\n" + page1.getKeyValuePair(); //$NON-NLS-1$
- InputStream is = new ByteArrayInputStream(writeToFile.getBytes());
- try {
- bundleFile.appendContents(is, false, true, null);
- is.close();
- is = null;
- } catch (CoreException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
+ if (bundleFile == null) {
+ return false;
}
+ /*
+ * Add "key=value" to the bundle file that is already exists.
+ * When the file is new key and value will be written to the file content
+ * via getInitialContent() method of the page2 during the file creation.
+ */
+ if (bundleFile.exists() && !page1.isNewFile()) {
+ /*
+ * https://jira.jboss.org/browse/JBIDE-7218
+ * Add only one line before adding the value.
+ */
+ String writeToFile = "\n" + page1.getKeyValuePair(); //$NON-NLS-1$
+ InputStream is = new ByteArrayInputStream(writeToFile.getBytes());
+ try {
+ bundleFile.appendContents(is, false, true, null);
+ is.close();
+ is = null;
+ } catch (CoreException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
}
/*
* Replace text in the editor
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2010-10-25 13:27:36 UTC (rev 26030)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/i18n/ExternalizeStringsWizardPage.java 2010-10-25 14:15:48 UTC (rev 26031)
@@ -110,6 +110,7 @@
private Status propsKeyStatus;
private Status propsValueStatus;
private Status duplicateKeyStatus;
+ private Status duplicateValueStatus;
private Table tagsTable;
/**
@@ -145,6 +146,7 @@
propsKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
propsValueStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
duplicateKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
+ duplicateValueStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
}
public void createControl(Composite parent) {
@@ -349,52 +351,69 @@
}
}
/*
- * Check the initial key value
- * If there is the error - add sequence number to the key
+ * Check the initial value status
+ * When the same value is already externalized --
+ * suggest to use already created key as well.
*/
- updateDuplicateKeyStatus();
- while (!duplicateKeyStatus.isOK()) {
- int index = propsKey.getText().lastIndexOf('_');
- String newKey = Constants.EMPTY;
- if (index != -1) {
+ updatePropertiesValueStatus();
+ updateDuplicateValueStatus();
+ if (propsValueStatus.isOK()) {
+ if (!duplicateValueStatus.isOK()
+ && JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_VALUE_EXISTS
+ .equalsIgnoreCase(duplicateValueStatus.getMessage())) {
+ applyStatus(this, new IStatus[] {duplicateValueStatus});
+ } else {
/*
- * String sequence at the end should be checked.
- * If it is a sequence number - it should be increased by 1.
- * If not - new number should be added.
+ * Check the initial key status
+ * If there is the error - add sequence number to the key
*/
- String numberString = propsKey.getText().substring(index + 1);
- int number;
- try {
- number = Integer.parseInt(numberString);
- number++;
- newKey = propsKey.getText().substring(0, index + 1) + number;
- } catch (NumberFormatException e) {
- newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
+ updateDuplicateKeyStatus();
+ while (!duplicateKeyStatus.isOK()) {
+ int index = propsKey.getText().lastIndexOf('_');
+ String newKey = Constants.EMPTY;
+ if (index != -1) {
+ /*
+ * String sequence at the end should be checked.
+ * If it is a sequence number - it should be increased by 1.
+ * If not - new number should be added.
+ */
+ String numberString = propsKey.getText().substring(index + 1);
+ int number;
+ try {
+ number = Integer.parseInt(numberString);
+ number++;
+ newKey = propsKey.getText().substring(0, index + 1) + number;
+ } catch (NumberFormatException e) {
+ newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
+ }
+ } else {
+ /*
+ * If the string has no sequence number - add it.
+ */
+ newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
+ }
+ /*
+ * Set the new key text
+ */
+ propsKey.setText(newKey);
+ updateDuplicateKeyStatus();
}
- } else {
/*
- * If the string has no sequence number - add it.
+ * https://jira.jboss.org/browse/JBIDE-6945
+ * Set the greeting message only.
+ * All the validation will take place in the fields' listeners
+ * after user enters some new values.
*/
- newKey = propsKey.getText() + "_1"; //$NON-NLS-1$
+ setMessage(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME,
+ IMessageProvider.INFORMATION);
}
- /*
- * Set the new key text
- */
- propsKey.setText(newKey);
- updateDuplicateKeyStatus();
+ } else {
+ applyStatus(this, new IStatus[] {propsValueStatus});
}
/*
- * https://jira.jboss.org/browse/JBIDE-6945
- * Set the greeting message only.
- * All the validation will take place in the fields' listeners
- * after user enters some new values.
- */
- setMessage(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_ENTER_KEY_NAME,
- IMessageProvider.INFORMATION);
- /*
* Update the Buttons state.
* When all the fields are correct --
- * then user should be abke to press OK
+ * then user should be able to press OK
*/
setPageComplete(isPageComplete());
/*
@@ -442,21 +461,41 @@
* @param key the key name
* @return <code>true</code> if there is a key with the specified name
*/
- private boolean isDuplicatedKey(String key) {
- boolean isDupliacted = false;
+ private boolean isKeyDuplicated(String key) {
+ boolean isDuplicated = false;
if ((tagsTable.getItemCount() > 0) && (null != key) && !isNewFile()) {
TableItem[] items = tagsTable.getItems();
for (TableItem tableItem : items) {
if (key.equalsIgnoreCase(tableItem.getText(0))) {
- isDupliacted = true;
+ isDuplicated = true;
break;
}
}
}
- return isDupliacted;
+ return isDuplicated;
}
/**
+ * Checks values in the selected resource bundle.
+ *
+ * @param value the text string to externalize
+ * @return <code>true</code> if there is a key with the specified name
+ */
+ private boolean isValueDuplicated(String value) {
+ boolean isDuplicated = false;
+ if ((tagsTable.getItemCount() > 0) && (null != value) && !isNewFile()) {
+ TableItem[] items = tagsTable.getItems();
+ for (TableItem tableItem : items) {
+ if (value.equalsIgnoreCase(tableItem.getText(1))) {
+ isDuplicated = true;
+ break;
+ }
+ }
+ }
+ return isDuplicated;
+ }
+
+ /**
* Update resource bundle table according to the selected file:
* it fills key and value columns.
*
@@ -605,7 +644,7 @@
* Update duplicate key status.
*/
private void updateDuplicateKeyStatus() {
- if (isDuplicatedKey(propsKey.getText())) {
+ if (isKeyDuplicated(propsKey.getText())) {
duplicateKeyStatus = new Status(
IStatus.ERROR,
JspEditorPlugin.PLUGIN_ID,
@@ -614,6 +653,20 @@
duplicateKeyStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
}
}
+
+ /**
+ * Update duplicate key status.
+ */
+ private void updateDuplicateValueStatus() {
+ if (isValueDuplicated(propsValue.getText())) {
+ duplicateValueStatus = new Status(
+ IStatus.WARNING,
+ JspEditorPlugin.PLUGIN_ID,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_VALUE_EXISTS);
+ } else {
+ duplicateValueStatus = new Status(IStatus.OK, JspEditorPlugin.PLUGIN_ID, Constants.EMPTY);
+ }
+ }
private void updatePropertiesValueStatus() {
String text = propsValue.getText();
@@ -655,10 +708,17 @@
updatePropertiesKeyStatus();
updatePropertiesValueStatus();
updateDuplicateKeyStatus();
+ updateDuplicateValueStatus();
/*
* Apply status to the dialog
*/
- applyStatus(this, new IStatus[] {propsKeyStatus, propsValueStatus, duplicateKeyStatus});
+ if (!duplicateValueStatus.isOK()) {
+ applyStatus(this, new IStatus[] { propsKeyStatus, propsValueStatus,
+ duplicateValueStatus});
+ } else {
+ applyStatus(this, new IStatus[] { propsKeyStatus, propsValueStatus,
+ duplicateKeyStatus});
+ }
/*
* Set page complete
*/
@@ -677,7 +737,6 @@
severeStatus = severeStatus.getSeverity() >= status.getSeverity()
? severeStatus : status;
}
-
String message = severeStatus.getMessage();
switch (severeStatus.getSeverity()) {
case IStatus.OK:
@@ -850,6 +909,21 @@
}
/**
+ * Use existed key-value pair from the properties file
+ * without writing any data to the file.
+ *
+ * @return
+ */
+ public boolean isDuplicatedKeyValue() {
+ boolean exists = false;
+ if (isValueDuplicated(propsValue.getText())
+ && isKeyDuplicated(propsKey.getText())) {
+ exists = true;
+ }
+ return exists;
+ }
+
+ /**
* Generate properties key.
* Replaces all non-word characters with
* underline character.
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2010-10-25 13:27:36 UTC (rev 26030)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/JstUIMessages.java 2010-10-25 14:15:48 UTC (rev 26031)
@@ -143,6 +143,7 @@
public static String EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING;
public static String EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION;
public static String EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT;
+ public static String EXTERNALIZE_STRINGS_DIALOG_VALUE_EXISTS;
public static String EXTERNALIZE_STRINGS_DIALOG_PLEASE_SELECT_BUNDLE;
public static String EXTERNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY;
public static String EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET;
Modified: trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2010-10-25 13:27:36 UTC (rev 26030)
+++ trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/messages/messages.properties 2010-10-25 14:15:48 UTC (rev 26031)
@@ -122,6 +122,7 @@
EXTERNALIZE_STRINGS_DIALOG_RB_IS_MISSING=Could not initialize resource bundles!
EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTION=Wrong selection! Please select correct string.
EXTERNALIZE_STRINGS_DIALOG_WRONG_SELECTED_TEXT=Wrong selected text. Please select correct string.
+EXTERNALIZE_STRINGS_DIALOG_VALUE_EXISTS=Such a string is already externalized.\n Use stored key or specify the new one.
EXTERNALIZE_STRINGS_DIALOG_PLEASE_SELECT_BUNDLE=- Please select bundle -
EXTERNALIZE_STRINGS_DIALOG_SELECTED_TEXT_IS_EMPTY=Selected text is empty
EXTERNALIZE_STRINGS_DIALOG_KEY_MUST_BE_SET=Key must be set
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-10-25 13:27:36 UTC (rev 26030)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/wizard/ExternalizeStringsDialogTest.java 2010-10-25 14:15:48 UTC (rev 26031)
@@ -181,17 +181,77 @@
isUnusedDialogOpened = true;
/*
- * Check generated property key
+ * Check the generated property key.
+ * It should be as is.
+ * The dialog should use the stored key-pair value.
+ * OK button should be enabled.
+ * No modifications to the properties file should be made.
*/
SWTBotText defKeyText = bot.textWithLabelInGroup(
JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
assertNotNull("Cannot find 'Property Key' text field", defKeyText); //$NON-NLS-1$
- assertText("User_1",defKeyText); //$NON-NLS-1$
+ assertText("User",defKeyText); //$NON-NLS-1$
- bot.button(WidgetVariables.CANCEL_BUTTON).click();
+ bot.button(WidgetVariables.OK_BUTTON).click();
isUnusedDialogOpened = false;
+ editor.close();
+ /*
+ * Check that properties file hasn't been modified.
+ */
+ SWTBotEditor editor2 = SWTTestExt.eclipse.openFile(
+ JBT_TEST_PROJECT_NAME, "JavaSource", "demo", //$NON-NLS-1$ //$NON-NLS-2$
+ "Messages.properties"); //$NON-NLS-1$
+ editor2.toTextEditor().selectLine(3);
+ String line = editor2.toTextEditor().getSelection();
+ assertEquals("'Messages.properties' was updated incorrectly", "User=User", line); //$NON-NLS-1$ //$NON-NLS-2$
+ /*
+ * Change the property value to the new one, let say 'User1'.
+ * And externalize the same string again.
+ */
+ bot.cTabItem("Source").activate(); //$NON-NLS-1$
+ editor2.toTextEditor().typeText(3,9, "1"); //$NON-NLS-1$
+ editor2.saveAndClose();
+ editor = SWTTestExt.packageExplorer.openFile(JBT_TEST_PROJECT_NAME,
+ "WebContent", "pages", TEST_PAGE); //$NON-NLS-1$ //$NON-NLS-2$
+ editor.setFocus();
+ /*
+ * Select some text
+ */
+ editor.toTextEditor().selectRange(7, 18, 4);
+ assertEquals("Replaced text is incorrect", "User", editor.toTextEditor().getSelection()); //$NON-NLS-1$ //$NON-NLS-2$
+ /*
+ * Get toolbar button
+ */
+ assertTrue(TOOLBAR_ICON_ENABLED, bot
+ .toolbarButtonWithTooltip(TOOL_TIP)
+ .isEnabled());
+ bot.toolbarButtonWithTooltip(TOOL_TIP).click();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).setFocus();
+ bot.shell(JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_TITLE).activate();
+ isUnusedDialogOpened = true;
+ /*
+ * The value has been changed and now unique.
+ * But the same key is in the bundle.
+ * Thus the dialog should suggest "User_1" as a key value.
+ */
+ defKeyText = bot.textWithLabelInGroup(
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPERTIES_KEY,
+ JstUIMessages.EXTERNALIZE_STRINGS_DIALOG_PROPS_STRINGS_GROUP);
+ assertNotNull("Cannot find 'Property Key' text field", defKeyText); //$NON-NLS-1$
+ assertText("User_1",defKeyText); //$NON-NLS-1$
+ bot.button(WidgetVariables.OK_BUTTON).click();
+ isUnusedDialogOpened = false;
+ /*
+ * Check that the new key has been added.
+ */
+ editor2 = SWTTestExt.eclipse.openFile(
+ JBT_TEST_PROJECT_NAME, "JavaSource", "demo", //$NON-NLS-1$ //$NON-NLS-2$
+ "Messages.properties"); //$NON-NLS-1$
+ editor2.toTextEditor().selectLine(4);
+ line = editor2.toTextEditor().getSelection();
+ assertEquals("'Messages.properties' was updated incorrectly", "User_1=User", line); //$NON-NLS-1$ //$NON-NLS-2$
}
public void testExternalizeStringsDialogInXhtml() throws Throwable {
14 years, 2 months
JBoss Tools SVN: r26030 - in trunk/seam: plugins/org.jboss.tools.seam.core/templates and 4 other directories.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-10-25 09:27:36 -0400 (Mon, 25 Oct 2010)
New Revision: 26030
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/templates/testng/
trunk/seam/plugins/org.jboss.tools.seam.core/templates/testng/testng.launch
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEntitiesWizard.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12EARNewOperationTest.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12WARNewOperationTest.java
Log:
https://jira.jboss.org/browse/JBIDE-7359 Added testng launch creation to Seam wizards.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetFilterSetFactory.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -61,6 +61,7 @@
FILTERS_TEMPLATE.addFilter("listName","${component.name}List"); //$NON-NLS-1$ //$NON-NLS-2$
FILTERS_TEMPLATE.addFilter("homeName","${component.name}Home"); //$NON-NLS-1$ //$NON-NLS-2$
FILTERS_TEMPLATE.addFilter("query","${query.text}"); //$NON-NLS-1$ //$NON-NLS-2$
+ FILTERS_TEMPLATE.addFilter("seamTestProject","${seam.test.project}"); //$NON-NLS-1$ //$NON-NLS-2$
HIBERNATE_DIALECT_TEMPLATE = new FilterSet();
HIBERNATE_DIALECT_TEMPLATE.addFilter("hibernate.dialect","${hibernate.dialect}"); //$NON-NLS-1$ //$NON-NLS-2$
Added: trunk/seam/plugins/org.jboss.tools.seam.core/templates/testng/testng.launch
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/templates/testng/testng.launch (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/templates/testng/testng.launch 2010-10-25 13:27:36 UTC (rev 26030)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.testng.eclipse.launchconfig">
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.testng.remote.RemoteTestNG"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="@seamTestProject@"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dsun.lang.ClassLoader.allowArraySyntax=true"/>
+<mapAttribute key="org.testng.eclipse.ALL_CLASS_METHODS">
+<mapEntry key="@testPackage@.@interfaceName@Test" value=""/>
+</mapAttribute>
+<listAttribute key="org.testng.eclipse.CLASS_TEST_LIST">
+<listEntry value="@testPackage@.@interfaceName@Test"/>
+</listAttribute>
+<listAttribute key="org.testng.eclipse.GROUP_LIST"/>
+<listAttribute key="org.testng.eclipse.GROUP_LIST_CLASS"/>
+<stringAttribute key="org.testng.eclipse.LOG_LEVEL" value="2"/>
+<listAttribute key="org.testng.eclipse.METHOD_TEST_LIST"/>
+<listAttribute key="org.testng.eclipse.PACKAGE_TEST_LIST"/>
+<mapAttribute key="org.testng.eclipse.PARAMETERS"/>
+<intAttribute key="org.testng.eclipse.TYPE" value="1"/>
+</launchConfiguration>
\ No newline at end of file
Property changes on: trunk/seam/plugins/org.jboss.tools.seam.core/templates/testng/testng.launch
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamActionWizard.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -10,19 +10,25 @@
******************************************************************************/
package org.jboss.tools.seam.ui.wizard;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.operations.IUndoableOperation;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.internal.core.LaunchManager;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.PlatformUI;
import org.jboss.tools.common.ui.widget.editor.INamedElement;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.internal.core.project.facet.SeamFacetInstallDataModelProvider;
import org.jboss.tools.seam.ui.ISeamHelpContextIds;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
/**
@@ -137,5 +143,14 @@
protected String getSessionBeanPackageName(IEclipsePreferences seamFacetPrefs, Map<String, INamedElement> wizardParams) {
return wizardParams.get(ISeamParameter.SEAM_PACKAGE_NAME).getValue().toString();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#shouldCreateTestLaunch()
+ */
+ @Override
+ protected boolean shouldCreateTestLaunch() {
+ return true;
+ }
};
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamBaseOperation.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -34,6 +34,9 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.core.LaunchManager;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
@@ -47,6 +50,7 @@
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetFilterSetFactory;
+import org.jboss.tools.seam.internal.core.project.facet.SeamFacetInstallDataModelProvider;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.osgi.service.prefs.BackingStoreException;
@@ -56,6 +60,8 @@
*/
public abstract class SeamBaseOperation extends AbstractOperation {
+ public static final String TESTNG_LAUNCH_CONFIG_TYPE_ID = "org.testng.eclipse.launchconfig";
+
/**
* @param label
*/
@@ -98,12 +104,14 @@
IStatus result = Status.OK_STATUS;
this.info = info;
+ launchFile = null;
+
final SeamProjectsSet seamPrjSet = new SeamProjectsSet(getProject(info));
try {
Map<String, Object> vars = loadParameters(info, seamPrjSet);
- List<FileMapping> fileMapping = getFileMappings(vars);
+ List<FileMapping> fileMapping = shouldCreateTestLaunch()?getFileMappingsWithTestLaunch(vars):getFileMappings(vars);
List<String[]> fileMappingCopy = applyVariables(fileMapping,vars);
FilterSetCollection filters = getFilterSetCollection(vars);
final File[] file = new File[fileMappingCopy.size()];
@@ -116,6 +124,13 @@
if(shouldTouchServer(seamPrjSet)) {
WebUtils.changeTimeStamp(seamPrjSet.getWarProject());
}
+ if(launchFile!=null && launchFile.exists()) {
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ if(manager instanceof LaunchManager) {
+ ((LaunchManager)manager).importConfigurations(new File[]{launchFile}, monitor);
+ }
+ launchFile.delete();
+ }
} catch (BackingStoreException e) {
result = new Status(IStatus.ERROR,SeamGuiPlugin.PLUGIN_ID,e.getMessage(),e);
} catch (IOException e) {
@@ -190,6 +205,7 @@
putResourceLocationProperty(vars, ISeamParameter.TEST_CASES_PACKAGE_NAME, testFolder);
putPackageLocationProperty(vars, ISeamParameter.ENTITY_BEAN_PACKAGE_PATH, entityFolder);
putResourceLocationProperty(vars, ISeamParameter.ENTITY_BEAN_PACKAGE_NAME, entityFolder);
+
return vars;
}
@@ -290,6 +306,55 @@
*/
public abstract List<FileMapping> getFileMappings(Map<String, Object> vars);
+ protected abstract boolean shouldCreateTestLaunch();
+
+ private File launchFile = null;
+
+ private String launchTemplatePath;
+
+ protected List<FileMapping> getFileMappingsWithTestLaunch(Map<String, Object> vars) {
+ List<FileMapping> mapping = new ArrayList<FileMapping>();
+ mapping.addAll(getFileMappings(vars));
+
+ launchFile = null;
+// Uncomment following code if we shouldn't create TestNG launch in case TestNG plug-in is not installed.
+// See https://jira.jboss.org/browse/JBIDE-7359
+// ----------------->
+// ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+// if(manager.getLaunchConfigurationType(SeamBaseOperation.TESTNG_LAUNCH_CONFIG_TYPE_ID)==null) {
+// // TestNG plug-in is not install. Don't verify attributes of the launch.
+// return mapping;
+// }
+// <-----------------
+
+// String namePrefix = vars.get(ISeamParameter.SEAM_LOCAL_INTERFACE_NAME) +"Test-JDK16.launch"; //$NON-NLS-1$
+ String namePrefix = vars.get(ISeamParameter.SEAM_LOCAL_INTERFACE_NAME) +"Test, ....launch"; //$NON-NLS-1$
+ String launchName = DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(namePrefix);
+ try {
+ launchFile = new File(SeamCorePlugin.getDefault().getStateLocation().toFile(), ".testNGlaunches/" + launchName);
+ if(launchFile.exists()) {
+ launchFile.delete();
+ }
+ if(launchTemplatePath==null) {
+ launchTemplatePath = new File(SeamFacetInstallDataModelProvider.getTemplatesFolder(), "/testng/testng.launch").getAbsolutePath(); //$NON-NLS-1$
+ }
+ mapping.add(new FileMapping(
+ launchTemplatePath,
+ launchFile.getAbsolutePath(),
+ FileMapping.TYPE.EAR,
+ true));
+ mapping.add(new FileMapping(
+ launchTemplatePath,
+ launchFile.getAbsolutePath(),
+ FileMapping.TYPE.WAR,
+ true));
+ } catch (IOException e) {
+ SeamGuiPlugin.getDefault().logError(e);
+ }
+
+ return mapping;
+ }
+
/**
*
* @param vars
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamConversationWizard.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -107,6 +107,15 @@
/*
* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#shouldCreateTestLaunch()
+ */
+ @Override
+ protected boolean shouldCreateTestLaunch() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#getSessionBeanPackageName(org.eclipse.core.runtime.preferences.IEclipsePreferences, java.util.Map)
*/
@Override
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamEntityWizard.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -142,6 +142,15 @@
/*
* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#shouldCreateTestLaunch()
+ */
+ @Override
+ protected boolean shouldCreateTestLaunch() {
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#getEntityBeanPackageName(org.eclipse.core.runtime.preferences.IEclipsePreferences, java.util.Map)
*/
@Override
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamFormWizard.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -126,6 +126,15 @@
/*
* (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#shouldCreateTestLaunch()
+ */
+ @Override
+ protected boolean shouldCreateTestLaunch() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
* @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#getSessionBeanPackageName(org.eclipse.core.runtime.preferences.IEclipsePreferences, java.util.Map)
*/
@Override
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEntitiesWizard.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEntitiesWizard.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamGenerateEntitiesWizard.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -359,6 +359,15 @@
// Return empty list;
return new ArrayList<FileMapping>();
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.tools.seam.ui.wizard.SeamBaseOperation#shouldCreateTestLaunch()
+ */
+ @Override
+ protected boolean shouldCreateTestLaunch() {
+ return false;
+ }
};
static SeamRuntime getRuntime(IProject project) {
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/META-INF/MANIFEST.MF 2010-10-25 13:27:36 UTC (rev 26030)
@@ -31,7 +31,8 @@
org.jboss.tools.common.ui,
org.jboss.tools.common.el.ui,
org.jboss.tools.jsf.text.ext,
- org.eclipse.datatools.enablement.hsqldb
+ org.eclipse.datatools.enablement.hsqldb,
+ org.eclipse.debug.core
Export-Package: org.jboss.tools.seam.ui.test,
org.jboss.tools.seam.ui.test.ca,
org.jboss.tools.seam.ui.test.hyperlink,
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/AbstractSeamNewOperationTest.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -10,9 +10,17 @@
******************************************************************************/
package org.jboss.tools.seam.ui.test.wizard;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
+import java.text.StringCharacterIterator;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -32,6 +40,10 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.internal.core.LaunchManager;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
@@ -39,6 +51,8 @@
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.validation.ValidationFramework;
+import org.jboss.tools.common.EclipseUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.ui.widget.editor.IFieldEditor;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
@@ -46,12 +60,13 @@
import org.jboss.tools.seam.core.test.project.facet.AbstractSeamFacetTest;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
import org.jboss.tools.seam.ui.wizard.ISeamParameter;
-import org.jboss.tools.seam.ui.wizard.SeamWizardFactory;
-import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
import org.jboss.tools.seam.ui.wizard.SeamActionWizard.SeamActionCreateOperation;
+import org.jboss.tools.seam.ui.wizard.SeamBaseOperation;
import org.jboss.tools.seam.ui.wizard.SeamConversationWizard.SeamConversationCreateOperation;
import org.jboss.tools.seam.ui.wizard.SeamEntityWizard.SeamEntityCreateOperation;
import org.jboss.tools.seam.ui.wizard.SeamFormWizard.SeamFormCreateOperation;
+import org.jboss.tools.seam.ui.wizard.SeamWizardFactory;
+import org.jboss.tools.seam.ui.wizard.SeamWizardUtils;
import org.jboss.tools.test.util.JUnitUtils;
import org.jboss.tools.test.util.JobUtils;
import org.osgi.service.prefs.BackingStoreException;
@@ -82,16 +97,15 @@
protected AbstractSeamNewOperationTest(String name) {
super(name);
- // TODO Auto-generated constructor stub
}
-
+
+ @Override
protected void setUp() throws Exception {
suspendAllValidation = ValidationFramework.getDefault().isSuspended();
ValidationFramework.getDefault().suspendAllValidation(true);
JobUtils.waitForIdle();
}
-
@Override
protected void tearDown() throws Exception {
// TODO Auto-generated method stub
@@ -110,6 +124,74 @@
abstract void assertNewConversationFilesAreCreatedSuccessfully(AdaptableRegistry data);
abstract void assertNewEntityFilesAreCreatedSuccessfully(AdaptableRegistry data);
+ protected ILaunchConfiguration getLaunchConfiguration(File file) {
+ ILaunchConfiguration[] configs = null;
+ try {
+ configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ return null;
+ }
+ for (ILaunchConfiguration config : configs) {
+ if(config.getName().equals(file.getName().substring(0, file.getName().lastIndexOf('.')))) {
+ return config;
+ }
+ }
+ return null;
+ }
+
+ protected void assertLaunchCreated(String testProjectName, String seamLocalInterfaceName) {
+// String namePrefix = seamLocalInterfaceName +"Test-JDK16.launch"; //$NON-NLS-1$
+ String namePrefix = seamLocalInterfaceName +"Test, ....launch"; //$NON-NLS-1$
+ String launchName = DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(namePrefix);
+ File launchFile = new File(LaunchManager.LOCAL_LAUNCH_CONFIGURATION_CONTAINER_PATH.toFile(), launchName);
+ assertTrue("TestNG launch file doesn't exest.", launchFile.exists());
+
+ ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
+ if(manager.getLaunchConfigurationType(SeamBaseOperation.TESTNG_LAUNCH_CONFIG_TYPE_ID)==null) {
+ // TestNG plug-in is not install. Don't verify attributes of the launch. Just verify it doesn't have any @...@ variables.
+ FileReader fr = null;
+ try {
+ fr = new FileReader(launchFile);
+ int ch;
+// StringBuffer sb = new StringBuffer();
+ while((ch = fr.read())!=-1) {
+ assertFalse("Some template varibales were not initialized.", ch=='@');
+// sb.append((char)ch);
+ }
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ } finally {
+ if(fr!=null) {
+ try {
+ fr.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return;
+ }
+
+ ILaunchConfiguration config = getLaunchConfiguration(launchFile);
+ assertNotNull("Can't find launch configuration for " + launchFile.toString() + " file.", config);
+ try {
+ String projectName = config.getAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", "");
+ assertEquals("Test project name is not correct in " + launchFile.toString(), testProjectName, projectName);
+ List<String> classNames = config.getAttribute("org.testng.eclipse.CLASS_TEST_LIST", new ArrayList<String>());
+ assertEquals("Wrong number of test classes in " + launchFile.toString(), 1, classNames.size());
+ String className = classNames.get(0);
+ assertEquals("Wrong test calss name in " + launchFile.toString(), className, seamLocalInterfaceName + "Test");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
protected void assertResourceIsCreatedAndHasNoProblems(IResource resource, String path) {
assertNotNull("Resource isn't created: " + path, resource);
assertTrue("Resource isn't created: " + path, resource.exists());
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12EARNewOperationTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12EARNewOperationTest.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12EARNewOperationTest.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -193,6 +193,8 @@
assertResourceIsCreatedAndHasNoProblems(seamPageNameXhtml,
seamProjectWebContentFolder.toString() + "/" +
seamPageName + ".xhtml");
+
+ assertLaunchCreated(seamPrjSet.getTestProject().getName(), seamLocalInterfaceName);
}
@Override
@@ -321,4 +323,4 @@
protected String getSeamRTName() {
return AbstractSeamNewOperationTest.SEAM_1_2_0;
}
-}
+}
\ No newline at end of file
Modified: trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12WARNewOperationTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12WARNewOperationTest.java 2010-10-25 13:20:33 UTC (rev 26029)
+++ trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/Seam12WARNewOperationTest.java 2010-10-25 13:27:36 UTC (rev 26030)
@@ -8,7 +8,6 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
-
package org.jboss.tools.seam.ui.test.wizard;
import java.io.File;
@@ -37,7 +36,6 @@
private ISeamProject seamWarProject = null;
private ISeamProject seamTestProject = null;
-
public Seam12WARNewOperationTest(String name) {
super(name);
}
@@ -75,13 +73,12 @@
seamTestProject = loadSeamProject(testProject);
}
}
-
-
+
protected void tearDown() throws Exception {
WorkbenchUtils.closeAllEditors();
-
+
super.tearDown();
-
+
warProject = null;
testProject = null;
seamWarProject = null;
@@ -109,7 +106,6 @@
return AbstractSeamNewOperationTest.SEAM_1_2_0;
}
-
@Override
void assertNewActionFilesAreCreatedSuccessfully(AdaptableRegistry data) {
IEclipsePreferences seamFacetPrefs = SeamCorePlugin.getSeamPreferences(warProject);
@@ -148,7 +144,8 @@
assertResourceIsCreatedAndHasNoProblems(seamPageNameXhtml,
seamProjectWebContentFolder.toString() + "/" +
seamPageName + ".xhtml");
-
+
+ assertLaunchCreated(seamPrjSet.getTestProject().getName(), seamLocalInterfaceName);
/*
"${" + ISeamParameter.SEAM_PROJECT_SRC_ACTION + "}/
${" + ISeamFacetDataModelProperties.SESSION_BEAN_PACKAGE_PATH + "}/
@@ -265,4 +262,4 @@
void assertNewFormFilesAreCreatedSuccessfully(AdaptableRegistry data) {
assertNewActionFilesAreCreatedSuccessfully(data);
}
-}
+}
\ No newline at end of file
14 years, 2 months
JBoss Tools SVN: r26029 - in trunk/tests/plugins/org.jboss.tools.ui.bot.ext: src/org/jboss/tools/ui/bot/ext and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: jpeterka
Date: 2010-10-25 09:20:33 -0400 (Mon, 25 Oct 2010)
New Revision: 26029
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestConnection.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestContextMenu.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestGraph.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestNode.java
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTZestBot.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF
Log:
Zest support for bot added into SWTBotExt
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF 2010-10-25 11:23:54 UTC (rev 26028)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/META-INF/MANIFEST.MF 2010-10-25 13:20:33 UTC (rev 26029)
@@ -19,7 +19,10 @@
org.junit4;bundle-version="4.5.0",
org.eclipse.jdt.core;bundle-version="3.5.0",
org.eclipse.ui.editors;bundle-version="3.5.0",
- org.eclipse.core.resources;bundle-version="3.5.0"
+ org.eclipse.core.resources;bundle-version="3.5.0",
+ org.eclipse.draw2d;bundle-version="3.6.1",
+ org.eclipse.zest.core;bundle-version="1.2.0",
+ org.eclipse.zest.layouts;bundle-version="1.1.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Eclipse-RegisterBuddy: org.apache.log4j
@@ -32,6 +35,7 @@
org.jboss.tools.ui.bot.ext.parts,
org.jboss.tools.ui.bot.ext.types,
org.jboss.tools.ui.bot.ext.view,
- org.jboss.tools.ui.bot.ext.widgets
+ org.jboss.tools.ui.bot.ext.widgets,
+ org.jboss.tools.ui.bot.ext.zest
Bundle-Vendor: JBoss by Red Hat
Bundle-ClassPath: .
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestConnection.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestConnection.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestConnection.java 2010-10-25 13:20:33 UTC (rev 26029)
@@ -0,0 +1,70 @@
+package org.jboss.tools.ui.bot.ext.zest;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphConnection;
+
+/**
+ * SWTBot zest connnection bot
+ *
+ * @author jpeterka
+ *
+ */
+public class SWTBotZestConnection extends AbstractSWTBot<GraphConnection> {
+
+
+ /**
+ * Default Constructor
+ * @param connection
+ */
+ public SWTBotZestConnection(GraphConnection connection) {
+ super(connection);
+ }
+
+ /**
+ * Provides click above Zest Connection
+ */
+ @Override
+ public AbstractSWTBot<GraphConnection> click() {
+ UIThreadRunnable.syncExec(new VoidResult() {
+
+ public void run() {
+ // Get midpoint
+ Graph graph = widget.getGraphModel();
+ PointList pl = widget.getConnectionFigure().getPoints();
+ Point midpoint = pl.getMidpoint();
+
+ Event event = new Event();
+ event.type = SWT.MouseMove;
+ event.x = graph.toDisplay(midpoint.x, midpoint.y).x;
+ event.y = graph.toDisplay(midpoint.x, midpoint.y).y;
+ widget.getDisplay().post(event);
+
+ event = new Event();
+ event.type = SWT.MouseDown;
+ event.button = 1;
+ widget.getDisplay().post(event);
+
+ event = new Event();
+ event.type = SWT.MouseUp;
+ event.button = 1;
+ widget.getDisplay().post(event);
+ }
+ });
+ return this;
+ }
+
+ /**
+ * Returns context menu of connection
+ * @return
+ */
+ public SWTBotZestContextMenu contextMenu() {
+ return new SWTBotZestContextMenu(widget.getGraphModel());
+ }
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestConnection.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestContextMenu.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestContextMenu.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestContextMenu.java 2010-10-25 13:20:33 UTC (rev 26029)
@@ -0,0 +1,168 @@
+package org.jboss.tools.ui.bot.ext.zest;
+
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withMnemonic;
+import static org.hamcrest.Matchers.allOf;
+import static org.hamcrest.Matchers.instanceOf;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
+import org.hamcrest.Matcher;
+
+/**
+ * Context menu bot for Zest widgets
+ *
+ * @author jpeterka
+ *
+ */
+public class SWTBotZestContextMenu extends AbstractSWTBot<Control> {
+
+ /**
+ * Default Constructor
+ *
+ * @param control
+ */
+ SWTBotZestContextMenu(Control control) {
+ super(control);
+ }
+
+ /**
+ * Invokes context menu sequence
+ *
+ * @param texts
+ */
+ public void clickMenu(final String... texts) {
+ log.debug("Clicking graph menu: ");
+
+ // Run in UI Thread
+ final MenuItem menuItem = UIThreadRunnable
+ .syncExec(new WidgetResult<MenuItem>() {
+ public MenuItem run() {
+ // Get menu from control
+
+ Menu menu = widget.getMenu();
+
+ MenuItem lastMenuItem = null;
+ lastMenuItem = getLastMenuItem(texts, menu);
+
+ log.debug("Final menu returned");
+ // if last menu found, click and hide
+ if (lastMenuItem != null) {
+ // Click
+ clickOnMenuItem(lastMenuItem);
+ // Hide
+ hideMenu(lastMenuItem.getParent());
+ }
+ return lastMenuItem;
+ }
+ });
+ if (menuItem == null)
+ throw new WidgetNotFoundException("Unable to find menuitem");
+
+ }
+
+ /**
+ * Gets last menitem on menuitem hierary. UIThread methods
+ *
+ * @param text
+ */
+ private MenuItem getLastMenuItem(String[] texts, Menu menu) {
+
+ if (menu == null)
+ throw new WidgetNotFoundException("No context menu found");
+
+ Menu nextMenu = menu;
+ MenuItem nextMenuItem = null;
+ for (String text : texts) {
+ // Get next menu
+ nextMenuItem = null;
+
+ nextMenuItem = getNextMenuItem(text, nextMenu);
+ // Set menu as next menu item menu
+ if (nextMenuItem == null) {
+ hideMenu(nextMenu);
+ return null;
+ } else {
+ log.debug("next menu for menu item " + nextMenuItem.getText()
+ + " found");
+ nextMenu = nextMenuItem.getMenu();
+ }
+ }
+ return nextMenuItem;
+ }
+
+ /**
+ * Gets next menuitem of given text. UIThread method
+ *
+ * @param text
+ * @param menu
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private MenuItem getNextMenuItem(String text, Menu menu) {
+
+ MenuItem nextMenuItem = null;
+
+ Matcher<?> matcher = allOf(instanceOf(MenuItem.class),
+ withMnemonic(text));
+
+ showMenu(menu);
+ MenuItem[] items = menu.getItems();
+ log.debug("Menu items found:" + items.length + " items");
+ // menu item loops
+ for (MenuItem i : items) {
+ log.debug("Trying to match " + text + " with " + i.getText());
+ if (matcher.matches(i)) {
+ nextMenuItem = i;
+ log.debug("Next menu item with text:" + text + " found");
+ break;
+ }
+ }
+
+ return nextMenuItem;
+ }
+
+ /**
+ * Clicks on given menuitem. UIThread method
+ *
+ * @param menuItem
+ */
+ private void clickOnMenuItem(final MenuItem menuItem) {
+ System.out.println("Menuitem:" + menuItem);
+ final Event event = new Event();
+ event.time = (int) System.currentTimeMillis();
+ event.widget = menuItem;
+ event.display = menuItem.getDisplay();
+ event.type = SWT.Selection;
+
+ log.debug("Click event generated");
+
+ menuItem.notifyListeners(SWT.Selection, event);
+ log.debug("Event sent");
+ }
+
+ /**
+ * Hides menu including all predecessor. UIThread method
+ *
+ * @param menu
+ */
+ private static void hideMenu(final Menu menu) {
+ menu.notifyListeners(SWT.Hide, new Event());
+ if (menu.getParentMenu() != null) {
+ hideMenu(menu.getParentMenu());
+ }
+ }
+
+ /**
+ * Shows menu. UIThread method
+ */
+ private void showMenu(final Menu menu) {
+ menu.notifyListeners(SWT.Show, new Event());
+ }
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestContextMenu.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestGraph.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestGraph.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestGraph.java 2010-10-25 13:20:33 UTC (rev 26029)
@@ -0,0 +1,223 @@
+package org.jboss.tools.ui.bot.ext.zest;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.eclipse.draw2d.EventDispatcher;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.results.WidgetResult;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBotControl;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphConnection;
+import org.eclipse.zest.core.widgets.GraphNode;
+
+/**
+ * Zest Graph Model bot
+ *
+ * @author jpeterka
+ *
+ */
+public class SWTBotZestGraph extends AbstractSWTBotControl<Graph> {
+
+ Logger log = Logger.getLogger(SWTBotZestGraph.class);
+
+ protected EventDispatcher eventDispatcher;
+
+ public SWTBotZestGraph(Graph g) {
+ super(g);
+ eventDispatcher = g.getLightweightSystem().getRootFigure()
+ .internalGetEventDispatcher();
+ }
+
+ /**
+ * Performs click above Bot zest Graph
+ */
+ @Override
+ protected AbstractSWTBot<Graph> click() {
+ UIThreadRunnable.syncExec(new VoidResult() {
+
+ public void run() {
+ // Move mouse
+ Event event = new Event();
+ event.type = SWT.MouseMove;
+ event.x = widget.toDisplay(widget.getLocation().x, widget
+ .getLocation().y).x;
+ event.y = widget.toDisplay(widget.getLocation().x, widget
+ .getLocation().y).y;
+ widget.getDisplay().post(event);
+ // Mouse down
+ event = new Event();
+ event.type = SWT.MouseDown;
+ event.button = 1;
+ widget.getDisplay().post(event);
+ // Mouse Up
+ event = new Event();
+ event.type = SWT.MouseUp;
+ event.button = 1;
+ widget.getDisplay().post(event);
+ }
+ });
+ return this;
+ }
+
+ /**
+ *
+ * @param nodeText
+ * @return
+ */
+ public SWTBotZestNode node(final String nodeText) {
+
+ GraphNode node = UIThreadRunnable
+ .syncExec(new WidgetResult<GraphNode>() {
+
+ @SuppressWarnings("unchecked")
+ public GraphNode run() {
+ List<GraphNode> nodes = widget.getNodes();
+ for (GraphNode n : nodes) {
+
+ System.out.println(n.getText());
+ if (n.getText().equals(nodeText))
+ return n;
+ }
+ return null;
+ }
+ });
+ return new SWTBotZestNode(node);
+ }
+
+ /***
+ * Returns Graph connection given by index
+ *
+ * @param index
+ * @return
+ */
+ public SWTBotZestConnection connection(final int index) {
+ GraphConnection connection = UIThreadRunnable
+ .syncExec(new WidgetResult<GraphConnection>() {
+
+ @SuppressWarnings("unchecked")
+ public GraphConnection run() {
+ List<GraphConnection> connections = widget
+ .getConnections();
+ if (connections.size() > index - 1) {
+ return connections.get(index);
+ }
+ throw new WidgetNotFoundException(
+ "Connection widget not found");
+ }
+ });
+ return new SWTBotZestConnection(connection);
+ }
+
+ /**
+ * Returns SWTBotZestConnection given by two Zest Nodes
+ * @param node1
+ * @param node2
+ * @return
+ */
+ public SWTBotZestConnection connection(final SWTBotZestNode node1,
+ final SWTBotZestNode node2) {
+ GraphConnection connection = UIThreadRunnable
+ .syncExec(new WidgetResult<GraphConnection>() {
+
+ @SuppressWarnings("unchecked")
+ public GraphConnection run() {
+ List<GraphConnection> connections = widget
+ .getConnections();
+
+ for (GraphConnection c : connections) {
+ log.info("Node1" + node1.widget.getText());
+ log.info("Node2" + node2.widget.getText());
+ log.info("Source" + c.getSource().getText());
+ log.info("Destination"
+ + c.getDestination().getText());
+ if ((c.getSource().getText().equals(node1.widget
+ .getText()))
+ && (c.getDestination().getText()
+ .equals(node2.widget.getText())))
+ return c;
+ }
+
+ throw new WidgetNotFoundException(
+ "Connection widget not found");
+ }
+ });
+ return new SWTBotZestConnection(connection);
+ }
+
+ /**
+ * Debug method, logs graph related informations
+ */
+ public void debugGraph() {
+ UIThreadRunnable.syncExec(new VoidResult() {
+ @SuppressWarnings("unchecked")
+ public void run() {
+ // Graph Info
+ log
+ .info("********************************************************************************");
+
+ Graph g = widget;
+ log.info("Graph Nodes:" + g.getNodes().size());
+ log.info("Graph Connections" + g.getConnections().size());
+
+ Point leftUpper = new Point(g.getBounds().x, g.getBounds().y);
+ Point rightLower = new Point(g.getBounds().x
+ + g.getBounds().width, g.getBounds().y
+ + g.getBounds().height);
+ int gXtoDisp = widget.toDisplay(leftUpper.x, leftUpper.y).x;
+ int gYtoDisp = widget.toDisplay(leftUpper.x, leftUpper.y).y;
+
+ log.info("Graph position:[" + gXtoDisp + "," + gYtoDisp
+ + "] -> [" + rightLower.x + "," + rightLower.y + "]");
+ log
+ .info("********************************************************************************");
+
+ // List Connections
+ List<GraphConnection> connections = widget.getConnections();
+ for (int i = 0; i < connections.size(); i++) {
+ GraphConnection c = connections.get(i);
+
+ PointList pl = c.getConnectionFigure().getPoints();
+ Point midpoint = pl.getMidpoint();
+ int mXtoDisp = widget.toDisplay(midpoint.x, midpoint.y).x;
+ int mYtoDisp = widget.toDisplay(midpoint.x, midpoint.y).y;
+
+ log.info("Connection:" + i + "[" + mXtoDisp + ","
+ + mYtoDisp + "]" + ",Text:" + c.getText()
+ + ",Tooltip:" + c.getTooltip());
+
+ }
+ // List Nodes
+ List<GraphNode> nodes = widget.getNodes();
+ for (int i = 0; i < nodes.size(); i++) {
+ GraphNode n = nodes.get(i);
+ int nXtoDisp = widget.toDisplay(n.getLocation().x, n
+ .getLocation().y).x;
+ int nYtoDisp = widget.toDisplay(n.getLocation().x, n
+ .getLocation().y).y;
+
+ log.info("Node:" + i + "[" + nXtoDisp + "," + nYtoDisp
+ + "],Text:" + n.getText() + ",Tooltip:"
+ + n.getTooltip());
+ }
+ log
+ .info("********************************************************************************");
+ }
+ });
+ }
+
+ /**
+ * Returns Context menu
+ * @return
+ */
+ public SWTBotZestContextMenu contextMenu() {
+ return new SWTBotZestContextMenu(widget);
+ }
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestGraph.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestNode.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestNode.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestNode.java 2010-10-25 13:20:33 UTC (rev 26029)
@@ -0,0 +1,157 @@
+package org.jboss.tools.ui.bot.ext.zest;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
+import org.eclipse.zest.core.widgets.Graph;
+import org.eclipse.zest.core.widgets.GraphNode;
+
+/**
+ * Provides SWTBot feature for Zest Node
+ *
+ * @author jpeterka
+ *
+ */
+public class SWTBotZestNode extends AbstractSWTBot<GraphNode> {
+
+ public SWTBotZestNode(GraphNode node) {
+ super(node);
+ }
+
+ /**
+ * Calculates element position to display, call it from UI thread
+ */
+ private void getDisplayPosition(Point point) {
+
+ Graph graph = widget.getGraphModel();
+
+ int absX = graph.toDisplay(widget.getLocation().x,
+ widget.getLocation().y).x;
+ int absY = graph.toDisplay(widget.getLocation().x,
+ widget.getLocation().y).y;
+
+ log.info("Node display position:" + absX + "," + absY);
+ point.x = absX;
+ point.y = absY;
+ }
+
+ /**
+ * Provides click on Zest Node
+ */
+ @Override
+ public AbstractSWTBot<GraphNode> click() {
+ UIThreadRunnable.syncExec(new VoidResult() {
+
+ public void run() {
+
+ Point p = new Point();
+ getDisplayPosition(p);
+
+ Event event = createEvent(SWT.MouseMove, p.x, p.y);
+ widget.getDisplay().post(event);
+
+ event = createEvent(SWT.MouseDown, 1);
+ widget.getDisplay().post(event);
+
+ event = createEvent(SWT.MouseUp, 1);
+ widget.getDisplay().post(event);
+ }
+ });
+ return this;
+ }
+
+ /**
+ * Provides dragTo method for Node. Node will be moved relatively according
+ * to x,y
+ *
+ * @param x
+ * relative points how element will be moved in x axis
+ * @param y
+ * relative points how element will be moved in y axis
+ * @throws InterruptedException
+ */
+ public void dragTo(int x, int y) throws InterruptedException {
+
+ final Point point = new Point();
+
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ getDisplayPosition(point);
+ }
+ });
+
+ log.info("Drag from:" + point.x + "," + point.y);
+ log.info("Drop to:" + (point.x + x) + "," + (point.y + y));
+ mouseDrag(point.x, point.y, point.x + x, point.y + y);
+ }
+
+ /**
+ * Returns SWTBotZestContextMenu, contextMenu
+ *
+ * @return
+ */
+ public SWTBotZestContextMenu contextMenu() {
+ return new SWTBotZestContextMenu(widget.getGraphModel());
+ }
+
+ /**
+ * Provides drag and drop of node in absolute positions
+ *
+ * @param fromXPosition
+ * @param fromYPosition
+ * @param toXPosition
+ * @param toYPosition
+ * @throws InterruptedException
+ */
+ public void mouseDrag(final int fromXPosition, final int fromYPosition,
+ final int toXPosition, final int toYPosition)
+ throws InterruptedException {
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ Event event = createEvent(SWT.MouseMove, fromXPosition,
+ fromYPosition);
+ widget.getDisplay().post(event);
+ }
+ });
+ Thread.sleep(100);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ Event event = createEvent(SWT.MouseDown, 1);
+ widget.getDisplay().post(event);
+ }
+ });
+ Thread.sleep(100);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ Event event = createEvent(SWT.MouseMove, toXPosition,
+ toYPosition);
+ widget.getDisplay().post(event);
+ }
+ });
+ Thread.sleep(100);
+ UIThreadRunnable.syncExec(new VoidResult() {
+ public void run() {
+ Event event = createEvent(SWT.MouseUp, 1);
+ widget.getDisplay().post(event);
+ }
+ });
+ }
+
+ private Event createEvent(int type, int x, int y) {
+ Event event = new Event();
+ event.type = type;
+ event.x = x;
+ event.y = y;
+ return event;
+ }
+
+ private Event createEvent(int type, int button) {
+ Event event = new Event();
+ event.type = type;
+ event.button = button;
+ return event;
+ }
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTBotZestNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTZestBot.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTZestBot.java (rev 0)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTZestBot.java 2010-10-25 13:20:33 UTC (rev 26029)
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Obeo
+ * All rights reserved. This program and the accompanying materials
+ * are 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
+ *
+ * Contributors:
+ * Mariot Chauvin <mariot.chauvin(a)obeo.fr> - initial API and implementation
+ *******************************************************************************/
+
+package org.jboss.tools.ui.bot.ext.zest;
+
+import java.util.List;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
+import org.eclipse.zest.core.widgets.Graph;
+
+/**
+ * SWTBot extension for Zest Graph support. May be deprecated,removed when
+ * Zest support is officially added into official SWTBot
+ * @author jpeterka
+ *
+ */
+public class SWTZestBot extends SWTWorkbenchBot {
+
+
+ /**
+ * Create SWTBotZestGraph
+ * @param index index of zest graph. Usually zero.
+ * @return the SWTbot zest graph instance
+ */
+ public SWTBotZestGraph getZestGraph(int index) {
+ List<? extends Graph> graphs = getFinder().findControls(WidgetMatcherFactory.widgetOfType(Graph.class));
+ SWTBotZestGraph graph = new SWTBotZestGraph(graphs.get(0));
+ return graph;
+ }
+
+}
Property changes on: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/zest/SWTZestBot.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
14 years, 2 months
JBoss Tools SVN: r26028 - trunk/documentation/qa/docs/Test_Cases.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-10-25 07:23:54 -0400 (Mon, 25 Oct 2010)
New Revision: 26028
Modified:
trunk/documentation/qa/docs/Test_Cases/VPEtests.doc
Log:
Added new SWTBot tests.
Modified: trunk/documentation/qa/docs/Test_Cases/VPEtests.doc
===================================================================
(Binary files differ)
14 years, 2 months
JBoss Tools SVN: r26027 - in trunk: vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test and 2 other directories.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-10-25 07:17:27 -0400 (Mon, 25 Oct 2010)
New Revision: 26027
Added:
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java
Modified:
trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java
trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
Log:
Added InsertActionsTest.
Modified: trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java
===================================================================
--- trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java 2010-10-25 11:14:55 UTC (rev 26026)
+++ trunk/jst/tests/org.jboss.tools.jst.ui.bot.test/src/org/jboss/tools/ui/bot/test/JBTSWTBotTestCase.java 2010-10-25 11:17:27 UTC (rev 26027)
@@ -13,7 +13,10 @@
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
public abstract class JBTSWTBotTestCase extends SWTTestExt implements
ILogListener {
@@ -361,5 +364,16 @@
}
return process;
}
-
+ /**
+ * Asserts if Problems View has no errors
+ * @param botExt
+ */
+ protected static void assertProbelmsViewNoErrors (SWTBotExt botExt){
+
+ SWTBotTreeItem[] errors = ProblemsView.getFilteredErrorsTreeItems(botExt, null, null, null, null);
+
+ assertTrue("There are errors in Problems view: " +
+ (errors != null && errors.length > 0 ? errors[0].getText() : ""),
+ errors == null);
+ }
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-10-25 11:14:55 UTC (rev 26026)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAllBotTests.java 2010-10-25 11:17:27 UTC (rev 26027)
@@ -5,6 +5,7 @@
import junit.framework.TestSuite;
import org.eclipse.swtbot.swt.finder.SWTBotTestCase;
import org.jboss.tools.vpe.ui.bot.test.editor.BlockCommentTest;
+import org.jboss.tools.vpe.ui.bot.test.editor.InsertActionsTest;
import org.jboss.tools.vpe.ui.bot.test.editor.ToggleCommentTest;
import org.jboss.tools.vpe.ui.bot.test.editor.VerificationOfNameSpacesTest;
import org.jboss.tools.vpe.ui.bot.test.editor.JspFileEditingTest;
@@ -66,6 +67,7 @@
suite.addTestSuite(PaletteEditorTest.class);
suite.addTestSuite(ToolbarTextFormattingTest.class);
suite.addTestSuite(VisualEditorContextMenuTest.class);
+ suite.addTestSuite(InsertActionsTest.class);
return new TestSetup(suite);
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2010-10-25 11:14:55 UTC (rev 26026)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/VPEAutoTestCase.java 2010-10-25 11:17:27 UTC (rev 26027)
@@ -13,6 +13,7 @@
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.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.jst.jsp.jspeditor.JSPMultiPageEditor;
import org.jboss.tools.test.TestProperties;
import org.jboss.tools.vpe.ui.bot.test.Activator;
@@ -414,24 +415,35 @@
protected abstract boolean isUnuseDialogOpened();
- protected void openPage(){
+ protected void openPage(String pageName){
SWTBot innerBot = bot.viewByTitle(WidgetVariables.PACKAGE_EXPLORER).bot();
SWTBotTree tree = innerBot.tree();
tree.expandNode(JBT_TEST_PROJECT_NAME)
- .expandNode("WebContent").expandNode("pages").getNode(TEST_PAGE).doubleClick(); //$NON-NLS-1$ //$NON-NLS-2$
+ .expandNode("WebContent").expandNode("pages").getNode(pageName).doubleClick(); //$NON-NLS-1$ //$NON-NLS-2$
+ bot.sleep(Timing.time3S());
}
+
+ protected void openPage(){
+ openPage(TEST_PAGE);
+ }
/**
* Creates new empty JSP page within test project
* @param pageName
*/
protected void createJspPage (String pageName){
- packageExplorer.selectTreeItem("pages", new String[] {VPEAutoTestCase.JBT_TEST_PROJECT_NAME,"WebContent"});
- open.newObject(ActionItem.NewObject.WebJSP.LABEL);
- bot.shell(IDELabel.Shell.NEW_JSP_FILE).activate();
- bot.textWithLabel(ActionItem.NewObject.WebJSP.TEXT_FILE_NAME).setText(pageName);
- bot.button(IDELabel.Button.NEXT).click();
- bot.table().select(IDELabel.NewJSPFileDialog.JSP_TEMPLATE);
- bot.button(IDELabel.Button.FINISH).click();
- bot.sleep(Timing.time2S());
+ SWTBotTreeItem tiPages = packageExplorer.selectTreeItem("pages", new String[] {VPEAutoTestCase.JBT_TEST_PROJECT_NAME,"WebContent"});
+ tiPages.expand();
+ try {
+ tiPages.getNode(pageName);
+ openPage(pageName);
+ } catch (WidgetNotFoundException e) {
+ open.newObject(ActionItem.NewObject.WebJSP.LABEL);
+ bot.shell(IDELabel.Shell.NEW_JSP_FILE).activate();
+ bot.textWithLabel(ActionItem.NewObject.WebJSP.TEXT_FILE_NAME).setText(pageName);
+ bot.button(IDELabel.Button.NEXT).click();
+ bot.table().select(IDELabel.NewJSPFileDialog.JSP_TEMPLATE);
+ bot.button(IDELabel.Button.FINISH).click();
+ bot.sleep(Timing.time2S());
+ }
}
}
Added: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java (rev 0)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java 2010-10-25 11:17:27 UTC (rev 26027)
@@ -0,0 +1,202 @@
+/*******************************************************************************
+
+ * Copyright (c) 2007-2010 Exadel, Inc. and 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
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.vpe.ui.bot.test.editor;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.vpe.ui.bot.test.tools.SWTBotWebBrowser;
+import org.mozilla.interfaces.nsIDOMNode;
+/**
+ * Tests JSP file Insert Actions
+ * @author vlado pakan
+ *
+ */
+public class InsertActionsTest extends VPEEditorTestCase {
+
+ private SWTBotExt botExt = null;
+
+ private static final String PAGE_TEXT = "<%@ taglib uri=\"http://java.sun.com/jsf/html\" prefix=\"h\" %>\n" +
+ "<html>\n" +
+ " <body>\n" +
+ " plain text inserted\n" +
+ " <h:outputText value=\"Studio\" />\n" +
+ " <h:inputText/>\n" +
+ " </body>\n" +
+ "</html>";
+
+ private static final String TEST_PAGE_NAME = "InsertActionsTest.jsp";
+
+ private SWTBotEclipseEditor jspTextEditor;
+ private SWTBotWebBrowser webBrowser;
+
+ public InsertActionsTest() {
+ super();
+ botExt = new SWTBotExt();
+ }
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ eclipse.maximizeActiveShell();
+ createJspPage(InsertActionsTest.TEST_PAGE_NAME);
+ jspTextEditor = botExt.editorByTitle(InsertActionsTest.TEST_PAGE_NAME).toTextEditor();
+ webBrowser = new SWTBotWebBrowser(InsertActionsTest.TEST_PAGE_NAME,botExt);
+
+ }
+ /**
+ * Insert Tag After Selected Tag
+ */
+ public void testInsertTagAfter(){
+
+ nsIDOMNode node = initJspPageBeforeInserting(InsertActionsTest.PAGE_TEXT, "INPUT");
+
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.INSERT_AFTER_MENU_LABEL,
+ SWTBotWebBrowser.JBOSS_MENU_LABEL, SWTBotWebBrowser.RICH_FACES_MENU_LABEL,
+ SWTBotWebBrowser.RICH_CALENDAR_TAG_MENU_LABEL);
+
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ String editorText = jspTextEditor.getText();
+ // Check if tag <rich:calendar> was properly added
+ assertTrue("File " + TEST_PAGE
+ + " has to contain string '<h:inputText/><rich:calendar>' but it doesn't.\nIt contains: " + editorText,
+ editorText.contains("<h:inputText/><rich:calendar>"));
+
+ assertTrue("Visual Representation of file " + TEST_PAGE
+ + " has to contain rich:calendar but it doesn't",
+ webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(), "SPAN",
+ new String[]{"title"},new String[] {"rich:calendar"}));
+
+ assertProbelmsViewNoErrors(botExt);
+
+ }
+ /**
+ * Insert Tag Before Selected Tag
+ */
+ public void testInsertTagBefore(){
+
+ nsIDOMNode node = initJspPageBeforeInserting(InsertActionsTest.PAGE_TEXT,"INPUT");
+
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.INSERT_BEFORE_MENU_LABEL,
+ SWTBotWebBrowser.JBOSS_MENU_LABEL, SWTBotWebBrowser.RICH_FACES_MENU_LABEL,
+ SWTBotWebBrowser.RICH_CALENDAR_TAG_MENU_LABEL);
+
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ String trimedEditorText = VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText());
+ // Check if tag <rich:calendar> was properly added
+ assertTrue("File " + TEST_PAGE
+ + " has to contain string '<rich:calendar></rich:calendar><h:inputText/>' but it doesn't.\nIt contains: " + trimedEditorText,
+ trimedEditorText.contains("<rich:calendar></rich:calendar><h:inputText/>"));
+
+ assertTrue("Visual Representation of file " + TEST_PAGE
+ + " has to contain rich:calendar but it doesn't",
+ webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(), "SPAN",
+ new String[]{"title"},new String[] {"rich:calendar"}));
+
+ assertProbelmsViewNoErrors(botExt);
+
+ }
+
+ /**
+ * Insert Tag Into Selected Tag
+ */
+ public void testInsertTagInto(){
+
+ nsIDOMNode node = initJspPageBeforeInserting("<%@ taglib uri=\"http://java.sun.com/jsf/html\" prefix=\"h\" %>\n" +
+ "<html>\n" +
+ " <body>\n" +
+ " plain text inserted\n" +
+ " <form>\n" +
+ " </form>\n" +
+ " </body>\n" +
+ "</html>",
+ "FORM");
+
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.INSERT_INTO_MENU_LABEL,
+ SWTBotWebBrowser.JBOSS_MENU_LABEL, SWTBotWebBrowser.RICH_FACES_MENU_LABEL,
+ SWTBotWebBrowser.RICH_CALENDAR_TAG_MENU_LABEL);
+
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ String trimedEditorText = VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText());
+ // Check if tag <rich:calendar> was properly added
+ assertTrue("File " + TEST_PAGE
+ + " has to contain string '<form><rich:calendar></rich:calendar></form>' but it doesn't.\nIt contains: " + trimedEditorText,
+ trimedEditorText.contains("<form><rich:calendar></rich:calendar></form>"));
+
+ assertTrue("Visual Representation of file " + TEST_PAGE
+ + " has to contain rich:calendar but it doesn't",
+ webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(), "FORM"));
+
+ assertProbelmsViewNoErrors(botExt);
+
+ }
+
+ /**
+ * Insert Tag Around Selected Tag
+ */
+ public void testInsertTagAround(){
+
+ nsIDOMNode node = initJspPageBeforeInserting(InsertActionsTest.PAGE_TEXT, "INPUT");
+
+ webBrowser.clickContextMenu(node,
+ SWTBotWebBrowser.INSERT_AROUND_MENU_LABEL,
+ SWTBotWebBrowser.JSF_MENU_LABEL, SWTBotWebBrowser.HTML_MENU_LABEL,
+ SWTBotWebBrowser.H_FORM_TAG_MENU_LABEL);
+
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ String trimedEditorText = VPEEditorTestCase.stripHTMLSourceText(jspTextEditor.getText());
+ // Check if tag <h:form> was properly added
+ assertTrue("File " + TEST_PAGE
+ + " has to contain string '<h:form><h:inputText/></h:form>' but it doesn't.\nIt contains: " + trimedEditorText,
+ trimedEditorText.contains("<h:form><h:inputText/></h:form>"));
+
+ assertTrue("Visual Representation of file " + TEST_PAGE
+ + " has to contain h:form but it doesn't",
+ webBrowser.containsNodeWithNameAndAttributes(webBrowser.getMozillaEditor().getDomDocument(), "FORM"));
+
+ assertProbelmsViewNoErrors(botExt);
+
+ }
+
+ /**
+ * Inits JSP Page before Tag will be inserted
+ */
+ private nsIDOMNode initJspPageBeforeInserting(String pageText , String nodeText) {
+
+ jspTextEditor.setText(pageText);
+ jspTextEditor.save();
+ botExt.sleep(Timing.time3S());
+ nsIDOMNode node = webBrowser.getDomNodeByTagName(nodeText, 0);
+ webBrowser.selectDomNode(node, 0);
+ botExt.sleep(Timing.time1S());
+
+ return node;
+
+ }
+
+ @Override
+ protected void closeUnuseDialogs() {
+
+ }
+
+ @Override
+ protected boolean isUnuseDialogOpened() {
+ return false;
+ }
+
+}
Property changes on: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/InsertActionsTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2010-10-25 11:14:55 UTC (rev 26026)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/editor/VPEEditorTestCase.java 2010-10-25 11:17:27 UTC (rev 26027)
@@ -79,5 +79,13 @@
}
super.tearDown();
}
+
+ /**
+ * Returns HTML Source striped from spaces, tabs and EOL
+ * @return String
+ */
+ protected static String stripHTMLSourceText(String editorText){
+ return editorText.replaceAll("\n", "").replaceAll("\t", "").replaceAll(" ", "");
+ }
}
Modified: trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java
===================================================================
--- trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-10-25 11:14:55 UTC (rev 26026)
+++ trunk/vpe/tests/org.jboss.tools.vpe.ui.bot.test/src/org/jboss/tools/vpe/ui/bot/test/tools/SWTBotWebBrowser.java 2010-10-25 11:17:27 UTC (rev 26027)
@@ -87,8 +87,12 @@
public static final String PASTE_MENU_LABEL = "Paste";
public static final String JSF_MENU_LABEL = "JSF";
+ public static final String JBOSS_MENU_LABEL = "JBoss";
+ public static final String RICH_FACES_MENU_LABEL = "RichFaces";
public static final String HTML_MENU_LABEL = "HTML";
public static final String H_OUTPUT_TEXT_TAG_MENU_LABEL = "<h:outputText>";
+ public static final String H_FORM_TAG_MENU_LABEL = "<h:form>";
+ public static final String RICH_CALENDAR_TAG_MENU_LABEL = "<rich:calendar>";
private Display display;
private IVisualEditor visualEditor;
@@ -368,13 +372,82 @@
}
/**
+ * Returns true if node or it's child has node with specified name and attributes with specified values
+ * @param node
+ * @param searchName
+ * @param attributeNames
+ * @param attributeValues
+ * @return
+ */
+ public boolean containsNodeWithNameAndAttributes(nsIDOMNode node, String searchName , String[] attributeNames , String[] attributeValues) {
+
+ boolean result = false;
+
+ String nodeName = node.getNodeName();
+ if (nodeName != null && nodeName.equals(searchName)) {
+ // Test Attributes
+ if (attributeNames != null){
+ boolean attributesAreEqual = true;
+ nsIDOMNamedNodeMap attributesMap = node.getAttributes();
+ for (int index = 0 ; index < attributeNames.length && attributesAreEqual; index++){
+ nsIDOMNode attributeNode = attributesMap.getNamedItem(attributeNames[index]);
+ if (attributeNode != null){
+ if (!attributeNode.getNodeValue().equalsIgnoreCase(attributeValues[index])){
+ attributesAreEqual = false;
+ }
+ }
+ else{
+ attributesAreEqual = false;
+ }
+ }
+ if (attributesAreEqual){
+ result = true;
+ }
+ }
+ else{
+ result = true;
+ }
+ }
+
+ if (!result) {
+ nsIDOMNodeList children = node.getChildNodes();
+
+ for (int i = 0; i < children.getLength() && !result; i++) {
+
+ nsIDOMNode child = children.item(i);
+
+ // leave out empty text nodes in test dom model
+ if ((child.getNodeType() == Node.TEXT_NODE)
+ && ((child.getNodeValue() == null) || (child.getNodeValue().trim()
+ .length() == 0)))
+ continue;
+
+ result = containsNodeWithNameAndAttributes(child, searchName,attributeNames,attributeValues);
+ }
+ }
+
+ return result;
+
+ }
+ /**
+ * Returns true if node or it's child has node with specified name
+ * @param node
+ * @param searchName
+ * @return
+ */
+ public boolean containsNodeWithNameAndAttributes(nsIDOMNode node, String searchName) {
+
+ return containsNodeWithNameAndAttributes(node, searchName,null,null);
+
+ }
+
+ /**
* Returns true if node or it's child has value searchText
* @param node
* @param searchText
* @return
*/
public boolean containsNodeWithValue(nsIDOMNode node, String searchText) {
-
boolean result = false;
String nodeValue = node.getNodeValue();
@@ -400,7 +473,6 @@
}
return result;
-
}
/**
* Returns Palette Viewer associated to JBoss Tools Palette
14 years, 2 months
JBoss Tools SVN: r26026 - trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-10-25 07:14:55 -0400 (Mon, 25 Oct 2010)
New Revision: 26026
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ProblemsView.java
Log:
Remove unused imports.
Modified: trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ProblemsView.java
===================================================================
--- trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ProblemsView.java 2010-10-25 11:13:22 UTC (rev 26025)
+++ trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/view/ProblemsView.java 2010-10-25 11:14:55 UTC (rev 26026)
@@ -10,9 +10,7 @@
******************************************************************************/
package org.jboss.tools.ui.bot.ext.view;
-import java.util.ArrayList;
import java.util.LinkedList;
-import java.util.List;
import org.apache.log4j.Logger;
import org.eclipse.swtbot.swt.finder.SWTBot;
@@ -23,7 +21,6 @@
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt.StringConditionType;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
-import org.jboss.tools.ui.bot.ext.gen.IView;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
import org.jboss.tools.ui.bot.ext.types.ViewType;
/**
14 years, 2 months
JBoss Tools SVN: r26025 - trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke.
by jbosstools-commits@lists.jboss.org
Author: vpakan(a)redhat.com
Date: 2010-10-25 07:13:22 -0400 (Mon, 25 Oct 2010)
New Revision: 26025
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java
Log:
Fix test method name.
Modified: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java 2010-10-25 10:10:32 UTC (rev 26024)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DomainSpecificLanguageEditorTest.java 2010-10-25 11:13:22 UTC (rev 26025)
@@ -38,7 +38,7 @@
*/
private static final String LANGUAGE_EXRESSION = "Message {msg} of type {t} contains {what}";
@Test
- public void testGuidedDroolsRulesEditorTest() {
+ public void testDomainSpecificLanguageEditor() {
createDslFile(DroolsAllBotTests.DOMAIN_SPECIFIC_LANGUAGE_FILE_NAME);
addDslExpression(DroolsAllBotTests.DOMAIN_SPECIFIC_LANGUAGE_FILE_NAME);
useDslExpression(DroolsAllBotTests.DOMAIN_SPECIFIC_LANGUAGE_FILE_NAME,
14 years, 2 months
JBoss Tools SVN: r26024 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2010-10-25 06:10:32 -0400 (Mon, 25 Oct 2010)
New Revision: 26024
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java
Log:
JBIDE-7395
https://jira.jboss.org/browse/JBIDE-7395
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java 2010-10-25 10:03:11 UTC (rev 26023)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java 2010-10-25 10:10:32 UTC (rev 26024)
@@ -142,6 +142,9 @@
public void setObject(XModelObject object) {
helper.setModelObject(object);
+ if(xtable != null && xtable.getTable() != null && xtable.getSelectionIndex() < 0 && xtable.getTable().getItemCount() > 0) {
+ xtable.getTable().select(0);
+ }
}
protected boolean areUpDounActionsEnabled() {
@@ -347,6 +350,7 @@
for (int i = 0; i < helper.size(); i++) {
if(helper.getModelObject(i) == object) {
xtable.setSelection(i);
+ updateBar();
return;
}
}
14 years, 2 months
JBoss Tools SVN: r26023 - trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-10-25 06:03:11 -0400 (Mon, 25 Oct 2010)
New Revision: 26023
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java
Log:
[JBIDE-7402] cleanup: extracted getPassword() method
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java 2010-10-25 10:02:48 UTC (rev 26022)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.ui/src/org/jboss/tools/internal/deltacloud/ui/wizards/EditCloudConnection.java 2010-10-25 10:03:11 UTC (rev 26023)
@@ -27,18 +27,26 @@
private static final String MAINPAGE_NAME = "EditCloudConnection.name"; //$NON-NLS-1$
private CloudConnectionPage mainPage;
private DeltaCloud cloud;
-
+
public EditCloudConnection(DeltaCloud cloud) {
super();
this.cloud = cloud;
}
-
+
@Override
public void init(IWorkbench workbench, IStructuredSelection selection) {
}
@Override
public void addPages() {
+ String password = getPassword();
+ mainPage = new CloudConnectionPage(WizardMessages.getString(MAINPAGE_NAME),
+ cloud.getName(), cloud.getURL(), cloud.getUsername(), password,
+ cloud.getType(), this);
+ addPage(mainPage);
+ }
+
+ private String getPassword() {
String password = "";
String key = DeltaCloud.getPreferencesKey(cloud.getURL(), cloud.getUsername());
ISecurePreferences root = SecurePreferencesFactory.getDefault();
@@ -48,10 +56,7 @@
} catch (Exception e) {
Activator.log(e);
}
- mainPage = new CloudConnectionPage(WizardMessages.getString(MAINPAGE_NAME),
- cloud.getName(), cloud.getURL(), cloud.getUsername(), password,
- cloud.getType(), this);
- addPage(mainPage);
+ return password;
}
@Override
@@ -72,7 +77,7 @@
return false;
}
}
-
+
@Override
public boolean performFinish() {
String name = mainPage.getModel().getName();
14 years, 2 months