Author: vpakan(a)redhat.com
Date: 2010-05-03 03:42:31 -0400 (Mon, 03 May 2010)
New Revision: 21849
Added:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DecisionTableTest.java
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
Log:
Added DecisionTableTest and RuleFlowTest to SWTBot Drools Test Suite.
Modified: trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF 2010-05-01
15:16:44 UTC (rev 21848)
+++ trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/META-INF/MANIFEST.MF 2010-05-03
07:42:31 UTC (rev 21849)
@@ -12,7 +12,8 @@
org.eclipse.swtbot.swt.finder;bundle-version="2.0.0",
org.junit4;bundle-version="4.5.0",
org.jboss.tools.ui.bot.ext;bundle-version="1.0.0",
- org.drools.eclipse;bundle-version="5.1.0"
+ org.drools.eclipse;bundle-version="5.1.0",
+ org.eclipse.swtbot.eclipse.gef.finder;bundle-version="0.1.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: JBoss by Red Hat
Modified:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-05-01
15:16:44 UTC (rev 21848)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/DroolsAllBotTests.java 2010-05-03
07:42:31 UTC (rev 21849)
@@ -14,12 +14,14 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.jboss.tools.drools.ui.bot.test.smoke.DecisionTableTest;
import org.jboss.tools.drools.ui.bot.test.smoke.DomainSpecificLanguageEditorTest;
import org.jboss.tools.drools.ui.bot.test.smoke.GuidedDroolsRulesEditorTest;
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsRuntime;
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsProject;
import org.jboss.tools.drools.ui.bot.test.smoke.ManageDroolsRules;
import org.jboss.tools.drools.ui.bot.test.smoke.DroolsRulesEditorTest;
+import org.jboss.tools.drools.ui.bot.test.smoke.RuleFlowTest;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
@@ -43,7 +45,9 @@
ManageDroolsRules.class,
DroolsRulesEditorTest.class,
GuidedDroolsRulesEditorTest.class,
- DomainSpecificLanguageEditorTest.class})
+ DomainSpecificLanguageEditorTest.class,
+ RuleFlowTest.class,
+ DecisionTableTest.class})
public class DroolsAllBotTests extends SWTTestExt {
public static final String DROOLS_PROJECT_NAME = "droolsTest";
public static final String DROOLS_RUNTIME_NAME = "Drools Test Runtime";
@@ -57,6 +61,9 @@
public static final String SAMPLE_DROOLS_RULE_NAME = "Sample.drl";
public static final String GUIDED_DROOLS_RULE_NAME = "GuidedRule.brl";
public static final String DOMAIN_SPECIFIC_LANGUAGE_FILE_NAME =
"DslTest.dsl";
+ public static final String RULE_FLOW_JAVA_TEST_FILE_NAME =
"ProcessTest.java";
+ public static final String RULE_FLOW_RF_FILE_NAME = "ruleflow.rf";
+ public static final String DECISION_TABLE_JAVA_TEST_FILE_NAME =
"DecisionTableTest.java";
private static String testDroolsRuntimeName = null;
public static String getTestDroolsRuntimeName() {
return testDroolsRuntimeName;
Added:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DecisionTableTest.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DecisionTableTest.java
(rev 0)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DecisionTableTest.java 2010-05-03
07:42:31 UTC (rev 21849)
@@ -0,0 +1,53 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.drools.ui.bot.test.smoke;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.junit.Test;
+/**
+ * Tests Decision Table
+ * @author Vladimir Pakan
+ *
+ */
+public class DecisionTableTest extends SWTTestExt{
+ /**
+ * Tests Decision Table
+ */
+ @Test
+ public void testRuleFlow() {
+ runDecisionTable(DroolsAllBotTests.DECISION_TABLE_JAVA_TEST_FILE_NAME);
+ }
+ /**
+ * Runs newly created Drools project and check result
+ * @param decisionTableFileName
+ */
+ private void runDecisionTable(String decisionTableFileName){
+ console.clearConsole();
+ bot.sleep(5000L);
+
+ SWTBotTreeItem tiTestFile = packageExplorer.selectTreeItem(decisionTableFileName,
+ new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_JAVA_TREE_NODE,
+ DroolsAllBotTests.COM_SAMPLE_TREE_NODE});
+
+ eclipse.runTreeItemAsJavaApplication(tiTestFile);
+
+ String consoleText = console.getConsoleText(3*1000L,60*1000L,true);
+
+ assertTrue(decisionTableFileName + " didn't run properly.\n" +
+ "Console Text was: " + consoleText + "\n" +
+ "Expected console text is: Hello World\nGoodbye cruel world\n",
+ "Hello World\nGoodbye cruel world\n".equals(consoleText));
+ }
+}
\ No newline at end of file
Property changes on:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/DecisionTableTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
===================================================================
---
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
(rev 0)
+++
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java 2010-05-03
07:42:31 UTC (rev 21849)
@@ -0,0 +1,402 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2010 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.drools.ui.bot.test.smoke;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.drools.ui.bot.test.DroolsAllBotTests;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.helper.KeyboardHelper;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+/**
+ * Tests Rule Flow
+ * @author Vladimir Pakan
+ *
+ */
+public class RuleFlowTest extends SWTTestExt{
+ private static final String RULE_FLOW_FILE_DIRECTORY = "src" + File.separator
+
+ "main" + File.separator +
+ "rules";
+ private static final String ROOT_NODE_NAME = "process";
+ private static final String HEADER_NODE_NAME = "header";
+ private static final String NODES_NODE_NAME = "nodes";
+ private static final String CONNECTIONS_NODE_NAME = "connections";
+ private static final String CONNECTION_NODE_NAME = "connection";
+ private static final int NODES_NODE_CHILDREN_COUNT = 14;
+ private static final int CONNECTIONS_NODE_CHILDREN_COUNT = 1;
+ private static final int ROOT_NODE_CHILDREN_COUNT = 3;
+ /**
+ * Tests Rule Flow
+ */
+ @Test
+ public void testRuleFlow() {
+ runRuleFlowCheck(DroolsAllBotTests.RULE_FLOW_JAVA_TEST_FILE_NAME);
+ ruleFlowEditorCheck(DroolsAllBotTests.RULE_FLOW_RF_FILE_NAME);
+ }
+ /**
+ * Runs newly created Drools project and check result
+ * @param droolsProjectName
+ */
+ private void runRuleFlowCheck(String droolsRuleTestFileName){
+ console.clearConsole();
+ bot.sleep(5000L);
+
+ SWTBotTreeItem tiTestFile = packageExplorer.selectTreeItem(droolsRuleTestFileName,
+ new String[] {DroolsAllBotTests.DROOLS_PROJECT_NAME,
+ DroolsAllBotTests.SRC_MAIN_JAVA_TREE_NODE,
+ DroolsAllBotTests.COM_SAMPLE_TREE_NODE});
+
+ eclipse.runTreeItemAsJavaApplication(tiTestFile);
+
+ String consoleText = console.getConsoleText(3*1000L,60*1000L,true);
+
+ assertTrue(droolsRuleTestFileName + " didn't run properly.\n" +
+ "Console Text was: " + consoleText + "\n" +
+ "Expected console text is: " + "Hello World\n",
+ "Hello World\n".equals(consoleText));
+ }
+ /**
+ * Add all possible object to RF diagram and then remove them
+ * @param ruleFlowRfFileName
+ */
+ private void ruleFlowEditorCheck (String ruleFlowFileName){
+ packageExplorer.show();
+ packageExplorer.openFile(DroolsAllBotTests.DROOLS_PROJECT_NAME ,
+ DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE,
+ DroolsAllBotTests.RULE_FLOW_RF_FILE_NAME);
+ // Test if Rule Flow RF File is opened in editor
+ assertTrue("Rule Flow RF File is not opened properly. File " +
ruleFlowFileName + " is not opened in editor",
+ SWTEclipseExt.existEditorWithLabel(bot,ruleFlowFileName));
+
+ SWTGefBot gefBot = new SWTGefBot();
+ SWTBotGefEditor gefEditor = gefBot.gefEditor(ruleFlowFileName);
+ final Control editorControl = (Control)gefEditor.getWidget();
+ Rectangle editorBounds = UIThreadRunnable.syncExec(new Result<Rectangle>() {
+ public Rectangle run() {
+ return editorControl.getBounds();
+ }
+ });
+ // Clear Editor
+ gefEditor.activateTool("Marquee");
+ gefEditor.mouseDrag(0,0,editorBounds.width - editorBounds.x, editorBounds.height -
editorBounds.y);
+ KeyboardHelper.pressKeyCode(bot.getDisplay(),(int)SWT.DEL);
+ // Draw each component
+ String[] tools = new String[]{"Start Event","End
Event","Rule Task",
+ "Gateway [diverge]","Gateway [converge]","Reusable
Sub-Process",
+ "Script Task","Timer Event","Error
Event","Message Event","User Task",
+ "Embedded Sub-Process","Log","Email"};
+ int xspacing = 100;
+ int xoffset = 10;
+ int yspacing = 100;
+ int yoffset = 10;
+ for (int toolIndex = 0;toolIndex < tools.length;toolIndex++){
+ gefEditor.activateTool(tools[toolIndex]);
+ gefEditor.mouseMoveLeftClick(xspacing * (toolIndex % 3) + xoffset,
+ yspacing * (toolIndex / 3) + yoffset);
+ }
+ // Add Sequence Flow between Start and End Node
+ gefEditor.activateTool("Sequence Flow");
+ // Click on Start Node
+ gefEditor.mouseMoveLeftClick(xoffset + 5, yoffset + 5);
+ // Click on End Node
+ gefEditor.mouseMoveLeftClick(xspacing + xoffset + 5, yoffset + 5);
+ gefEditor.save();
+ checkFullRFFile(DroolsAllBotTests.DROOLS_PROJECT_NAME , ruleFlowFileName);
+ // Delete each component
+ gefEditor.activateTool("Select");
+ for (int toolIndex = 0;toolIndex < tools.length;toolIndex++){
+ gefEditor.mouseMoveLeftClick(xspacing * (toolIndex % 3) + xoffset + 5,
+ yspacing * (toolIndex / 3) + yoffset + 5);
+ KeyboardHelper.pressKeyCode(bot.getDisplay(),(int)SWT.DEL);
+ }
+ gefEditor.save();
+ checkEmptyRFFile(DroolsAllBotTests.DROOLS_PROJECT_NAME , ruleFlowFileName);
+ }
+ /**
+ * Check content of Rule Flow file containing all possible objects
+ *
+ * @param projectName
+ * @param ruleFlowFileName
+ */
+ private void checkFullRFFile(String projectName, String ruleFlowFileName) {
+
+ Document doc = loadXmlFile(SWTUtilExt.getPathToProject(projectName)
+ + File.separator + RuleFlowTest.RULE_FLOW_FILE_DIRECTORY
+ + File.separator + ruleFlowFileName);
+
+ String errorDescription = null;
+ Element rootNode = doc.getDocumentElement();
+ doc.normalizeDocument();
+ if (rootNode.getNodeName().equals(ROOT_NODE_NAME)) {
+ NodeList rootNodeList = rootNode.getChildNodes();
+ List<Node> rootNodes = removeTextNodes(rootNodeList);
+ if (rootNodes.size() == ROOT_NODE_CHILDREN_COUNT) {
+ Node header = rootNodes.get(0);
+ errorDescription = checkEmptyFileNode(header, HEADER_NODE_NAME);
+ if (errorDescription == null) {
+ Node nodesNode = rootNodes.get(1);
+ errorDescription = checkNodeName(nodesNode, NODES_NODE_NAME);
+ if (errorDescription == null) {
+ errorDescription = checkNodesFileNodes(removeTextNodes(nodesNode
+ .getChildNodes()));
+ if (errorDescription == null) {
+ Node connectionsNode = rootNodes.get(2);
+ errorDescription = checkNodeName(connectionsNode,
+ CONNECTIONS_NODE_NAME);
+ if (errorDescription == null) {
+ errorDescription =
checkConnectionsFileNodes(removeTextNodes(connectionsNode
+ .getChildNodes()));
+ }
+ }
+ }
+ }
+ } else {
+ errorDescription = "Root node has to have " + ROOT_NODE_CHILDREN_COUNT
+ + " child nodes but it has " + rootNodeList.getLength();
+ }
+ } else {
+ errorDescription = "Root node has to have name '" + ROOT_NODE_NAME
+ + "' but it has name '" + rootNode.getNodeName() +
"'";
+ }
+ assertNull(errorDescription,errorDescription);
+ }
+ /**
+ * Check content of empty Rule Flow file
+ * @param projectName
+ * @param ruleFlowRfFileName
+ */
+ private void checkEmptyRFFile(String projectName, String ruleFlowFileName){
+
+ Document doc = loadXmlFile(SWTUtilExt.getPathToProject(projectName) +
+ File.separator + RuleFlowTest.RULE_FLOW_FILE_DIRECTORY + File.separator +
+ ruleFlowFileName);
+
+ String errorDescription = null;
+
+ Element rootNode = doc.getDocumentElement();
+ doc.normalizeDocument();
+ if (rootNode.getNodeName().equals(ROOT_NODE_NAME)) {
+ NodeList rootNodeList = rootNode.getChildNodes();
+ List<Node> nodes = removeTextNodes(rootNodeList);
+ if (nodes.size() == ROOT_NODE_CHILDREN_COUNT) {
+ Node header = nodes.get(0);
+ errorDescription = checkEmptyFileNode(header, HEADER_NODE_NAME);
+ if (errorDescription == null) {
+ Node nodesNode = nodes.get(1);
+ errorDescription = checkEmptyFileNode(nodesNode, NODES_NODE_NAME);
+ if (errorDescription == null) {
+ Node connnections = nodes.get(2);
+ errorDescription = checkEmptyFileNode(connnections, CONNECTIONS_NODE_NAME);
+ }
+ }
+ } else {
+ errorDescription = "Root node has to have " +
+ ROOT_NODE_CHILDREN_COUNT +
+ " child nodes but it has " +
+ rootNodeList.getLength();
+ }
+ } else {
+ errorDescription = "Root node has to have name '" + ROOT_NODE_NAME
+ + "' but it has name '" + rootNode.getNodeName() +
"'";
+ }
+ assertNull(errorDescription,errorDescription);
+
+ }
+ /**
+ * Loads and parse XML file with fileName from file system
+ * @param fileName - full path to XML file
+ * @return
+ */
+ private Document loadXmlFile (String fileName){
+ File file = new File(fileName);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db;
+ Document doc = null;
+ try {
+ db = dbf.newDocumentBuilder();
+ doc = db.parse(file);
+ } catch (ParserConfigurationException pce) {
+ throw new RuntimeException(pce);
+ } catch (SAXException saxe) {
+ throw new RuntimeException(saxe);
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ }
+ return doc;
+ }
+ private static List<Node> removeTextNodes(NodeList rootNodeList){
+ LinkedList<Node> nodes = new LinkedList<Node>();
+ for (int index = 0 ; index < rootNodeList.getLength(); index++){
+ Node node = rootNodeList.item(index);
+ if (!node.getNodeName().equals("#text")){
+ nodes.add(node);
+ }
+ }
+ return nodes;
+ }
+ /**
+ * Check if node is correct for empty file
+ * @param node
+ * @param expectedNodeName
+ * @return
+ */
+ private static String checkEmptyFileNode (Node node,String expectedNodeName){
+ String errorDescription = null;
+ if (node.getNodeName().equals(expectedNodeName)){
+ if (removeTextNodes(node.getChildNodes()).size() == 0){
+ if(node.getTextContent().trim().length() != 0){
+ errorDescription = expectedNodeName + " node has to have no text value but
it has " +
+ node.getTextContent();
+ }
+ }
+ else{
+ errorDescription = expectedNodeName + " node has to have no children but is
has " +
+ removeTextNodes(node.getChildNodes()).size();
+
+ }
+ }
+ else{
+ errorDescription = checkNodeName(node, expectedNodeName);
+ }
+
+ return errorDescription;
+
+ }
+ /**
+ * Check nodes of Nodes children.
+ * @param nodes - list of nodes of nodes node stripped from text nodes
+ * @return
+ */
+ private static String checkNodesFileNodes(List<Node> nodes){
+ String errorDescription = null;
+
+ if (nodes.size() == NODES_NODE_CHILDREN_COUNT){
+ List<String> mandatoryNodes = getMandatoryNodesOfNodesNode();
+ int index = 0;
+ Iterator<Node> iterator = nodes.iterator();
+ while (index < nodes.size() && errorDescription == null){
+ String nodeName = iterator.next().getNodeName();
+ if (mandatoryNodes.contains(nodeName)){
+ mandatoryNodes.remove(nodeName);
+ }
+ else{
+ errorDescription = "Nodes node cannot contain node " + nodeName;
+ }
+ index++;
+ }
+ if (errorDescription == null && mandatoryNodes.size() > 0) {
+ StringBuilder sb = new StringBuilder("");
+ for (String nodeName : mandatoryNodes){
+ if (sb.length() != 0){
+ sb.append(", ");
+ }
+ sb.append(nodeName);
+ }
+ errorDescription = "Nodes node doesn't contain all necesarry
nodes.\n" +
+ "These node(s) are missing within nodes node: " +
+ sb.toString();
+ }
+ }
+ else{
+ errorDescription = "Nodes node has to have " +
+ NODES_NODE_CHILDREN_COUNT +
+ " child nodes but it has " +
+ nodes.size();
+ }
+
+ return errorDescription;
+ }
+ /**
+ * Returns list of mandatory nodes of nodes node
+ * @return
+ */
+ private static List<String> getMandatoryNodesOfNodesNode(){
+ LinkedList<String> allowedNodes = new LinkedList<String>();
+ allowedNodes.add("split");
+ allowedNodes.add("timerNode");
+ allowedNodes.add("humanTask");
+ allowedNodes.add("ruleSet");
+ allowedNodes.add("actionNode");
+ allowedNodes.add("composite");
+ allowedNodes.add("end");
+ allowedNodes.add("workItem");
+ allowedNodes.add("fault");
+ allowedNodes.add("subProcess");
+ allowedNodes.add("start");
+ allowedNodes.add("workItem");
+ allowedNodes.add("eventNode");
+ allowedNodes.add("join");
+ return allowedNodes;
+ }
+
+ /**
+ * Check nodes of connections children.
+ * @param nodes - list of nodes of connections node stripped from text nodes
+ * @return
+ */
+ private static String checkConnectionsFileNodes(List<Node> nodes){
+ String errorDescription = null;
+
+ if (nodes.size() == CONNECTIONS_NODE_CHILDREN_COUNT){
+ Node connectioNode = nodes.get(0);
+ errorDescription = checkEmptyFileNode(connectioNode, CONNECTION_NODE_NAME);
+ }
+ else{
+ errorDescription = "Conections node has to have " +
+ CONNECTIONS_NODE_CHILDREN_COUNT +
+ " child nodes but it has " +
+ nodes.size();
+ }
+
+ return errorDescription;
+ }
+ /**
+ * Check if node has expected name
+ * @param node
+ * @param expectedNodeName
+ * @return
+ */
+ private static String checkNodeName (Node node, String expectedNodeName){
+ String errorDescription = null;
+
+ if (!node.getNodeName().equals(expectedNodeName)){
+ errorDescription = "Node has to have name '" +
+ expectedNodeName + "' but it has name '" +
+ node.getNodeName() + "'";
+ }
+
+ return errorDescription;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/drools/tests/org.jboss.tools.drools.ui.bot.test/src/org/jboss/tools/drools/ui/bot/test/smoke/RuleFlowTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java
===================================================================
---
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-05-01
15:16:44 UTC (rev 21848)
+++
trunk/jst/tests/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/SWTUtilExt.java 2010-05-03
07:42:31 UTC (rev 21849)
@@ -23,6 +23,7 @@
import java.util.Properties;
import org.apache.log4j.Logger;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.Job;
@@ -692,5 +693,36 @@
return result;
}
-
+ /**
+ * Returns location of file within plugin
+ * @param pluginId
+ * @param fileName
+ * @return
+ */
+ public static String getPathToFileWithinPlugin(String pluginId,
+ String fileName) {
+
+ String filePath = null;
+ try {
+ filePath = FileLocator.toFileURL(
+ Platform.getBundle(pluginId).getEntry("/")).getFile()
+ + fileName;
+ } catch (IOException e) {
+ // do nothing filePath is null
+ e.printStackTrace();
+ }
+
+ return filePath;
+ }
+ /**
+ * Returns path to project with projectName
+ * @param projectName
+ * @return
+ */
+ public static String getPathToProject(String projectName) {
+ return ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() +
+ File.separator +
+ projectName;
+ }
+
}
\ No newline at end of file