Author: DartPeng
Date: 2010-01-20 04:30:35 -0500 (Wed, 20 Jan 2010)
New Revision: 19822
Modified:
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/editor/X2XTest.java
Log:
Modified:
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/editor/X2XTest.java
===================================================================
---
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/editor/X2XTest.java 2010-01-20
07:10:16 UTC (rev 19821)
+++
workspace/dart/org.jboss.tools.smooks.ui.bot.test/src/org/jboss/tools/smooks/ui/bot/test/editor/X2XTest.java 2010-01-20
09:30:35 UTC (rev 19822)
@@ -53,8 +53,8 @@
public class X2XTest extends AbstractSmooksUIBotTest {
private String fileName = "edi-to-java.xml";
-
- public void testNewCSV2JavaFile(){
+
+ public void testNewCSV2JavaFile() {
fileName = "csv-to-java.xml";
SWTGefBot gefBot = new SWTGefBot();
this.newSmooksConfigFile(getTestProjectName(), fileName);
@@ -63,15 +63,18 @@
bot.menu(IDEWorkbenchMessages.Workbench_window).menu("Maximize Active View or
Editor").click();
final SWTBot innerBot = editor.bot();
this.selectInputNode(innerBot);
-
+
innerBot.comboBoxWithLabel("Input Type:").setSelection("CSV");
-// innerBot.button("Browse").click();
-// workspaceFileSelectionWithSmooksFileSelectionWizardPage(bot, "File
Selection", new String[] {
-// getTestProjectName(), "src", "ediresources" },
"edi-to-xml-order-mapping.xml");
-// innerBot.button("Add").click();
-// workspaceFileSelectionWithSmooksFileSelectionWizardPage(bot, "EDI File
Selection", new String[] {
-// getTestProjectName(), "src", "ediresources" },
"input-message.edi");
+ // innerBot.button("Browse").click();
+ // workspaceFileSelectionWithSmooksFileSelectionWizardPage(bot,
+ // "File Selection", new String[] {
+ // getTestProjectName(), "src", "ediresources" },
+ // "edi-to-xml-order-mapping.xml");
+ // innerBot.button("Add").click();
+ // workspaceFileSelectionWithSmooksFileSelectionWizardPage(bot,
+ // "EDI File Selection", new String[] {
+ // getTestProjectName(), "src", "ediresources" },
"input-message.edi");
}
@@ -86,58 +89,56 @@
final SWTBot innerBot = editor.bot();
+ // Select at the Input Task node
this.selectInputNode(innerBot);
+ // configurate the EDI reader in the configuration panel
innerBot.comboBoxWithLabel("Input Type:").setSelection("EDI");
-
innerBot.button("Browse").click();
+ // Open File Selection Dialog to set file path
workspaceFileSelectionWithSmooksFileSelectionWizardPage(bot, "File
Selection", new String[] {
getTestProjectName(), "src", "ediresources" },
"edi-to-xml-order-mapping.xml");
-
innerBot.button("Add").click();
workspaceFileSelectionWithSmooksFileSelectionWizardPage(bot, "EDI File
Selection", new String[] {
getTestProjectName(), "src", "ediresources" },
"input-message.edi");
+ // Validate the edi-to-xml
SWTBotTree inputModelViewer = innerBot.tree();
assertTrue(inputModelViewer.getAllItems().length > 0);
assertNotNull(inputModelViewer.getTreeItem("Order"));
- // SWTBotGefFigureCanvas tt1 = new
- // SWTBotGefFigureCanvas(getGraph(innerBot));
- // tt1.contextMenu("Add Task").menu("Java Mapping").click();
+ // add task node via pop menu
selectNode(innerBot, TaskTypeManager.TASK_ID_INPUT, 3);
- final SWTBotMenu menu1 = findProcessMapViewerContext(getGraph(innerBot), "Add
Task");
- bot.getDisplay().syncExec(new Runnable() {
+ SWTBotMenu addJavaMappingMenu = findProcessMapViewerContext(getGraph(innerBot),
"Java Mapping");
+ addJavaMappingMenu.click();
- public void run() {
- SWTBotMenu m = menu1.menu("Java Mapping");// .menu("Java
Mapping");
- m.click();
- }
- });
+ // select at the java mapping task
selectNode(innerBot, TaskTypeManager.TASK_ID_JAVA_MAPPING, 1);
SWTBotGefEditor editor1 = gefBot.gefEditor(fileName);
+ // add java class model via pop menu , at first , we need to active the root edit part
editor1.rootEditPart().click();
-
- // add java class model
editor1.clickContextMenu("Java Class ");
+ // open java bean creation dialog
bot.shell("New Java Class Model").activate();
-
bot.textWithLabel("Bean ID :").setText("order1");
bot.textWithLabel("Java Class
:").setText("edi2java.example.model.Order");
+ // expand all tree node to add the java bean model
expandTreeNode(bot.tree().getAllItems());
-
+
bot.button("Finish").click();
// change bean id
editor1.clickContextMenu("Properties");
editor1.rootEditPart().click();
- // mapping
+ /** start to mapping **/
+
+ //move the input figure location to the top-left
editor1.mouseDrag("EDI Input Model", 0, 0);
SWTBotGefEditPart editPart = editor1.getEditPart("Order");
@@ -154,30 +155,32 @@
SWTBotGefEditPart order_id = editor1.getEditPart("order-id");
SWTBotGefEditPart orderId = editor1.getEditPart("orderId");
dragLink(editor1, order_id, orderId, false, false);
+
SWTBotGefEditPart status_code = editor1.getEditPart("status-code");
SWTBotGefEditPart orderStatus = editor1.getEditPart("orderStatus");
dragLink(editor1, status_code, orderStatus, false, false);
+
SWTBotGefEditPart net_amount = editor1.getEditPart("net-amount");
SWTBotGefEditPart netAmount = editor1.getEditPart("netAmount");
dragLink(editor1, net_amount, netAmount, false, false);
+
SWTBotGefEditPart total_amount = editor1.getEditPart("total-amount");
SWTBotGefEditPart totalAmount = editor1.getEditPart("totalAmount");
dragLink(editor1, total_amount, totalAmount, false, false);
+
SWTBotGefEditPart tax1 = editor1.getEditPart("tax1");
SWTBotGefEditPart tax = editor1.getEditPart("tax");
dragLink(editor1, tax1, tax, false, false);
+
SWTBotGefEditPart date1 = editor1.getEditPart("date1");
SWTBotGefEditPart date = editor1.getEditPart("date");
- date.select();
-// state.click();
-// editor1.mouseMoveLeftClick("state");
- editor1.clickContextMenu("Delete");
-// dragLink(editor1, date1, date, false, false);
+ dragLink(editor1, date1, date, false, false);
editor1.clickContextMenu("Auto Layout");
final FigureCanvas canvas = getFigureCanvas(gefBot);
+ // sometimes the editor's size isn't big enough , we need to scroll it
UIThreadRunnable.syncExec(new VoidResult() {
/*
@@ -241,15 +244,17 @@
SWTBotGefEditPart price = editor1.getEditPart("price");
dragLink(editor1, price1, price, false, false);
+ // show property view
editor1.clickContextMenu("Properties");
editor1.rootEditPart().click();
+ // active customer,then property view will change
customer.click();
editor1.clickContextMenu("Properties");
final SWTBot viewBot = bot.viewByTitle("Properties").bot();
- final String tabText = "Decode Parameter";
+ final String tabText = "Decode";
viewBot.textWithLabel("Name :").setText("Order");
-
+
UIThreadRunnable.syncExec(new VoidResult() {
/*
@@ -262,39 +267,39 @@
}
});
-// selectTabbedPropertyView(viewBot , tabText);
-// viewBot.button("New Parameter").click();
-// viewBot.table().click(0, 0);
-// viewBot.text().setText("format");
-// viewBot.table().click(0, 1);
-// viewBot.text().setText("EEE MMM dd HH:mm:ss z yyyy");
-// viewBot.table().click(0, 0);
- // viewBot.label("");
- // viewBot.cTabItem(1).activate();
- //
- // bot.sleep(6000);
-
- // run smooks config file
-// bot.activeEditor();
-// bot.menu(IDEWorkbenchMessages.Workbench_window).menu("Maximize Active View or
Editor").click();
+ date.click();
+ editor1.clickContextMenu("Properties");
+ // change to the decode tab
+ selectTabbedPropertyView(viewBot, tabText);
+ viewBot.ccomboBox().setSelection("Date");
+ viewBot.table().click(0, 1);
+ viewBot.text().setText("EEE MMM dd HH:mm:ss z yyyy");
+ viewBot.table().click(1, 1);
+ viewBot.text().setText("en");
+ viewBot.table().click(2, 1);
+ viewBot.text().setText("IE");
editor.saveAndClose();
+
+ // select the smooks config file
SWTBot viewbot = bot.viewByTitle("Package Explorer").bot();
final SWTBotTreeItem item =
viewbot.tree().expandNode(getTestProjectName()).getNode(fileName);
item.select();
+ // open run config dialog via menubar
bot.menu("Run").menu("Run Configurations...").click();
bot.activeShell().activate();
bot.tree().getTreeItem("Smooks Configuration").doubleClick();
bot.textWithLabel("Project:").setText(getTestProjectName());
bot.textWithLabel("Configuration:").setText(fileName);
bot.button("Run").click();
-
+
+ // get the result text from Console viewer
SWTBot consoleBot = bot.viewByTitle("Console").bot();
String text = consoleBot.styledText().getText();
System.out.println(text);
+
+ // TODO validate the result
}
-
-
private SWTBotGefEditPart getTopLevelEditPart(SWTBotGefEditor editor, String label) {
SWTBotGefEditPart part = editor.getEditPart(label);
if (part.part() instanceof TreeContainerEditPart) {